From 017863bfc0a6daf03a3d92a9da8b84551ba5791f Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 14:47:47 -0400 Subject: [PATCH 1/6] VolumesFrom support container names --- app/components/containersNetwork/containersNetworkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js index 3219a0951..216261638 100644 --- a/app/components/containersNetwork/containersNetworkController.js +++ b/app/components/containersNetwork/containersNetworkController.js @@ -54,7 +54,7 @@ angular.module('containersNetwork', ['ngVis']) }; this.addVolumeEdgeIfExists = function(from, to) { - if (from.VolumesFrom != null && from.VolumesFrom[to.Id] != null) { + if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null)) { this.edges.add({ from: from.Id, to: to.Id, From 8e0baf0e378a2af1971a7a55728f42d80c938976 Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 16:01:33 -0400 Subject: [PATCH 2/6] Optionally include stopped containers --- .../containersNetwork/containersNetwork.html | 1 + .../containersNetworkController.js | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/components/containersNetwork/containersNetwork.html b/app/components/containersNetwork/containersNetwork.html index e9bce03de..f213de493 100644 --- a/app/components/containersNetwork/containersNetwork.html +++ b/app/components/containersNetwork/containersNetwork.html @@ -15,6 +15,7 @@ +
" + "
  • ID: " + container.Id + "
  • " + "
  • Image: " + container.Image + "
  • " + - ""}); + "", + color: (container.State.Running ? null : "gray") + }); }; this.addLinkEdgeIfExists = function(from, to) { @@ -240,10 +242,19 @@ angular.module('containersNetwork', ['ngVis']) $scope.network.addContainer(container); }; - Container.query({all: 0}, function(d) { - for (var i = 0; i < d.length; i++) { - Container.get({id: d[i].Id}, addContainer, showFailure); - } - }); - + var update = function (data) { + Container.query(data, function(d) { + for (var i = 0; i < d.length; i++) { + Container.get({id: d[i].Id}, addContainer, showFailure); + } + }); + }; + update({all: 0}); + + $scope.includeStopped = false; + $scope.toggleIncludeStopped = function() { + $scope.network.updateShownContainers([]); + update({all: $scope.includeStopped ? 1 : 0}); + }; + }]); From 34a3f8186a0e38c2fbad83ecf793a286944de20a Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 16:20:28 -0400 Subject: [PATCH 3/6] Missed passing run state --- .../containersNetwork/containersNetworkController.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js index 98e99cc22..db26d53f5 100644 --- a/app/components/containersNetwork/containersNetworkController.js +++ b/app/components/containersNetwork/containersNetworkController.js @@ -6,6 +6,7 @@ angular.module('containersNetwork', ['ngVis']) // names have the following format: /Name this.Name = data.Name.substring(1); this.Image = data.Config.Image; + this.Running = data.State.Running; var dataLinks = data.HostConfig.Links; if (dataLinks != null) { this.Links = {}; @@ -42,7 +43,7 @@ angular.module('containersNetwork', ['ngVis']) "
  • ID: " + container.Id + "
  • " + "
  • Image: " + container.Image + "
  • " + "", - color: (container.State.Running ? null : "gray") + color: (container.Running ? null : "gray") }); }; From 3db2008c39b01a9b3eb011e979beb0505990269f Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 16:22:31 -0400 Subject: [PATCH 4/6] Have to provide a color --- app/components/containersNetwork/containersNetworkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js index db26d53f5..63946139a 100644 --- a/app/components/containersNetwork/containersNetworkController.js +++ b/app/components/containersNetwork/containersNetworkController.js @@ -43,7 +43,7 @@ angular.module('containersNetwork', ['ngVis']) "
  • ID: " + container.Id + "
  • " + "
  • Image: " + container.Image + "
  • " + "", - color: (container.Running ? null : "gray") + color: (container.Running ? "cyan" : "gray") }); }; From 758ac41648b8454a0572c4d568227d23027e3f92 Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 16:37:19 -0400 Subject: [PATCH 5/6] Color and edge cleanup --- .../containersNetworkController.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js index 63946139a..8d901e311 100644 --- a/app/components/containersNetwork/containersNetworkController.js +++ b/app/components/containersNetwork/containersNetworkController.js @@ -43,12 +43,19 @@ angular.module('containersNetwork', ['ngVis']) "
  • ID: " + container.Id + "
  • " + "
  • Image: " + container.Image + "
  • " + "", - color: (container.Running ? "cyan" : "gray") + color: (container.Running ? "#8888ff" : "#cccccc") }); }; - this.addLinkEdgeIfExists = function(from, to) { - if (from.Links != null && from.Links[to.Name] != null) { + this.hasEdge = function(from, to) { + return this.edges.getIds({ + filter: function (item) { + return item.from == from.Id && item.to == to.Id; + } }); + }; + + this.addLinkEdgeIfExists = function(from, to) { + if (from.Links != null && from.Links[to.Name] != null && !this.hasEdge(from, to)) { this.edges.add({ from: from.Id, to: to.Id, @@ -57,7 +64,7 @@ angular.module('containersNetwork', ['ngVis']) }; this.addVolumeEdgeIfExists = function(from, to) { - if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null)) { + if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null) && !this.hasEdge(from, to)) { this.edges.add({ from: from.Id, to: to.Id, From 7748adf0e62f48a3473b32f0d267a0d20e0431eb Mon Sep 17 00:00:00 2001 From: Karl Gutwin Date: Wed, 12 Aug 2015 16:38:50 -0400 Subject: [PATCH 6/6] Color and edge cleanup --- app/components/containersNetwork/containersNetworkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js index 8d901e311..1d46d7aa9 100644 --- a/app/components/containersNetwork/containersNetworkController.js +++ b/app/components/containersNetwork/containersNetworkController.js @@ -51,7 +51,7 @@ angular.module('containersNetwork', ['ngVis']) return this.edges.getIds({ filter: function (item) { return item.from == from.Id && item.to == to.Id; - } }); + } }).length > 0; }; this.addLinkEdgeIfExists = function(from, to) {