Set default dashboard per user group

Comments

28 comments

  • Avatar
    Malinda Jepsen

    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? 

    0
    Comment actions Permalink
  • Avatar
    Febrillian

    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?

    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    @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!

    0
    Comment actions Permalink
  • Avatar
    Malinda Jepsen

    @Takashi:  You made my day!  I can't wait to play with that for my deployments!  Now, if you told me there was a button on a dashboard that I could use to do an update to another site, I would be even happier!

    Thanks!

    0
    Comment actions Permalink
  • Avatar
    Scott Vickers

    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();
    }

    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    Hi Scott,

    The last update was to add support for Active Directory groups, but it should work fine with regular groups as well.  The change was to check for the current users groups (AD and regular) and evaluate them all.  Was there a specific issue you were seeing?

    -Takashi

    0
    Comment actions Permalink
  • Avatar
    Larry Craig

    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
    }
    }
    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    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";
    }
    0
    Comment actions Permalink
  • Avatar
    Duncan Wakefield (Edited )

    How do I get the Group ID please?

    Actually just found it via REST API 0.9

    Did I miss where it said which part of the 'js' file is the Group ID and which is the Dashboard ID?

    0
    Comment actions Permalink
  • Avatar
    Gopinath Venkataramanan

    What kind of licensing is required to enable rebranding. I am getting this error

    0
    Comment actions Permalink
  • Avatar
    Sisense License

    This has stopped working for me after i upgraded to 7.1 is there a fix?

    Now my Default homepage is coming up with an error and cannot be fixed. 
    I've tried reinstalling the plugin and still no response after a login.

    even clicking the top left logo will cause this error to appear.

    1
    Comment actions Permalink
  • Avatar
    Greg Lee

    I am having the same issue. Since upgrading to 7.1 - I get the same error. To be sure, I downloaded the latest version and replaced it, same error.

    0
    Comment actions Permalink
  • Avatar
    Sisense License


    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.

     

     

    0
    Comment actions Permalink
  • Avatar
    Sisense License

    Don't forget to place those files within 

    C:\Program Files\Sisense\PrismWeb\plugins\customHomepage

    0
    Comment actions Permalink
  • Avatar
    Greg Lee

    Hi Sisense License :)

    That worked. The homepage does load slower than it used to which results in users seeing the HTML tags first, but then it refreshes to render the homepage.

    Thanks for the workaround! Hopefully they can get it to load faster.

    Greg

    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    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

    0
    Comment actions Permalink
  • Avatar
    Antti Wolk

    Hello,

     

    if I understand the logic correctly we have to add the ID of the User Group and then the ID of the Dashboard.

    I have marked the ID of the User group. Is this correct, or have I misunderstood something?
    If it is right, please tell me where can I find it?

    0
    Comment actions Permalink
  • Avatar
    Duncan Wakefield

    Hi Antti,

    To find your group id, you can use the REST API.  Look for 'Groups' and then run the first query to GET groups.

    Hope this helps.

    Duncan

    0
    Comment actions Permalink
  • Avatar
    Elliott Herz

    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

    0
    Comment actions Permalink
  • Avatar
    Antti Wolk (Edited )

    Thank you very much for your help.

     

    0
    Comment actions Permalink
  • Avatar
    Antti Wolk (Edited )

    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

     

    0
    Comment actions Permalink
  • Avatar
    Antti Wolk

    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)

    0
    Comment actions Permalink
  • Avatar
    Ravi Verma

    Hi,

    Can I set default dashboard for a specific user instead of user group?

     

    Best regards,

    Ravi

    0
    Comment actions Permalink
  • Avatar
    Roopa Raghavan

    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 file
    Any help is appreciated.

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Roopa Raghavan

    @Ravi Can you try to add that one user to a group and then get the group ID via the REST API --> get groups and then add that group ID and the dashboard ID you want to show to your homepages.js file?

    0
    Comment actions Permalink
  • Avatar
    Duncan Wakefield

    Can you set a different default dashboard if the user logs into the Mobile App?  Mobile is a very different user experience and would be nice to redirect them to a simple landing page.

    0
    Comment actions Permalink
  • Avatar
    Antti Wolk

    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
    }
    0
    Comment actions Permalink
  • Avatar
    Duncan Wakefield (Edited )

    @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.

    1
    Comment actions Permalink

Please sign in to leave a comment.