Hi all,
I'm trying to make a simple dropdown in splunk framework that visualize all my source.
What I'm suppose to insert in the block content, to visualize the dropdown?
And I would like use the results of the search instead of 1, 2, 3, How I can do this?
{% extends "splunkdj:base_with_app_bar.html" %}
{% load splunkmvc %}
{% block content %}
{% endblock content%}
{% block js %}
<script>
var deps = [
"splunkjs/ready!",
"splunkjs/mvc/searchmanager",
"splunkjs/mvc/dropdownview"
];
require(deps, function(mvc) {
var SearchManager = require("splunkjs/mvc/searchmanager");
new SearchManager({
id: "mysearch-log",
search: "index=waratek | stats dc(source) by source | eval rule=source | fields rule"
});
var DropdownView = require("splunkjs/mvc/dropdownview");
new DropdownView({
id: "drop-list",
default: "One",
el: $("#divToHangOn")
}).render();
var choices = [{label: " One", value: "One"},
{label:" Two", value: "Two"},
{label:" Three", value: "Three"}];
//I would like use the results of the search instead of this 3 values
//like=label:" Two", value: rule[2]
//like=label:" Three", value: rule[3]
splunkjs.mvc.Components.getInstance("drop-list").settings.set("choices", choices);
var sbg = splunkjs.mvc.Components.getInstance("drop-list");
var sbResult = document.getElementById("example-dropdown-result");
sbg.on("change", function(){
sbResult.innerHTML = sbg.val();
});
//write the drop-list click in a in a file
});
</script>
{% endblock js %}
Thank you
... View more