diff --git a/app/app.js b/app/app.js
index c782bd031..fb9018dd1 100644
--- a/app/app.js
+++ b/app/app.js
@@ -1,10 +1,10 @@
'use strict';
-angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard'])
+angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {templateUrl: 'app/components/dashboard/dashboard.html', controller: 'DashboardController'});
$routeProvider.when('/containers/', {templateUrl: 'partials/containers.html', controller: 'ContainersController'});
- $routeProvider.when('/containers/:id/', {templateUrl: 'partials/container.html', controller: 'ContainerController'});
+ $routeProvider.when('/containers/:id/', {templateUrl: 'app/components/container/container.html', controller: 'ContainerController'});
$routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'});
$routeProvider.when('/images/:id/', {templateUrl: 'partials/image.html', controller: 'ImageController'});
$routeProvider.when('/settings', {templateUrl: 'partials/settings.html', controller: 'SettingsController'});
diff --git a/partials/container.html b/app/components/container/container.html
similarity index 100%
rename from partials/container.html
rename to app/components/container/container.html
diff --git a/app/components/container/containerController.js b/app/components/container/containerController.js
new file mode 100644
index 000000000..8ec9cb1e2
--- /dev/null
+++ b/app/components/container/containerController.js
@@ -0,0 +1,104 @@
+angular.module('container', [])
+.controller('ContainerController', ['$scope', '$routeParams', '$location', 'Container', 'Messages', 'ViewSpinner',
+function($scope, $routeParams, $location, Container, Messages, ViewSpinner) {
+ $scope.changes = [];
+
+ var update = function() {
+ Container.get({id: $routeParams.id}, function(d) {
+ $scope.container = d;
+ ViewSpinner.stop();
+ }, function(e) {
+ if (e.status === 404) {
+ $('.detail').hide();
+ Messages.error("Not found", "Container not found.");
+ } else {
+ Messages.error("Failure", e.data);
+ }
+ ViewSpinner.stop();
+ });
+ };
+
+ $scope.start = function(){
+ ViewSpinner.spin();
+ Container.start({
+ id: $scope.container.Id,
+ HostConfig: $scope.container.HostConfig
+ }, function(d) {
+ update();
+ Messages.send("Container started", $routeParams.id);
+ }, function(e) {
+ update();
+ Messages.error("Failure", "Container failed to start." + e.data);
+ });
+ };
+
+ $scope.stop = function() {
+ ViewSpinner.spin();
+ Container.stop({id: $routeParams.id}, function(d) {
+ update();
+ Messages.send("Container stopped", $routeParams.id);
+ }, function(e) {
+ update();
+ Messages.error("Failure", "Container failed to stop." + e.data);
+ });
+ };
+
+ $scope.kill = function() {
+ ViewSpinner.spin();
+ Container.kill({id: $routeParams.id}, function(d) {
+ update();
+ Messages.send("Container killed", $routeParams.id);
+ }, function(e) {
+ update();
+ Messages.error("Failure", "Container failed to die." + e.data);
+ });
+ };
+
+ $scope.pause = function() {
+ ViewSpinner.spin();
+ Container.pause({id: $routeParams.id}, function(d) {
+ update();
+ Messages.send("Container paused", $routeParams.id);
+ }, function(e) {
+ update();
+ Messages.error("Failure", "Container failed to pause." + e.data);
+ });
+ };
+
+ $scope.unpause = function() {
+ ViewSpinner.spin();
+ Container.unpause({id: $routeParams.id}, function(d) {
+ update();
+ Messages.send("Container unpaused", $routeParams.id);
+ }, function(e) {
+ update();
+ Messages.error("Failure", "Container failed to unpause." + e.data);
+ });
+ };
+
+ $scope.remove = function() {
+ ViewSpinner.spin();
+ Container.remove({id: $routeParams.id}, function(d) {
+ update();
+ Messages.send("Container removed", $routeParams.id);
+ }, function(e){
+ update();
+ Messages.error("Failure", "Container failed to remove." + e.data);
+ });
+ };
+
+ $scope.hasContent = function(data) {
+ return data !== null && data !== undefined;
+ };
+
+ $scope.getChanges = function() {
+ ViewSpinner.spin();
+ Container.changes({id: $routeParams.id}, function(d) {
+ $scope.changes = d;
+ ViewSpinner.stop();
+ });
+ };
+
+ update();
+ $scope.getChanges();
+}]);
diff --git a/app/controllers.js b/app/controllers.js
index 48b97f783..6a8a3afb3 100644
--- a/app/controllers.js
+++ b/app/controllers.js
@@ -67,110 +67,6 @@ function SettingsController($scope, System, Docker, Settings, Messages) {
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, ViewSpinner) {
- $scope.changes = [];
-
- var update = function() {
- Container.get({id: $routeParams.id}, function(d) {
- $scope.container = d;
- ViewSpinner.stop();
- }, function(e) {
- if (e.status === 404) {
- $('.detail').hide();
- Messages.error("Not found", "Container not found.");
- } else {
- Messages.error("Failure", e.data);
- }
- ViewSpinner.stop();
- });
- };
-
- $scope.start = function(){
- ViewSpinner.spin();
- Container.start({
- id: $scope.container.Id,
- HostConfig: $scope.container.HostConfig
- }, function(d) {
- update();
- Messages.send("Container started", $routeParams.id);
- }, function(e) {
- update();
- Messages.error("Failure", "Container failed to start." + e.data);
- });
- };
-
- $scope.stop = function() {
- ViewSpinner.spin();
- Container.stop({id: $routeParams.id}, function(d) {
- update();
- Messages.send("Container stopped", $routeParams.id);
- }, function(e) {
- update();
- Messages.error("Failure", "Container failed to stop." + e.data);
- });
- };
-
- $scope.kill = function() {
- ViewSpinner.spin();
- Container.kill({id: $routeParams.id}, function(d) {
- update();
- Messages.send("Container killed", $routeParams.id);
- }, function(e) {
- update();
- Messages.error("Failure", "Container failed to die." + e.data);
- });
- };
-
- $scope.pause = function() {
- ViewSpinner.spin();
- Container.pause({id: $routeParams.id}, function(d) {
- update();
- Messages.send("Container paused", $routeParams.id);
- }, function(e) {
- update();
- Messages.error("Failure", "Container failed to pause." + e.data);
- });
- };
-
- $scope.unpause = function() {
- ViewSpinner.spin();
- Container.unpause({id: $routeParams.id}, function(d) {
- update();
- Messages.send("Container unpaused", $routeParams.id);
- }, function(e) {
- update();
- Messages.error("Failure", "Container failed to unpause." + e.data);
- });
- };
-
- $scope.remove = function() {
- ViewSpinner.spin();
- Container.remove({id: $routeParams.id}, function(d) {
- update();
- Messages.send("Container removed", $routeParams.id);
- }, function(e){
- update();
- Messages.error("Failure", "Container failed to remove." + e.data);
- });
- };
-
- $scope.hasContent = function(data) {
- return data !== null && data !== undefined;
- };
-
- $scope.getChanges = function() {
- ViewSpinner.spin();
- Container.changes({id: $routeParams.id}, function(d) {
- $scope.changes = d;
- ViewSpinner.stop();
- });
- };
-
- update();
- $scope.getChanges();
-}
-
// Controller for the list of containers
function ContainersController($scope, Container, Settings, Messages, ViewSpinner) {
$scope.predicate = '-Created';
diff --git a/index.html b/index.html
index 0b3519b7f..588d48a92 100644
--- a/index.html
+++ b/index.html
@@ -40,6 +40,7 @@
+