diff --git a/app/app.js b/app/app.js index b44f1d7dc..63d23f9c3 100644 --- a/app/app.js +++ b/app/app.js @@ -1,11 +1,11 @@ 'use strict'; -angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers']) +angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'images']) .config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/', {templateUrl: 'app/components/dashboard/dashboard.html', controller: 'DashboardController'}); $routeProvider.when('/containers/', {templateUrl: 'app/components/containers/containers.html', controller: 'ContainersController'}); $routeProvider.when('/containers/:id/', {templateUrl: 'app/components/container/container.html', controller: 'ContainerController'}); - $routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'}); + $routeProvider.when('/images/', {templateUrl: 'app/components/images/images.html', controller: 'ImagesController'}); $routeProvider.when('/images/:id/', {templateUrl: 'partials/image.html', controller: 'ImageController'}); $routeProvider.when('/settings', {templateUrl: 'partials/settings.html', controller: 'SettingsController'}); $routeProvider.otherwise({redirectTo: '/'}); diff --git a/partials/images.html b/app/components/images/images.html similarity index 100% rename from partials/images.html rename to app/components/images/images.html diff --git a/app/components/images/imagesController.js b/app/components/images/imagesController.js new file mode 100644 index 000000000..f13730ca9 --- /dev/null +++ b/app/components/images/imagesController.js @@ -0,0 +1,52 @@ +angular.module('images', []) +.controller('ImagesController', ['$scope', 'Image', 'ViewSpinner', 'Messages', +function($scope, Image, ViewSpinner, Messages) { + $scope.toggle = false; + $scope.predicate = '-Created'; + + $scope.showBuilder = function() { + $('#build-modal').modal('show'); + }; + + $scope.removeAction = function() { + ViewSpinner.spin(); + var counter = 0; + var complete = function() { + counter = counter - 1; + if (counter === 0) { + ViewSpinner.stop(); + } + }; + angular.forEach($scope.images, function(i) { + if (i.Checked) { + counter = counter + 1; + Image.remove({id: i.Id}, function(d) { + angular.forEach(d, function(resource) { + Messages.send("Image deleted", resource.Deleted); + }); + var index = $scope.images.indexOf(i); + $scope.images.splice(index, 1); + complete(); + }, function(e) { + Messages.error("Failure", e.data); + complete(); + }); + } + }); + }; + + $scope.toggleSelectAll = function() { + angular.forEach($scope.images, function(i) { + i.Checked = $scope.toggle; + }); + }; + + ViewSpinner.spin(); + Image.query({}, function(d) { + $scope.images = d.map(function(item) { return new ImageViewModel(item); }); + ViewSpinner.stop(); + }, function (e) { + Messages.error("Failure", e.data); + ViewSpinner.stop(); + }); +}]); diff --git a/app/controllers.js b/app/controllers.js index 518ecf019..a94922637 100644 --- a/app/controllers.js +++ b/app/controllers.js @@ -67,58 +67,6 @@ function SettingsController($scope, System, Docker, Settings, Messages) { System.get({}, function(d) { $scope.info = d; }); } -// 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'); - }; - - $scope.removeAction = function() { - ViewSpinner.spin(); - var counter = 0; - var complete = function() { - counter = counter - 1; - if (counter === 0) { - ViewSpinner.stop(); - } - }; - angular.forEach($scope.images, function(i) { - if (i.Checked) { - counter = counter + 1; - Image.remove({id: i.Id}, function(d) { - angular.forEach(d, function(resource) { - Messages.send("Image deleted", resource.Deleted); - }); - var index = $scope.images.indexOf(i); - $scope.images.splice(index, 1); - complete(); - }, function(e) { - Messages.error("Failure", e.data); - complete(); - }); - } - }); - }; - - $scope.toggleSelectAll = function() { - angular.forEach($scope.images, function(i) { - i.Checked = $scope.toggle; - }); - }; - - ViewSpinner.spin(); - Image.query({}, function(d) { - $scope.images = d.map(function(item) { return new ImageViewModel(item); }); - ViewSpinner.stop(); - }, function (e) { - Messages.error("Failure", e.data); - ViewSpinner.stop(); - }); -} - // Controller for a single image and actions on that image function ImageController($scope, $q, $routeParams, $location, Image, Container, Messages) { $scope.history = []; diff --git a/index.html b/index.html index 45638dc9d..ec48b7265 100644 --- a/index.html +++ b/index.html @@ -42,6 +42,7 @@ +