With our initial embedding complete, now you can make sure all dashboards accessible by the user are shown in your application in the right place!
Each frontend component has a getAccessibleDashboards method, which you can use to dynamically retrieve a list of dashboards by providing it the embed key and token of the user.
When the getAccessibleDashboards promise resolves, it will contain a list of dashboards and also the following properties:
Below, an example of this response:
[
{
"id": "< dashboard_1_id >",
"modifiedAt": "2021-02-10T09:13:27.114Z",
"name": "< dashboard_1_name >",
"tags": [
"< dashboard_1_tag_1 >",
"< dashboard_1_tag_2 >"
],
"accessibleBy": [
{
"model": "User",
"id": "< user_A_id >",
"name": "< user_A_name >"
},
{
"model": "User",
"id": "< user_B_id >",
"name": "< user_B_name >"
},
{
"model": "Group",
"id": "< group_id >",
"name": "< group_name >"
},
],
"accessRights": {
"flagRead": true,
"flagUse": true,
"flagModify": false,
"flagOwn": false
}
},
...,
]
Now that we know what will be returned by the getAccessibleDashboards method, we can make use of it in several ways! Listed below are the most frequent uses for the getAccessibleDashboards method, but you can definitely get creative, here 😉
If the user only has view access (i.e. only flagRead true in accessRights), your user will not be able to edit the dashboard, and it thus makes sense not to show an "edit dashboard" button.
This could be useful to keep a nice overview of all different dashboards to which your user has access. You can do this based on:
Our sample embedding page gives an example of dashboard groups shown in the sidebar and dynamically filling the top navigation bar with the different dashboards!
If you have several dashboards in one place, we would recommend sorting them in a way that makes sense for your users. You can do this based on e.g.:
When your user creates a new dashboard, you want that dashboard to also show in your navigation. The easiest way to achieve this is to
Example code:
const luzmoDashboard = document.querySelector("luzmo-dashboard");
luzmoDashboard.addEventListener("load", (data) => {
luzmoDashboard.getAccessibleDashboards()
.then(dashboards => {
if (dashboards.length !== dashboardCount) { // only update navigation when the dashboardCount has changed
populateMenu(dashboards); // call a function which takes care of building the navigation UI
dashboardCount = dashboards.length;
}
})
});
The next article will list all available features that can be toggled for your users, as well as how to toggle them!