Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

How to conditionally display HTML panels with a token, set via a javascript program?

$
0
0
I have a fair idea that `depends="$token$"` can be used to display or hide the panel. My requirement is that I get the list of roles for a user, via a Javascript file, and load it onto tokens present on the dashboard. Now, these tokens will be set to "null" when the dashboard initially loads, and from the script, set to the role value. The dashboard itself is filled with panels which I need to conditionally display based on the roles returned from the search. Here is some code I have put together: trying to render based on token setting from JS
I also have CSS attached to the dashboard And, here is the JS code: require([ "jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!" ], function( $, mvc ) { var tokens = mvc.Components.get("default"); var permissionGrant = "power"; tokens.set("role1", permissionGrant); }); So, summarizing, the JS will set the token "role1" with a value from a search(In the example I have hardcoded the value). The panel will then make a request and get the relevant HTML page and render it. Thanks in advance. Splunk for Life :)

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>