]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/static/js/cluster.js
Initial checkin.
[people/shoehn/ipfire.org.git] / www / static / js / cluster.js
1 nodes = new Array();
2 id = 0;
3 busy = false;
4
5 update = function() {
6 $.getJSON("/api/cluster_info", { id : id++ },
7 function(data) {
8 // If we are already busy then exit
9 if (busy == true) return;
10
11 var count = 0;
12
13 if (data.error != "null") return;
14
15 busy = true;
16
17 $.each(data.result.nodes, function(i, node) {
18 var nodeid = node.hostname.replace(/\./g, "");
19 count++;
20
21 nodes[nodeid] = true;
22
23 if ($("#" + nodeid).length) {
24 $("#" + nodeid + "_speed").html(node.speed);
25 } else {
26 row = "<tr id=\"" + nodeid + "\" class=\"node\">";
27 row += " <td id=\"" + nodeid + "_hostname\"></td>";
28 row += " <td id=\"" + nodeid + "_arch\">" + node.arch + "</td>";
29 row += " <td><span id=\"" + nodeid + "_loadbar\"></span></td>";
30 row += " <td><span id=\"" + nodeid + "_jobs\"></span></td>";
31 row += " <td id=\"" + nodeid + "_speed\">" + node.speed + "</td>";
32 row += "</tr>";
33 $("#nodes").append(row);
34 }
35 $("#" + nodeid + "_loadbar").progressBar(node.load, {showText: false});
36 $("#" + nodeid + "_jobs").progressBar(node.jobcount.split("/")[0], { max: node.jobcount.split("/")[1], textFormat: 'fraction'});
37 if (node.installing == true) {
38 $("#" + nodeid + "_hostname").html(node.hostname + " *");
39 } else {
40 $("#" + nodeid + "_hostname").html(node.hostname);
41 }
42 });
43
44 $("#loadbar").progressBar(data.result.cluster.load);
45 $("#jobbar").progressBar(data.result.cluster.jobcount.split("/")[0], { max: data.result.cluster.jobcount.split("/")[1], textFormat: 'fraction'});
46 for (var nodeid in nodes) {
47 if (nodes[nodeid] == false) {
48 $("#" + nodeid).remove();
49 nodes.pop(nodeid);
50 } else {
51 nodes[nodeid] = false;
52 }
53 }
54 $("#count").html(count);
55 busy = false;
56 });
57 }
58
59 $(document).ready(function(){
60 // Init loadbar
61 $("#loadbar").progressBar();
62
63 update();
64 setInterval("update()", 2000);
65 })