From 72cef567becc5f2b74072d96ab20cc6092176f59 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sat, 8 Jun 2013 18:43:16 -0900 Subject: [PATCH 1/6] Remove less files --- Makefile | 9 ------ README.md | 3 +- css/app.less | 85 ---------------------------------------------------- 3 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 Makefile delete mode 100644 css/app.less diff --git a/Makefile b/Makefile deleted file mode 100644 index efc1779fb..000000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -REF = HEAD -VERSION = $(shell git describe --always $(REF)) - -all: less - -less: - less css/*.less > css/app.css - -.PHONY: all less diff --git a/README.md b/README.md index ca73374fb..05e7aa42f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ DockerUI is a web interface to interact with the Remote API. The goal is to pro ![Container](/container.png) ###Installation -Open js/app.(ts/js - js file if you don't want to compile typescript) and change the DOCKER_ENDPOINT constant to your docker ip and port. Then host the site like any other html/js application. +Open js/app.js and change the DOCKER_ENDPOINT constant to your docker ip and port. Then host the site like any other html/js application. .constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243'); @@ -14,7 +14,6 @@ Open js/app.(ts/js - js file if you don't want to compile typescript) and change ###Stack * Angular.js -* Less * Flatstrap ( Flat Twitter Bootstrap ) diff --git a/css/app.less b/css/app.less deleted file mode 100644 index 62c986b38..000000000 --- a/css/app.less +++ /dev/null @@ -1,85 +0,0 @@ - body { - padding-top: 20px; - padding-bottom: 60px; - } - - /* Custom container */ - .container { - margin: 0 auto; - max-width: 1000px; - } - .container > hr { - margin: 60px 0; - } - - /* Main marketing message and sign up button */ - .jumbotron { - margin: 80px 0; - text-align: center; - } - .jumbotron h1 { - font-size: 100px; - line-height: 1; - } - .jumbotron .lead { - font-size: 24px; - line-height: 1.25; - } - .jumbotron .btn { - font-size: 21px; - padding: 14px 24px; - } - - /* Supporting marketing content */ - .marketing { - margin: 60px 0; - } - .marketing p + h4 { - margin-top: 28px; - } - - - /* Customize the navbar links to be fill the entire space of the .navbar */ - .navbar .navbar-inner { - padding: 0; - } - .navbar .nav { - margin: 0; - } - .navbar .nav li { - display: table-cell; - width: 1%; - float: none; - } - .navbar .nav li a { - font-weight: bold; - text-align: center; - border-left: 1px solid rgba(255,255,255,.75); - border-right: 1px solid rgba(0,0,0,.1); - } - .navbar .nav li:first-child a { - border-left: 0; - border-radius: 3px 0 0 3px; - } - .navbar .nav li:last-child a { - border-right: 0; - border-radius: 0 3px 3px 0; - } - - .btn-group button { - margin: 3px; - } - - .detail { - width: 80%; - margin: 0 auto; - } - - .btn-remove { - margin: 0 auto; - max-width: 70%; - } - - .actions { - margin: 0 auto; - } From d4c556752fa16a45fd6fbfb453baf5ea11a19687 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 14:11:40 -0900 Subject: [PATCH 2/6] Add images views and controllers --- js/controllers.js | 39 ++++++++++++++++++++ js/filters.js | 7 ++++ js/services.js | 4 +- partials/container.html | 1 - partials/image.html | 81 +++++++++++++++++++++++++++++++++++++++++ partials/images.html | 21 +++++++++++ 6 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 partials/image.html create mode 100644 partials/images.html diff --git a/js/controllers.js b/js/controllers.js index 6df90d70b..2deaf25c8 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -90,3 +90,42 @@ function ContainersController($scope, Container) { $scope.containers = d; }); } + +function ImagesController($scope, Image) { + + $scope.predicate = '-Created'; + Image.query({}, function(d) { + $scope.images = d; + }); +} + +function ImageController($scope, $routeParams, Image) { + $scope.history = []; + $scope.tag = {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) { + $scope.response = d; + }); + } + }; + + $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, tag: tag.tag, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { + $scope.response = d; + }); + }; + + Image.get({id: $routeParams.id}, function(d) { + $scope.image = d; + }); + + $scope.getHistory(); +} diff --git a/js/filters.js b/js/filters.js index c068dd12a..623c45093 100644 --- a/js/filters.js +++ b/js/filters.js @@ -24,4 +24,11 @@ angular.module('dockerui.filters', []) } return 'success'; }; + }) + .filter('getdate', function() { + return function(data) { + //Multiply by 1000 for the unix format + var date = new Date(data * 1000); + return date.toDateString(); + }; }); diff --git a/js/services.js b/js/services.js index daab27383..edc6b2337 100644 --- a/js/services.js +++ b/js/services.js @@ -19,11 +19,11 @@ angular.module('dockerui.services', ['ngResource']) .factory('Image', function($resource, DOCKER_ENDPOINT) { // Resource for docker images // http://docs.docker.io/en/latest/api/docker_remote_api.html#images - return $resource(DOCKER_ENDPOINT + '/images/:name/:action', {}, { + return $resource(DOCKER_ENDPOINT + '/images/:id/:action', {}, { query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, get :{method: 'GET', params: { action:'json'}}, search :{method: 'GET', params: { action:'search'}}, - history :{method: 'GET', params: { action:'history'}}, + history :{method: 'GET', params: { action:'history'}, isArray: true}, create :{method: 'POST', params: {action:'create'}}, insert :{method: 'POST', params: {action:'insert'}}, push :{method: 'POST', params: {action:'push'}}, diff --git a/partials/container.html b/partials/container.html index b72d3789e..1b858c163 100644 --- a/partials/container.html +++ b/partials/container.html @@ -1,4 +1,3 @@ -

Container: {{ container.Id }}

diff --git a/partials/image.html b/partials/image.html new file mode 100644 index 000000000..701439bcf --- /dev/null +++ b/partials/image.html @@ -0,0 +1,81 @@ +
+

Image: {{ image.id }}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Created:{{ image.created }}
Parent:{{ image.parent }}
Container:{{ image.container }}
Hostname:{{ image.container_config.Hostname }}
User:{{ image.container_config.User }}
Cmd:{{ image.container_config.Cmd }}
Volumes:{{ image.container_config.Volumes }}
Volumes from:{{ image.container_config.VolumesFrom }}
+ +
+
+ History: +
+
+ +
+
+ +
+
    +
  • + {{ change.Id }}: Created: {{ change.Created|getdate }} Created by: {{ change.CreatedBy }} +
  • +
+
+ +
+ +
+
+
+ Add Tag + + + + + + +
+
+
+
+ +
+ +
+
diff --git a/partials/images.html b/partials/images.html new file mode 100644 index 000000000..0840f3938 --- /dev/null +++ b/partials/images.html @@ -0,0 +1,21 @@ + +

Images:

+ + + + + + + + + + + + + + + + + + +
IdTagRepositoryCreated
{{ image.Id|truncate:10}}{{ image.Tag }}{{ image.Repository }}{{ image.Created|getdate }}
From 92e81a76dc573f90bcb84c46d52844c10b2007ca Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 14:56:54 -0900 Subject: [PATCH 3/6] Update post in service with correct id --- js/controllers.js | 35 ++++++++++++++++++++++++++++------- js/filters.js | 2 ++ js/services.js | 23 ++++++++++++++--------- partials/container.html | 6 +++++- partials/containers.html | 11 +++++++---- partials/image.html | 6 ++---- 6 files changed, 58 insertions(+), 25 deletions(-) diff --git a/js/controllers.js b/js/controllers.js index 2deaf25c8..e9e8100ef 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -49,16 +49,22 @@ function SettingsController() { } function ContainerController($scope, $routeParams, Container) { + $('#response').hide(); $scope.start = function(){ Container.start({id: $routeParams.id}, function(d) { $scope.response = d; + $('#response').show(); + setTimeout($('#response').hide, 5000); }); }; $scope.stop = function() { + Container.stop({id: $routeParams.id}, function(d) { $scope.response = d; + $('#response').show(); + setTimeout($('#response').hide, 5000); }); }; @@ -85,11 +91,26 @@ function ContainerController($scope, $routeParams, Container) { $scope.getChanges(); } -function ContainersController($scope, Container) { - Container.query({}, function(d) { - $scope.containers = d; - }); -} +function ContainersController($scope, Container, Settings) { + $scope.displayAll = Settings.displayAll; + $scope.predicate = '-Created'; + var update = function(data) { + Container.query(data, function(d) { + $scope.containers = d; + }); + }; + + $scope.toggleGetAll = function() { + Settings.displayAll = $scope.displayAll; + var u = update; + var data = {all: 0}; + if ($scope.displayAll) { + data.all = 1; + } + u(data); + }; + update({all: $scope.displayAll ? 1 : 0}); + } function ImagesController($scope, Image) { @@ -101,7 +122,7 @@ function ImagesController($scope, Image) { function ImageController($scope, $routeParams, Image) { $scope.history = []; - $scope.tag = {tag: '', repo: '', force: false}; + $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) { @@ -118,7 +139,7 @@ function ImageController($scope, $routeParams, Image) { $scope.updateTag = function() { var tag = $scope.tag; - Image.tag({id: $routeParams.id, tag: tag.tag, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { + Image.tag({id: $routeParams.id, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { $scope.response = d; }); }; diff --git a/js/filters.js b/js/filters.js index 623c45093..b271ff3fb 100644 --- a/js/filters.js +++ b/js/filters.js @@ -21,6 +21,8 @@ angular.module('dockerui.filters', []) return function(text) { if (text === 'Ghost') { return 'important'; + } else if (text.indexOf('Exit') != -1 && text !== 'Exit 0') { + return 'warning'; } return 'success'; }; diff --git a/js/services.js b/js/services.js index edc6b2337..4a86342b4 100644 --- a/js/services.js +++ b/js/services.js @@ -7,13 +7,13 @@ angular.module('dockerui.services', ['ngResource']) return $resource(DOCKER_ENDPOINT + '/containers/:id/:action', {}, { query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, get :{method: 'GET', params: { action:'json'}}, - start: {method: 'POST', params: { action: 'start'}}, - stop: {method: 'POST', params: {t: 5, action: 'stop'}}, - restart: {method: 'POST', params: {t: 5, action: 'restart' }}, - kill :{method: 'POST', params: {action:'kill'}}, + start: {method: 'POST', params: {id: '@id', action: 'start'}}, + stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}}, + restart: {method: 'POST', params: {id: '@id', t: 5, action: 'restart' }}, + kill :{method: 'POST', params: {id: '@id', action:'kill'}}, changes :{method: 'GET', params: {action:'changes'}, isArray: true}, create :{method: 'POST', params: {action:'create'}}, - remove :{method: 'DELETE', params: {v:0}} + remove :{method: 'DELETE', params: {id: '@id', v:0}} }); }) .factory('Image', function($resource, DOCKER_ENDPOINT) { @@ -25,9 +25,14 @@ angular.module('dockerui.services', ['ngResource']) search :{method: 'GET', params: { action:'search'}}, history :{method: 'GET', params: { action:'history'}, isArray: true}, create :{method: 'POST', params: {action:'create'}}, - insert :{method: 'POST', params: {action:'insert'}}, - push :{method: 'POST', params: {action:'push'}}, - tag :{method: 'POST', params: {action:'tag'}}, - delete :{method: 'DELETE'} + insert :{method: 'POST', params: {id: '@id', action:'insert'}}, + push :{method: 'POST', params: {id: '@id', action:'push'}}, + tag :{method: 'POST', params: {id: '@id', action:'tag'}}, + delete :{id: '@id', method: 'DELETE'} }); + }) + .factory('Settings', function() { + return { + displayAll: false + }; }); diff --git a/partials/container.html b/partials/container.html index 1b858c163..6a44f02c1 100644 --- a/partials/container.html +++ b/partials/container.html @@ -1,4 +1,8 @@
+
+ +
+

Container: {{ container.Id }}

@@ -26,7 +30,7 @@ Image: - {{ container.Image }} + {{ container.Image }} Running: diff --git a/partials/containers.html b/partials/containers.html index bced94dd0..aaf8aaf4c 100644 --- a/partials/containers.html +++ b/partials/containers.html @@ -1,6 +1,9 @@

Containers:

+
+ Display All +
@@ -12,11 +15,11 @@ - + - - - + + + diff --git a/partials/image.html b/partials/image.html index 701439bcf..39617359c 100644 --- a/partials/image.html +++ b/partials/image.html @@ -61,11 +61,9 @@
- Add Tag - - + Tag to Repo - + From 665e750c7bba03df475714b3cf57c82b7a5c419d Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 15:28:07 -0900 Subject: [PATCH 4/6] Add response display for success and error --- js/controllers.js | 99 ++++++++++++++++++++++++++++++++--------- partials/container.html | 4 +- partials/image.html | 7 ++- 3 files changed, 85 insertions(+), 25 deletions(-) diff --git a/js/controllers.js b/js/controllers.js index e9e8100ef..70c9a67c8 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -1,4 +1,5 @@ +// Controller for the top masthead function MastheadController($scope) { $scope.template = 'partials/masthead.html'; @@ -13,6 +14,7 @@ function MastheadController($scope) { $scope.iclass = ''; $scope.sclass = ''; + //This is shitty, I need help with this crap. switch(link) { case 'home': $scope.hclass = 'active'; @@ -32,46 +34,66 @@ function MastheadController($scope) { }; } -function SideBarController($scope, Container) { - $scope.template = 'partials/sidebar.html'; - - Container.query({}, function(d) { - $scope.containers = d; - }); -} - function HomeController() { } -function SettingsController() { +function SettingsController($scope, Settings) { } +// Controls the page that displays a single container and actions on that container. function ContainerController($scope, $routeParams, Container) { $('#response').hide(); + $scope.alertClass = 'block'; + + var showAndHide = function(hide) { + $('#response').show(); + if (hide) { + setTimeout(function() { $('#response').hide();}, 5000); + } + }; $scope.start = function(){ Container.start({id: $routeParams.id}, function(d) { - $scope.response = d; - $('#response').show(); - setTimeout($('#response').hide, 5000); - }); + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Container started.'; + showAndHide(true); + }, function(e) { + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); + }); }; $scope.stop = function() { - Container.stop({id: $routeParams.id}, function(d) { - $scope.response = d; - $('#response').show(); - setTimeout($('#response').hide, 5000); + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Container stopped.'; + 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) { - $scope.response = d; + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Container removed.'; + showAndHide(true); + }, function(e){ + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); }); } }; @@ -91,9 +113,11 @@ function ContainerController($scope, $routeParams, Container) { $scope.getChanges(); } +// Controller for the list of containers function ContainersController($scope, Container, Settings) { $scope.displayAll = Settings.displayAll; $scope.predicate = '-Created'; + var update = function(data) { Container.query(data, function(d) { $scope.containers = d; @@ -104,29 +128,52 @@ function ContainersController($scope, Container, Settings) { Settings.displayAll = $scope.displayAll; var u = update; var data = {all: 0}; + if ($scope.displayAll) { data.all = 1; } u(data); }; + update({all: $scope.displayAll ? 1 : 0}); - } +} +// Controller for the list of images function ImagesController($scope, Image) { - $scope.predicate = '-Created'; + Image.query({}, function(d) { $scope.images = d; }); } +// Controller for a single image and actions on that image function ImageController($scope, $routeParams, Image) { $scope.history = []; $scope.tag = {repo: '', force: false}; + + $('#response').hide(); + $scope.alertClass = 'block'; + + var showAndHide = function(hide) { + $('#response').show(); + if (hide) { + setTimeout(function() { $('#response').hide();}, 5000); + } + }; + $scope.remove = function() { if (confirm("Are you sure you want to delete this image?")) { Image.remove({id: $routeParams.id}, function(d) { - $scope.response = d; + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Image removed.'; + showAndHide(true); + }, function(e) { + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); }); } }; @@ -140,7 +187,15 @@ function ImageController($scope, $routeParams, Image) { $scope.updateTag = function() { var tag = $scope.tag; Image.tag({id: $routeParams.id, repo: tag.repo, force: tag.force ? 1 : 0}, function(d) { - $scope.response = d; + console.log(d); + $scope.alertClass = 'success'; + $scope.response = 'Tag added.'; + showAndHide(true); + }, function(e) { + console.log(e); + $scope.alertClass = 'error'; + $scope.response = e.data; + showAndHide(false); }); }; diff --git a/partials/container.html b/partials/container.html index 6a44f02c1..6132913ff 100644 --- a/partials/container.html +++ b/partials/container.html @@ -1,6 +1,6 @@
-
- +
+ {{ response }}

Container: {{ container.Id }}

diff --git a/partials/image.html b/partials/image.html index 39617359c..a521dfd5e 100644 --- a/partials/image.html +++ b/partials/image.html @@ -1,4 +1,9 @@
+ +
+ {{ response }} +
+

Image: {{ image.id }}

{{ container.Id|truncate:10}}{{ container.Image }}{{ container.Command }}{{ container.Created }}{{ container.Image }}{{ container.Command|truncate:40 }}{{ container.Created|getdate }} {{ container.Status }}
@@ -67,7 +72,7 @@ - + From 406f06cb3e3e062081730ca4cdb6f345f75ccf66 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 16:31:05 -0900 Subject: [PATCH 5/6] Add settings page and badge filters --- js/controllers.js | 72 ++++++++++++++++++++++++++++++++++++++--- js/filters.js | 26 +++++++++++++++ js/services.js | 22 +++++++++++++ partials/container.html | 5 +-- partials/image.html | 4 +-- partials/settings.html | 67 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 188 insertions(+), 8 deletions(-) create mode 100644 partials/settings.html 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 + + + + + + + + +
+ +
+
+
From 880966f3ba20a2d2b016b447c48473056fb9f2fc Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 17:16:37 -0900 Subject: [PATCH 6/6] Add ability to launch container from image --- js/controllers.js | 43 ++++++++++++++++++++++++++++++++++++ partials/image.html | 5 +++++ partials/startcontainer.html | 27 ++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 partials/startcontainer.html diff --git a/js/controllers.js b/js/controllers.js index bb34ff93f..362d097b0 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -269,3 +269,46 @@ function ImageController($scope, $routeParams, $location, Image) { $scope.getHistory(); } + +function StartContainerController($scope, $routeParams, $location, Container) { + $scope.template = 'partials/startcontainer.html'; + $scope.memory = 0; + $scope.memorySwap = 0; + $scope.env = ''; + $scope.dns = ''; + $scope.volumesFrom = ''; + $scope.commands = ''; + + $scope.launchContainer = function() { + var cmds = null; + if ($scope.commands !== '') { + cmds = $scope.commands.split('\n'); + } + var id = $routeParams.id; + var ctor = Container; + var loc = $location; + var s = $scope; + + Container.create({ + Image: id, + Memory: $scope.memory, + MemorySwap: $scope.memorySwap, + Cmd: cmds, + VolumesFrom: $scope.volumesFrom + }, function(d) { + console.log(d); + if (d.Id) { + ctor.start({id: d.Id}, function(cd) { + console.log(cd); + loc.path('/containers/' + d.Id + '/'); + }, function(e) { + console.log(e); + s.resonse = e.data; + }); + } + }, function(e) { + console.log(e); + $scope.response = e.data; + }); + }; +} diff --git a/partials/image.html b/partials/image.html index dc8cb8183..05f7b021a 100644 --- a/partials/image.html +++ b/partials/image.html @@ -76,6 +76,11 @@
+ +
+ +
+
diff --git a/partials/startcontainer.html b/partials/startcontainer.html new file mode 100644 index 000000000..98a81f608 --- /dev/null +++ b/partials/startcontainer.html @@ -0,0 +1,27 @@ + +
+ {{ response }} +
+ + +
+
+ Start container from Image + + + + Place each command on a new line + + + + + + + + + + +
+ +
+