From 92e81a76dc573f90bcb84c46d52844c10b2007ca Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 14:56:54 -0900 Subject: [PATCH] Update post in service with correct id --- js/controllers.js | 35 ++++++++++++++++++++++++++++------- js/filters.js | 2 ++ js/services.js | 23 ++++++++++++++--------- partials/container.html | 6 +++++- partials/containers.html | 11 +++++++---- partials/image.html | 6 ++---- 6 files changed, 58 insertions(+), 25 deletions(-) diff --git a/js/controllers.js b/js/controllers.js index 2deaf25c8..e9e8100ef 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -49,16 +49,22 @@ function SettingsController() { } function ContainerController($scope, $routeParams, Container) { + $('#response').hide(); $scope.start = function(){ Container.start({id: $routeParams.id}, function(d) { $scope.response = d; + $('#response').show(); + setTimeout($('#response').hide, 5000); }); }; $scope.stop = function() { + Container.stop({id: $routeParams.id}, function(d) { $scope.response = d; + $('#response').show(); + setTimeout($('#response').hide, 5000); }); }; @@ -85,11 +91,26 @@ function ContainerController($scope, $routeParams, Container) { $scope.getChanges(); } -function ContainersController($scope, Container) { - Container.query({}, function(d) { - $scope.containers = d; - }); -} +function ContainersController($scope, Container, Settings) { + $scope.displayAll = Settings.displayAll; + $scope.predicate = '-Created'; + var update = function(data) { + Container.query(data, function(d) { + $scope.containers = d; + }); + }; + + $scope.toggleGetAll = function() { + Settings.displayAll = $scope.displayAll; + var u = update; + var data = {all: 0}; + if ($scope.displayAll) { + data.all = 1; + } + u(data); + }; + update({all: $scope.displayAll ? 1 : 0}); + } function ImagesController($scope, Image) { @@ -101,7 +122,7 @@ function ImagesController($scope, Image) { function ImageController($scope, $routeParams, Image) { $scope.history = []; - $scope.tag = {tag: '', repo: '', force: false}; + $scope.tag = {repo: '', force: false}; $scope.remove = function() { if (confirm("Are you sure you want to delete this image?")) { Image.remove({id: $routeParams.id}, function(d) { @@ -118,7 +139,7 @@ function ImageController($scope, $routeParams, Image) { $scope.updateTag = function() { var tag = $scope.tag; - Image.tag({id: $routeParams.id, tag: tag.tag, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { + Image.tag({id: $routeParams.id, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { $scope.response = d; }); }; diff --git a/js/filters.js b/js/filters.js index 623c45093..b271ff3fb 100644 --- a/js/filters.js +++ b/js/filters.js @@ -21,6 +21,8 @@ angular.module('dockerui.filters', []) return function(text) { if (text === 'Ghost') { return 'important'; + } else if (text.indexOf('Exit') != -1 && text !== 'Exit 0') { + return 'warning'; } return 'success'; }; diff --git a/js/services.js b/js/services.js index edc6b2337..4a86342b4 100644 --- a/js/services.js +++ b/js/services.js @@ -7,13 +7,13 @@ angular.module('dockerui.services', ['ngResource']) return $resource(DOCKER_ENDPOINT + '/containers/:id/:action', {}, { query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, get :{method: 'GET', params: { action:'json'}}, - start: {method: 'POST', params: { action: 'start'}}, - stop: {method: 'POST', params: {t: 5, action: 'stop'}}, - restart: {method: 'POST', params: {t: 5, action: 'restart' }}, - kill :{method: 'POST', params: {action:'kill'}}, + start: {method: 'POST', params: {id: '@id', action: 'start'}}, + stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}}, + restart: {method: 'POST', params: {id: '@id', t: 5, action: 'restart' }}, + kill :{method: 'POST', params: {id: '@id', action:'kill'}}, changes :{method: 'GET', params: {action:'changes'}, isArray: true}, create :{method: 'POST', params: {action:'create'}}, - remove :{method: 'DELETE', params: {v:0}} + remove :{method: 'DELETE', params: {id: '@id', v:0}} }); }) .factory('Image', function($resource, DOCKER_ENDPOINT) { @@ -25,9 +25,14 @@ angular.module('dockerui.services', ['ngResource']) search :{method: 'GET', params: { action:'search'}}, history :{method: 'GET', params: { action:'history'}, isArray: true}, create :{method: 'POST', params: {action:'create'}}, - insert :{method: 'POST', params: {action:'insert'}}, - push :{method: 'POST', params: {action:'push'}}, - tag :{method: 'POST', params: {action:'tag'}}, - delete :{method: 'DELETE'} + insert :{method: 'POST', params: {id: '@id', action:'insert'}}, + push :{method: 'POST', params: {id: '@id', action:'push'}}, + tag :{method: 'POST', params: {id: '@id', action:'tag'}}, + delete :{id: '@id', method: 'DELETE'} }); + }) + .factory('Settings', function() { + return { + displayAll: false + }; }); diff --git a/partials/container.html b/partials/container.html index 1b858c163..6a44f02c1 100644 --- a/partials/container.html +++ b/partials/container.html @@ -1,4 +1,8 @@
+
+ +
+

Container: {{ container.Id }}

@@ -26,7 +30,7 @@ Image: - {{ container.Image }} + {{ container.Image }} Running: diff --git a/partials/containers.html b/partials/containers.html index bced94dd0..aaf8aaf4c 100644 --- a/partials/containers.html +++ b/partials/containers.html @@ -1,6 +1,9 @@

Containers:

+
+ Display All +
@@ -12,11 +15,11 @@ - + - - - + + + diff --git a/partials/image.html b/partials/image.html index 701439bcf..39617359c 100644 --- a/partials/image.html +++ b/partials/image.html @@ -61,11 +61,9 @@
- Add Tag - - + Tag to Repo - +
{{ container.Id|truncate:10}}{{ container.Image }}{{ container.Command }}{{ container.Created }}{{ container.Image }}{{ container.Command|truncate:40 }}{{ container.Created|getdate }} {{ container.Status }}