From 71c091ae0d7058f94dd3ab954f205de8f10f5039 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 13 Jul 2016 10:53:03 +1200 Subject: [PATCH] feat(ui): docker 1.9 support (#65) --- app/components/containers/containers.html | 8 +++---- .../containers/containersController.js | 7 ++++++- app/shared/filters.js | 21 ++++++++++++++++--- app/shared/viewmodel.js | 7 +++++-- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/components/containers/containers.html b/app/components/containers/containers.html index 36b26fa8f..0a7ca115a 100644 --- a/app/components/containers/containers.html +++ b/app/components/containers/containers.html @@ -39,7 +39,7 @@ - + State @@ -52,7 +52,7 @@ - + IP Address @@ -85,10 +85,10 @@ - {{ container.State }} + {{ container.Status|containerstatus }} {{ container|swarmcontainername}} {{ container|containername}} - {{ container.IP ? container.IP : '-' }} + {{ container.IP ? container.IP : '-' }} {{ container|swarmhostname}} {{ container.Image }} {{ container.Command|truncate:60 }} diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js index 76fc50428..b7662e243 100644 --- a/app/components/containers/containersController.js +++ b/app/components/containers/containersController.js @@ -4,6 +4,7 @@ function ($scope, Container, Settings, Messages, Config, errorMsgFilter) { $scope.state = {}; $scope.state.displayAll = Settings.displayAll; + $scope.state.displayIP = false; $scope.sortType = 'State'; $scope.sortReverse = true; $scope.state.selectedItemCount = 0; @@ -22,7 +23,11 @@ function ($scope, Container, Settings, Messages, Config, errorMsgFilter) { containers = hideContainers(d); } $scope.containers = containers.map(function (container) { - return new ContainerViewModel(container); + var model = new ContainerViewModel(container); + if (model.IP) { + $scope.state.displayIP = true; + } + return model; }); $('#loadContainersSpinner').hide(); }); diff --git a/app/shared/filters.js b/app/shared/filters.js index 4b5b93700..f1b40abfb 100644 --- a/app/shared/filters.js +++ b/app/shared/filters.js @@ -21,16 +21,31 @@ angular.module('dockerui.filters', []) .filter('containerstatusbadge', function () { 'use strict'; return function (text) { - if (text === 'paused') { + var status = _.toLower(text); + if (status.indexOf('paused') !== -1) { return 'warning'; - } else if (text === 'created') { + } else if (status.indexOf('created') !== -1) { return 'info'; - } else if (text === 'exited') { + } else if (status.indexOf('exited') !== -1) { return 'danger'; } return 'success'; }; }) +.filter('containerstatus', function () { + 'use strict'; + return function (text) { + var status = _.toLower(text); + if (status.indexOf('paused') !== -1) { + return 'paused'; + } else if (status.indexOf('created') !== -1) { + return 'created'; + } else if (status.indexOf('exited') !== -1) { + return 'stopped'; + } + return 'running'; + }; +}) .filter('nodestatusbadge', function () { 'use strict'; return function (text) { diff --git a/app/shared/viewmodel.js b/app/shared/viewmodel.js index 901a2fd86..1b222692e 100644 --- a/app/shared/viewmodel.js +++ b/app/shared/viewmodel.js @@ -10,9 +10,12 @@ function ImageViewModel(data) { function ContainerViewModel(data) { this.Id = data.Id; - this.State = data.State; + this.Status = data.Status; this.Names = data.Names; - this.IP = data.NetworkSettings.Networks[Object.keys(data.NetworkSettings.Networks)[0]].IPAddress; + // Unavailable in Docker < 1.10 + if (data.NetworkSettings) { + this.IP = data.NetworkSettings.Networks[Object.keys(data.NetworkSettings.Networks)[0]].IPAddress; + } this.Image = data.Image; this.Command = data.Command; this.Checked = false;