diff --git a/js/controllers.js b/js/controllers.js index 70c9a67c8..bb34ff93f 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -38,12 +38,56 @@ function HomeController() { } -function SettingsController($scope, Settings) { - +function SettingsController($scope, Auth, System, Docker, Settings) { + $scope.auth = {}; + $scope.info = {}; + $scope.docker = {}; + + $('#response').hide(); + $scope.alertClass = 'block'; + + var showAndHide = function(hide) { + $('#response').show(); + if (hide) { + setTimeout(function() { $('#response').hide();}, 5000); + } + }; + + $scope.updateAuthInfo = function() { + if ($scope.auth.password != $scope.auth.cpassword) { + $scope.response = 'Your passwords do not match.'; + showAndHide(true); + return; + } + Auth.update( + {username: $scope.auth.username, email: $scope.auth.email, password: $scope.auth.password}, function(d) { + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Auth information updated.'; + showAndHide(true); + }, function(e) { + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); + }); + }; + + 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, Container) { +function ContainerController($scope, $routeParams, $location, Container) { $('#response').hide(); $scope.alertClass = 'block'; @@ -82,6 +126,20 @@ function ContainerController($scope, $routeParams, Container) { }); }; + $scope.kill = function() { + Container.kill({id: $routeParams.id}, function(d) { + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Container killed.'; + showAndHide(true); + }, function(e) { + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); + }); + }; + $scope.remove = function() { if (confirm("Are you sure you want to remove the container?")) { Container.remove({id: $routeParams.id}, function(d) { @@ -108,6 +166,9 @@ function ContainerController($scope, $routeParams, Container) { Container.get({id: $routeParams.id}, function(d) { $scope.container = d; + }, function(e) { + console.log(e); + $location.path('/containers/'); }); $scope.getChanges(); @@ -148,7 +209,7 @@ function ImagesController($scope, Image) { } // Controller for a single image and actions on that image -function ImageController($scope, $routeParams, Image) { +function ImageController($scope, $routeParams, $location, Image) { $scope.history = []; $scope.tag = {repo: '', force: false}; @@ -201,6 +262,9 @@ function ImageController($scope, $routeParams, Image) { Image.get({id: $routeParams.id}, function(d) { $scope.image = d; + }, function(e) { + console.log(e); + $location.path('/images/'); }); $scope.getHistory(); diff --git a/js/filters.js b/js/filters.js index b271ff3fb..bac632e30 100644 --- a/js/filters.js +++ b/js/filters.js @@ -27,6 +27,32 @@ angular.module('dockerui.filters', []) return 'success'; }; }) + .filter('getstatetext', function() { + return function(state) { + if (state == undefined) return ''; + + if (state.Ghost && state.Running) { + return 'Ghost'; + } + if (state.Running) { + return 'Running'; + } + return 'Stopped'; + }; + }) + .filter('getstatelabel', function() { + return function(state) { + if (state == undefined) return ''; + + if (state.Ghost && state.Running) { + return 'label-important'; + } + if (state.Running) { + return 'label-success'; + } + return ''; + }; + }) .filter('getdate', function() { return function(data) { //Multiply by 1000 for the unix format diff --git a/js/services.js b/js/services.js index 4a86342b4..21a15056a 100644 --- a/js/services.js +++ b/js/services.js @@ -31,6 +31,28 @@ angular.module('dockerui.services', ['ngResource']) delete :{id: '@id', method: 'DELETE'} }); }) + .factory('Docker', function($resource, DOCKER_ENDPOINT) { + // Information for docker + // http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information + return $resource(DOCKER_ENDPOINT + '/version', {}, { + get: {method: 'GET'} + }); + }) + .factory('Auth', function($resource, DOCKER_ENDPOINT) { + // Auto Information for docker + // http://docs.docker.io/en/latest/api/docker_remote_api.html#set-auth-configuration + return $resource(DOCKER_ENDPOINT + '/auth', {}, { + get: {method: 'GET'}, + update: {method: 'POST'} + }); + }) + .factory('System', function($resource, DOCKER_ENDPOINT) { + // System for docker + // http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information + return $resource(DOCKER_ENDPOINT + '/info', {}, { + get: {method: 'GET'} + }); + }) .factory('Settings', function() { return { displayAll: false diff --git a/partials/container.html b/partials/container.html index 6132913ff..df0d0e84d 100644 --- a/partials/container.html +++ b/partials/container.html @@ -8,6 +8,7 @@
+
@@ -33,8 +34,8 @@ - - + +
{{ container.Image }}
Running:{{ container.State.Running }}State:{{ container.State|getstatetext }}
diff --git a/partials/image.html b/partials/image.html index a521dfd5e..dc8cb8183 100644 --- a/partials/image.html +++ b/partials/image.html @@ -14,11 +14,11 @@ Parent: - {{ image.parent }} + {{ image.parent }} Container: - {{ image.container }} + {{ image.container }} Hostname: diff --git a/partials/settings.html b/partials/settings.html new file mode 100644 index 000000000..24bb92a37 --- /dev/null +++ b/partials/settings.html @@ -0,0 +1,67 @@ +
+
+ {{ response }} +
+ +

Docker Information

+
+

+ Version{{ docker.Version }}
+ GitCommit{{ docker.GitCommit }}
+ GoVersion{{ docker.GoVersion }}
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Containers:{{ info.Containers }}
Images:{{ info.Images }}
Debug:{{ info.Debug }}
NFd:{{ info.NFd }}
NGoroutines:{{ info.NGoroutines }}
MemoryLimit:{{ info.MemoryLimit }}
SwapLimit:{{ info.SwapLimit }}
NFd:{{ info.NFd }}
+ +
+
+ Auth Information + + + + + + + + +
+ +
+
+