Custom sidebar
Customize sidebar elements including menus, links, dropdowns and icons.
Last updated
Customize sidebar elements including menus, links, dropdowns and icons.
Last updated
When selecting "left navbar" as the navigation menu style, you'll be able to choose from 2 options for it:
Default
Custom, in which case the "navigation menu" option will be enabled.
The "default" option will render a fixed left sidebar with Ubidots' standard menu layout in the app, where all the options will appear to end users based on their role of permissions.
When selecting the "custom" option, you'll be able to customize the sidebar at will. For example, in the below sidebar, menus, names, icons and dropdowns have been changed:
This is possible via the "edit menu" button, which opens an XML editor that includes a preview where you can see what the XML translates to:
This is the XML that creates the custom sidebar seen above:
The custom sidebar uses XML to map UI elements to code, which is the engine that allows the creation of a sidebar tailored to a specific application.
The available UI elements, and their hierarchy, are:
Using these XML elements comes with rules that are enforced by the editor and warns you of errors in the syntax:
The XML needs to start with:
<!DOCTYPE tree PUBLIC '-//UBIDOTS//DTD Menu App XML V1.0//EN' "-">
The <tree>
element is mandatory. It must have at least 1 or more <menu>
or <link>
elements.
The <menu>
element must have at least 1 <toggle>
and 1 <collapsable>
elements.
The <collapsable>
element must have at least 1 <menulink>
element.
The <link>
element must have at least 1 <icon>
and <label>
elements.
Here's a quick summary of the available elements, but you can click the links and read more details:
Root element. All other elements must be inside.
–
Allows creating dropdown menus.
defaultShow: determines whether the dropdown is open or closed when loading the app.
Comprises the dropdown itself.
–
Represents the icon the dropdown.
Text in the dropdown menu.
–
Arrow icon in the dropdown menu.
–
Comprises a parent element for all the options in the dropdown.
–
Actual options displayed under a dropdown menu.
path: where the menulink redirects to upon clicking.
permissions: list of end-user permissions under which the menulink will be visible.
tags: list of end-user tags under which the menulink will be visible.
open: open link in same tab or redirect.
exact: highlights the menulink when in the exact path defined by path.
Creates direct access to links.
path: where the menulink redirects to upon clicking.
permissions: list of end-user permissions under which the menulink will be visible.
tags: list of end-user tags under which the menulink will be visible.
open: open links in same tab or redirect.
exact: highlights the menulink when in the exact path defined by path.
Creates titles of different sizes. It helps in creating defined sections in the sidebar.
type: determines the size. It can be "h1", "h2", "h3", "h4", "normal" or "bold".
Creates horizontal lines that serve as section separation.
–
Parent element where all <menulink>
and <link>
reside:
Elements used to create dropdown menus:
This will create a dropdown menu, with its options, as follows:
These are the properties of the <menulink>
element:
path
This is a path in Ubidots to either a direct resource, for example "/app/dashboards/663d484aaa8d92005751b2e2", or a module "/app/dashboards/", or a full URL in Ubidots or an external website.
permissions
tags
open
Available options are: - "tab": link opens in a new tab. - "redirect": link opens in the same tab.
exact
Element to create shortcuts, in other words, direct access to modules or resources:
This will create a direct link, as follows:
The properties of the <link>
element are the same as the <menulink>
Title/label element and horizontal separation line.
This will create the following:
The available permissions for each possible path that's exposed to the end users in the application are:
Devices
"/app/devices/"
"ubi_datasource.view_device"
Device groups
"/app/device-groups/"
"ubi_datasource.view_devicegroup"
Dashboards
"/app/dashboards/"
"ubi_dashboards.view_dashboardpg"
Events
"/app/events/"
"ubi_events.view_eventpg"
Reports
"/app/data-analysis/"
"ubi_data_analysis.view_report"
Organizations
"/app/organizations/"
"customuser.view_organization"
Users
"/app/organizations/users"
"customuser.view_user"
With permissions, the <menulink>
and <link>
elements will only appear to those end users whose assigned permissions match that in the element configuration.
The <menulink>
and <link>
elements receive a "tag" property that adds a visibility layer on top of the permissions assigned to an end user. The way it works is by matching the tags of an end user with those specified in the <menulink>
or <link>
(learn more about tag filtering). Simply put, if the user has the same tags as the element, it means the element will be visible to the user.
This filtering by tags allows customizing the sidebar based on the user accessing the platform. For example, say you want to create a direct link that takes users to their own home dashboard, you would create an XML as follows:
Let's assume 2 end users, with tags "tag1" and "tag2", respectively. Note that there are 2 home links in the XML, however, since they have different tags ("tag1" and "tag2"), each home link will appear to the respective user.
Likewise, this will preview the following sidebar. We have marked what each user would see:
name: name of icon from .
Comma separated list of associated with the path. An end user will only see this menulink option if its permissions match.
Comma separated list of . This adds a visibility layer to the sidebar. An end user will only see this menulink option if its tags match. See also .
"true" or "false". Highlights the menulink when in the exact path defined by path.