From a08ea134fcc39d8f08dc67af79f419249695dcc2 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 25 Dec 2016 21:33:14 +0100 Subject: [PATCH] feat(container-creation): add ability to specify labels in the container creation view (#412) --- .../createContainerController.js | 25 +++++++++- .../createContainer/createcontainer.html | 46 +++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index 617f3d49b..5f5346c68 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -7,7 +7,8 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai Console: 'none', Volumes: [], Registry: '', - NetworkContainer: '' + NetworkContainer: '', + Labels: [] }; $scope.imageConfig = {}; @@ -24,7 +25,8 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai Binds: [], NetworkMode: 'bridge', Privileged: false - } + }, + Labels: {} }; $scope.addVolume = function() { @@ -51,6 +53,14 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai $scope.config.HostConfig.PortBindings.splice(index, 1); }; + $scope.addLabel = function() { + $scope.formValues.Labels.push({ name: '', value: ''}); + }; + + $scope.removeLabel = function(index) { + $scope.formValues.Labels.splice(index, 1); + }; + Config.$promise.then(function (c) { $scope.swarm = c.swarm; var containersToHideLabels = c.hiddenLabels; @@ -222,6 +232,16 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai config.HostConfig.NetworkMode = networkMode; } + function prepareLabels(config) { + var labels = {}; + $scope.formValues.Labels.forEach(function (label) { + if (label.name && label.value) { + labels[label.name] = label.value; + } + }); + config.Labels = labels; + } + function prepareConfiguration() { var config = angular.copy($scope.config); prepareNetworkConfig(config); @@ -230,6 +250,7 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai prepareConsole(config); prepareEnvironmentVariables(config); prepareVolumes(config); + prepareLabels(config); return config; } diff --git a/app/components/createContainer/createcontainer.html b/app/components/createContainer/createcontainer.html index b6aa18322..208b0cd2a 100644 --- a/app/components/createContainer/createcontainer.html +++ b/app/components/createContainer/createcontainer.html @@ -95,6 +95,16 @@ + +
+ +
+ + label + +
+
+ @@ -109,6 +119,7 @@
  • Command
  • Volumes
  • Network
  • +
  • Labels
  • Security/Host
  • @@ -306,6 +317,41 @@ + +
    +
    + +
    + +
    + + label + +
    + +
    +
    +
    + name + +
    +
    + value + + + + +
    +
    +
    + +
    + +
    +
    +