create continued

This commit is contained in:
Marc Wäckerlin
2016-01-29 15:55:54 +00:00
parent e4f48c46d2
commit 0baaccf273
3 changed files with 47 additions and 26 deletions

View File

@@ -74,8 +74,8 @@ var Docker = function() {
var _containers = this;
this.Status = Object.freeze({
Error: {color: "red", action1: "start", action2: "remove", bash: false},
Terminated: {color: "yellow", action1: "start", action2: "remove", bash: false},
Error: {color: "indianred1", action1: "start", action2: "remove", bash: false},
Terminated: {color: "yellow2", action1: "start", action2: "remove", bash: false},
Restarting: {color: "lightblue", action1: "start", action2: "remove", bash: false},
Paused: {color: "grey", action1: "unpause", action2: null, bash: false},
Running: {color: "lightgreen", action1: "pause", action2: "stop", bash: true},
@@ -95,6 +95,8 @@ var Docker = function() {
}
function getIps(n, ips) {
if (n.ports) n.ports.forEach(function(p) {
if (!p.ip||p.ip==""||p.ip=="0.0.0.0"||p.ip==0)
p.ip=window.location.hostname;
if (!ips[p.ip]) ips[p.ip] = [];
ips[p.ip].push(p);
});
@@ -122,12 +124,13 @@ var Docker = function() {
}
function graphNode(n, omitstats) {
var res = "";
var label = n.image.name+'\\n'+n.name
var label = (n.image?n.image.name:'UNDEFINED')+'\\n'
+(n.name?n.name:"UNKNOWN")
+(omitstats?'':'\\ncpu: ????? mem: ?????');
res += '"'+n.name+'"'
+' [label="'+label
+'",URL="#'+n.name
+'",style=filled,fillcolor='+n.status.color+"];\n";
+'",fillcolor='+(n.status?n.status.color+',style=filled':'red,shape=octagon,style=filled')+"];\n";
if (n.ports) n.ports.forEach(function(p) {
res += '"'+(p.ip?p.ip+":":"")+p.external+'" -> "'+n.name
+'" [label="'+p.internal+'"];\n';
@@ -152,7 +155,7 @@ var Docker = function() {
});
return res;
}
function graphVolumesConnections(n) {
function graphVolumesConnections(n, nodes) {
var res = "";
if (n.volumes) n.volumes.forEach(function(v) {
if (v.host)
@@ -177,11 +180,11 @@ var Docker = function() {
res += "{rank=same;\n";
for (name in n) res += graphVolumesOutside(n[name]);
res+="}\n";
for (name in n) res += graphVolumesConnections(n[name]);
for (name in n) res += graphVolumesConnections(n[name], n);
return res;
}
function addNodes(ns, name) {
var n = nodes[name] || ns[name];
var n = nodes[name] || ns[name] || {name: name};
ns[name] = n;
if (n.links) n.links.forEach(function(peer) {
if (!ns[peer.container]) addNodes(ns, peer.container);