Dashboards & Visualizations

Is it possible to open a pop-up window from a drilldown?

Msugiyama
Path Finder

Dear ALL,

Is it possible to display a "yes" or "no" pop-up window before performing a search from the dashboard drilldown?

To prevent operational mistakes, I would like to stop opening the search SPL if there is a problem.

Labels (1)
Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Msugiyama 

Just understanding your case,  you want to get confirmation (using JS confirm OR Popup ) from user on drilldown whether search could perform OR not.. right?

If I'm right can you please share, in case of Yes, how you want to execute search on drilldown and what should be the behaviour if No?  And what panel you are using for drilldown.

Note: In both ways, you need to go through javascript extensions. 

 

KV

0 Karma

Msugiyama
Path Finder

Thanks for the reply.
I'll check the references you gave me.

I'm assuming I'll create a custom search command that deletes the files in the drill down.
To prevent operation errors, I would like to display "yes" or "no" before deleting the file.

The dashboard panel will display a list of files stored in the target directory.
Select a file and display the popup.
→ If "Yes", execute the custom search command to delete the file.
→ If "No", abort the execution.
We are looking into whether or not these things can be done.

Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Msugiyama 

Can you please try this Simple XML Dashboard?

 

<dashboard script="a.js">
  <label>Delete File with Confirmation</label>
  <row>
    <panel>
      <table id="tbl_files">
        <title>Files</title>
        <search>
          <query>| makeresults count=10 | eval a=1 | accum a | eval file="/opt/myfiles/A"+a+"_file.txt"</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">cell</option>
        <drilldown>
          <condition>
            
          </condition>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>

 

a.js

require([
    'underscore',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager',
    'jquery',
    "splunkjs/mvc/simplexml/ready!"
], function(_, mvc, SearchManager, $) {
    var tokens = mvc.Components.get("submitted");
    var tbl_files = mvc.Components.get('tbl_files');

    var fileDeleteSearch = new SearchManager({
        id: "fileDeleteSearch",
        earliest_time: "0",
        latest_time: "",
        preview: true,
        autostart: false,
        cache: false,
        search: '| makeresults count=1 | eval comment = "Execute Command for delete $file_name$ file."'
    }, { tokens: true, tokenNamespace: "submitted" });



    fileDeleteSearch.on("search:error", function(e) {
        console.log("Error", e);
        console.log("Error", tokens.get("file_name"));

    })
    fileDeleteSearch.on("search:done", function() {
        var myResults = fileDeleteSearch.data("results"); // get the data from that search

        myResults.on("data", function() {
            resultArray = myResults.data().rows;
            console.log(resultArray);
            alert("File Deleted");
        })
    })


    tbl_files.on("click", function(e) {
        e.preventDefault();
        var file_name = e.data['click.value2'];
        console.log(e.data['click.value2'])
        if (confirm('Are you sure you want to delete ' + file_name + ' file?')) {
            // Delete the file
            tokens.set("file_name", file_name);
            console.log('Delete ' + file_name);
            fileDeleteSearch.startSearch();

        } else {
            alert("File Deletion Aborted");
            // Do nothing!
            console.log('File Deletion Aborted ' + file_name);
        }
    });
});

 

I hope this will help you.

 

Thanks
KV
▄︻̷̿┻̿═━一   😉

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...