单击 splunk html 面板中的图像时如何传递或设置令牌?
How to pass or set token when click on image in html panel in splunk?
我想在 HTML 面板
中点击图像后设置或传递值给令牌
这是我的面板代码:
<form script="my.js">
<row>
<panel>
<html>
<a id="mydivId">
<img src="/static/app/My_app/bck_city.png"/>
</a>
</html>
</panel>
</row>
</form>
点击上面面板的图片后,下面的标记应该设置值
(我想设置token="mytoken",点击上图后有一些值)
<row>
<panel>
<title>mypanel</title>
<event>
<search>
<query>|makeresults
|eval result=$mytoken$
|table result</query>
<earliest>-15m</earliest>
<latest>now</latest>
</search>
<option name="list.drilldown">none</option>
<option name="refresh.display">progressbar</option>
</event>
</panel>
</row>
我也尝试通过 .js 设置令牌值
require(['underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/utils',
'splunkjs/mvc/tokenutils',
'splunkjs/mvc/simplexml/ready!'], function ($) {
var utils = require("splunkjs/mvc/utils");
$(document).ready(function () {
$("#mydivId").on("click", function (){
var tokens = mvc.Components.get("default");
var tokenValue = tokens.get("mytoken");
tokens.set("mytoken", "cheese");
});
});
});
enter image description here
我在这里为您发布了一个示例:
https://github.com/bshuler/splunk_app_for_Whosebug_questions
但基础知识是:
查看:
<dashboard script="set_token.js">
<row>
<panel>
<title>mytoken = $mytoken$</title>
<html>
<a id="mydivId">
<img src="/static/app/Whosebug/set_token.jpg"/>
</a>
</html>
</panel>
</row>
<row>
<panel>
<table>
<search id="search1">
<query>| makeresults | eval my_value="$mytoken$"</query>
<earliest>-15m</earliest>
<latest>now</latest>
</search>
<option name="drilldown">none</option>
</table>
</panel>
</row>
</dashboard>
和javascriptset_token.js
require([
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function(mvc) {
// Get your div
var my_div = $("#mydivId");
// Respond to clicks
my_div.on("click", function(e) {
var tokens = mvc.Components.get("submitted");
tokens.set("mytoken", "cheese");
});
});
我想在 HTML 面板
中点击图像后设置或传递值给令牌这是我的面板代码:
<form script="my.js">
<row>
<panel>
<html>
<a id="mydivId">
<img src="/static/app/My_app/bck_city.png"/>
</a>
</html>
</panel>
</row>
</form>
点击上面面板的图片后,下面的标记应该设置值 (我想设置token="mytoken",点击上图后有一些值)
<row>
<panel>
<title>mypanel</title>
<event>
<search>
<query>|makeresults
|eval result=$mytoken$
|table result</query>
<earliest>-15m</earliest>
<latest>now</latest>
</search>
<option name="list.drilldown">none</option>
<option name="refresh.display">progressbar</option>
</event>
</panel>
</row>
我也尝试通过 .js 设置令牌值
require(['underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/utils',
'splunkjs/mvc/tokenutils',
'splunkjs/mvc/simplexml/ready!'], function ($) {
var utils = require("splunkjs/mvc/utils");
$(document).ready(function () {
$("#mydivId").on("click", function (){
var tokens = mvc.Components.get("default");
var tokenValue = tokens.get("mytoken");
tokens.set("mytoken", "cheese");
});
});
});
enter image description here
我在这里为您发布了一个示例:
https://github.com/bshuler/splunk_app_for_Whosebug_questions
但基础知识是:
查看:
<dashboard script="set_token.js">
<row>
<panel>
<title>mytoken = $mytoken$</title>
<html>
<a id="mydivId">
<img src="/static/app/Whosebug/set_token.jpg"/>
</a>
</html>
</panel>
</row>
<row>
<panel>
<table>
<search id="search1">
<query>| makeresults | eval my_value="$mytoken$"</query>
<earliest>-15m</earliest>
<latest>now</latest>
</search>
<option name="drilldown">none</option>
</table>
</panel>
</row>
</dashboard>
和javascriptset_token.js
require([
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function(mvc) {
// Get your div
var my_div = $("#mydivId");
// Respond to clicks
my_div.on("click", function(e) {
var tokens = mvc.Components.get("submitted");
tokens.set("mytoken", "cheese");
});
});