cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Widget Using Web Access Token

zach_myt
10 - ETL
10 - ETL

We have an embedded dashboard that utilizes web access token for filtering on different organizations. We have a widget that only needs to be displayed to certain organizations. Does anyone know if we can filter individual widgets using the web access tokens?

1 ACCEPTED SOLUTION

zach_myt
10 - ETL
10 - ETL

I spoke with a Sisense developer and he stated this was not possible via WAT. Also since my prism is one user and group there isn't anything unique there. So the final options are:

1) Create a pivot widget with data on what you want to filter on, organization name in my case, then if that widget contains the organization you want to hide the widget for then simply hide the widget using the .hide(). This does show the widget for a moment then remove it. It will also need to be on its own row since the dashboard will not redraw the widgets to account for the removed one.

 

widget.on('ready', function(widget,result) {
 
   let orgs_with_location_codes = ["Org_1","Org_2"]
 
   let selected_org = $(`widget[widgetid="66293bbcaf582e003f18f101"`).find('.table-grid__content__inner').eq(1).text().trim();
 
if(orgs_with_location_codes.indexOf(selected_org) == -1){
     $(`widget[widgetid="66293ac8af582e003f18f0d5"`).hide(); //widget to hide
     $(`widget[widgetid="66293bbcaf582e003f18f101"`).hide(); //pivot used to filter org
}
 
});

 

 
2) Use a query parameter of hide widget = true in the dashboard URL then access the query parameter in the script to hide it like the above solution.
 
3) Have 2 dashboards, one with the widget and one without then redirect accordingly.
 
We will probably go with option 1 since it is the least code/admin heavy.

View solution in original post

6 REPLIES 6

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hey @zach_myt ,

If you have user attached to the sub property in the WAT payload, I think you can see the user using 'prism.user'. You then should be able to show / hide the widget based on the userid related to the WAT:

const hideWidgets = ['659f84e9800ddf004150f24a', '659f84e9800ddf004150f24a']
const usersToHide = ['userid1', 'userid2']

dashboard.on('domready', () => {
	if (!usersToHide.includes(prism.user._id)) { return }
	prism.$ngscope.$broadcast('tab-change', {
		show: [],
		hide: hideWidgets || [],
		tabsConfig: 'multiply',
		renderWidgets: false
	})
})

This dashboard script requires that Tabber plugin be enabled, and pretty much works by telling Sisense that you're on a tab that doesn't include the widgets in the hideWidgets array.

The condition may need to change based on what the WAT exposes to Sisense, so if this doesn't work, you might see something in the prism.user object that may identify the specific WAT - let me know if this is the case - i'd be interested to hear.

Happy to take a look with you over Sisense Services | Free 30-Minute Sisense Consultation (rapidbi.com.au) and provide advice over a screenshare if you need to get more specific than the code above.

Let me know how you go?

zach_myt
10 - ETL
10 - ETL

All users are logging into our application which has no relation to Sisense user logins. Siesnse dashboards are currently embedded via an iFrame in our application. Our application has thousands of users but our Sisense instance only has around 20. The WAT does filtering for Organizations only currently since those organizations are listed in Sisense. I would like logic to be:

If WAT = 123 for Organization = 123 then hide widget_id = abc

Does that make sense?

hi @zach_myt ,

We're on the same page. WAT is not necessarily linked to a user (in most cases not). I've shared a link below on linking WAT to a user for the purpose of using connection parameters as a work around.

Using Web Access Tokens (sisense.com)

In this documentation, you can see that they've link a user to the WAT which I assume you can then act on from a dashboard level.

My approach to your problem would be to link a group to each WAT and then check to see if this group is accessible from the dashboard script in the prism.user (it's usually prism.user.groups.groupNames or something like this...) object - if it is, you can use this conditionally to hide specific widgets (as per script provided).

If it doesn't - then you might consider parsing the iFrame url for the token before using it dashboard side, but this feels more like a hack. I think you should look for other solutions before perusing this one.

Although we have implemented WAT for customers in the past, we don't actively maintain a test environment leveraging WAT. I suspect that there are additional properties accessible to the dashboard script where WAT is employed, but I don't have any way to explore and confirm this.

If you'd like to explore together, then Sisense Services | Free 30-Minute Sisense Consultation (rapidbi.com.au) could be a good way forward (if you use the link and provide some details, we can schedule a 30-minute no-obligation call where we try to solve your problem). I'd be happy to take a look with you and try find a better / less hack property directly related to the WAT that we can use dashboard script side.

Thanks,

Daniel

RAPID BI

[email protected]

RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

zach_myt
10 - ETL
10 - ETL

I don't have access to the WAT section of the application, my dev team does but I had a thought before getting them involved. Would it be possible to use the dashboard script to do this without getting the WAT or do I absolutely need the WAT to hide the widget?

I ask because prism.user._id looks to be the same value for all sites I sign into. I should note we only have 1 WAT for all organizations, could the dev team be using the WAT differently on the back end to achieve the filtering?

zach_myt
10 - ETL
10 - ETL

I opened a ticket with support and they said there is no claim on the WAT that will currently let you hide one widget so there will have to be some customization here. I was unable to identify anything unique to organizations in the prism object so far. 

@rapidbisupport since we are only using 1 WAT for all organization I do not think your approach will work, although I do see the groups the dashboard is shared with like you mentioned in prism.user.groupsNames.name

zach_myt
10 - ETL
10 - ETL

I spoke with a Sisense developer and he stated this was not possible via WAT. Also since my prism is one user and group there isn't anything unique there. So the final options are:

1) Create a pivot widget with data on what you want to filter on, organization name in my case, then if that widget contains the organization you want to hide the widget for then simply hide the widget using the .hide(). This does show the widget for a moment then remove it. It will also need to be on its own row since the dashboard will not redraw the widgets to account for the removed one.

 

widget.on('ready', function(widget,result) {
 
   let orgs_with_location_codes = ["Org_1","Org_2"]
 
   let selected_org = $(`widget[widgetid="66293bbcaf582e003f18f101"`).find('.table-grid__content__inner').eq(1).text().trim();
 
if(orgs_with_location_codes.indexOf(selected_org) == -1){
     $(`widget[widgetid="66293ac8af582e003f18f0d5"`).hide(); //widget to hide
     $(`widget[widgetid="66293bbcaf582e003f18f101"`).hide(); //pivot used to filter org
}
 
});

 

 
2) Use a query parameter of hide widget = true in the dashboard URL then access the query parameter in the script to hide it like the above solution.
 
3) Have 2 dashboards, one with the widget and one without then redirect accordingly.
 
We will probably go with option 1 since it is the least code/admin heavy.