Remove filters and drill downs on sign out
Introduction:
To set the dashboard to default state we can remove all the filters and all the drill downs from the javascript API.
The filters and drills will be removed only when clicking the sign-out button.
Using Javascript:
Edit the dashboard script and insert the following code:
It will attach the sign out button event that will trigger on click.
It removes all the filters from the dashboard and drills up every widget to the top level.
dashboard.on('refreshend', function(se, ev){
$('.signout-text').on('click', function(){
//Remove all filters
prism.$ngscope.dashboard.filters.clear();
prism.$ngscope.dashboard.filters.update([], {refresh:true, save:true});
// remove all drill downs
_.each(se.widgets.$$widgets, function(widget, index){
if(_.find(widget.rawQueryResult.metadata, function(md){return md.through != undefined})){
var id = widget.oid;
var scope = angular.element($('widget[widgetid="'+id+'"]')).scope()
var activity = prism.$injector.get('base.services.$activity');
prism.$command.create('dashboard.commands.drillUp', { $scope: scope, $activity: activity }).execute();
}
})
})
})
Dashboard_Remove_Filters_And_Drill_Downs.zip
-
Hi Eli,
I have not tried the script but do you think it could be adapted so that drilling down any one widget would automatically drill down all the other widgets of the dashboard sharing the same dimension (assuming same aggregation)?
Also, I am testing the script to see how removing filters and drillup work but changing the selector to the user icon and adding a few console logs here and there:
dashboard.on('refreshend', function(se, ev){
$('.app-icon--header-user').on('click', function(){
console.clear();
console.log(se);
console.log(ev);
//Remove all filters
prism.$ngscope.dashboard.filters.clear();
prism.$ngscope.dashboard.filters.update([], {refresh:true, save:true});
// remove all drill downs
_.each(se.widgets.$$widgets, function(widget, index){
let id = widget.oid;
let scope = angular.element($('widget[widgetid="'+id+'"]')).scope()
let activity = prism.$injector.get('base.services.$activity');
console.log(id + ", scope: " + scope + ", activity: " );
console.log(JSON.stringify(activity));
if(_.find(widget.rawQueryResult.metadata, function(md){return md.through != undefined})){
prism.$command.create('dashboard.commands.drillUp', { $scope: scope, $activity: activity }).execute();
}
})
})
})I get the following results
c {_id: "5dbafdbc9939eae3386878e2", title: "DashboardTest", oid: "5dbafdbc9939eae3386878e1", desc: "", source: null, …}
{dashboard: c, completedQueries: 0}
5dbb03e475c70be3644aad28, scope: undefined, activity:
{}
5ddfbc9c9aeff53db4de54b3, scope: undefined, activity:
{}
5ddfbcd39aeff53db4de54bc, scope: undefined, activity:
{}
5ddfc1a59aeff53db4de54d5, scope: undefined, activity:
{}
5ddfc2a09aeff53db4de54d9, scope: undefined, activity:
{}
5ddfc3b281966d063870d5b5, scope: undefined, activity:
{}
5ddfc81a81966d063870d5be, scope: undefined, activity:
{}Testing in Chrome 78.0.3904.108 and Windows 10 64bit and Sisense 8.0.1.10112.
Thanks
Please sign in to leave a comment.
Comments
3 comments