Show labels in the client HTML interface
Note that I'm not familiar with JavaScript, so I'm not sure whether the changes to monitor.js are correct, please review carefully.
This commit is contained in:
parent
244f524bf5
commit
225725d951
3 changed files with 44 additions and 0 deletions
|
@ -118,6 +118,19 @@
|
|||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Labels</h3>
|
||||
<table id="label-table" class="condensed-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span4">Name</th>
|
||||
<th class="span1">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -46,6 +46,10 @@ body {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
.string {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.graph-button {
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
|
|
|
@ -255,6 +255,29 @@ $(document).ready(function () {
|
|||
subscribe(onDataReceived);
|
||||
}
|
||||
|
||||
function addDynamicLabels(table, group_fn) {
|
||||
var labels = {};
|
||||
function onDataReceived(stats, time) {
|
||||
$.each(group_fn(stats), function (key, value) {
|
||||
var elem;
|
||||
if (key in labels) {
|
||||
elem = labels[key];
|
||||
} else {
|
||||
// Add UI element
|
||||
table.find("tbody:last").append(
|
||||
'<tr><td>' + key + '</td>' +
|
||||
'<td class="string">N/A</td></tr>');
|
||||
elem = table.find("tbody > tr > td:last");
|
||||
labels[key] = elem;
|
||||
}
|
||||
if (!paused)
|
||||
elem.text(value);
|
||||
});
|
||||
}
|
||||
|
||||
subscribe(onDataReceived);
|
||||
}
|
||||
|
||||
function initAll() {
|
||||
// Metrics
|
||||
var current_bytes_used = function (stats) {
|
||||
|
@ -334,6 +357,10 @@ $(document).ready(function () {
|
|||
}, function (label) {
|
||||
return label;
|
||||
});
|
||||
|
||||
addDynamicLabels($("#label-table"), function (stats) {
|
||||
return stats.labels;
|
||||
});
|
||||
}
|
||||
|
||||
initAll();
|
||||
|
|
Loading…
Reference in a new issue