<?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 Re: SplunkJS and HTML Dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195234#M12201</link>
    <description>&lt;P&gt;I added a bit more clarification to what I'm trying to accomplish to my post above. I feel like there is a foundational thing here I'm not understanding and to me the documentation isn't making clear.&lt;/P&gt;

&lt;P&gt;I did start with a simple XML dashboard and converted to HTML. But like your example above, that is a lot of javascript for just a one SingleView component. Is it all necessary? I can't strip out all that unnecessary stuff, keep jus the CSS files, follow the dashboards style guide and use SplunkJS example code?&lt;/P&gt;

&lt;P&gt;I know it's something I'm missing, I just don't know what it is.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jun 2014 12:49:55 GMT</pubDate>
    <dc:creator>devicenul1</dc:creator>
    <dc:date>2014-06-12T12:49:55Z</dc:date>
    <item>
      <title>SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195231#M12198</link>
      <description>&lt;P&gt;Trying to build a simple HTML dashboard but there seems to be some foundational thing I'm not understanding. I've created a simple dashboard and converted to HTML, in the editor I've narrowed it down to just this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;title&amp;gt;test HTML | Splunk&amp;lt;/title&amp;gt;
    &amp;lt;link rel="shortcut icon" href="{{SPLUNKWEB_URL_PREFIX}}/static/img/favicon.ico" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="{{SPLUNKWEB_URL_PREFIX}}/static/css/bootstrap.min.css" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" media="all" href="{{SPLUNKWEB_URL_PREFIX}}/static/css/pages/dashboard-simple-bootstrap.min.css" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" media="all" href="{{SPLUNKWEB_URL_PREFIX}}/static/app/search/dashboard.css" /&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;!--
    BEGIN LAYOUT
    This section contains the layout for the dashboard. Splunk uses proprietary
    styles in &amp;lt;div&amp;gt; tags, similar to Bootstrap's grid system.
    --&amp;gt;
    &amp;lt;div class="dashboard-body container-fluid main-section-body" data-role="main"&amp;gt;
        &amp;lt;div class="span 12 dashboard-header clearfix"&amp;gt;
            &amp;lt;h2&amp;gt;test HTML&amp;lt;/h2&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="dashboard-row"&amp;gt;
            &amp;lt;div class="dashboard-cell" style="width: 100%;"&amp;gt;
                &amp;lt;div class="dashboard-panel"&amp;gt;
                        &amp;lt;div class="panel-head"&amp;gt;
                            &amp;lt;p&amp;gt;panel-head&amp;lt;/p&amp;gt;
                        &amp;lt;/div&amp;gt;
                        &amp;lt;div class="panel-body"&amp;gt;
                            &amp;lt;p&amp;gt;panel-body&amp;lt;/p&amp;gt;
                            &amp;lt;div class="splunk-view" id="single1"&amp;gt;&amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;!--
    END LAYOUT
    --&amp;gt;
    &amp;lt;script type="text/javascript"&amp;gt;
      var deps = [
        "splunkjs/mvc",
        "splunkjs/mvc/singleview",
        "splunkjs/mvc/searchmanager"
      ];

      require(deps, function() {
        var SingleView = require("splunkjs/mvc/singleview");
        var SearchManager = require("splunkjs/mvc/searchmanager");

        new SingleView({
            id: "single1",
            managerid: "search1",
            beforeLabel: "count of Events",
            el: $("#single1")
        });

        new SearchManager({
            id: "search1",
            earliest_time: "-15m",
            latest_time: "now",
            search: "index=_internal | stats count"
        });
      });
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's just an empty page with just panel-head and panel-body showing up, the styles seem to be all messed up too. I suspect that I &lt;STRONG&gt;must&lt;/STRONG&gt; create a new Splunk app and build the dashboards html pages in my custom app. Is that what I'm missing?&lt;/P&gt;

&lt;P&gt;What my code is trying to accomplish, a working dashboard (minimal code) using the example code from the Web Framework Toolkit for the SingleView form component.&lt;/P&gt;

&lt;P&gt;What I'm trying to accomplish, understanding how to start a Dashboard using a sample / examples from the documentation / web framework toolkit with minimum amount of required code.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2014 20:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195231#M12198</guid>
      <dc:creator>devicenul1</dc:creator>
      <dc:date>2014-06-10T20:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195232#M12199</link>
      <description>&lt;P&gt;&lt;A href="http://www.youtube.com/watch?v=f4zyjLyBp64"&gt;http://www.youtube.com/watch?v=f4zyjLyBp64&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 20:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195232#M12199</guid>
      <dc:creator>devicenul1</dc:creator>
      <dc:date>2014-06-11T20:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195233#M12200</link>
      <description>&lt;P&gt;What exactly are you trying to do here?&lt;/P&gt;

&lt;P&gt;It looks like you took a Simple XML dashboard that included a single value element, and converted that to HTML.  Then you modified the HTML page to remove the splunk bar, etc.   &lt;/P&gt;

&lt;P&gt;What may need clarification here is what you were trying to do.&lt;/P&gt;

&lt;P&gt;If I take a Simple XML dashboard (like the one you built here), and convert it to html, it works fine for me.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;title&amp;gt;Convert to HTML | Splunk&amp;lt;/title&amp;gt;
    &amp;lt;link rel="shortcut icon" href="{{SPLUNKWEB_URL_PREFIX}}/static/img/favicon.ico" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="{{SPLUNKWEB_URL_PREFIX}}/static/css/build/bootstrap.min.css" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" media="all" href="{{SPLUNKWEB_URL_PREFIX}}/static/css/build/pages/dashboard-simple-bootstrap.min.css" /&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" media="all" href="{{SPLUNKWEB_URL_PREFIX}}/static/app/search/dashboard.css" /&amp;gt;
    &amp;lt;!--[if IE 7]&amp;gt;&amp;lt;link rel="stylesheet" href="{{SPLUNKWEB_URL_PREFIX}}/static/css/sprites-ie7.css" /&amp;gt;&amp;lt;![endif]--&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body class="simplexml preload"&amp;gt;

&amp;lt;!-- 
BEGIN LAYOUT
This section contains the layout for the dashboard. Splunk uses proprietary
styles in &amp;lt;div&amp;gt; tags, similar to Bootstrap's grid system. 
--&amp;gt;
&amp;lt;a class="navSkip" href="#navSkip" tabindex="1"&amp;gt;Screen reader users, click here to skip the navigation bar&amp;lt;/a&amp;gt;
&amp;lt;div class="header"&amp;gt;
    &amp;lt;div id="placeholder-splunk-bar"&amp;gt;
        &amp;lt;a href="{{SPLUNKWEB_URL_PREFIX}}/app/launcher/home" class="brand" title="splunk &amp;amp;gt; listen to your data"&amp;gt;splunk&amp;lt;strong&amp;gt;&amp;amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/a&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div id="placeholder-app-bar"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;a id="navSkip"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;div class="dashboard-body container-fluid main-section-body" data-role="main"&amp;gt;
    &amp;lt;div class="dashboard-header clearfix"&amp;gt;
        &amp;lt;h2&amp;gt;Convert to HTML&amp;lt;/h2&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="dashboard-row dashboard-row1"&amp;gt;
        &amp;lt;div class="dashboard-cell" style="width: 100%;"&amp;gt;
            &amp;lt;div class="dashboard-panel clearfix"&amp;gt;                
                &amp;lt;div class="panel-element-row"&amp;gt;

                    &amp;lt;div class="dashboard-element single" id="element1" style="width: 100%"&amp;gt;
                        &amp;lt;div class="panel-body"&amp;gt;&amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class="footer"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;!-- 
END LAYOUT
--&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
    function _curTime(){ return new Date().getTime(); }
    var __pageStart = _curTime(), last = __pageStart;
    function __log_perf(type) { var cur = _curTime(); console.log('[PERF] %o in duration=%o ms (sinceLast=%o ms)', type, cur-__pageStart, cur-last); last = cur;  }
    if(window.console &amp;amp;&amp;amp; typeof window.console.timeStamp === 'function') { var orig = __log_perf; __log_perf = function(type){ console.timeStamp(type); orig(type); } }
    document.addEventListener('DOMContentLoaded', function(){ __log_perf('DOMContentLoaded'); });
    document.addEventListener('load', function(){ __log_perf('load'); });
&amp;lt;/script&amp;gt;
&amp;lt;script src="{{SPLUNKWEB_URL_PREFIX}}/config?autoload=1"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="{{SPLUNKWEB_URL_PREFIX}}/static/js/i18n.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="{{SPLUNKWEB_URL_PREFIX}}/i18ncatalog?autoload=1"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="{{SPLUNKWEB_URL_PREFIX}}/static/js/build/simplexml.min/config.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
__log_perf('loaded static scripts');
require.config({
    baseUrl: "{{SPLUNKWEB_URL_PREFIX}}/static/js",
    waitSeconds: 0 // Disable require.js load timeout
});
__log_perf('configured require');

//
// LIBRARY REQUIREMENTS
//
// In the require function, we include the necessary libraries and modules for
// the HTML dashboard. Then, we pass variable names for these libraries and
// modules as function parameters, in order.
// 
// When you add libraries or modules, remember to retain this mapping order
// between the library or module and its function parameter. You can do this by
// adding to the end of these lists, as shown in the commented examples below.

require([
    "splunkjs/mvc",
    "splunkjs/mvc/utils",
    "splunkjs/mvc/tokenutils",
    "underscore",
    "jquery",
    "splunkjs/mvc/simplexml",
    "splunkjs/mvc/headerview",
    "splunkjs/mvc/footerview",
    "splunkjs/mvc/simplexml/dashboardview",
    "splunkjs/mvc/simplexml/element/chart",
    "splunkjs/mvc/simplexml/element/event",
    "splunkjs/mvc/simplexml/element/html",
    "splunkjs/mvc/simplexml/element/list",
    "splunkjs/mvc/simplexml/element/map",
    "splunkjs/mvc/simplexml/element/single",
    "splunkjs/mvc/simplexml/element/table",
    "splunkjs/mvc/simpleform/formutils",
    "splunkjs/mvc/simpleform/input/dropdown",
    "splunkjs/mvc/simpleform/input/radiogroup",
    "splunkjs/mvc/simpleform/input/multiselect",
    "splunkjs/mvc/simpleform/input/checkboxgroup",
    "splunkjs/mvc/simpleform/input/text",
    "splunkjs/mvc/simpleform/input/timerange",
    "splunkjs/mvc/simpleform/input/submit",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/savedsearchmanager",
    "splunkjs/mvc/postprocessmanager",
    "splunkjs/mvc/simplexml/urltokenmodel"
    // Add comma-separated libraries and modules manually here, for example:
    // ..."splunkjs/mvc/simplexml/urltokenmodel",
    // "splunkjs/mvc/checkboxview"
    ],
    function(
        mvc,
        utils,
        TokenUtils,
        _,
        $,
        DashboardController,
        HeaderView,
        FooterView,
        Dashboard,
        ChartElement,
        EventElement,
        HtmlElement,
        ListElement,
        MapElement,
        SingleElement,
        TableElement,
        FormUtils,
        DropdownInput,
        RadioGroupInput,
        MultiSelectInput,
        CheckboxGroupInput,
        TextInput,
        TimeRangeInput,
        SubmitButton,
        SearchManager,
        SavedSearchManager,
        PostProcessManager,
        UrlTokenModel

        // Add comma-separated parameter names here, for example: 
        // ...UrlTokenModel, 
        // CheckboxView
        ) {

        __log_perf('required dependencies');
        $('body').on('loaded', function(){ __log_perf('preload done'); });

        __log_perf('imported dependencies');

        var pageLoading = true;


        // 
        // TOKENS
        //

        // Create token namespaces
        var urlTokenModel = new UrlTokenModel();
        mvc.Components.registerInstance('url', urlTokenModel);
        var defaultTokenModel = mvc.Components.getInstance('default', {create: true});
        var submittedTokenModel = mvc.Components.getInstance('submitted', {create: true});

        urlTokenModel.on('url:navigate', function() {
            defaultTokenModel.set(urlTokenModel.toJSON());
            if (!_.isEmpty(urlTokenModel.toJSON()) &amp;amp;&amp;amp; !_.all(urlTokenModel.toJSON(), _.isUndefined)) {
                submitTokens();
            } else {
                submittedTokenModel.clear();
            }
        });

        // Initialize tokens
        defaultTokenModel.set(urlTokenModel.toJSON());

        function submitTokens() {
            // Copy the contents of the defaultTokenModel to the submittedTokenModel and urlTokenModel
            FormUtils.submitForm({ replaceState: pageLoading });
        }

        function setToken(name, value) {
            defaultTokenModel.set(name, value);
            submittedTokenModel.set(name, value);
        }

        function unsetToken(name) {
            defaultTokenModel.unset(name);
            submittedTokenModel.unset(name);
        }
        __log_perf('created submission models');

        //
        // SEARCH MANAGERS
        //

        var search1 = new SearchManager({
            "id": "search1",
            "status_buckets": 0,
            "search": "index=_internal | stats count",
            "latest_time": "now",
            "cancelOnUnload": true,
            "earliest_time": "-15m",
            "app": utils.getCurrentApp(),
            "auto_cancel": 90,
            "preview": true,
            "runWhenTimeIsUndefined": false
        }, {tokens: true, tokenNamespace: "submitted"});

        __log_perf('started search search1');


        //
        // SPLUNK HEADER AND FOOTER
        //

        new HeaderView({
            id: 'header',
            section: 'dashboards',
            el: $('.header'),
            acceleratedAppNav: true,
            useSessionStorageCache: true
        }, {tokens: true}).render();

        new FooterView({
            id: 'footer',
            el: $('.footer')
        }, {tokens: true}).render();


        //
        // DASHBOARD EDITOR
        //

        new Dashboard({
            id: 'dashboard',
            el: $('.dashboard-body')
        }, {tokens: true}).render();


        //
        // VIEWS: VISUALIZATION ELEMENTS
        //

        var element1 = new SingleElement({
            "id": "element1",
            "linkView": "search",
            "drilldown": "none",
            "beforeLabel": "count of Events",
            "managerid": "search1",
            "el": $('#element1')
        }, {tokens: true}).render();
        __log_perf('initialized element element1');

        __log_perf('initialized components');

        // Initialize time tokens to default
        if (!defaultTokenModel.has('earliest') &amp;amp;&amp;amp; !defaultTokenModel.has('latest')) {
            defaultTokenModel.set({ earliest: '0', latest: '' });
        }

        submitTokens();


        //
        // DASHBOARD READY
        //

        DashboardController.ready();
        pageLoading = false;

    }
);
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jun 2014 21:44:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195233#M12200</guid>
      <dc:creator>nfilippi_splunk</dc:creator>
      <dc:date>2014-06-11T21:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195234#M12201</link>
      <description>&lt;P&gt;I added a bit more clarification to what I'm trying to accomplish to my post above. I feel like there is a foundational thing here I'm not understanding and to me the documentation isn't making clear.&lt;/P&gt;

&lt;P&gt;I did start with a simple XML dashboard and converted to HTML. But like your example above, that is a lot of javascript for just a one SingleView component. Is it all necessary? I can't strip out all that unnecessary stuff, keep jus the CSS files, follow the dashboards style guide and use SplunkJS example code?&lt;/P&gt;

&lt;P&gt;I know it's something I'm missing, I just don't know what it is.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2014 12:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195234#M12201</guid>
      <dc:creator>devicenul1</dc:creator>
      <dc:date>2014-06-12T12:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195235#M12202</link>
      <description>&lt;P&gt;did that make it a bit more clear? something still not making sense?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 13:01:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195235#M12202</guid>
      <dc:creator>devicenul1</dc:creator>
      <dc:date>2014-06-13T13:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS and HTML Dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195236#M12203</link>
      <description>&lt;P&gt;I'm going to mark this as the answer as I think you were trying to get across the concept that you can't use SplunkJS within splunk. It's an additional component you download and wire for your own web apps. I was assuming (Since the documentation between the web framework and SplunkJS link to each other) that they were all useable inside Splunk. This would be the foundational thing I wasn't understanding.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 17:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/SplunkJS-and-HTML-Dashboard/m-p/195236#M12203</guid>
      <dc:creator>devicenul1</dc:creator>
      <dc:date>2014-06-13T17:42:22Z</dc:date>
    </item>
  </channel>
</rss>

