Splunk Enterprise

Dashboard - Screenshot Button

threadover
Loves-to-Learn Everything

Hello,

I am trying to figure out why the script for my dashboard will not produce results. I am getting the error below.

"..//appname/appserver/static/components/html2canvas ” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff)

Dashboard XML

 

    <panel>
      <html>
        <div>
         <input id="btn-submit" type="button" class="btn btn-primary" value="Download Screenshot"/>
        </div>
      </html>  
    </panel>

 

JS in ...//appserver/static/test.js

 

require([
"underscore",
"jquery",
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!",
"//splunk/etc/apps/appname/appserver/static/components/html2canvas",
],
function(_, $, mvc,html2canvas) {

$("#btn-submit").on("click", function(e){
    var screenshot = require("//splunk/etc/apps/appname/appserver/static/components/html2canvas");

    screenshot(document.querySelector("#test1"), {scale:2}).then(canvas => {
        console.log(canvas);

        var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");

        var link = document.createElement('a');
        link.download = "Dashboard Report.png";
        link.href = image;
        link.click();
    });
  });
});

 

Any assistance is greatly appreciated.

0 Karma
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...