diff --git a/app/app.js b/app/app.js index 63d23f9c3..11773f159 100644 --- a/app/app.js +++ b/app/app.js @@ -1,12 +1,12 @@ 'use strict'; -angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'images']) +angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'images', 'image']) .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: 'app/components/images/images.html', controller: 'ImagesController'}); - $routeProvider.when('/images/:id/', {templateUrl: 'partials/image.html', controller: 'ImageController'}); + $routeProvider.when('/images/:id/', {templateUrl: 'app/components/image/image.html', controller: 'ImageController'}); $routeProvider.when('/settings', {templateUrl: 'partials/settings.html', controller: 'SettingsController'}); $routeProvider.otherwise({redirectTo: '/'}); }]) diff --git a/partials/image.html b/app/components/image/image.html similarity index 100% rename from partials/image.html rename to app/components/image/image.html diff --git a/app/components/image/imageController.js b/app/components/image/imageController.js new file mode 100644 index 000000000..a361f3543 --- /dev/null +++ b/app/components/image/imageController.js @@ -0,0 +1,55 @@ +angular.module('image', []) +.controller('ImageController', ['$scope', '$q', '$routeParams', '$location', 'Image', 'Container', 'Messages', +function($scope, $q, $routeParams, $location, Image, Container, Messages) { + $scope.history = []; + $scope.tag = {repo: '', force: false}; + + $scope.remove = function() { + Image.remove({id: $routeParams.id}, function(d) { + Messages.send("Image Removed", $routeParams.id); + }, function(e) { + $scope.error = e.data; + $('#error-message').show(); + }); + }; + + $scope.getHistory = function() { + Image.history({id: $routeParams.id}, function(d) { + $scope.history = d; + }); + }; + + $scope.updateTag = function() { + var tag = $scope.tag; + Image.tag({id: $routeParams.id, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { + Messages.send("Tag Added", $routeParams.id); + }, function(e) { + $scope.error = e.data; + $('#error-message').show(); + }); + }; + + Image.get({id: $routeParams.id}, function(d) { + $scope.image = d; + $scope.tag = d.id; + var t = $routeParams.tag; + if (t && t !== ":") { + $scope.tag = t; + var promise = getContainersFromImage($q, Container, t); + + promise.then(function(containers) { + newLineChart('#containers-started-chart', containers, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); }); + }); + } + }, function(e) { + if (e.status === 404) { + $('.detail').hide(); + $scope.error = "Image not found.
" + $routeParams.id; + } else { + $scope.error = e.data; + } + $('#error-message').show(); + }); + + $scope.getHistory(); +}]); diff --git a/app/controllers.js b/app/controllers.js index a94922637..ea3bf23a8 100644 --- a/app/controllers.js +++ b/app/controllers.js @@ -67,61 +67,6 @@ function SettingsController($scope, System, Docker, Settings, Messages) { System.get({}, function(d) { $scope.info = d; }); } -// Controller for a single image and actions on that image -function ImageController($scope, $q, $routeParams, $location, Image, Container, Messages) { - $scope.history = []; - $scope.tag = {repo: '', force: false}; - - $scope.remove = function() { - Image.remove({id: $routeParams.id}, function(d) { - Messages.send("Image Removed", $routeParams.id); - }, function(e) { - $scope.error = e.data; - $('#error-message').show(); - }); - }; - - $scope.getHistory = function() { - Image.history({id: $routeParams.id}, function(d) { - $scope.history = d; - }); - }; - - $scope.updateTag = function() { - var tag = $scope.tag; - Image.tag({id: $routeParams.id, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { - Messages.send("Tag Added", $routeParams.id); - }, function(e) { - $scope.error = e.data; - $('#error-message').show(); - }); - }; - - Image.get({id: $routeParams.id}, function(d) { - $scope.image = d; - $scope.tag = d.id; - var t = $routeParams.tag; - if (t && t !== ":") { - $scope.tag = t; - var promise = getContainersFromImage($q, Container, t); - - promise.then(function(containers) { - newLineChart('#containers-started-chart', containers, function(c) { return new Date(c.Created * 1000).toLocaleDateString(); }); - }); - } - }, function(e) { - if (e.status === 404) { - $('.detail').hide(); - $scope.error = "Image not found.
" + $routeParams.id; - } else { - $scope.error = e.data; - } - $('#error-message').show(); - }); - - $scope.getHistory(); -} - function StartContainerController($scope, $routeParams, $location, Container, Messages) { $scope.template = 'partials/startcontainer.html'; $scope.config = { diff --git a/index.html b/index.html index ec48b7265..d80be8b81 100644 --- a/index.html +++ b/index.html @@ -42,6 +42,7 @@ +