summaryrefslogtreecommitdiff
path: root/src/viz
diff options
context:
space:
mode:
Diffstat (limited to 'src/viz')
-rw-r--r--src/viz/index.html3
-rw-r--r--src/viz/index.js32
2 files changed, 33 insertions, 2 deletions
diff --git a/src/viz/index.html b/src/viz/index.html
index 02a8149..f81a707 100644
--- a/src/viz/index.html
+++ b/src/viz/index.html
@@ -14,8 +14,9 @@
<body>
<div class="">
<h1>Sfive Stat Display</h1>
- <div id="menu" class="container"></div>
+ <div id="menu" class="container"><a href="#settings">Settings</a>&nbsp;</div>
<div id="content"></div>
+ <div id="settings" class="container"></div>
</div>
</body>
</html>
diff --git a/src/viz/index.js b/src/viz/index.js
index 2485912..de66d9c 100644
--- a/src/viz/index.js
+++ b/src/viz/index.js
@@ -1,6 +1,7 @@
var qintv_ms = 5000;
var uripart = "/updates?";
var lastfrom = "";
+var possible_display_functions = {"Off":"none", "Value":showvalue, "Gauge":showgauge, "Graph":showasgraph};
var stuff_to_display = {"clients":"none","*":showvalue,"client-count":showvalue, "bytes-sent":showgauge, "fuckups-per-second":showasgraph};
var sidseen = [];
@@ -21,9 +22,12 @@ function getstreamdiv(sid) {
return elem;
}
-function killvalue(name) {
+function killvalue(name, nosetselect) {
stuff_to_display[name]="none";
$.each(sidseen,function(index,sid){ $("#li-"+sid+"_"+name).remove() });
+ if (nosetselect != 1) {
+ document.getElementById("opts-"+name).selectedIndex=0;
+ }
}
function showvalue(sid, name, value, jsdate) {
@@ -64,6 +68,31 @@ function showasgraph(sid, name, value, jsdate) {
graphs[divid].updateOptions({'file':graphdata[divid]});
}
+function showasetting(name) {
+ var setid = "opts-"+name;
+ if (! document.getElementById(setid)) {
+ var sts = $('<select/>').attr('id',setid).attr('onchange',"changeSetting('"+name+"',this);");
+ $.each(possible_display_functions, function(key, value) {
+ var stsopt = $("<option/>").text(key);
+ if (stuff_to_display[name] == value) {
+ stsopt.attr("selected","true");
+ }
+ sts.append(stsopt);
+ });
+ var stsdiv=$("<div>"+name+":</div>");
+ stsdiv.append(sts);
+ $("#settings").append(stsdiv);
+ }
+}
+
+function changeSetting(name, selobj) {
+ var newdispfunc = possible_display_functions[selobj.options[selobj.selectedIndex].text];
+ if (newdispfunc) {
+ killvalue(name, 1);
+ stuff_to_display[name]=newdispfunc;
+ }
+}
+
function graphS5Status(data) {
sidseen=[];
$.each(data, function(index, stream) {
@@ -75,6 +104,7 @@ function graphS5Status(data) {
var data = stream.data;
console.log(data);
for (var key in data) {
+ showasetting(key);
if (typeof(stuff_to_display[key]) == 'function') {
stuff_to_display[key](sid, key, data[key], jsdate);
} else if (! stuff_to_display[key]) {