From 3bcd1bf665ddfb8bc3d90e631d41dda913c468f4 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 14:20:29 +1200 Subject: [PATCH 1/6] chore(grunt): add new lint task --- gruntFile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gruntFile.js b/gruntFile.js index b9b0d9a5c..606b7fc73 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -35,6 +35,7 @@ module.exports = function (grunt) { 'recess:min', 'copy' ]); + grunt.registerTask('lint', ['jshint']); grunt.registerTask('test-watch', ['karma:watch']); grunt.registerTask('run', ['if:binaryNotExist', 'build', 'shell:buildImage', 'shell:run']); grunt.registerTask('run-swarm', ['if:binaryNotExist', 'build', 'shell:buildImage', 'shell:runSwarm', 'watch:buildSwarm']); From 2d311518a77eaa520e499f9358589e0d2ab03663 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 14:21:00 +1200 Subject: [PATCH 2/6] refactor(ui): fix jshint issue --- app/components/createContainer/createContainerController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index 2e7000286..99b0e23df 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -8,7 +8,7 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, V $scope.formValues = { Console: 'none', - Volumes: [], + Volumes: [] }; $scope.config = { From 446322dcbe4de05fbc8821144418a316f58d216c Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 15:14:40 +1200 Subject: [PATCH 3/6] feat(ui): new volume creation view (#36) --- app/app.js | 5 ++ .../createContainerController.js | 1 - app/components/createVolume/createVolume.html | 40 ----------- .../createVolume/createVolumeController.js | 65 ++++++++++------- app/components/createVolume/createvolume.html | 69 +++++++++++++++++++ app/components/volumes/volumes.html | 6 +- 6 files changed, 117 insertions(+), 69 deletions(-) delete mode 100644 app/components/createVolume/createVolume.html create mode 100644 app/components/createVolume/createvolume.html diff --git a/app/app.js b/app/app.js index 6c882a01e..c21c25c79 100644 --- a/app/app.js +++ b/app/app.js @@ -72,6 +72,11 @@ angular.module('uifordocker', [ templateUrl: 'app/components/createContainer/createcontainer.html', controller: 'CreateContainerController' }) + .state('actions.create.volume', { + url: "/volume", + templateUrl: 'app/components/createVolume/createvolume.html', + controller: 'CreateVolumeController' + }) .state('docker', { url: '/docker/', templateUrl: 'app/components/docker/docker.html', diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index 99b0e23df..ba4d929db 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -201,7 +201,6 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, V $scope.create = function () { var config = prepareConfiguration(); - console.log(JSON.stringify(config, null, 4)); if ($scope.state.alwaysPull) { pullImageAndCreateContainer(config); diff --git a/app/components/createVolume/createVolume.html b/app/components/createVolume/createVolume.html deleted file mode 100644 index 7e6a5987c..000000000 --- a/app/components/createVolume/createVolume.html +++ /dev/null @@ -1,40 +0,0 @@ - diff --git a/app/components/createVolume/createVolumeController.js b/app/components/createVolume/createVolumeController.js index 9193b9f71..d33d4c7e1 100644 --- a/app/components/createVolume/createVolumeController.js +++ b/app/components/createVolume/createVolumeController.js @@ -1,39 +1,56 @@ angular.module('createVolume', []) -.controller('CreateVolumeController', ['$scope', '$state', 'Messages', 'Volume', 'ViewSpinner', 'errorMsgFilter', -function ($scope, $state, Messages, Volume, ViewSpinner, errorMsgFilter) { - $scope.template = 'app/components/createVolume/createVolume.html'; +.controller('CreateVolumeController', ['$scope', '$state', 'Volume', 'Messages', 'ViewSpinner', 'errorMsgFilter', +function ($scope, $state, Volume, Messages, ViewSpinner, errorMsgFilter) { - $scope.init = function () { - $scope.createVolumeConfig = { - "Name": "", - "Driver": "", - "DriverOpts": {} - }; - $scope.availableDrivers = ['local', 'local-persist']; - $scope.selectedDriver = { value: $scope.availableDrivers[0] }; + $scope.formValues = { + DriverOptions: [] }; - $scope.init(); + $scope.config = { + Driver: 'local' + }; - $scope.addVolume = function addVolume(createVolumeConfig) { - $('#error-message').hide(); + $scope.addDriverOption = function() { + $scope.formValues.DriverOptions.push({ name: '', value: '' }); + }; + + $scope.removeDriverOption = function(index) { + $scope.formValues.DriverOptions.splice(index, 1); + }; + + function createVolume(config) { ViewSpinner.spin(); - $('#create-volume-modal').modal('hide'); - createVolumeConfig.Driver = $scope.selectedDriver.value; - console.log(JSON.stringify(createVolumeConfig, null, 4)); - Volume.create(createVolumeConfig, function (d) { + Volume.create(config, function (d) { if (d.Name) { Messages.send("Volume created", d.Name); + ViewSpinner.stop(); + $state.go('volumes', {}, {reload: true}); } else { - Messages.error('Failure', errorMsgFilter(d)); + ViewSpinner.stop(); + Messages.error('Unable to create volume', errorMsgFilter(d)); } - ViewSpinner.stop(); - $state.go('volumes', {}, {reload: true}); }, function (e) { ViewSpinner.stop(); - $scope.error = "Cannot create volume " + createVolumeConfig.Name + " Reason: " + e.data; - $('#create-volume-modal').modal('show'); - $('#error-message').show(); + Messages.error('Unable to create volume', e.data); }); + } + + function prepareDriverOptions(config) { + var options = {}; + $scope.formValues.DriverOptions.forEach(function (option) { + options[option.name] = option.value; + }); + config.DriverOpts = options; + } + + function prepareConfiguration() { + var config = angular.copy($scope.config); + prepareDriverOptions(config); + return config; + } + + $scope.create = function () { + var config = prepareConfiguration(); + createVolume(config); }; }]); diff --git a/app/components/createVolume/createvolume.html b/app/components/createVolume/createvolume.html new file mode 100644 index 000000000..d6fb53e5a --- /dev/null +++ b/app/components/createVolume/createvolume.html @@ -0,0 +1,69 @@ + + + + Volumes > Add volume + + + +
+
+ + +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ + driver option + +
+ +
+
+
+ name + +
+
+ value + + + + +
+
+
+ +
+ +
+
+
+
+
+ +
+
+ + Cancel +
+
diff --git a/app/components/volumes/volumes.html b/app/components/volumes/volumes.html index 0c8e51104..5919b014b 100644 --- a/app/components/volumes/volumes.html +++ b/app/components/volumes/volumes.html @@ -15,10 +15,8 @@
-
- - -
+ + Add volume
From 530eb20dfc03534e94c9eb730499c596fee53648 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 15:38:34 +1200 Subject: [PATCH 4/6] feat(ui): new network creation view (#37) --- app/app.js | 5 ++ .../createNetwork/createNetwork.html | 45 ----------- .../createNetwork/createNetworkController.js | 67 ++++++++++------ .../createNetwork/createnetwork.html | 80 +++++++++++++++++++ app/components/networks/networks.html | 6 +- 5 files changed, 129 insertions(+), 74 deletions(-) delete mode 100644 app/components/createNetwork/createNetwork.html create mode 100644 app/components/createNetwork/createnetwork.html diff --git a/app/app.js b/app/app.js index c21c25c79..50c2fc7a3 100644 --- a/app/app.js +++ b/app/app.js @@ -77,6 +77,11 @@ angular.module('uifordocker', [ templateUrl: 'app/components/createVolume/createvolume.html', controller: 'CreateVolumeController' }) + .state('actions.create.network', { + url: "/network", + templateUrl: 'app/components/createNetwork/createnetwork.html', + controller: 'CreateNetworkController' + }) .state('docker', { url: '/docker/', templateUrl: 'app/components/docker/docker.html', diff --git a/app/components/createNetwork/createNetwork.html b/app/components/createNetwork/createNetwork.html deleted file mode 100644 index 6c317a9f9..000000000 --- a/app/components/createNetwork/createNetwork.html +++ /dev/null @@ -1,45 +0,0 @@ - diff --git a/app/components/createNetwork/createNetworkController.js b/app/components/createNetwork/createNetworkController.js index a0e56882e..0bf69748c 100644 --- a/app/components/createNetwork/createNetworkController.js +++ b/app/components/createNetwork/createNetworkController.js @@ -1,41 +1,58 @@ angular.module('createNetwork', []) .controller('CreateNetworkController', ['$scope', '$state', 'Messages', 'Network', 'ViewSpinner', 'errorMsgFilter', function ($scope, $state, Messages, Network, ViewSpinner, errorMsgFilter) { - $scope.template = 'app/components/createNetwork/createNetwork.html'; - - $scope.init = function () { - $scope.createNetworkConfig = { - "Name": '', - "Driver": '', - "IPAM": { - "Config": [{}] - } - }; + $scope.formValues = { + DriverOptions: [] }; - $scope.init(); + $scope.config = { + Driver: 'bridge', + CheckDuplicate: true, + Internal: false + }; - $scope.createNetwork = function addNetwork(createNetworkConfig) { - if (_.isEmpty(createNetworkConfig.IPAM.Config[0])) { - delete createNetworkConfig.IPAM; - } - $('#error-message').hide(); + $scope.addDriverOption = function() { + $scope.formValues.DriverOptions.push({ name: '', value: '' }); + }; + + $scope.removeDriverOption = function(index) { + $scope.formValues.DriverOptions.splice(index, 1); + }; + + function createNetwork(config) { ViewSpinner.spin(); - $('#create-network-modal').modal('hide'); - Network.create(createNetworkConfig, function (d) { + Network.create(config, function (d) { if (d.Id) { Messages.send("Network created", d.Id); + ViewSpinner.stop(); + $state.go('networks', {}, {reload: true}); } else { - Messages.error('Failure', errorMsgFilter(d)); + ViewSpinner.stop(); + Messages.error('Unable to create network', errorMsgFilter(d)); } - ViewSpinner.stop(); - $scope.init(); - $state.go('networks', {}, {reload: true}); }, function (e) { ViewSpinner.stop(); - $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data; - $('#create-network-modal').modal('show'); - $('#error-message').show(); + Messages.error('Unable to create network', e.data); }); + } + + function prepareDriverOptions(config) { + var options = {}; + $scope.formValues.DriverOptions.forEach(function (option) { + options[option.name] = option.value; + }); + config.Options = options; + } + + function prepareConfiguration() { + var config = angular.copy($scope.config); + prepareDriverOptions(config); + return config; + } + + $scope.create = function () { + var config = prepareConfiguration(); + console.log(JSON.stringify(config, null, 4)); + createNetwork(config); }; }]); diff --git a/app/components/createNetwork/createnetwork.html b/app/components/createNetwork/createnetwork.html new file mode 100644 index 000000000..f4ae1d756 --- /dev/null +++ b/app/components/createNetwork/createnetwork.html @@ -0,0 +1,80 @@ + + + + Networks > Add network + + + +
+
+ + +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ + driver option + +
+ +
+
+
+ name + +
+
+ value + + + + +
+
+
+ +
+ + +
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+ + Cancel +
+
diff --git a/app/components/networks/networks.html b/app/components/networks/networks.html index d057c8594..dc5f22f52 100644 --- a/app/components/networks/networks.html +++ b/app/components/networks/networks.html @@ -16,10 +16,8 @@
-
- - -
+ + Add network
From 59820e737ece4636c716429f3a170f08e820bfe2 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 16:32:46 +1200 Subject: [PATCH 5/6] feat(ui): new pull image view (#39) --- app/app.js | 1 - .../createNetwork/createNetworkController.js | 1 - app/components/images/images.html | 162 +++++++++++------- app/components/images/imagesController.js | 37 +++- app/components/pullImage/pullImage.html | 35 ---- .../pullImage/pullImageController.js | 56 ------ 6 files changed, 131 insertions(+), 161 deletions(-) delete mode 100644 app/components/pullImage/pullImage.html delete mode 100644 app/components/pullImage/pullImageController.js diff --git a/app/app.js b/app/app.js index 50c2fc7a3..090a903fa 100644 --- a/app/app.js +++ b/app/app.js @@ -14,7 +14,6 @@ angular.module('uifordocker', [ 'docker', 'images', 'image', - 'pullImage', 'containerLogs', 'stats', 'swarm', diff --git a/app/components/createNetwork/createNetworkController.js b/app/components/createNetwork/createNetworkController.js index 0bf69748c..44a7bd858 100644 --- a/app/components/createNetwork/createNetworkController.js +++ b/app/components/createNetwork/createNetworkController.js @@ -52,7 +52,6 @@ function ($scope, $state, Messages, Network, ViewSpinner, errorMsgFilter) { $scope.create = function () { var config = prepareConfiguration(); - console.log(JSON.stringify(config, null, 4)); createNetwork(config); }; }]); diff --git a/app/components/images/images.html b/app/components/images/images.html index 2fda922d4..0a539ee8a 100644 --- a/app/components/images/images.html +++ b/app/components/images/images.html @@ -1,5 +1,3 @@ -
- @@ -10,68 +8,100 @@ Images -
- - - - -
-
- - -
-
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - -
- - Id - - - - - - Repository - - - - - - VirtualSize - - - - - - Created - - - -
{{ image.Id|truncate:20}}{{ image|repotag }}{{ image.VirtualSize|humansize }}{{ image.Created|getdate }}
-
-
- +
+
+ + + + +
+ +
+ +
+ +
+
+ + +
+
+ Note: if you don't specify the tag in the image name, latest will be used. +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ + + + +
+ +
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ + Id + + + + + + Repository + + + + + + VirtualSize + + + + + + Created + + + +
{{ image.Id|truncate:20}}{{ image|repotag }}{{ image.VirtualSize|humansize }}{{ image.Created|getdate }}
+
+
+ +
diff --git a/app/components/images/imagesController.js b/app/components/images/imagesController.js index 113e7d718..20dbf294f 100644 --- a/app/components/images/imagesController.js +++ b/app/components/images/imagesController.js @@ -1,12 +1,16 @@ angular.module('images', []) -.controller('ImagesController', ['$scope', 'Image', 'ViewSpinner', 'Messages', -function ($scope, Image, ViewSpinner, Messages) { +.controller('ImagesController', ['$scope', '$state', 'Image', 'ViewSpinner', 'Messages', +function ($scope, $state, Image, ViewSpinner, Messages) { $scope.state = {}; $scope.sortType = 'Created'; $scope.sortReverse = true; $scope.state.toggle = false; $scope.state.selectedItemCount = 0; + $scope.config = { + Image: '' + }; + $scope.order = function(sortType) { $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false; $scope.sortType = sortType; @@ -31,6 +35,35 @@ function ($scope, Image, ViewSpinner, Messages) { } }; + function createImageConfig(imageName) { + var imageNameAndTag = imageName.split(':'); + var imageConfig = { + fromImage: imageNameAndTag[0], + tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest' + }; + return imageConfig; + } + + $scope.pullImage = function() { + ViewSpinner.spin(); + var image = _.toLower($scope.config.Image); + var imageConfig = createImageConfig(image); + Image.create(imageConfig, function (data) { + var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error'); + if (err) { + var detail = data[data.length - 1]; + ViewSpinner.stop(); + Messages.error('Error', detail.error); + } else { + ViewSpinner.stop(); + $state.go('images', {}, {reload: true}); + } + }, function (e) { + ViewSpinner.stop(); + Messages.error('Error', 'Unable to pull image ' + image); + }); + }; + $scope.removeAction = function () { ViewSpinner.spin(); var counter = 0; diff --git a/app/components/pullImage/pullImage.html b/app/components/pullImage/pullImage.html deleted file mode 100644 index 777a6390e..000000000 --- a/app/components/pullImage/pullImage.html +++ /dev/null @@ -1,35 +0,0 @@ -
diff --git a/app/components/pullImage/pullImageController.js b/app/components/pullImage/pullImageController.js deleted file mode 100644 index a9aae1c97..000000000 --- a/app/components/pullImage/pullImageController.js +++ /dev/null @@ -1,56 +0,0 @@ -angular.module('pullImage', []) -.controller('PullImageController', ['$scope', '$state', 'Messages', 'Image', 'ViewSpinner', -function ($scope, $state, Messages, Image, ViewSpinner) { - $scope.template = 'app/components/pullImage/pullImage.html'; - - $scope.init = function () { - $scope.config = { - registry: '', - fromImage: '', - tag: 'latest' - }; - }; - - $scope.init(); - - function failedRequestHandler(e, Messages) { - Messages.error('Error', errorMsgFilter(e)); - } - - $scope.pull = function () { - $('#error-message').hide(); - var config = angular.copy($scope.config); - var imageName = (config.registry ? config.registry + '/' : '' ) + - (config.fromImage) + - (config.tag ? ':' + config.tag : ''); - - ViewSpinner.spin(); - $('#pull-modal').modal('hide'); - Image.create(config, function (data) { - ViewSpinner.stop(); - if (data.constructor === Array) { - var f = data.length > 0 && data[data.length - 1].hasOwnProperty('error'); - //check for error - if (f) { - var d = data[data.length - 1]; - $scope.error = "Cannot pull image " + imageName + " Reason: " + d.error; - $('#pull-modal').modal('show'); - $('#error-message').show(); - } else { - Messages.send("Image Added", imageName); - $scope.init(); - $state.go('images', {}, {reload: true}); - } - } else { - Messages.send("Image Added", imageName); - $scope.init(); - $state.go('images', {}, {reload: true}); - } - }, function (e) { - ViewSpinner.stop(); - $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data; - $('#pull-modal').modal('show'); - $('#error-message').show(); - }); - }; -}]); From b573a8bafa3b8ec88981070cfa82c1212cd6c77a Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 6 Jul 2016 16:41:21 +1200 Subject: [PATCH 6/6] chore(version): bump version number --- app/app.js | 2 +- bower.json | 2 +- dockerui.go | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app.js b/app/app.js index 090a903fa..9c98988a7 100644 --- a/app/app.js +++ b/app/app.js @@ -144,4 +144,4 @@ angular.module('uifordocker', [ .constant('DOCKER_ENDPOINT', 'dockerapi') .constant('DOCKER_PORT', '') // Docker port, leave as an empty string if no port is requred. If you have a port, prefix it with a ':' i.e. :4243 .constant('CONFIG_ENDPOINT', '/config') - .constant('UI_VERSION', 'v1.1.0'); + .constant('UI_VERSION', 'v1.2.0'); diff --git a/bower.json b/bower.json index af99b81db..cb28dcf38 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "uifordocker", - "version": "1.1.0", + "version": "1.2.0", "homepage": "https://github.com/kevana/ui-for-docker", "authors": [ "Michael Crosby ", diff --git a/dockerui.go b/dockerui.go index 885fdc1dc..7e29a73b9 100644 --- a/dockerui.go +++ b/dockerui.go @@ -173,7 +173,7 @@ func csrfWrapper(h http.Handler) http.Handler { } func main() { - kingpin.Version("1.1.0") + kingpin.Version("1.2.0") kingpin.Parse() configuration := Config{ diff --git a/package.json b/package.json index 21b1815ed..577f9fb4a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Michael Crosby & Kevan Ahlquist", "name": "uifordocker", "homepage": "https://github.com/kevana/ui-for-docker", - "version": "1.1.0", + "version": "1.2.0", "repository": { "type": "git", "url": "git@github.com:kevana/ui-for-docker.git"