Set default dashboard per user group

Comments

25 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? 

  • 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?

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

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

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

  • 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

  • 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
    }
    }
  • 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";
    }
  • 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?

  • Avatar
    Gopinath Venkataramanan

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

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

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

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

     

     

  • Avatar
    Sisense License

    Don't forget to place those files within 

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

  • 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

  • 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

  • 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?

  • 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

  • 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

  • Avatar
    Antti Wolk (Edited )

    Thank you very much for your help.

     

  • 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

     

  • 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)

  • Avatar
    Ravi Verma

    Hi,

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

     

    Best regards,

    Ravi

  • 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

  • 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?

Please sign in to leave a comment.