summaryrefslogtreecommitdiffstats
path: root/static/status-dnbd3.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/status-dnbd3.html')
-rw-r--r--static/status-dnbd3.html52
1 files changed, 25 insertions, 27 deletions
diff --git a/static/status-dnbd3.html b/static/status-dnbd3.html
index 7ee5a2f..8fdcfa6 100644
--- a/static/status-dnbd3.html
+++ b/static/status-dnbd3.html
@@ -46,12 +46,23 @@ function myGraph(el) {
var ccX = 0, ccY = 0, ccCount = 0;
// Add and remove elements on the graph object
- this.addNode = function (id, radius, color, distance, x, y) {
+ this.addNode = function (id, x, y) {
title = id;
id = makeId("a", id);
- if (!distance) distance = 5;
- distance *= w / 2000;
- if (!radius) radius = 5;
+ var distance = 2;
+ var radius = 4;
+ var color = "#0000FF"; // Blue
+ // Other attr if server.
+ var s = servers[title]
+ if(s) {
+// console.log(color);
+ distance = 6;
+ radius = 15;
+ }
+
+// if (!distance) distance = 5;
+// distance *= w / 2000;
+// if (!radius) radius = 5;
var node = findNode(id);
// Add node, if it doesn't exist
if (!node) {
@@ -59,7 +70,7 @@ function myGraph(el) {
x = ccX / ccCount;
y = ccY / ccCount;
}
- nodes.push({"id":id, "title": title, "distance":distance, "radius":radius, "lifetime":2, "x":x, "y":y, "color":color});
+ nodes.push({"id":id, "title": title, "distance":distance, "radius":radius, "x":x, "y":y, "color":color});
changed = true;
} else {
var visNode = vis.select("#" + id);
@@ -67,14 +78,11 @@ function myGraph(el) {
visNode.select("circle").attr("r", radius);
}
- node.distance = distance;
- node.radius = radius;
node.lifetime = 2;
- node.color = color;
var s = servers[title];
if (s && visNode) {
- visNode.select("circle").style("fill", s.color);
+ visNode.select("circle").style("fill", s.color)
}
}
}
@@ -102,22 +110,12 @@ function myGraph(el) {
}
}
-// this.removeNode = function (id) {
-// var i = 0;
-// var n = findNode(id);
-// while (i < links.length) {
-// if ((links[i]['source'] === n)||(links[i]['target'] == n)) links.splice(i,1);
-// else i++;
-// }
-// var index = findNodeIndex(id);
-// if(index !== undefined) {
-// nodes.splice(index, 1);
-// changed = true;
-// }
-// }
-
this.addLink = function (sourceId, targetId) {
+ // Link between servers?
+ var stroke = "#56f";
+ if (servers[sourceId] && servers[targetId]) stroke = "#f00";
+
sourceId = makeId("a", sourceId);
targetId = makeId("a", targetId);
var sourceNode = findNode(sourceId);
@@ -128,7 +126,7 @@ function myGraph(el) {
if (!link) {
var index = $.inArray(sourceId + targetId, pendingLinks);
if (index !== -1) {
- links.push({"source": sourceNode, "target": targetNode, "lifetime":2});
+ links.push({"source": sourceNode, "target": targetNode, "lifetime":2, "color": stroke});
changed = true;
} else {
newLinks.push(sourceId + targetId);
@@ -264,7 +262,7 @@ function myGraph(el) {
.data(links, function(d) { return d.source.id + "-" + d.target.id; });
link.enter().insert("line")
- .attr("class", "link");
+ .attr("class", "link").style({stroke: function(d) { return d.color }});
link.exit().remove();
@@ -349,7 +347,7 @@ setInterval( function() {
function updateGraph(g, data){
if (g) {
for (var i = 0; i < g.nodes.length; ++i) {
- graph.addNode(g.nodes[i].name, g.nodes[i].radius, g.nodes[i].color, g.nodes[i].distance, 0, 0); // g.nodes[i].x, g.nodes[i].y);
+ graph.addNode(g.nodes[i].name, g.nodes[i].x, g.nodes[i].y); // g.nodes[i].x, g.nodes[i].y);
}
for (var i = 0; i < g.edges.length; ++i) {
graph.addLink(g.edges[i].source, g.edges[i].target);
@@ -423,7 +421,7 @@ function updateTrafficGraph(stats, data){
servers[stats[i].address] = server = { 'lastUptime': 0, 'lastTimestamp': 0, 'lastSent': 0, 'line': new TimeSeries({logarithmicScale: true}), 'index': serverCount++ , 'uploadRate': 0, 'downloadRate': 0, 'uploadPeak': 0 }
server.color = colorList(stats[i].address);
smoothie.addTimeSeries(server['line'], {lineWidth:2, strokeStyle: server.color});
-// console.log("Added");
+ //console.log(server);
}
// Server seems to have rebootet, redo values but add no point to chart.
if (server['lastUptime'] > stats[i].uptime) {