<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Progress bar/status for custom script in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/511713#M34112</link>
    <description>&lt;P&gt;I am building application in which which click of button, custom script (python) is executed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_0-1596098606590.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9959iF7440D59DE76ECDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_0-1596098606590.png" alt="yogip86_0-1596098606590.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_0-1596098606590.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In this image once we click Run Simulation button, it execute custom script (python). The issue is i am not able to see the progress on application/dashboard. I have to see console to see if execution is complete.&lt;/P&gt;&lt;P&gt;Below is html panel on dashboard.&lt;/P&gt;&lt;P&gt;&amp;lt;panel&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;button class="btn btn-default" id="run_search_btn"&amp;gt;Run Simulation&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/html&amp;gt;&lt;BR /&gt;&amp;lt;/panel&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want something like below :&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is screenshot from MLTK app. Once we click on "find cluster", it show status as "Running" (2nd screenshot below). How I can style my button to show such status in my custom script run?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_1-1596099072539.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9960i855C12D840FA3576/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_1-1596099072539.png" alt="yogip86_1-1596099072539.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_1-1596099072539.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_2-1596099124672.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9961i9AFA1DC4167D5140/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_2-1596099124672.png" alt="yogip86_2-1596099124672.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_2-1596099124672.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jul 2020 08:54:54 GMT</pubDate>
    <dc:creator>yogip86</dc:creator>
    <dc:date>2020-07-30T08:54:54Z</dc:date>
    <item>
      <title>Progress bar/status for custom script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/511713#M34112</link>
      <description>&lt;P&gt;I am building application in which which click of button, custom script (python) is executed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_0-1596098606590.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9959iF7440D59DE76ECDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_0-1596098606590.png" alt="yogip86_0-1596098606590.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_0-1596098606590.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In this image once we click Run Simulation button, it execute custom script (python). The issue is i am not able to see the progress on application/dashboard. I have to see console to see if execution is complete.&lt;/P&gt;&lt;P&gt;Below is html panel on dashboard.&lt;/P&gt;&lt;P&gt;&amp;lt;panel&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;button class="btn btn-default" id="run_search_btn"&amp;gt;Run Simulation&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/html&amp;gt;&lt;BR /&gt;&amp;lt;/panel&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want something like below :&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is screenshot from MLTK app. Once we click on "find cluster", it show status as "Running" (2nd screenshot below). How I can style my button to show such status in my custom script run?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_1-1596099072539.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9960i855C12D840FA3576/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_1-1596099072539.png" alt="yogip86_1-1596099072539.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_1-1596099072539.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yogip86_2-1596099124672.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9961i9AFA1DC4167D5140/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yogip86_2-1596099124672.png" alt="yogip86_2-1596099124672.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;yogip86_2-1596099124672.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 08:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/511713#M34112</guid>
      <dc:creator>yogip86</dc:creator>
      <dc:date>2020-07-30T08:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Progress bar/status for custom script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/511828#M34126</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222777"&gt;@yogip86&lt;/a&gt;&amp;nbsp;you can use Simple XML JS extension to change the Button attribute to disabled. Refer to one of my older answers on similar lines:&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Security/Can-i-restrict-permissions-for-the-text-box-drilldown-inputs/td-p/338529" target="_blank"&gt;https://community.splunk.com/t5/Security/Can-i-restrict-permissions-for-the-text-box-drilldown-inputs/td-p/338529&lt;/A&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;On Click of the Run Simulation button, you can set a dummy Token using SplunkJS which should have dependency with the custom command search that you want to run. This will ensure that the Custom command does not execute when the dashboard loads.&lt;/LI&gt;&lt;LI&gt;Disable the Run simulation button by setting the button's disabled attribute.&lt;/LI&gt;&lt;LI&gt;Call startSearch() function using SplunkJS based on the Search ID to start the custom command search.&lt;/LI&gt;&lt;LI&gt;Once the search completes, capture the same using done search event handler in JS.&lt;/LI&gt;&lt;LI&gt;Unset the dummy token after search completes so that Simulation can be executed again.&lt;/LI&gt;&lt;LI&gt;Enable the Run Simulation button using jQuery to remove disabled attribute.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;PS: I have added alert messages towards beginning and end of custom command execution to capture and demo the behavior, you can get rid of them if not required.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2020-07-30 at 11.08.08 PM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9972i7D5677E0AC26FCC5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-07-30 at 11.08.08 PM.png" alt="Screen Shot 2020-07-30 at 11.08.08 PM.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Screen Shot 2020-07-30 at 11.08.08 PM.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2020-07-30 at 11.18.17 PM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9973i51A1B91FACF2310E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-07-30 at 11.18.17 PM.png" alt="Screen Shot 2020-07-30 at 11.18.17 PM.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Screen Shot 2020-07-30 at 11.18.17 PM.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Following is a run Anywhere example based on details provided.&lt;BR /&gt;Simple XML Dashboard Code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="run_simulation.js"&amp;gt;
  &amp;lt;label&amp;gt;Command Execution on Button Click&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="false"&amp;gt;&amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;b&amp;gt;Demand&amp;lt;/b&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;Category 1&amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="text" token="min_deviation" searchWhenChanged="false"&amp;gt;
        &amp;lt;label&amp;gt;Min Deviation (%age)&amp;lt;/label&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;input type="text" token="max_deviation" searchWhenChanged="false"&amp;gt;
        &amp;lt;label&amp;gt;Min Deviation (%age)&amp;lt;/label&amp;gt;
      &amp;lt;/input&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;Category 2&amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="text" token="field3" searchWhenChanged="false"&amp;gt;
        &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;input type="text" token="field4" searchWhenChanged="false"&amp;gt;
        &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;/input&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;button id="run_simulation" class="btn btn-primary"&amp;gt;Run Simulation&amp;lt;/button&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Required JS Code&amp;nbsp;&lt;STRONG&gt;run_simulation.js&lt;/STRONG&gt;:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
        'jquery',
        'splunkjs/mvc',
        'splunkjs/mvc/searchmanager',
        'splunkjs/mvc/simplexml/ready!'
], function ($,mvc,SearchManager) {
        var submittedTokenModel=mvc.Components.get("submitted");
        var sSim = new SearchManager({
                "search": "index=_internal earliest=-1h latest=now | table _time component log_level _raw",
                "id": "sSim",
                "tokenDependencies": {
                        "depends": "$runSimulation$"
                }
        }, { tokens: true, tokenNamespace: "submitted" });

        $('#run_simulation').on("click", function () {
                $('#run_simulation').attr( "disabled", "disabled" );
                alert("Starting Simulation!");
                submittedTokenModel.set("runSimulation","true");
                sSim.startSearch();
        });

        sSim.on("search:done", function () {
                alert("Simulation Complete,");
                submittedTokenModel.unset("runSimulation");
                $("#run_simulation").removeAttr( "disabled");
        });
});&lt;/LI-CODE&gt;&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 18:05:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/511828#M34126</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-07-30T18:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Progress bar/status for custom script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/512927#M34222</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; . It worked for me!!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 06:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Progress-bar-status-for-custom-script/m-p/512927#M34222</guid>
      <dc:creator>yogip86</dc:creator>
      <dc:date>2020-08-07T06:23:43Z</dc:date>
    </item>
  </channel>
</rss>

