All Apps and Add-ons

How to create a module that has a "+" symbol to expand and display inputlookup results under a chart panel?

subtrakt
Contributor

Hello Friends!

I have a dashboard with panels...I have a lookup with instructions on who to contact if x is seen the panel...I'd like to put an HTML module or something, that has + to expand the instructions below the panel so the users knows what to do, if they see x. The module can be in the same Row as the panel. I don't need post-processing, dynamics, or anything fancy. Just a simple dropdown with the inputlookup results.

I would imagine an inline search with this '|inputlookup whotocontact.csv' on the module. Is there any way I can do the +(expand) -(collapse) with the whotocontact.csv contents?

Is the HTML module what I should use? Here's the XML for one of my panels on the dashboard.

    <param name="useHistory">True</param>
    <param name="savedSearch">searchpanelx</param>
    <module name="HiddenChartFormatter">
<param name="charting.legend">legend</param>
<param name="charting.legend.labelStyle.maximumWidth">400</param>
<param name="charting.legend.labelStyle.minimumWidth">400</param>
<module name="JobProgressIndicator"/>
        <param name="charting.chart.stackMode">stacked</param>
        <param name="charting.legend.placement">right</param>
        <param name="charting.chart">column</param>
    <param name="charting.fieldColors">{"Nothing":0x00FF00}</param>
        <module name="FlashChart">
            <param name="height">230px</param>
            <module name="HiddenSearch" layoutPanel="panel_row5_col1" autoRun="True">
                <param name="search"><![CDATA[`searchmacrox`]]></param>
        <param name="earliest">-2h</param>
                <module name="ConvertToDrilldownSearch">
                <module name="ViewRedirectorLink">
        <param name="popup">True</param>
                    <param name="viewTarget">flashtimeline</param>
                    <param name="label">All Results</param>
        </module>
                </module>
            </module>
        </module>
    </module>
  </module>
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

That sounds a lot like the expandable help text as found in the SoS app for example. Here's the relevant section grabbed from one of those views:

<module name="Button" layoutPanel="viewHeader">
  <param name="label">&#9658; Learn more</param>
  <param name="customBehavior">helpButton</param>
  <module name="ServerSideInclude" layoutPanel="viewHeader">
    <param name="src">indexing_performance.html</param>
  </module>
</module>

The SSI could just be a local HTML module, depending on reuse or simply amount of content.

Note, this makes use of Sideview Util's customBehavior calling a function from SoS's application.js to do the actual opening and closing of the content.

View solution in original post

sideview
SplunkTrust
SplunkTrust

You can implement this with some custom code in a customBehavior, using the customBehavior module. This is what the Sos app does with it's "Learn more" buttons. (As an aside I miss the olden days when that button text switched to "Learn less" when clicked. )

But customBehavior is kind of a last resort, and there's a couple ways to do this sort of thing without it. The best way is probably with a Switcher module. You would see a Switcher most commonly downstream from a Tabs module or a Pulldown module, and it would normally toggle which one of say 5 different "sets of modules" is active at any one time depending on the selected tab. But Switcher is a little more abstract than that.

Switcher will have one or more sub-branches of child modules, and then at any one time depending on some $foo$ token coming from above, it will show zero or one of those child branches. So in the case where it's switching between showing zero or 1 child branches, it can be thought of a "VisibilityToggler" module too.

The only ingredient missing to exactly match your requirement here, would be a sort of "ToggleLink" module, that had a link or button you could click, and whose label would toggle between "show instructions" and "hide instructions". However you can accomplish the same thing broadly speaking with a Checkbox module whose label says "show instructions".

The whole thing is a little silly and abstract looking, but if you break down the simple tasks that the individual modules are doing, it's at least modular, and even better, it doesn't require reading, writing or understanding Javascript.

<module name="Checkbox">
  <param name="label">show instructions</param>
  <param name="name">showInstructions</param>
  <param name="onValue">yesPleaseShowInstructions</param>

  <module name="Switcher" group=" ">
    <param name="selectedGroup">$showInstructions$</param>

    <module name="HTML" group="yesPleaseShowInstructions">
      <param name="html">Your instructions here</param>
    </module>
  </module>
</module>

martin_mueller
SplunkTrust
SplunkTrust

That sounds a lot like the expandable help text as found in the SoS app for example. Here's the relevant section grabbed from one of those views:

<module name="Button" layoutPanel="viewHeader">
  <param name="label">&#9658; Learn more</param>
  <param name="customBehavior">helpButton</param>
  <module name="ServerSideInclude" layoutPanel="viewHeader">
    <param name="src">indexing_performance.html</param>
  </module>
</module>

The SSI could just be a local HTML module, depending on reuse or simply amount of content.

Note, this makes use of Sideview Util's customBehavior calling a function from SoS's application.js to do the actual opening and closing of the content.

martin_mueller
SplunkTrust
SplunkTrust

Make sure you're not mixing up several Splunk Answers persona in one question, that's confusing.

Yeah, application.js is loaded by default.

To use that in one of your views you would copy the relevant JavaScript code to your application.js.

You can ignore the version numbers in any URLs, those are optional. For example, this http://localhost:8000/en-US/static/@213098.2/img/bookmark/apple-icon-57x57-precomposed.png gives me the same thing as this http://localhost:8000/en-US/static/img/bookmark/apple-icon-57x57-precomposed.png

0 Karma

DerekKing
Path Finder

Thanks for the help Martin - Appreciated.

ppablo
Retired

Hi @DerekKing (aka @subtrakt)

If @martin_mueller's answer solved your question, please be sure to accept his answer by clicking on the "Accept" button below his initial response.

0 Karma

DerekKing
Path Finder

My first caveat - My HTML is poor, so apologies if this is a basic question.

I cant see anywhere in the SOS page that calls the application.js script. Does this mean it is 'inferred' due to its location ?

How would I actually implement the expand functionality in one of my views please ? I also see looking at the source the SOS link uses @220630 as part of the path to .css files. Could you just explain the rationale behind actual links, because i'm having a problem understanding how I would change this to meet my environment.

Many Thanks
Derek

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...