<?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 Reading a text token with javascript. in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Reading-a-text-token-with-javascript/m-p/537145#M36711</link>
    <description>&lt;P&gt;I am starting to add some JS elements to dashboards.&amp;nbsp; I can't quite get the text input box to work like I think it should be. (nor is the time range working, but I hadn't worked on that really). I feel like I am close but I have tried a few options and it isn't loading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="js/views/js_testing.js"&amp;gt;
  &amp;lt;label&amp;gt;JS Testing&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="true"&amp;gt;
    &amp;lt;input type="text" token="ip_field1"&amp;gt;
      &amp;lt;label&amp;gt;Test Value&amp;lt;/label&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="time" token="field1"&amp;gt;
      &amp;lt;label&amp;gt;Time Picker&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Test data - $ip_field1$&amp;lt;/title&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div id="mytable1"/&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Javascript&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// LIBRARIES

require([
    "splunkjs/mvc",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/singleview",
    "splunkjs/mvc/tableview",
    "splunkjs/mvc/simplexml/ready!"
], function(
    mvc,
    SearchManager,
    SingleView,
    TableView
) {

 // SEARCH MANAGERS
    var search1 = new SearchManager({
        id: "connections",
        search: "index=zeek_conn id.orig_h=$ip_field1$ OR id.resp_h=$ip_field1$ | table _time id.orig_h id.resp_h",
        preview: true,
        cache: true,
        earliest_time: "-30d",
        latest_time: "now"
    }, {tokens: true});

// TOKENS
    var tokens = mvc.Components.get("default");
    $(document).on("click", "#submit", function(e){
        var tok1 = tokens.get("ip_field1");

        if (tok1 == undefined || tok1 == ""){
            tokens.set("ip_field1", "*");
        }
    });
    
    var mytoken = tokens.get("ip_field1");

// INSERT_TABLE_VIEW
    var table1 = new TableView({
        id: "my-table1",
        managerid: "connections",
        el: $("#mytable1")
    }).render();

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 00:03:47 GMT</pubDate>
    <dc:creator>mike-48735</dc:creator>
    <dc:date>2021-01-26T00:03:47Z</dc:date>
    <item>
      <title>Reading a text token with javascript.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Reading-a-text-token-with-javascript/m-p/537145#M36711</link>
      <description>&lt;P&gt;I am starting to add some JS elements to dashboards.&amp;nbsp; I can't quite get the text input box to work like I think it should be. (nor is the time range working, but I hadn't worked on that really). I feel like I am close but I have tried a few options and it isn't loading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="js/views/js_testing.js"&amp;gt;
  &amp;lt;label&amp;gt;JS Testing&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="true"&amp;gt;
    &amp;lt;input type="text" token="ip_field1"&amp;gt;
      &amp;lt;label&amp;gt;Test Value&amp;lt;/label&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="time" token="field1"&amp;gt;
      &amp;lt;label&amp;gt;Time Picker&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Test data - $ip_field1$&amp;lt;/title&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div id="mytable1"/&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Javascript&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// LIBRARIES

require([
    "splunkjs/mvc",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/singleview",
    "splunkjs/mvc/tableview",
    "splunkjs/mvc/simplexml/ready!"
], function(
    mvc,
    SearchManager,
    SingleView,
    TableView
) {

 // SEARCH MANAGERS
    var search1 = new SearchManager({
        id: "connections",
        search: "index=zeek_conn id.orig_h=$ip_field1$ OR id.resp_h=$ip_field1$ | table _time id.orig_h id.resp_h",
        preview: true,
        cache: true,
        earliest_time: "-30d",
        latest_time: "now"
    }, {tokens: true});

// TOKENS
    var tokens = mvc.Components.get("default");
    $(document).on("click", "#submit", function(e){
        var tok1 = tokens.get("ip_field1");

        if (tok1 == undefined || tok1 == ""){
            tokens.set("ip_field1", "*");
        }
    });
    
    var mytoken = tokens.get("ip_field1");

// INSERT_TABLE_VIEW
    var table1 = new TableView({
        id: "my-table1",
        managerid: "connections",
        el: $("#mytable1")
    }).render();

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 00:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Reading-a-text-token-with-javascript/m-p/537145#M36711</guid>
      <dc:creator>mike-48735</dc:creator>
      <dc:date>2021-01-26T00:03:47Z</dc:date>
    </item>
  </channel>
</rss>

