Commit e4bb7f00 authored by Geoff Simmons's avatar Geoff Simmons

Implement visibility changes in govarnishstat (verbosity & current=0).

parent dce6a94e
......@@ -98,6 +98,7 @@ var addr = "ws://" + location.hostname + ":" + location.port
var tbl
var tbody
var show0 = false
var show0_checkbox
var formatting = true
var verbosity = "INFO"
var verbose_select
......@@ -222,6 +223,7 @@ function getStats() {
ws.onmessage = function (evt) {
var stats = JSON.parse(evt.data)
var row = document.getElementById(stats.name)
row.setAttribute("data-raw", stats.value)
var cells = row.cells
if (cells[1].classList.contains("b")) {
format_bitmap(cells[1], stats.value, stats.bitmap)
......@@ -268,33 +270,58 @@ function getHitrate() {
};
}
function setHidden(rows) {
function resetVisibility() {
var rows = tbody.rows
for (i = 0; i < rows.length; i++) {
rows[i].classList.add("hidden")
}
}
function setVisible(rows) {
for (i = 0; i < rows.length; i++) {
rows[i].classList.remove("hidden")
var raw = rows[i].getAttribute("data-raw")
if (raw == "0" && !show0) {
rows[i].classList.add("hidden")
continue
}
if (rows[i].classList.contains("INFO")) {
rows[i].classList.remove("hidden")
continue
}
switch(verbosity) {
case "INFO":
if (rows[i].classList.contains("DIAG")) {
rows[i].classList.add("hidden")
continue
}
if (rows[i].classList.contains("DEBUG")) {
rows[i].classList.add("hidden")
continue
}
case "DIAG":
if (rows[i].classList.contains("DIAG")) {
rows[i].classList.remove("hidden")
continue
}
if (rows[i].classList.contains("DEBUG")) {
rows[i].classList.add("hidden")
continue
}
case "DEBUG":
if (rows[i].classList.contains("DIAG")) {
rows[i].classList.remove("hidden")
continue
}
if (rows[i].classList.contains("DEBUG")) {
rows[i].classList.remove("hidden")
continue
}
}
}
}
function setVerbosity() {
var verbosity = verbose_select.value
verbosity = verbose_select.value
resetVisibility()
}
if (verbosity == "INFO") {
setHidden(diag)
setHidden(debug)
return
}
if (verbosity == "DIAG") {
setVisible(diag)
setHidden(debug)
return
}
setVisible(diag)
setVisible(debug)
function toggleShow0() {
show0 = !show0
resetVisibility()
}
window.onload = function() {
......@@ -307,6 +334,8 @@ window.onload = function() {
verbose_select.addEventListener("change", setVerbosity);
diag = document.getElementsByClassName("DIAG")
debug = document.getElementsByClassName("DEBUG")
show0_checkbox = document.getElementById("show0")
show0_checkbox.onclick = toggleShow0
}
</script>
......@@ -370,10 +399,7 @@ window.onload = function() {
</div>
<div class="controls">
<p>Current=0</p>
<select id="zero">
<option value="false">Hide</option>
<option value="true">Show</option>
</select>
<input type="checkbox" id="show0">Show
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment