Changed status.html to use /xml-rpc?method=stats every 5 seconds instead

of reloading the page every 10 seconds.
This breaks in IE, will fix it later.
This commit is contained in:
Anders Betnér 2006-03-31 20:08:40 +00:00
parent 8fc0ab5272
commit eb9a771dad
5 changed files with 152 additions and 11 deletions

View File

@ -8,12 +8,12 @@ adminroot_DATA = ftr.html linkOpaque.gif status.html aspl-license.txt \
mt-daapd.css mt-daapd.png config.html index.html required.gif \
gpl-license.html aspl-license.html thanks.html feedback.html \
playlist.html playlist.js smart.html smart.js DAAPApplet-0.1.jar \
smartpopup.html applet.html mt-daapd.js CREDITS
smartpopup.html applet.html mt-daapd.js CREDITS status.js
EXTRA_DIST = ftr.html linkOpaque.gif status.html aspl-license.txt \
gpl-license.txt linkTransparent.gif config-update.html hdr.html \
mt-daapd.css mt-daapd.png config.html index.html required.gif \
gpl-license.html aspl-license.html thanks.html feedback.html \
playlist.html playlist.js smart.html smart.js DAAPApplet-0.1.jar \
smartpopup.html applet.html mt-daapd.js CREDITS
smartpopup.html applet.html mt-daapd.js CREDITS status.js

View File

@ -4,7 +4,8 @@
<title>mt-daapd</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="mt-daapd.css" />
@ispage status.html:<meta http-equiv="refresh" content="10" />:@
@ispage status.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@
@ispage status.html:<script type="text/javascript" src="status.js"></script>:@
@ispage smart.html:<script type="text/javascript" src="smart.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="lib-js/script.aculo.us/builder.js"></script>:@

View File

@ -1,12 +1,80 @@
@include hdr.html@
<style type="text/css">
table {
margin-top: 2ex;
}
#service, #stat {
width: 60ex;
}
#thread {
width: 80ex;
}
#service td, #thread td {
text-align: left;
}
#service th, #thread th {
text-align: left;
}
</style>
<h1>Status</h1>
<p>
@THREADSTAT@
</p>
<p>
@SERVICE-STATUS@
</p>
<table id="service">
<thead>
<tr>
<th>Service</th>
<th>Status</th>
<th>Control</th>
</tr>
</thead>
<tbody>
<tr>
<td>Rendezvous</td>
<td id="rendezvous">Running</td>
<td><!-- <a href="config-update.html?action=stopmdns">Stop MDNS Server</a> --></td>
</tr>
<tr>
<td>DAAP Server</td>
<td id="daap_server">Running</td>
<td><!-- <a href="config-update.html?action=stopdaap">Stop DAAP Server</a> --></td>
</tr>
<tr>
<td>File scanner</td>
<td id="file_scanner">Idle</td>
<td><a href="config-update.html?action=rescan">Start Scan</a></td>
</tr>
</tbody>
</table>
<table id="stat">
<col style="width: 20ex;" />
<col />
<tr>
<th>Uptime</th>
<td id="uptime"> </td>
</tr>
<tr>
<th>Songs</th>
<td id="songs"> </td>
</tr>
<tr>
<th>Songs Served</th>
<td id="songs_served"> </td>
</tr>
<tr>
<th>DB Version</th>
<td>2</td>
</tr>
</table>
<table id="thread">
<col style="width: 20ex;" />
<col />
<thead>
<tr>
<th>Host</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr><td></td><td></td></tr>
</tbody>
</table>
@include ftr.html@

71
admin-root/status.js Normal file
View File

@ -0,0 +1,71 @@
Event.observe(window,'load',initStatus);
var UPDATE_FREQUENCY = 5000; // number of ms between updates
function initStatus(e) {
new Ajax.Request('xml-rpc?method=stats',{method: 'get',onComplete:rsStats});
window.setInterval(function () {
new Ajax.Request('xml-rpc?method=stats',{method: 'get',onComplete:rsStats});
},UPDATE_FREQUENCY);
}
function rsStats(request) {
['service','stat'].each(function (tag) {
$A(request.responseXML.getElementsByTagName(tag)).each(function (element) {
var node = $(element.firstChild.firstChild.nodeValue.toLowerCase().replace(/\ /,'_'));
node.replaceChild(document.createTextNode(element.childNodes[1].firstChild.nodeValue),node.firstChild);
});
});
var thread = $A(request.responseXML.getElementsByTagName('thread'));
var threadTable = new Table('thread');
threadTable.removeTBodyRows();
thread.each(function (element) {
row = [];
row.push(element.childNodes[1].firstChild.nodeValue);
row.push(element.childNodes[2].firstChild.nodeValue);
threadTable.addTbodyRow(row);
});
}
Table = Class.create();
Object.extend(Table.prototype,{
initialize: function (id) {
this.tbody = $(id).getElementsByTagName('tbody')[0];
},
removeTBodyRows: function () {
Element.removeChildren(this.tbody);
},
addTbodyRow: function (cells) {
var tr = document.createElement('tr');
cells.each(function (cell) {
var td = document.createElement('td');
td.appendChild(document.createTextNode(cell));
tr.appendChild(td);
});
this.tbody.appendChild(tr);
}
});
Object.extend(Element, {
removeChildren: function(element) {
while(element.hasChildNodes()) {
element.removeChild(element.firstChild);
}
},
textContent: function(node) {
if ((!node) || !node.hasChildNodes()) {
// Empty text node
return '';
} else {
if (node.textContent) {
// W3C ?
return node.textContent;
} else if (node.text) {
// IE
return node.text;
}
}
// We shouldn't end up here;
return '';
}
});

View File

@ -96,6 +96,7 @@ Section "MainSection" SEC01
File "..\..\admin-root\aspl-license.txt"
File "..\..\admin-root\aspl-license.html"
File "..\..\admin-root\applet.html"
File "..\..\admin-root\smart.js"
SetOutPath "$INSTDIR\admin-root\lib-js"
File "..\..\admin-root\lib-js\prototype.js"
File "..\..\admin-root\lib-js\rico.js"