Dashboards & Visualizations

New button next to edit and export button

DataOrg
Builder

i want to create a new button and place it in the row where default(EDIT, Export) button present.
the new button will be hyper link .

0 Karma

niketn
Legend

Here is a slightly different version with jQuery.

require([
 'underscore',
 'jquery',
 'splunkjs/mvc',
 'splunkjs/mvc/simplexml/ready!'], function (_, $, mvc) {
    var objEditMenu=$("div.dashboard-header-editmenu");
    if (objEditMenu!==undefined){
        $('<a target="_blank" class="btn edit-btn anchor-right" style="float: right;margin-right: 10px;" href="https://google.com">Google</a>').insertAfter('div.dashboard-header-editmenu');
    };
});
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

andrewtrobec
Motivator

This works perfectly, thanks!

0 Karma

gaurav_maniar
Builder

Hi,

create a example.js file at app_name/appserver/static location, and add the following code,

require([
 "splunkjs/mvc",
 "splunkjs/mvc/simplexml/ready!"
 ], function(mvc) {

    var x = document.getElementsByClassName("dashboard-view-controls");
    var y = "<a class=\"btn\" href=\"https://www.google.com\" target=\"_blank\">Extra Button</a>\n";
    x[0].innerHTML = y + x[0].innerHTML;

 });

Include this script on your dashboard XML and it's done - <dashboard script="example.js">
You can change values in var y according to your requirement.

Please Upvote & Accept the answer if it helps.

happy splunking......!! 🙂

andrewtrobec
Motivator

This works well, but in my case it creates an undesired effect: the Export button on the right side of the Edit button stops working.

Using Splunk 7.3.2 with Chrome Version 79.0.3945.117

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...