From 6c29377992896fc936d1723d0f0e99ce457e1db6 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 10 Aug 2016 18:12:33 +1200 Subject: [PATCH 1/2] feat(ui): display swarm host IP instead of swarm hostname in containers view (#118) --- app/components/containers/containers.html | 2 +- .../containers/containersController.js | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/components/containers/containers.html b/app/components/containers/containers.html index 0a7ca115a..844d247ea 100644 --- a/app/components/containers/containers.html +++ b/app/components/containers/containers.html @@ -89,7 +89,7 @@ {{ container|swarmcontainername}} {{ container|containername}} {{ container.IP ? container.IP : '-' }} - {{ container|swarmhostname}} + {{ container.hostIP }} {{ container.Image }} {{ container.Command|truncate:60 }} diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js index b7662e243..0db7b4dc8 100644 --- a/app/components/containers/containersController.js +++ b/app/components/containers/containersController.js @@ -1,6 +1,6 @@ angular.module('containers', []) -.controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'Config', 'errorMsgFilter', -function ($scope, Container, Settings, Messages, Config, errorMsgFilter) { +.controller('ContainersController', ['$scope', 'Container', 'Info', 'Settings', 'Messages', 'Config', 'errorMsgFilter', +function ($scope, Container, Info, Settings, Messages, Config, errorMsgFilter) { $scope.state = {}; $scope.state.displayAll = Settings.displayAll; @@ -27,6 +27,9 @@ function ($scope, Container, Settings, Messages, Config, errorMsgFilter) { if (model.IP) { $scope.state.displayIP = true; } + if ($scope.swarm) { + model.hostIP = $scope.swarm_hosts[_.split(container.Names[0], '/')[1]]; + } return model; }); $('#loadContainersSpinner').hide(); @@ -154,10 +157,32 @@ function ($scope, Container, Settings, Messages, Config, errorMsgFilter) { }); }; + function retrieveSwarmHostsInfo(data) { + var swarm_hosts = {}; + var systemStatus = data.SystemStatus; + var node_count = parseInt(systemStatus[3][1], 10); + var node_offset = 4; + for (i = 0; i < node_count; i++) { + var host = {}; + host.name = _.trim(systemStatus[node_offset][0]); + host.ip = _.split(systemStatus[node_offset][1], ':')[0]; + swarm_hosts[host.name] = host.ip; + node_offset += 9; + } + return swarm_hosts; + } + $scope.swarm = false; Config.$promise.then(function (c) { hiddenLabels = c.hiddenLabels; $scope.swarm = c.swarm; - update({all: Settings.displayAll ? 1 : 0}); + if (c.swarm) { + Info.get({}, function (d) { + $scope.swarm_hosts = retrieveSwarmHostsInfo(d); + update({all: Settings.displayAll ? 1 : 0}); + }); + } else { + update({all: Settings.displayAll ? 1 : 0}); + } }); }]); From de3353feba67669f9fb7fa1a228d33f3c9a0a387 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 10 Aug 2016 18:37:25 +1200 Subject: [PATCH 2/2] feat(global): add the --logo flag to specify an external logo picture --- README.md | 3 ++- api/main.go | 2 ++ api/settings.go | 1 + index.html | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89a0c7d31..6e2d54965 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ UI For Docker is a web interface for the Docker Remote API. The goal is to prov The current Docker version support policy is the following: `N` to `N-2` included where `N` is the latest version. -At the moment, the following versions are supported: 1.9, 1.10 & 1.11. +At the moment, the following versions are supported: 1.9, 1.10 & 1.11. ## Run @@ -113,3 +113,4 @@ The following options are available for the `ui-for-docker` binary: * `--tlscacert`: Path to the CA (default `/certs/ca.pem`) * `--tlscert`: Path to the TLS certificate file (default `/certs/cert.pem`) * `--tlskey`: Path to the TLS key (default `/certs/key.pem`) +* `--logo`: URL to a picture to be displayed as a logo in the UI diff --git a/api/main.go b/api/main.go index a2c5a0f15..1ab338b69 100644 --- a/api/main.go +++ b/api/main.go @@ -18,6 +18,7 @@ func main() { tlskey = kingpin.Flag("tlskey", "Path to the TLS key").Default("/certs/key.pem").String() swarm = kingpin.Flag("swarm", "Swarm cluster support").Default("false").Short('s').Bool() labels = pairs(kingpin.Flag("hide-label", "Hide containers with a specific label in the UI").Short('l')) + logo = kingpin.Flag("logo", "URL for the logo displayed in the UI").String() ) kingpin.Parse() @@ -36,6 +37,7 @@ func main() { settings := &Settings{ Swarm: *swarm, HiddenLabels: *labels, + Logo: *logo, } api := newAPI(apiConfig) diff --git a/api/settings.go b/api/settings.go index 801904f61..b707a8e69 100644 --- a/api/settings.go +++ b/api/settings.go @@ -9,6 +9,7 @@ import ( type Settings struct { Swarm bool `json:"swarm"` HiddenLabels pairList `json:"hiddenLabels"` + Logo string `json:"logo"` } // configurationHandler defines a handler function used to encode the configuration in JSON diff --git a/index.html b/index.html index 434d0f048..389d0056e 100644 --- a/index.html +++ b/index.html @@ -32,7 +32,8 @@