From 38f859f52d8cb79719971c823a8f3463cf2ce466 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sat, 22 Jun 2013 09:23:25 -0900 Subject: [PATCH 1/3] Update build and msg paritals --- css/app.css | 5 +- js/app.js | 2 +- js/controllers.js | 107 +++++++++++++++++++++++------------------ js/services.js | 6 +-- partials/builder.html | 1 + partials/image.html | 11 ++++- partials/settings.html | 16 ------ 7 files changed, 77 insertions(+), 71 deletions(-) diff --git a/css/app.css b/css/app.css index dc0d0731e..d9738bf2f 100644 --- a/css/app.css +++ b/css/app.css @@ -102,7 +102,7 @@ margin: 0 auto; } -#editor { +#editor { height: 300px; width: 100%; border: 1px solid #DDD; @@ -110,6 +110,7 @@ } .messages { - overflow: scroll; max-height: 50px; + overflow-y: scroll; + overflow-x: hidden; } diff --git a/js/app.js b/js/app.js index cb85fd625..1da29030d 100644 --- a/js/app.js +++ b/js/app.js @@ -14,4 +14,4 @@ angular.module('dockerui', ['dockerui.services', 'dockerui.filters']) .constant('DOCKER_ENDPOINT', 'http://192.168.1.9') .constant('DOCKER_PORT', ':4243') .constant('UI_VERSION', 'v0.2') - .constant('DOCKER_API_VERSION', 'v1.1'); + .constant('DOCKER_API_VERSION', 'v1.2'); diff --git a/js/controllers.js b/js/controllers.js index 0d7068b68..530657a69 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -10,14 +10,14 @@ function MessageController($scope, Messages) { $scope.template = 'partials/messages.html'; $scope.messages = []; $scope.$watch('messages.length', function(o, n) { - $('#message-display').show(); + $('#message-display').show(); }); $scope.$on(Messages.event, function(e, msg) { $scope.messages.push(msg); setTimeout(function() { - $('#message-display').hide('slow'); - }, 10000); + $('#message-display').hide('slow'); + }, 30000); }); } @@ -38,70 +38,62 @@ function SideBarController($scope, Container, Settings) { }); } -function SettingsController($scope, Auth, System, Docker, Settings, Messages) { - $scope.auth = {}; +function SettingsController($scope, System, Docker, Settings, Messages) { $scope.info = {}; $scope.docker = {}; $scope.endpoint = Settings.endpoint; $scope.apiVersion = Settings.version; - $scope.updateAuthInfo = function() { - if ($scope.auth.password != $scope.auth.cpassword) { - alert('Your passwords do not match.'); - return; - } - Auth.update({ - username: $scope.auth.username, - email: $scope.auth.email, - password: $scope.auth.password - }, function(d) { - Messages.send({class: 'text-success', data: 'Auth information updated.'}); - }, function(e) { - Messages.send({class: 'text-error', data: e.data}); - }); - }; - - Auth.get({}, function(d) { $scope.auth = d; }); Docker.get({}, function(d) { $scope.docker = d; }); System.get({}, function(d) { $scope.info = d; }); } // Controls the page that displays a single container and actions on that container. -function ContainerController($scope, $routeParams, $location, Container, Messages) { +function ContainerController($scope, $routeParams, $location, Container, Messages, ViewSpinner) { $scope.changes = []; $scope.start = function(){ + ViewSpinner.spin(); Container.start({id: $routeParams.id}, function(d) { Messages.send({class: 'text-success', data: 'Container started.'}); + ViewSpinner.stop(); }, function(e) { failedRequestHandler(e, Messages); + ViewSpinner.stop(); }); }; $scope.stop = function() { + ViewSpinner.spin(); Container.stop({id: $routeParams.id}, function(d) { Messages.send({class: 'text-success', data: 'Container stopped.'}); + ViewSpinner.stop(); }, function(e) { failedRequestHandler(e, Messages); + ViewSpinner.stop(); }); }; $scope.kill = function() { + ViewSpinner.spin(); Container.kill({id: $routeParams.id}, function(d) { Messages.send({class: 'text-success', data: 'Container killed.'}); + ViewSpinner.stop(); }, function(e) { failedRequestHandler(e, Messages); + ViewSpinner.stop(); }); }; $scope.remove = function() { - if (confirm("Are you sure you want to remove the container?")) { - Container.remove({id: $routeParams.id}, function(d) { - Messages.send({class: 'text-success', data: 'Container removed.'}); - }, function(e){ - failedRequestHandler(e, Messages); - }); - } + ViewSpinner.spin(); + Container.remove({id: $routeParams.id}, function(d) { + Messages.send({class: 'text-success', data: 'Container removed.'}); + ViewSpinner.stop(); + }, function(e){ + failedRequestHandler(e, Messages); + ViewSpinner.stop(); + }); }; $scope.hasContent = function(data) { @@ -141,12 +133,25 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner }; var batch = function(items, action) { + ViewSpinner.spin(); + var counter = 0; + var complete = function() { + counter = counter -1; + if (counter === 0) { + ViewSpinner.stop(); + } + }; angular.forEach(items, function(c) { if (c.Checked) { + counter = counter + 1; action({id: c.Id}, function(d) { - Messages.send({class: 'text-success', data: d}); + Messages.send({class: 'text-success', data: 'Container ' + c.Id + ' Removed.'}); + var index = $scope.containers.indexOf(c); + $scope.containers.splice(index, 1); + complete(); }, function(e) { failedRequestHandler(e, Messages); + complete(); }); } }); @@ -157,7 +162,7 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner i.Checked = $scope.toggle; }); }; - + $scope.toggleGetAll = function() { Settings.displayAll = $scope.displayAll; var data = {all: 0}; @@ -190,6 +195,7 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner // Controller for the list of images function ImagesController($scope, Image, ViewSpinner, Messages) { $scope.toggle = false; + $scope.predicate = '-Created'; $scope.showBuilder = function() { $('#build-modal').modal('show'); @@ -204,7 +210,7 @@ function ImagesController($scope, Image, ViewSpinner, Messages) { ViewSpinner.stop(); } }; - angular.forEach($scope.images, function(i) { + angular.forEach($scope.images, function(i) { if (i.Checked) { counter = counter + 1; Image.remove({id: i.Id}, function(d) { @@ -222,7 +228,7 @@ function ImagesController($scope, Image, ViewSpinner, Messages) { } }); }; - + $scope.toggleSelectAll = function() { angular.forEach($scope.images, function(i) { i.Checked = $scope.toggle; @@ -243,15 +249,13 @@ function ImagesController($scope, Image, ViewSpinner, Messages) { function ImageController($scope, $routeParams, $location, Image, Messages) { $scope.history = []; $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) { - Messages.send({class: 'text-success', data: 'Image removed.'}); - }, function(e) { - failedRequestHandler(e, Messages); - }); - } + Image.remove({id: $routeParams.id}, function(d) { + Messages.send({class: 'text-success', data: 'Image removed.'}); + }, function(e) { + failedRequestHandler(e, Messages); + }); }; $scope.getHistory = function() { @@ -307,10 +311,10 @@ function StartContainerController($scope, $routeParams, $location, Container, Me var s = $scope; Container.create({ - Image: id, - Memory: $scope.config.memory, - MemorySwap: $scope.config.memorySwap, - Cmd: cmds, + Image: id, + Memory: $scope.config.memory, + MemorySwap: $scope.config.memorySwap, + Cmd: cmds, VolumesFrom: $scope.config.volumesFrom }, function(d) { if (d.Id) { @@ -331,12 +335,19 @@ function BuilderController($scope, Dockerfile, Messages) { $scope.template = '/partials/builder.html'; ace.config.set('basePath', '/lib/ace-builds/src-noconflict/'); + var spinner = new Spinner(); $scope.build = function() { + spinner.spin(document.getElementById('build-modal')); Dockerfile.build(editor.getValue(), function(d) { - Messages.send({class:'text-info', data: d}); + console.log(d.currentTarget.response); + $scope.messages = d.currentTarget.response; + $scope.$apply(); + spinner.stop(); }, function(e) { - Messages.send({class:'text-error', data: e}); + $scope.messages = e; + $scope.$apply(); + spinner.stop(); }); }; } diff --git a/js/services.js b/js/services.js index a59da988c..f15570ac2 100644 --- a/js/services.js +++ b/js/services.js @@ -80,12 +80,12 @@ angular.module('dockerui.services', ['ngResource']) return { event: 'messageSend', send: function(msg) { - $rootScope.$broadcast('messageSend', msg); - } + $rootScope.$broadcast('messageSend', msg); + } }; }) .factory('Dockerfile', function(Settings) { - var url = Settings.rawUrl + '/build'; + var url = Settings.rawUrl + '/build'; return { build: function(file, callback) { var data = new FormData(); diff --git a/partials/builder.html b/partials/builder.html index ea2192aaa..8cc96d336 100644 --- a/partials/builder.html +++ b/partials/builder.html @@ -5,6 +5,7 @@