I am starting to add some JS elements to dashboards. 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.
<form script="js/views/js_testing.js">
<label>JS Testing</label>
<fieldset submitButton="true">
<input type="text" token="ip_field1">
<label>Test Value</label>
</input>
<input type="time" token="field1">
<label>Time Picker</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
</fieldset>
<row>
<panel>
<title>Test data - $ip_field1$</title>
<html>
<div id="mytable1"/>
</html>
</panel>
</row>
</form>
Javascript:
// 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();
});
Thanks!