Set default dashboard per user group
Download: Sisense v6 Download, Sisense v7 Download
Introduction
When a user logs into Sisense Web, they get taken to a standard home page. This plugin allows admins to define default dashboards for each user group. So instead of landing on a home page, each user will automatically get redirected to their default dashboard.
Steps
Step 1 - Add the Plugin
Download the attachment and unzip the contents into your C:\Program Files\Sisense\PrismWeb\plugins\ folder. If you are using version 7.2 and higher unzip the contents into your C:\Program Files\Sisense\app\plugins\ folder. If the plugins folder doesn't exist, just create it. After those files have been unzipped there, you may also have to restart the web server.
Step 2 - Configure Default Dashboards
In the set of attached files, open up homepages.js. This file contains a mapping of user groups (by name) and what dashboards (by ID) to open instead of the standard home page. Add to this list as needed for each group that requires a default dashboard. This list also contains an option for "default", which will be used if the logged in user does not belong to any groups.
// Add an object to hold the default homepages for each group prism.customHomepage = { "settings": { "multipleGroups" : "default" // Can be "first","last", or "default" }, "homepages": { "default":"57d164b48517b9b01b000022", // Default Dashboard "57d31bc0105e6e9c36000003": "57b76a3e4591399c1b000001", // Dept A Group "57d341a1105e6e9c3600006f": "57d164ae8517b9b01b00000d" // Dept B Group } }
Step 3 - Enable through the Rebranding API
Open the REST API reference page, and run the /api/branding POST command with the following payload. This will enable the plugin to run and replace the homepage based on user group.
{ "homePage":"/plugins/customHomepage/defaultHomepage.html" }
References/Notes
- Use of this plugin requires a license for Rebranding
- The multipleGroups property decides what to do when a user belongs to multiple groups. The value here can be first (first match in config file), last (last match from the config file), or default (use the default dashboard)
- UPDATED June 7, 2016 - This plugin has been updated to not require an API call to GET /API/Groups, since this endpoint is not accessible to viewers. The change requires the homepages.js file be updated to map default dashboards to GroupIDs instead of Group Names.
- UPDATED June 8, 2016 - Added support to Active Directory groups and to users with no assigned groups
- UPDATED July 5, 2016 - Modified code to work with changes to v6.4
- UPDATED Sept 9, 2016 - Updated to work with Active Directory groups in v6.4. Also included an option to decide which default dashboard to use, if a user belongs to multiple groups
- UPDATED May 4, 2018 - Updated to work with Sisense v7
-
Thanks Takashi! Now, if I just didn't have to change those IDs when I import a dashboard... I see that the new RESTAPI has a "Patch" endpoint for dashboards. Is this so that we can replace an existing dashboard (e.g. when moving from test to production) rather than having to delete and then import?
-
Hi Takashi,
I got some error when using this plugins. It keep showing error 404. I try to hardcode the dashboard id in var newUrl in init.js like below.
var newUrl = "/app/main#/dashboards/" + "570f16a76caa5a4036000016";//dashboardId;
And it keep showing the same error.Is there other step that need to be done for the plugin to work?
-
@Malinda, Yep, the PATCH web service call to api/v1/dashboards is for updating existing dashboards in the system
@Febrillian, if you're getting a 404 error that typically means your user does not have access to something. Likely, the user you are testing this with does not have access to the dashboard (via the share dashboard popup).
Hope this helps!
-
Looks like this only works with ActiveDirectory now. Possible fix?
if (prism.user.activeDirectory == true) {
if (typeof prism.user.resolevdGroups !== 'undefined'){
groupId = prism.user.resolevdGroups.first();
}
}else if (typeof prism.user.groups!=='undefined'){
groupId = prism.user.groups.first();
} -
I've configured this for a test user group, but still want the Sisense Admin group to be directed to the stock Sisense homepage for easy access to documentation, videos, etc.
Is this possible? My intent is ONLY to have the project teams directed to their respective homepage dashboard, while not impacting the Admins.
// Add an object to hold the default homepages for each group
prism.customHomepage = {
"settings": {
"multipleGroups" : "default" // Can be "first","last", or "default"
},
"homepages": {
"default":"57d164b48517b9b01b000022", // Admin Group (What dashboard ID for Sisense default?)
"58c6fc14e10a9b202c000055": "58c6e0ece10a9b202c000010" // Testing Group
}
} -
Hi Larry,
there's not an easy way to undo the branding option for specific users, once its been set via the REST API. However, it could be possible to provide a different landing page than a dashboard. If you set your admin group's setting to null in the homepages.js file. Then if you open the init.js file, at the very bottom is a portion that evaluates the dashboard ID. just change this logic to match the below sample, and put in a new url for your admins
// Make sure something was picked
if (dashboardId) {
// Define the new url
var newUrl = "/app/main#/dashboards/" + dashboardId;
// Change the url
window.location.href = newUrl;
} else {
// Use a different homepage
window.location.href = "my custom homepage url";
} -
Hi Greg,Support go into contact with me the fix is to do this.
I cannot upload the files here however you need to create a main.js text file with the following code:
prism.run([
function () {
prism.on("apploaded", function(e, args){
var needRun = (e.currentScope.appstate === 'homepage') && (prism.brand.homePage === '/plugins/customHomepage/defaultHomepage.html');
if (needRun) {
// Get all the groups a user could belong to
var adGroups = prism.user.resolevdGroups ? prism.user.resolevdGroups : null,
sisenseGroups = prism.user.groups ? prism.user.groups : [],
allGroups = adGroups ? adGroups : sisenseGroups;
// Find all matches in the config file
var dashboardId = null,
matchedHomepages = [];
for (key in prism.customHomepage.homepages){
// Look for user groups that match this key
var matchedGroup = $.grep(allGroups, function(w){
return w == key;
});
// Was there a match
var isMatch = (key !== "default") && (matchedGroup.length>0);
if (isMatch){
matchedHomepages.push(prism.customHomepage.homepages[key]);
}
}// Business Logic
if (matchedHomepages.length == 0){
// No match in the config file, use default
dashboardId = prism.customHomepage.homepages.default;
} else if (matchedHomepages.length == 1){
// Only 1 match, use it
dashboardId = matchedHomepages[0];
} else {
// Multiple matches on groups
var userPref = prism.customHomepage.settings.multipleGroups;
if (userPref == "first"){
// Config file says to use the first match
dashboardId = matchedHomepages[0];
} else if (userPref == "last"){
// Config file says to use the last match
dashboardId = matchedHomepages[matchedHomepages.length-1];
} else if (userPref == "default") {
// Config files says to use default
dashboardId = prism.customHomepage.homepages.default;
} else {
// Catchall for other options, use default
dashboardId = prism.customHomepage.homepages.default;
}
}
}
if (dashboardId) {
// Define the new url
var newUrl = "/app/main#/dashboards/" + dashboardId;
// Change the url
window.location.href = newUrl;
}
});}
]);--------------------------------------------------------------------------------------------------------------------------------
And also edit your plugin.json to only have this code:
----------------------------------------------------------------------------------------------------------------
{
"name": "Set custom homepage",
"source": [
"main.js",
"homepages.js"
],
"style": [],
"folderName": "customHomePage",
"lastUpdate": "2018-05-03T13:50:58.512Z",
"isEnabled": true,
"version": "0"
}------------------------------------------------------------------------------------------------------
Then Reset your IIS.
And it should be up and running again.
-
Hi guys,
We've updated the forum post to include the new updated version of the plugin, there are now a v6 version and v7 version. The main difference is that in Sisense v7, we introduced a new API that fires when the application has loaded and that's what the new version of the plugin is using.
thanks!
-Takashi
-
Hey Guys,
You can also check in the prism.user object.
There is a field called prism.user.groups that us a list of the groupIDs
There is a field called prism.user.groupsName that is probably the appropriate place to grab the groupIDs and the associated group name.
You can open a web browser, go to the developer tools, go the console, and enter in prism.user and checkout what's available.
Best,
Elliott
-
Hi,
Does anybody else face issues with older IE and Edge browsers?
I get the message that the publisher of defaulthomepage.js is not verified. The security settings do not allow to download the defaulthomepage.js file.
It is strange, because the js files name is homepage.js
Anyone else with this problem?
thanks
-
Hi,
I get the following error. Does anybody know how to solve it?Error: Plugins error:
Module parse failed: C:\Program Files\Sisense\app\plugins-service\node_modules\imports-loader\index.js?define=>false&exports=>false&module=>false!C:\Program Files\Sisense\app\plugins-service\src\features\plugins\webpack\loaders\final-loader\index.js!C:\Program Files\Sisense\app\plugins\customHomepage\plugin.json Unexpected token (20:2)
You may need an appropriate loader to handle this file type.
| "5af46c6b19f8d42050e46f7a": "5b641346c99414065c44f3a5", // Demo Group
| "5b6d40c833afc2203cf1fbac": "5b48bad11723c1149441a148" // Full ACCESS
| "5bb7371ce6dbc62360383739": "5b48bad11723c1149441a148" // 10 countries
| "5bbc534bce94ff21488076c2": "5b48bad11723c1149441a148" // Aftermarket Volumes
| }at Object.define (/systemPlugins/main.e17b6ec14d8ad1dd2336.js:10247)
at __webpack_require__ (/systemPlugins/main.e17b6ec14d8ad1dd2336.js:20)
at Object._runPlugins (/systemPlugins/main.e17b6ec14d8ad1dd2336.js:1178)
at app-main.js:1
at Object.l [as invoke] (common.js:1)
at common.js:1
at A (common.js:1)
at kt (common.js:1)
at r (common.js:1)
at Object.Te [as bootstrap] (common.js:1) -
when users that don't belong to any groups login they see the message "Error 403: sorry...
you don't have permission to access this Dashboard"Does this mean that my dashboard which is an imagewidget (only) needs to be shared with every single user before they see it as their landing homepage?[But customHomePages plugin works for users that belong to groups and have dashboards shared with them.]I thought that was what the default group function was in the homepages.js fileAny help is appreciated.
Thanks
-
When a user has rights for more than one group the redirect does not work anymore.
In this case a user has rights for multiple groups. Each of the group should redirect to the same dashboard.When the user has access to only one it works, as soon as he gets access to two the redirect fails. WHat is the problem?
// Add an object to hold the default homepages for each group
prism.customHomepage = {
"settings": {
"multipleGroups" : "default" // Can be "first","last", or "default"
},
"homepages": {
"default":"5b48bad11723c1149441a148",
"5af46c6b19f8d42050e46f7a": "5b641346c99414065c44f3a5", // Demo Group
"5b6d40c833afc2203cf1fbac": "5b48bad11723c1149441a148", // Full ACCESS
"5bcf14b2421846215cea2811": "5bcf1b2005cd4c2670681835", // Germany
"5bf8205673ca112fe4e74f06": "5bcf1b2005cd4c2670681835", // Finland
"5c4ebd096b2909244cc7d316": "5bcf1b2005cd4c2670681835", // France
"5c5461b3b0c6a91dc08ff3e6": "5bcf1b2005cd4c2670681835", // Poland
"5c5461b7b0c6a91dc08ff3e7": "5bcf1b2005cd4c2670681835", // Italy
"5c5461f407eadc21306ca5e0": "5bcf1b2005cd4c2670681835", // Spain
"5c5461ff07eadc21306ca5e1": "5bcf1b2005cd4c2670681835", // UK
"5c54629007eadc21306ca5e2": "5bcf1b2005cd4c2670681835", // Russia
"5c640f56b92ae524cc72305d": "5bcf1b2005cd4c2670681835", // Norway
"5b632e02c99414065c44b678": "5b48bad11723c1149441a148", // Garage Structure
"5d1f60f3f7e0592560a2800b": "5b48bad11723c1149441a148", // Homepage
"5b632df7c99414065c44b670": "5d3efbfab68b8a25cca82220", // Distribution Overview
"5d3c09974383a30d448f0333": "5d3efbfab68b8a25cca82220", // Distribution Top 5
"5d3ee0bdf77b4b1d28233c72": "5d3efbfab68b8a25cca82220", // Distribution Italy
"5d3ee0c7f77b4b1d28233c73": "5d3efbfab68b8a25cca82220", // Distribution Spain
"5d3ee0d3f77b4b1d28233c74": "5d3efbfab68b8a25cca82220", // Distribution Czech Republic
"5d3ee0dcf77b4b1d28233c75": "5d3efbfab68b8a25cca82220", // Distribution Slovenia
"5d3ee0e5f77b4b1d28233c76": "5d3efbfab68b8a25cca82220", // Distribution Poland
"5d3ee1f7f77b4b1d28233c77": "5d3efbfab68b8a25cca82220", // Distribution Germany
"5d3ee1fdf77b4b1d28233c78": "5d3efbfab68b8a25cca82220", // Distribution France
"5d3ee203f77b4b1d28233c79": "5d3efbfab68b8a25cca82220" // Distribution UK
} -
@Antti Wolk
As per the documentation, I think you need to change the value of multiGroups.
- The multipleGroups property decides what to do when a user belongs to multiple groups. The value here can be first(first match in config file), last (last match from the config file), or default (use the default dashboard)
You have
"multipleGroups" : "default"
I am in the process of setting this up and when I left the value as default and the user belonged to multiple groups, they got the defaultHomepage.html that is in the plugin folder. When I change to "first" or "last", it works accordingly.
Please sign in to leave a comment.
Comments
31 comments