Splunk Search

can i hide and show the modules ??

rakesh_498115
Motivator

Hi..

I have created a advanced xml with certain no of modules in it.can i hide the modules and display when ever i need .. is this possible in splunk ??

please help

Tags (2)
0 Karma

joebensimo
Path Finder

If all you need to do is hide a module from the UI, this can be easily done with CSS (and maybe some ValueSetter modules). I am doing this by adding a cssClass parameter to modules set to the ViewRedirector class suffixed with a variable that will be blank when want the item hidden.

ViewRedirector$variableThatWillBeBlankWhenIWantToHideTheModule$

When the suffixed variable's value is NULL or an empty string, the class will be ViewRedirector, which contains display:none which hides the module from the UI. When the variable value is not blank, it will assign a non-existent (unless you create it) class name and will therefore not hide the module.

If you don't want to use the existing ViewRedirector class, you can create your own class that contains display:none.

Please be aware that this only hides the module from view in the browser. Any settings set in it before it is hidden will still exist.

0 Karma

Bhuavana
Explorer

Hi could you please share me your above sample code?

0 Karma

guilhem
Contributor

Using sideviewUtils and customBehavior, here's what I have come up with (write this inside the /Myapp/appserver/static/application.js file):

// Declare the name of the customBahavior inside the module you want to hide according to upstream context (here I have called it hideModule).
Sideview.utils.declareCustomBehavior("hideModule", hideFunction);

// Register the function you want to call whant this customBehavior is triggered
function hideFunction(module)
{
        // Register the callback for the event you want your custom behavior to trigger on,
        // Here I want it to trigger on context change
        module.onContextChange=contextFunctionCallBack;
}

// Hide/Show the module according to upstream context value
function contextFunctionCallBack()
{
        // Note that the name "MyCustomValue" have to be declared in a module upstream
        if(this.getContext().get("MyContextValue") == -1)
        {
                this.show();
        }
        else
        {
                this.hide();
        }
}

This has worked nicely for me.

One thing remains, I want to be able to hide the module when the page is displayed (by default the module should be hidden), I didn't found a way to do this (see topic here).

guilhem
Contributor

I have the same problem, I want to show/ hide modules, but I really do not want to use the switcher module as I would have to duplicate all of the subtree hierarchy.

Could you provide a core js file where this functionality is implemented?

Many thanks,

Guilhem

0 Karma

guilhem
Contributor

Thanks! I will try to do it myself (I have wandered a bit in the sideview *.js files). If I have any trouble I'll let you know.

0 Karma

sideview
SplunkTrust
SplunkTrust

I often have to show and hide modules in my apps, and I use a customBehavior with a little bit of Javascript. The most common case I hit is where there's a Pulldown or TextField that is only relevant when some other value is selected upstream. It's quite easy to wire up with a customBehavior though; if you post it as another question I can answer it and give sample code.

0 Karma

sowings
Splunk Employee
Splunk Employee

You can use the "Switcher" module family to show or hide certain pieces of the dashboard. Without more specifics, however, it's difficult for me to provide a more targeted answer.

sideview
SplunkTrust
SplunkTrust

Switcher is a module included in Sideview Utils 2.0, and there is a page of documentation about Switcher inside the app. It's possible sowings is talking about the TabSwitcher/LinkSwitcher/PulldownSwitcher modules in splunk core, but since Switcher is a more fundamental app that just does the show/hide stuff, I think he's talking about Switcher.

Also, in general hiding and showing modules according to custom logic is something that is commonly done from Sideview "customBehavior" code, that you write in application.js

0 Karma

rakesh_498115
Motivator

can you please provide an example for that swichter module ??

0 Karma
.conf21 Now Fully Virtual!
Register for FREE Today!

We've made .conf21 totally virtual and totally FREE! Our completely online experience will run from 10/19 through 10/20 with some additional events, too!