diff --git a/app/components/container/containerController.js b/app/components/container/containerController.js
index 08590676f..b33f1eea4 100644
--- a/app/components/container/containerController.js
+++ b/app/components/container/containerController.js
@@ -1,312 +1,208 @@
- angular.module('container', [])
- .controller('ContainerController', ['$scope', '$routeParams', '$location', 'Container', 'ContainerCommit', 'Image', 'Messages', 'ViewSpinner', '$timeout',
- function ($scope, $routeParams, $location, Container, ContainerCommit, Image, Messages, ViewSpinner, $timeout) {
- $scope.changes = [];
- $scope.editEnv = false;
- $scope.editPorts = false;
- $scope.editBinds = false;
- $scope.newCfg = {
- Env: [],
- Ports: {}
- };
+angular.module('container', [])
+.controller('ContainerController', ['$scope', '$stateParams', '$state', '$filter', 'Container', 'ContainerCommit', 'Image', 'Messages', 'ViewSpinner', '$timeout',
+function ($scope, $stateParams, $state, $filter, Container, ContainerCommit, Image, Messages, ViewSpinner, $timeout) {
+ $scope.changes = [];
+ $scope.editEnv = false;
+ $scope.editPorts = false;
+ $scope.editBinds = false;
+ $scope.newCfg = {
+ Env: [],
+ Ports: {}
+ };
- var update = function () {
- ViewSpinner.spin();
- Container.get({id: $routeParams.id}, function (d) {
- $scope.container = d;
- $scope.container.edit = false;
- $scope.container.newContainerName = d.Name;
+ var update = function () {
+ ViewSpinner.spin();
+ Container.get({id: $stateParams.id}, function (d) {
+ $scope.container = d;
+ $scope.container.edit = false;
+ $scope.container.newContainerName = $filter('trimcontainername')(d.Name);
- // fill up env
- if (d.Config.Env) {
- $scope.newCfg.Env = d.Config.Env.map(function (entry) {
- return {name: entry.split('=')[0], value: entry.split('=')[1]};
- });
- }
+ // fill up env
+ if (d.Config.Env) {
+ $scope.newCfg.Env = d.Config.Env.map(function (entry) {
+ return {name: entry.split('=')[0], value: entry.split('=')[1]};
+ });
+ }
- // fill up ports
- $scope.newCfg.Ports = {};
- angular.forEach(d.Config.ExposedPorts, function(i, port) {
- if (d.HostConfig.PortBindings && port in d.HostConfig.PortBindings) {
- $scope.newCfg.Ports[port] = d.HostConfig.PortBindings[port];
- }
- else {
- $scope.newCfg.Ports[port] = [];
- }
- });
+ // fill up ports
+ $scope.newCfg.Ports = {};
+ angular.forEach(d.Config.ExposedPorts, function(i, port) {
+ if (d.HostConfig.PortBindings && port in d.HostConfig.PortBindings) {
+ $scope.newCfg.Ports[port] = d.HostConfig.PortBindings[port];
+ }
+ else {
+ $scope.newCfg.Ports[port] = [];
+ }
+ });
- // fill up bindings
- $scope.newCfg.Binds = [];
- var defaultBinds = {};
- angular.forEach(d.Config.Volumes, function(value, vol) {
- defaultBinds[vol] = { ContPath: vol, HostPath: '', ReadOnly: false, DefaultBind: true };
- });
- angular.forEach(d.HostConfig.Binds, function(binding, i) {
- var mountpoint = binding.split(':')[0];
- var vol = binding.split(':')[1] || '';
- var ro = binding.split(':').length > 2 && binding.split(':')[2] === 'ro';
- var defaultBind = false;
- if (vol === '') {
- vol = mountpoint;
- mountpoint = '';
- }
+ // fill up bindings
+ $scope.newCfg.Binds = [];
+ var defaultBinds = {};
+ angular.forEach(d.Config.Volumes, function(value, vol) {
+ defaultBinds[vol] = { ContPath: vol, HostPath: '', ReadOnly: false, DefaultBind: true };
+ });
+ angular.forEach(d.HostConfig.Binds, function(binding, i) {
+ var mountpoint = binding.split(':')[0];
+ var vol = binding.split(':')[1] || '';
+ var ro = binding.split(':').length > 2 && binding.split(':')[2] === 'ro';
+ var defaultBind = false;
+ if (vol === '') {
+ vol = mountpoint;
+ mountpoint = '';
+ }
- if (vol in defaultBinds) {
- delete defaultBinds[vol];
- defaultBind = true;
- }
- $scope.newCfg.Binds.push({ ContPath: vol, HostPath: mountpoint, ReadOnly: ro, DefaultBind: defaultBind });
- });
- angular.forEach(defaultBinds, function(bind) {
- $scope.newCfg.Binds.push(bind);
- });
+ if (vol in defaultBinds) {
+ delete defaultBinds[vol];
+ defaultBind = true;
+ }
+ $scope.newCfg.Binds.push({ ContPath: vol, HostPath: mountpoint, ReadOnly: ro, DefaultBind: defaultBind });
+ });
+ angular.forEach(defaultBinds, function(bind) {
+ $scope.newCfg.Binds.push(bind);
+ });
- 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();
- });
+ 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.start = function () {
+ ViewSpinner.spin();
+ Container.start({
+ id: $scope.container.Id,
+ HostConfig: $scope.container.HostConfig
+ }, function (d) {
+ update();
+ Messages.send("Container started", $stateParams.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.stop = function () {
+ ViewSpinner.spin();
+ Container.stop({id: $stateParams.id}, function (d) {
+ update();
+ Messages.send("Container stopped", $stateParams.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.kill = function () {
+ ViewSpinner.spin();
+ Container.kill({id: $stateParams.id}, function (d) {
+ update();
+ Messages.send("Container killed", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to die." + e.data);
+ });
+ };
- $scope.restartEnv = function () {
- var config = angular.copy($scope.container.Config);
+ $scope.commit = function () {
+ ViewSpinner.spin();
+ ContainerCommit.commit({id: $stateParams.id, repo: $scope.container.Config.Image}, function (d) {
+ update();
+ Messages.send("Container commited", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to commit." + e.data);
+ });
+ };
+ $scope.pause = function () {
+ ViewSpinner.spin();
+ Container.pause({id: $stateParams.id}, function (d) {
+ update();
+ Messages.send("Container paused", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to pause." + e.data);
+ });
+ };
- config.Env = $scope.newCfg.Env.map(function(entry) {
- return entry.name+"="+entry.value;
- });
+ $scope.unpause = function () {
+ ViewSpinner.spin();
+ Container.unpause({id: $stateParams.id}, function (d) {
+ update();
+ Messages.send("Container unpaused", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to unpause." + e.data);
+ });
+ };
- var portBindings = angular.copy($scope.newCfg.Ports);
- angular.forEach(portBindings, function(item, key) {
- if (item.length === 0) {
- delete portBindings[key];
- }
- });
+ $scope.remove = function () {
+ ViewSpinner.spin();
+ Container.remove({id: $stateParams.id}, function (d) {
+ update();
+ $state.go('containers', {}, {reload: true});
+ Messages.send("Container removed", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to remove." + e.data);
+ });
+ };
+ $scope.restart = function () {
+ ViewSpinner.spin();
+ Container.restart({id: $stateParams.id}, function (d) {
+ update();
+ Messages.send("Container restarted", $stateParams.id);
+ }, function (e) {
+ update();
+ Messages.error("Failure", "Container failed to restart." + e.data);
+ });
+ };
- var binds = [];
- angular.forEach($scope.newCfg.Binds, function(b) {
- if (b.ContPath !== '') {
- var bindLine = '';
- if (b.HostPath !== '') {
- bindLine = b.HostPath + ':';
- }
- bindLine += b.ContPath;
- if (b.ReadOnly) {
- bindLine += ':ro';
- }
- if (b.HostPath !== '' || !b.DefaultBind) {
- binds.push(bindLine);
- }
- }
- });
+ $scope.hasContent = function (data) {
+ return data !== null && data !== undefined;
+ };
+ $scope.getChanges = function () {
+ ViewSpinner.spin();
+ Container.changes({id: $stateParams.id}, function (d) {
+ $scope.changes = d;
+ ViewSpinner.stop();
+ });
+ };
- ViewSpinner.spin();
- ContainerCommit.commit({id: $routeParams.id, tag: $scope.container.Config.Image, config: config }, function (d) {
- if ('Id' in d) {
- var imageId = d.Id;
- Image.inspect({id: imageId}, function(imageData) {
- // Append current host config to image with new port bindings
- imageData.Config.HostConfig = angular.copy($scope.container.HostConfig);
- imageData.Config.HostConfig.PortBindings = portBindings;
- imageData.Config.HostConfig.Binds = binds;
- if (imageData.Config.HostConfig.NetworkMode === 'host') {
- imageData.Config.Hostname = '';
- }
+ $scope.renameContainer = function () {
+ // #FIXME fix me later to handle http status to show the correct error message
+ Container.rename({id: $stateParams.id, 'name': $scope.container.newContainerName}, function (data) {
+ if (data.name) {
+ $scope.container.Name = data.name;
+ Messages.send("Container renamed", $stateParams.id);
+ } else {
+ $scope.container.newContainerName = $scope.container.Name;
+ Messages.error("Failure", "Container failed to rename.");
+ }
+ });
+ $scope.container.edit = false;
+ };
- Container.create(imageData.Config, function(containerData) {
- if (!('Id' in containerData)) {
- Messages.error("Failure", "Container failed to create.");
- return;
- }
- // Stop current if running
- if ($scope.container.State.Running) {
- Container.stop({id: $routeParams.id}, function (d) {
- Messages.send("Container stopped", $routeParams.id);
- // start new
- Container.start({
- id: containerData.Id
- }, function (d) {
- $location.url('/containers/' + containerData.Id + '/');
- Messages.send("Container started", $routeParams.id);
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to start." + e.data);
- });
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to stop." + e.data);
- });
- } else {
- // start new
- Container.start({
- id: containerData.Id
- }, function (d) {
- $location.url('/containers/'+containerData.Id+'/');
- Messages.send("Container started", $routeParams.id);
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to start." + e.data);
- });
- }
+ $scope.addEntry = function (array, entry) {
+ array.push(entry);
+ };
+ $scope.rmEntry = function (array, entry) {
+ var idx = array.indexOf(entry);
+ array.splice(idx, 1);
+ };
- }, function(e) {
- update();
- Messages.error("Failure", "Image failed to get." + e.data);
- });
- }, function (e) {
- update();
- Messages.error("Failure", "Image failed to get." + e.data);
- });
-
- } else {
- update();
- Messages.error("Failure", "Container commit failed.");
- }
-
-
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to commit." + e.data);
- });
- };
-
- $scope.commit = function () {
- ViewSpinner.spin();
- ContainerCommit.commit({id: $routeParams.id, repo: $scope.container.Config.Image}, function (d) {
- update();
- Messages.send("Container commited", $routeParams.id);
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to commit." + 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();
- $location.path('/containers');
- Messages.send("Container removed", $routeParams.id);
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to remove." + e.data);
- });
- };
-
- $scope.restart = function () {
- ViewSpinner.spin();
- Container.restart({id: $routeParams.id}, function (d) {
- update();
- Messages.send("Container restarted", $routeParams.id);
- }, function (e) {
- update();
- Messages.error("Failure", "Container failed to restart." + 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();
- });
- };
-
- $scope.renameContainer = function () {
- // #FIXME fix me later to handle http status to show the correct error message
- Container.rename({id: $routeParams.id, 'name': $scope.container.newContainerName}, function (data) {
- if (data.name) {
- $scope.container.Name = data.name;
- Messages.send("Container renamed", $routeParams.id);
- } else {
- $scope.container.newContainerName = $scope.container.Name;
- Messages.error("Failure", "Container failed to rename.");
- }
- });
- $scope.container.edit = false;
- };
-
- $scope.addEntry = function (array, entry) {
- array.push(entry);
- };
- $scope.rmEntry = function (array, entry) {
- var idx = array.indexOf(entry);
- array.splice(idx, 1);
- };
-
- $scope.toggleEdit = function() {
- $scope.edit = !$scope.edit;
- };
-
- update();
- $scope.getChanges();
- }]);
+ $scope.toggleEdit = function() {
+ $scope.edit = !$scope.edit;
+ };
+ update();
+ $scope.getChanges();
+}]);
diff --git a/app/components/containerLogs/containerLogsController.js b/app/components/containerLogs/containerLogsController.js
index 27977f11d..0f1280792 100644
--- a/app/components/containerLogs/containerLogsController.js
+++ b/app/components/containerLogs/containerLogsController.js
@@ -1,76 +1,79 @@
angular.module('containerLogs', [])
- .controller('ContainerLogsController', ['$scope', '$routeParams', '$location', '$anchorScroll', 'ContainerLogs', 'Container', 'ViewSpinner',
- function ($scope, $routeParams, $location, $anchorScroll, ContainerLogs, Container, ViewSpinner) {
- $scope.stdout = '';
- $scope.stderr = '';
- $scope.showTimestamps = false;
- $scope.tailLines = 2000;
+.controller('ContainerLogsController', ['$scope', '$stateParams', '$anchorScroll', 'ContainerLogs', 'Container', 'ViewSpinner',
+function ($scope, $stateParams, $anchorScroll, ContainerLogs, Container, ViewSpinner) {
+ $scope.state = {};
+ $scope.state.displayTimestampsOut = false;
+ $scope.state.displayTimestampsErr = false;
+ $scope.stdout = '';
+ $scope.stderr = '';
+ $scope.tailLines = 2000;
- ViewSpinner.spin();
- Container.get({id: $routeParams.id}, function (d) {
- $scope.container = d;
- ViewSpinner.stop();
- }, function (e) {
- if (e.status === 404) {
- Messages.error("Not found", "Container not found.");
- } else {
- Messages.error("Failure", e.data);
- }
- ViewSpinner.stop();
- });
+ ViewSpinner.spin();
+ Container.get({id: $stateParams.id}, function (d) {
+ $scope.container = d;
+ ViewSpinner.stop();
+ }, function (e) {
+ if (e.status === 404) {
+ Messages.error("Not found", "Container not found.");
+ } else {
+ Messages.error("Failure", e.data);
+ }
+ ViewSpinner.stop();
+ });
- function getLogs() {
- ViewSpinner.spin();
- ContainerLogs.get($routeParams.id, {
- stdout: 1,
- stderr: 0,
- timestamps: $scope.showTimestamps,
- tail: $scope.tailLines
- }, function (data, status, headers, config) {
- // Replace carriage returns with newlines to clean up output
- data = data.replace(/[\r]/g, '\n');
- // Strip 8 byte header from each line of output
- data = data.substring(8);
- data = data.replace(/\n(.{8})/g, '\n');
- $scope.stdout = data;
- ViewSpinner.stop();
- });
+ function getLogs() {
+ ViewSpinner.spin();
+ getLogsStdout();
+ getLogsStderr();
+ ViewSpinner.stop();
+ }
- ContainerLogs.get($routeParams.id, {
- stdout: 0,
- stderr: 1,
- timestamps: $scope.showTimestamps,
- tail: $scope.tailLines
- }, function (data, status, headers, config) {
- // Replace carriage returns with newlines to clean up output
- data = data.replace(/[\r]/g, '\n');
- // Strip 8 byte header from each line of output
- data = data.substring(8);
- data = data.replace(/\n(.{8})/g, '\n');
- $scope.stderr = data;
- ViewSpinner.stop();
- });
- }
+ function getLogsStderr() {
+ ContainerLogs.get($stateParams.id, {
+ stdout: 0,
+ stderr: 1,
+ timestamps: $scope.state.displayTimestampsErr,
+ tail: $scope.tailLines
+ }, function (data, status, headers, config) {
+ // Replace carriage returns with newlines to clean up output
+ data = data.replace(/[\r]/g, '\n');
+ // Strip 8 byte header from each line of output
+ data = data.substring(8);
+ data = data.replace(/\n(.{8})/g, '\n');
+ $scope.stderr = data;
+ });
+ }
- // initial call
- getLogs();
- var logIntervalId = window.setInterval(getLogs, 5000);
+ function getLogsStdout() {
+ ContainerLogs.get($stateParams.id, {
+ stdout: 1,
+ stderr: 0,
+ timestamps: $scope.state.displayTimestampsOut,
+ tail: $scope.tailLines
+ }, function (data, status, headers, config) {
+ // Replace carriage returns with newlines to clean up output
+ data = data.replace(/[\r]/g, '\n');
+ // Strip 8 byte header from each line of output
+ data = data.substring(8);
+ data = data.replace(/\n(.{8})/g, '\n');
+ $scope.stdout = data;
+ });
+ }
- $scope.$on("$destroy", function () {
- // clearing interval when view changes
- clearInterval(logIntervalId);
- });
+ // initial call
+ getLogs();
+ var logIntervalId = window.setInterval(getLogs, 5000);
- $scope.scrollTo = function (id) {
- $location.hash(id);
- $anchorScroll();
- };
+ $scope.$on("$destroy", function () {
+ // clearing interval when view changes
+ clearInterval(logIntervalId);
+ });
- $scope.toggleTimestamps = function () {
- getLogs();
- };
+ $scope.toggleTimestampsOut = function () {
+ getLogsStdout();
+ };
- $scope.toggleTail = function () {
- getLogs();
- };
- }]);
+ $scope.toggleTimestampsErr = function () {
+ getLogsStderr();
+ };
+}]);
diff --git a/app/components/containerLogs/containerlogs.html b/app/components/containerLogs/containerlogs.html
index 406d04e66..0a20d5ddc 100644
--- a/app/components/containerLogs/containerlogs.html
+++ b/app/components/containerLogs/containerlogs.html
@@ -1,43 +1,47 @@
-
-
-
-
-
-
stdout
-
stderr
+
+
-
-
-
+
{{ container.Name|trimcontainername }}
+
+
+
+
+
+
+
+
+
diff --git a/app/components/containerTop/containerTop.html b/app/components/containerTop/containerTop.html
deleted file mode 100644
index 4db3ca5ce..000000000
--- a/app/components/containerTop/containerTop.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
Top for: {{ containerName }}
-
-
-
-
-
-
-
-
- {{title}}
-
-
-
-
- {{processInfo}}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/components/containerTop/containerTopController.js b/app/components/containerTop/containerTopController.js
deleted file mode 100644
index fe658c7bf..000000000
--- a/app/components/containerTop/containerTopController.js
+++ /dev/null
@@ -1,25 +0,0 @@
-angular.module('containerTop', [])
- .controller('ContainerTopController', ['$scope', '$routeParams', 'ContainerTop', 'Container', 'ViewSpinner', function ($scope, $routeParams, ContainerTop, Container, ViewSpinner) {
- $scope.ps_args = '';
-
- /**
- * Get container processes
- */
- $scope.getTop = function () {
- ViewSpinner.spin();
- ContainerTop.get($routeParams.id, {
- ps_args: $scope.ps_args
- }, function (data) {
- $scope.containerTop = data;
- ViewSpinner.stop();
- });
- };
-
- Container.get({id: $routeParams.id}, function (d) {
- $scope.containerName = d.Name.substring(1);
- }, function (e) {
- Messages.error("Failure", e.data);
- });
-
- $scope.getTop();
- }]);
\ No newline at end of file
diff --git a/app/components/containers/containers.html b/app/components/containers/containers.html
index 5e66102ad..8d3c847f5 100644
--- a/app/components/containers/containers.html
+++ b/app/components/containers/containers.html
@@ -1,76 +1,82 @@
+
-
Containers:
-
-
-
+
+
+
+
diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js
index 02f7dbc88..0672cda7f 100644
--- a/app/components/containers/containersController.js
+++ b/app/components/containers/containersController.js
@@ -1,118 +1,138 @@
angular.module('containers', [])
- .controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner',
- function ($scope, Container, Settings, Messages, ViewSpinner) {
- $scope.sortType = 'Created';
- $scope.sortReverse = true;
- $scope.toggle = false;
- $scope.displayAll = Settings.displayAll;
+.controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner',
+function ($scope, Container, Settings, Messages, ViewSpinner) {
- $scope.order = function (sortType) {
- $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
- $scope.sortType = sortType;
- };
+ $scope.state = {};
+ $scope.state.displayAll = Settings.displayAll;
+ $scope.sortType = 'Created';
+ $scope.sortReverse = true;
+ $scope.state.toggle = false;
+ $scope.state.selectedItemCount = 0;
- var update = function (data) {
- ViewSpinner.spin();
- Container.query(data, function (d) {
- $scope.containers = d.map(function (item) {
- return new ContainerViewModel(item);
- });
- ViewSpinner.stop();
- });
- };
+ $scope.order = function (sortType) {
+ $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
+ $scope.sortType = sortType;
+ };
- var batch = function (items, action, msg) {
- ViewSpinner.spin();
- var counter = 0;
- var complete = function () {
- counter = counter - 1;
- if (counter === 0) {
- ViewSpinner.stop();
- update({all: Settings.displayAll ? 1 : 0});
- }
- };
- angular.forEach(items, function (c) {
- if (c.Checked) {
- if (action === Container.start) {
- Container.get({id: c.Id}, function (d) {
- c = d;
- counter = counter + 1;
- action({id: c.Id, HostConfig: c.HostConfig || {}}, function (d) {
- Messages.send("Container " + msg, c.Id);
- var index = $scope.containers.indexOf(c);
- complete();
- }, function (e) {
- Messages.error("Failure", e.data);
- complete();
- });
- }, function (e) {
- if (e.status === 404) {
- $('.detail').hide();
- Messages.error("Not found", "Container not found.");
- } else {
- Messages.error("Failure", e.data);
- }
- complete();
- });
- }
- else {
- counter = counter + 1;
- action({id: c.Id}, function (d) {
- Messages.send("Container " + msg, c.Id);
- var index = $scope.containers.indexOf(c);
- complete();
- }, function (e) {
- Messages.error("Failure", e.data);
- complete();
- });
+ var update = function (data) {
+ ViewSpinner.spin();
+ $scope.state.selectedItemCount = 0;
+ Container.query(data, function (d) {
+ $scope.containers = d.filter(function (container) {
+ return container.Image !== 'swarm';
+ }).map(function (container) {
+ return new ContainerViewModel(container);
+ });
+ ViewSpinner.stop();
+ });
+ };
- }
+ var batch = function (items, action, msg) {
+ ViewSpinner.spin();
+ var counter = 0;
+ var complete = function () {
+ counter = counter - 1;
+ if (counter === 0) {
+ ViewSpinner.stop();
+ update({all: Settings.displayAll ? 1 : 0});
+ }
+ };
+ angular.forEach(items, function (c) {
+ if (c.Checked) {
+ if (action === Container.start) {
+ Container.get({id: c.Id}, function (d) {
+ c = d;
+ counter = counter + 1;
+ action({id: c.Id, HostConfig: c.HostConfig || {}}, function (d) {
+ Messages.send("Container " + msg, c.Id);
+ var index = $scope.containers.indexOf(c);
+ complete();
+ }, function (e) {
+ Messages.error("Failure", e.data);
+ complete();
+ });
+ }, function (e) {
+ if (e.status === 404) {
+ $('.detail').hide();
+ Messages.error("Not found", "Container not found.");
+ } else {
+ Messages.error("Failure", e.data);
+ }
+ complete();
+ });
+ }
+ else {
+ counter = counter + 1;
+ action({id: c.Id}, function (d) {
+ Messages.send("Container " + msg, c.Id);
+ var index = $scope.containers.indexOf(c);
+ complete();
+ }, function (e) {
+ Messages.error("Failure", e.data);
+ complete();
+ });
- }
- });
- if (counter === 0) {
- ViewSpinner.stop();
- }
- };
+ }
- $scope.toggleSelectAll = function () {
- angular.forEach($scope.filteredContainers, function (i) {
- i.Checked = $scope.toggle;
- });
- };
+ }
+ });
+ if (counter === 0) {
+ ViewSpinner.stop();
+ }
+ };
- $scope.toggleGetAll = function () {
- Settings.displayAll = $scope.displayAll;
- update({all: Settings.displayAll ? 1 : 0});
- };
+ $scope.selectItem = function (item) {
+ if (item.Checked) {
+ $scope.state.selectedItemCount++;
+ } else {
+ $scope.state.selectedItemCount--;
+ }
+ };
- $scope.startAction = function () {
- batch($scope.containers, Container.start, "Started");
- };
+ $scope.toggleSelectAll = function () {
+ $scope.state.selectedItem = $scope.state.toggle;
+ angular.forEach($scope.state.filteredContainers, function (i) {
+ i.Checked = $scope.state.toggle;
+ });
+ if ($scope.state.toggle) {
+ $scope.state.selectedItemCount = $scope.state.filteredContainers.length;
+ } else {
+ $scope.state.selectedItemCount = 0;
+ }
+ };
- $scope.stopAction = function () {
- batch($scope.containers, Container.stop, "Stopped");
- };
+ $scope.toggleGetAll = function () {
+ Settings.displayAll = $scope.state.displayAll;
+ update({all: Settings.displayAll ? 1 : 0});
+ };
- $scope.restartAction = function () {
- batch($scope.containers, Container.restart, "Restarted");
- };
+ $scope.startAction = function () {
+ batch($scope.containers, Container.start, "Started");
+ };
- $scope.killAction = function () {
- batch($scope.containers, Container.kill, "Killed");
- };
+ $scope.stopAction = function () {
+ batch($scope.containers, Container.stop, "Stopped");
+ };
- $scope.pauseAction = function () {
- batch($scope.containers, Container.pause, "Paused");
- };
+ $scope.restartAction = function () {
+ batch($scope.containers, Container.restart, "Restarted");
+ };
- $scope.unpauseAction = function () {
- batch($scope.containers, Container.unpause, "Unpaused");
- };
+ $scope.killAction = function () {
+ batch($scope.containers, Container.kill, "Killed");
+ };
- $scope.removeAction = function () {
- batch($scope.containers, Container.remove, "Removed");
- };
+ $scope.pauseAction = function () {
+ batch($scope.containers, Container.pause, "Paused");
+ };
- update({all: Settings.displayAll ? 1 : 0});
- }]);
+ $scope.unpauseAction = function () {
+ batch($scope.containers, Container.unpause, "Unpaused");
+ };
+
+ $scope.removeAction = function () {
+ batch($scope.containers, Container.remove, "Removed");
+ };
+
+ update({all: Settings.displayAll ? 1 : 0});
+}]);
diff --git a/app/components/containersNetwork/containersNetwork.html b/app/components/containersNetwork/containersNetwork.html
deleted file mode 100644
index ba265e880..000000000
--- a/app/components/containersNetwork/containersNetwork.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
Containers Network
-
-
-
-
- Hide Selected
- Show Selected Downstream
- Show Selected Upstream
- Show All
-
-
Include stopped containers
-
-
-
-
-
diff --git a/app/components/containersNetwork/containersNetworkController.js b/app/components/containersNetwork/containersNetworkController.js
deleted file mode 100644
index 26546afb2..000000000
--- a/app/components/containersNetwork/containersNetworkController.js
+++ /dev/null
@@ -1,271 +0,0 @@
-angular.module('containersNetwork', ['ngVis'])
- .controller('ContainersNetworkController', ['$scope', '$location', 'Container', 'Messages', 'VisDataSet', function ($scope, $location, Container, Messages, VisDataSet) {
-
- function ContainerNode(data) {
- this.Id = data.Id;
- // names have the following format: /Name
- this.Name = data.Name.substring(1);
- this.Image = data.Config.Image;
- this.Running = data.State.Running;
- var dataLinks = data.HostConfig.Links;
- if (dataLinks != null) {
- this.Links = {};
- for (var i = 0; i < dataLinks.length; i++) {
- // links have the following format: /TargetContainerName:/SourceContainerName/LinkAlias
- var link = dataLinks[i].split(":");
- var target = link[0].substring(1);
- var alias = link[1].substring(link[1].lastIndexOf("/") + 1);
- // only keep shortest alias
- if (this.Links[target] == null || alias.length < this.Links[target].length) {
- this.Links[target] = alias;
- }
- }
- }
- var dataVolumes = data.HostConfig.VolumesFrom;
- //converting array into properties for simpler and faster access
- if (dataVolumes != null) {
- this.VolumesFrom = {};
- for (var j = 0; j < dataVolumes.length; j++) {
- this.VolumesFrom[dataVolumes[j]] = true;
- }
- }
- }
-
- function ContainersNetworkData() {
- this.nodes = new VisDataSet();
- this.edges = new VisDataSet();
-
- this.addContainerNode = function (container) {
- this.nodes.add({
- id: container.Id,
- label: container.Name,
- title: "
" +
- "ID: " + container.Id + " " +
- "Image: " + container.Image + " " +
- " ",
- color: (container.Running ? "#8888ff" : "#cccccc")
- });
- };
-
- this.hasEdge = function (from, to) {
- return this.edges.getIds({
- filter: function (item) {
- return item.from === from.Id && item.to === to.Id;
- }
- }).length > 0;
- };
-
- this.addLinkEdgeIfExists = function (from, to) {
- if (from.Links != null && from.Links[to.Name] != null && !this.hasEdge(from, to)) {
- this.edges.add({
- from: from.Id,
- to: to.Id,
- label: from.Links[to.Name]
- });
- }
- };
-
- this.addVolumeEdgeIfExists = function (from, to) {
- if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null) && !this.hasEdge(from, to)) {
- this.edges.add({
- from: from.Id,
- to: to.Id,
- color: {color: '#A0A0A0', highlight: '#A0A0A0', hover: '#848484'}
- });
- }
- };
-
- this.removeContainersNodes = function (containersIds) {
- this.nodes.remove(containersIds);
- };
- }
-
- function ContainersNetwork() {
- this.data = new ContainersNetworkData();
- this.containers = {};
- this.selectedContainersIds = [];
- this.shownContainersIds = [];
- this.events = {
- select: function (event) {
- $scope.network.selectedContainersIds = event.nodes;
- $scope.$apply(function () {
- $scope.query = '';
- });
- },
- doubleClick: function (event) {
- $scope.$apply(function () {
- $location.path('/containers/' + event.nodes[0]);
- });
- }
- };
- this.options = {
- navigation: true,
- keyboard: true,
- height: '500px', width: '700px',
- nodes: {
- shape: 'box'
- },
- edges: {
- style: 'arrow'
- },
- physics: {
- barnesHut: {
- springLength: 200
- }
- }
- };
-
- this.addContainer = function (data) {
- var container = new ContainerNode(data);
- this.containers[container.Id] = container;
- this.shownContainersIds.push(container.Id);
- this.data.addContainerNode(container);
- for (var otherContainerId in this.containers) {
- var otherContainer = this.containers[otherContainerId];
- this.data.addLinkEdgeIfExists(container, otherContainer);
- this.data.addLinkEdgeIfExists(otherContainer, container);
- this.data.addVolumeEdgeIfExists(container, otherContainer);
- this.data.addVolumeEdgeIfExists(otherContainer, container);
- }
- };
-
- this.selectContainers = function (query) {
- if (this.component != null) {
- this.selectedContainersIds = this.searchContainers(query);
- this.component.selectNodes(this.selectedContainersIds);
- }
- };
-
- this.searchContainers = function (query) {
- if (query.trim() === "") {
- return [];
- }
- var selectedContainersIds = [];
- for (var i = 0; i < this.shownContainersIds.length; i++) {
- var container = this.containers[this.shownContainersIds[i]];
- if (container.Name.indexOf(query) > -1 ||
- container.Image.indexOf(query) > -1 ||
- container.Id.indexOf(query) > -1) {
- selectedContainersIds.push(container.Id);
- }
- }
- return selectedContainersIds;
- };
-
- this.hideSelected = function () {
- var i = 0;
- while (i < this.shownContainersIds.length) {
- if (this.selectedContainersIds.indexOf(this.shownContainersIds[i]) > -1) {
- this.shownContainersIds.splice(i, 1);
- } else {
- i++;
- }
- }
- this.data.removeContainersNodes(this.selectedContainersIds);
- $scope.query = '';
- this.selectedContainersIds = [];
- };
-
- this.searchDownstream = function (containerId, downstreamContainersIds) {
- if (downstreamContainersIds.indexOf(containerId) > -1) {
- return;
- }
- downstreamContainersIds.push(containerId);
- var container = this.containers[containerId];
- if (container.Links == null && container.VolumesFrom == null) {
- return;
- }
- for (var otherContainerId in this.containers) {
- var otherContainer = this.containers[otherContainerId];
- if (container.Links != null && container.Links[otherContainer.Name] != null) {
- this.searchDownstream(otherContainer.Id, downstreamContainersIds);
- } else if (container.VolumesFrom != null &&
- container.VolumesFrom[otherContainer.Id] != null) {
- this.searchDownstream(otherContainer.Id, downstreamContainersIds);
- }
- }
- };
-
- this.updateShownContainers = function (newShownContainersIds) {
- for (var containerId in this.containers) {
- if (newShownContainersIds.indexOf(containerId) > -1 &&
- this.shownContainersIds.indexOf(containerId) === -1) {
- this.data.addContainerNode(this.containers[containerId]);
- } else if (newShownContainersIds.indexOf(containerId) === -1 &&
- this.shownContainersIds.indexOf(containerId) > -1) {
- this.data.removeContainersNodes(containerId);
- }
- }
- this.shownContainersIds = newShownContainersIds;
- };
-
- this.showSelectedDownstream = function () {
- var downstreamContainersIds = [];
- for (var i = 0; i < this.selectedContainersIds.length; i++) {
- this.searchDownstream(this.selectedContainersIds[i], downstreamContainersIds);
- }
- this.updateShownContainers(downstreamContainersIds);
- };
-
- this.searchUpstream = function (containerId, upstreamContainersIds) {
- if (upstreamContainersIds.indexOf(containerId) > -1) {
- return;
- }
- upstreamContainersIds.push(containerId);
- var container = this.containers[containerId];
- for (var otherContainerId in this.containers) {
- var otherContainer = this.containers[otherContainerId];
- if (otherContainer.Links != null && otherContainer.Links[container.Name] != null) {
- this.searchUpstream(otherContainer.Id, upstreamContainersIds);
- } else if (otherContainer.VolumesFrom != null &&
- otherContainer.VolumesFrom[container.Id] != null) {
- this.searchUpstream(otherContainer.Id, upstreamContainersIds);
- }
- }
- };
-
- this.showSelectedUpstream = function () {
- var upstreamContainersIds = [];
- for (var i = 0; i < this.selectedContainersIds.length; i++) {
- this.searchUpstream(this.selectedContainersIds[i], upstreamContainersIds);
- }
- this.updateShownContainers(upstreamContainersIds);
- };
-
- this.showAll = function () {
- for (var containerId in this.containers) {
- if (this.shownContainersIds.indexOf(containerId) === -1) {
- this.data.addContainerNode(this.containers[containerId]);
- this.shownContainersIds.push(containerId);
- }
- }
- };
-
- }
-
- $scope.network = new ContainersNetwork();
-
- var showFailure = function (event) {
- Messages.error('Failure', e.data);
- };
-
- var addContainer = function (container) {
- $scope.network.addContainer(container);
- };
-
- var update = function (data) {
- Container.query(data, function (d) {
- for (var i = 0; i < d.length; i++) {
- Container.get({id: d[i].Id}, addContainer, showFailure);
- }
- });
- };
- update({all: 0});
-
- $scope.includeStopped = false;
- $scope.toggleIncludeStopped = function () {
- $scope.network.updateShownContainers([]);
- update({all: $scope.includeStopped ? 1 : 0});
- };
-
- }]);
diff --git a/app/components/createNetwork/createNetwork.html b/app/components/createNetwork/createNetwork.html
new file mode 100644
index 000000000..6c317a9f9
--- /dev/null
+++ b/app/components/createNetwork/createNetwork.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ {{ error }}
+
+
+
+
+
diff --git a/app/components/createNetwork/createNetworkController.js b/app/components/createNetwork/createNetworkController.js
new file mode 100644
index 000000000..a0e56882e
--- /dev/null
+++ b/app/components/createNetwork/createNetworkController.js
@@ -0,0 +1,41 @@
+angular.module('createNetwork', [])
+.controller('CreateNetworkController', ['$scope', '$state', 'Messages', 'Network', 'ViewSpinner', 'errorMsgFilter',
+function ($scope, $state, Messages, Network, ViewSpinner, errorMsgFilter) {
+ $scope.template = 'app/components/createNetwork/createNetwork.html';
+
+ $scope.init = function () {
+ $scope.createNetworkConfig = {
+ "Name": '',
+ "Driver": '',
+ "IPAM": {
+ "Config": [{}]
+ }
+ };
+ };
+
+ $scope.init();
+
+ $scope.createNetwork = function addNetwork(createNetworkConfig) {
+ if (_.isEmpty(createNetworkConfig.IPAM.Config[0])) {
+ delete createNetworkConfig.IPAM;
+ }
+ $('#error-message').hide();
+ ViewSpinner.spin();
+ $('#create-network-modal').modal('hide');
+ Network.create(createNetworkConfig, function (d) {
+ if (d.Id) {
+ Messages.send("Network created", d.Id);
+ } else {
+ Messages.error('Failure', errorMsgFilter(d));
+ }
+ ViewSpinner.stop();
+ $scope.init();
+ $state.go('networks', {}, {reload: true});
+ }, function (e) {
+ ViewSpinner.stop();
+ $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data;
+ $('#create-network-modal').modal('show');
+ $('#error-message').show();
+ });
+ };
+}]);
diff --git a/app/components/createVolume/createVolume.html b/app/components/createVolume/createVolume.html
new file mode 100644
index 000000000..7e6a5987c
--- /dev/null
+++ b/app/components/createVolume/createVolume.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ {{ error }}
+
+
+
+
+
diff --git a/app/components/createVolume/createVolumeController.js b/app/components/createVolume/createVolumeController.js
new file mode 100644
index 000000000..9193b9f71
--- /dev/null
+++ b/app/components/createVolume/createVolumeController.js
@@ -0,0 +1,39 @@
+angular.module('createVolume', [])
+.controller('CreateVolumeController', ['$scope', '$state', 'Messages', 'Volume', 'ViewSpinner', 'errorMsgFilter',
+function ($scope, $state, Messages, Volume, ViewSpinner, errorMsgFilter) {
+ $scope.template = 'app/components/createVolume/createVolume.html';
+
+ $scope.init = function () {
+ $scope.createVolumeConfig = {
+ "Name": "",
+ "Driver": "",
+ "DriverOpts": {}
+ };
+ $scope.availableDrivers = ['local', 'local-persist'];
+ $scope.selectedDriver = { value: $scope.availableDrivers[0] };
+ };
+
+ $scope.init();
+
+ $scope.addVolume = function addVolume(createVolumeConfig) {
+ $('#error-message').hide();
+ ViewSpinner.spin();
+ $('#create-volume-modal').modal('hide');
+ createVolumeConfig.Driver = $scope.selectedDriver.value;
+ console.log(JSON.stringify(createVolumeConfig, null, 4));
+ Volume.create(createVolumeConfig, function (d) {
+ if (d.Name) {
+ Messages.send("Volume created", d.Name);
+ } else {
+ Messages.error('Failure', errorMsgFilter(d));
+ }
+ ViewSpinner.stop();
+ $state.go('volumes', {}, {reload: true});
+ }, function (e) {
+ ViewSpinner.stop();
+ $scope.error = "Cannot create volume " + createVolumeConfig.Name + " Reason: " + e.data;
+ $('#create-volume-modal').modal('show');
+ $('#error-message').show();
+ });
+ };
+}]);
diff --git a/app/components/dashboard/dashboard.html b/app/components/dashboard/dashboard.html
index 769d743fa..de814476a 100644
--- a/app/components/dashboard/dashboard.html
+++ b/app/components/dashboard/dashboard.html
@@ -1,52 +1,71 @@
-
-
-
-
-
-
UI For Docker
-
-
The UI for Docker container engine
-
Learn more.
-
+
+
-
-
-
-
-
-
Status
-
- You are using an outdated browser. Please upgrade your browser to improve your experience.
-
-
-
+
{{ containerData.total }}
+
+
+
+
+
-
-
-
-
Containers created
-
- You are using an outdated browser. Please upgrade your browser to improve your experience.
-
-
Images created
-
- You are using an outdated browser. Please upgrade your browser to improve your experience.
-
+
{{ containerData.running }}
+
+
+
+
+
+
{{ containerData.stopped }}
+
+
+
+
+
+
+
+
+
+
+ {{ containerData.ghost }}
+
+
+
+
+
+
+
+
+
+
+
+
+ You are using an outdated browser. Please upgrade your browser to improve your experience.
+
+
+
+
+
+
+
+
+
+ You are using an outdated browser. Please upgrade your browser to improve your experience.
+
+
+
+
diff --git a/app/components/dashboard/dashboardController.js b/app/components/dashboard/dashboardController.js
index e5863dc59..642ccc1aa 100644
--- a/app/components/dashboard/dashboardController.js
+++ b/app/components/dashboard/dashboardController.js
@@ -1,75 +1,46 @@
angular.module('dashboard', [])
- .controller('DashboardController', ['$scope', 'Container', 'Image', 'Settings', 'LineChart', function ($scope, Container, Image, Settings, LineChart) {
- $scope.predicate = '-Created';
- $scope.containers = [];
+ .controller('DashboardController', ['$scope', 'Container', 'Image', 'Settings', 'LineChart', function ($scope, Container, Image, Settings, LineChart) {
- var getStarted = function (data) {
- $scope.totalContainers = data.length;
- LineChart.build('#containers-started-chart', data, function (c) {
- return new Date(c.Created * 1000).toLocaleDateString();
- });
- var s = $scope;
- Image.query({}, function (d) {
- s.totalImages = d.length;
- LineChart.build('#images-created-chart', d, function (c) {
- return new Date(c.Created * 1000).toLocaleDateString();
- });
- });
- };
+ $scope.containerData = {};
- var opts = {animation: false};
- if (Settings.firstLoad) {
- opts.animation = true;
- Settings.firstLoad = false;
- localStorage.setItem('firstLoad', false);
- $('#masthead').show();
+ var buildCharts = function (data) {
+ $scope.containerData.total = data.length;
+ LineChart.build('#containers-started-chart', data, function (c) {
+ return new Date(c.Created * 1000).toLocaleDateString();
+ });
+ var s = $scope;
+ Image.query({}, function (d) {
+ s.totalImages = d.length;
+ LineChart.build('#images-created-chart', d, function (c) {
+ return new Date(c.Created * 1000).toLocaleDateString();
+ });
+ });
+ };
- setTimeout(function () {
- $('#masthead').slideUp('slow');
- }, 5000);
- }
+ Container.query({all: 1}, function (d) {
+ var running = 0;
+ var ghost = 0;
+ var stopped = 0;
- Container.query({all: 1}, function (d) {
- var running = 0;
- var ghost = 0;
- var stopped = 0;
+ // TODO: centralize that
+ var containers = d.filter(function (container) {
+ return container.Image !== 'swarm';
+ });
- for (var i = 0; i < d.length; i++) {
- var item = d[i];
+ for (var i = 0; i < containers.length; i++) {
+ var item = containers[i];
+ if (item.Status === "Ghost") {
+ ghost += 1;
+ } else if (item.Status.indexOf('Exit') !== -1) {
+ stopped += 1;
+ } else {
+ running += 1;
+ }
+ }
+ $scope.containerData.running = running;
+ $scope.containerData.stopped = stopped;
+ $scope.containerData.ghost = ghost;
- if (item.Status === "Ghost") {
- ghost += 1;
- } else if (item.Status.indexOf('Exit') !== -1) {
- stopped += 1;
- } else {
- running += 1;
- $scope.containers.push(new ContainerViewModel(item));
- }
- }
-
- getStarted(d);
-
- var c = new Chart($('#containers-chart').get(0).getContext("2d"));
- var data = [
- {
- value: running,
- color: '#5bb75b',
- title: 'Running'
- }, // running
- {
- value: stopped,
- color: '#C7604C',
- title: 'Stopped'
- }, // stopped
- {
- value: ghost,
- color: '#E2EAE9',
- title: 'Ghost'
- } // ghost
- ];
-
- c.Doughnut(data, opts);
- var lgd = $('#chart-legend').get(0);
- legend(lgd, data);
- });
- }]);
+ buildCharts(containers);
+ });
+}]);
diff --git a/app/components/dashboard/master-ctrl.js b/app/components/dashboard/master-ctrl.js
new file mode 100644
index 000000000..7bba9bb1f
--- /dev/null
+++ b/app/components/dashboard/master-ctrl.js
@@ -0,0 +1,35 @@
+angular.module('dashboard')
+.controller('MasterCtrl', ['$scope', '$cookieStore', 'Settings', function ($scope, $cookieStore, Settings) {
+ /**
+ * Sidebar Toggle & Cookie Control
+ */
+ var mobileView = 992;
+
+ $scope.getWidth = function() {
+ return window.innerWidth;
+ };
+
+ $scope.$watch($scope.getWidth, function(newValue, oldValue) {
+ if (newValue >= mobileView) {
+ if (angular.isDefined($cookieStore.get('toggle'))) {
+ $scope.toggle = ! $cookieStore.get('toggle') ? false : true;
+ } else {
+ $scope.toggle = true;
+ }
+ } else {
+ $scope.toggle = false;
+ }
+
+ });
+
+ $scope.toggleSidebar = function() {
+ $scope.toggle = !$scope.toggle;
+ $cookieStore.put('toggle', $scope.toggle);
+ };
+
+ window.onresize = function() {
+ $scope.$apply();
+ };
+
+ $scope.uiVersion = Settings.uiVersion;
+}]);
diff --git a/app/components/events/events.html b/app/components/events/events.html
deleted file mode 100644
index 08d010ae1..000000000
--- a/app/components/events/events.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
Events
-
-
-
-
-
-
- Event
- From
- ID
- Time
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/components/events/eventsController.js b/app/components/events/eventsController.js
deleted file mode 100644
index c11a96683..000000000
--- a/app/components/events/eventsController.js
+++ /dev/null
@@ -1,42 +0,0 @@
-angular.module('events', ['ngOboe'])
- .controller('EventsController', ['Settings', '$scope', 'Oboe', 'Messages', '$timeout', function (Settings, $scope, oboe, Messages, $timeout) {
- $scope.updateEvents = function () {
- $scope.dockerEvents = [];
-
- // TODO: Clean up URL building
- var url = Settings.url + '/events?';
-
- if ($scope.model.since) {
- var sinceSecs = Math.floor($scope.model.since.getTime() / 1000);
- url += 'since=' + sinceSecs + '&';
- }
- if ($scope.model.until) {
- var untilSecs = Math.floor($scope.model.until.getTime() / 1000);
- url += 'until=' + untilSecs;
- }
-
- oboe({
- url: url,
- pattern: '{id status time}'
- })
- .then(function (node) {
- // finished loading
- $timeout(function () {
- $scope.$apply();
- });
- }, function (error) {
- // handle errors
- Messages.error("Failure", error.data);
- }, function (node) {
- // node received
- $scope.dockerEvents.push(node);
- });
- };
-
- // Init
- $scope.model = {};
- $scope.model.since = new Date(Date.now() - 86400000); // 24 hours in the past
- $scope.model.until = new Date();
- $scope.updateEvents();
-
- }]);
\ No newline at end of file
diff --git a/app/components/footer/footerController.js b/app/components/footer/footerController.js
deleted file mode 100644
index 3e7cd2532..000000000
--- a/app/components/footer/footerController.js
+++ /dev/null
@@ -1,9 +0,0 @@
-angular.module('footer', [])
- .controller('FooterController', ['$scope', 'Settings', 'Version', function ($scope, Settings, Version) {
- $scope.template = 'app/components/footer/statusbar.html';
-
- $scope.uiVersion = Settings.uiVersion;
- Version.get({}, function (d) {
- $scope.apiVersion = d.ApiVersion;
- });
- }]);
diff --git a/app/components/footer/statusbar.html b/app/components/footer/statusbar.html
deleted file mode 100644
index 3bc0085d1..000000000
--- a/app/components/footer/statusbar.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/app/components/image/image.html b/app/components/image/image.html
index da77ead42..10b2d9ecb 100644
--- a/app/components/image/image.html
+++ b/app/components/image/image.html
@@ -1,120 +1,92 @@
-
-
-
- {{ error }}
+
+
+
+
+
+
+
+ {{ id }}
+
+
+
+
-
-
-
-
Image: {{ id }}
-
-
- Start Container
-
-
-
-
Containers created:
-
- You are using an outdated browser. Please upgrade your browser to improve your experience.
-
-
-
-
-
-
- Tags:
-
+
+
+
+
+
+
+
+
+
+ Created
+ {{ image.Created | date: 'medium'}}
+
+
+ Tags
+
- {{ tag }}
- Remove tag
-
+ {{ tag }}
+ Remove tag
+
-
-
-
- Created:
- {{ image.Created | date: 'medium'}}
-
-
- Parent:
- {{ image.Parent }}
-
-
- Size (Virtual Size):
- {{ image.Size|humansize }} ({{ image.VirtualSize|humansize }})
-
+
+
+
+ Parent
+ {{ image.Parent }}
+
+
+ Size (Virtual Size)
+ {{ image.Size|humansize }} ({{ image.VirtualSize|humansize }})
+
-
- Hostname:
- {{ image.ContainerConfig.Hostname }}
-
-
- User:
- {{ image.ContainerConfig.User }}
-
-
- Cmd:
- {{ image.ContainerConfig.Cmd }}
-
-
- Volumes:
- {{ image.ContainerConfig.Volumes }}
-
-
- Volumes from:
- {{ image.ContainerConfig.VolumesFrom }}
-
-
- Built with:
- Docker {{ image.DockerVersion }} on {{ image.Os}}, {{ image.Architecture }}
-
-
-
-
-
-
-
-
-
-
- {{ change.Id }} : Created: {{ change.Created|getdate }} Created by: {{ change.CreatedBy
- }}
-
-
-
-
-
-
-
-
-
-
-
- Remove Image
-
+
+ Hostname
+ {{ image.ContainerConfig.Hostname }}
+
+
+ User
+ {{ image.ContainerConfig.User }}
+
+
+ Cmd
+ {{ image.ContainerConfig.Cmd }}
+
+
+ Volumes
+ {{ image.ContainerConfig.Volumes }}
+
+
+ Volumes from
+ {{ image.ContainerConfig.VolumesFrom }}
+
+
+ Built with
+ Docker {{ image.DockerVersion }} on {{ image.Os}}, {{ image.Architecture }}
+
+
+
+
+
+
diff --git a/app/components/image/imageController.js b/app/components/image/imageController.js
index 6a903206a..e1710a62f 100644
--- a/app/components/image/imageController.js
+++ b/app/components/image/imageController.js
@@ -1,106 +1,58 @@
angular.module('image', [])
- .controller('ImageController', ['$scope', '$q', '$routeParams', '$location', 'Image', 'Container', 'Messages', 'LineChart',
- function ($scope, $q, $routeParams, $location, Image, Container, Messages, LineChart) {
- $scope.history = [];
- $scope.tagInfo = {repo: '', version: '', force: false};
- $scope.id = '';
- $scope.repoTags = [];
+.controller('ImageController', ['$scope', '$q', '$stateParams', '$state', 'Image', 'Container', 'Messages', 'LineChart',
+function ($scope, $q, $stateParams, $state, Image, Container, Messages, LineChart) {
+ $scope.tagInfo = {repo: '', version: '', force: false};
+ $scope.id = '';
+ $scope.repoTags = [];
- $scope.removeImage = function (id) {
- Image.remove({id: id}, function (d) {
- d.forEach(function(msg){
- var key = Object.keys(msg)[0];
- Messages.send(key, msg[key]);
- });
- // If last message key is 'Deleted' then assume the image is gone and send to images page
- if (d[d.length-1].Deleted) {
- $location.path('/images');
- } else {
- $location.path('/images/' + $scope.id); // Refresh the current page.
- }
- }, function (e) {
- $scope.error = e.data;
- $('#error-message').show();
- });
- };
+ $scope.removeImage = function (id) {
+ Image.remove({id: id}, function (d) {
+ d.forEach(function(msg){
+ var key = Object.keys(msg)[0];
+ Messages.send(key, msg[key]);
+ });
+ // If last message key is 'Deleted' then assume the image is gone and send to images page
+ if (d[d.length-1].Deleted) {
+ $state.go('images', {}, {reload: true});
+ } else {
+ $state.go('image', {id: $scope.id}, {reload: true});
+ }
+ }, function (e) {
+ $scope.error = e.data;
+ $('#error-message').show();
+ });
+ };
- $scope.getHistory = function () {
- Image.history({id: $routeParams.id}, function (d) {
- $scope.history = d;
- });
- };
+ /**
+ * Get RepoTags from the /images/query endpoint instead of /image/json,
+ * for backwards compatibility with Docker API versions older than 1.21
+ * @param {string} imageId
+ */
+ function getRepoTags(imageId) {
+ Image.query({}, function (d) {
+ d.forEach(function(image) {
+ if (image.Id === imageId && image.RepoTags[0] !== '
:') {
+ $scope.RepoTags = image.RepoTags;
+ }
+ });
+ });
+ }
- $scope.addTag = function () {
- var tag = $scope.tagInfo;
- Image.tag({
- id: $routeParams.id,
- repo: tag.repo,
- tag: tag.version,
- force: tag.force ? 1 : 0
- }, function (d) {
- Messages.send("Tag Added", $routeParams.id);
- $location.path('/images/' + $scope.id);
- }, function (e) {
- $scope.error = e.data;
- $('#error-message').show();
- });
- };
-
- function getContainersFromImage($q, Container, imageId) {
- var defer = $q.defer();
-
- Container.query({all: 1, notruc: 1}, function (d) {
- var containers = [];
- for (var i = 0; i < d.length; i++) {
- var c = d[i];
- if (c.ImageID === imageId) {
- containers.push(new ContainerViewModel(c));
- }
- }
- defer.resolve(containers);
- });
-
- return defer.promise;
- }
-
- /**
- * Get RepoTags from the /images/query endpoint instead of /image/json,
- * for backwards compatibility with Docker API versions older than 1.21
- * @param {string} imageId
- */
- function getRepoTags(imageId) {
- Image.query({}, function (d) {
- d.forEach(function(image) {
- if (image.Id === imageId && image.RepoTags[0] !== ':') {
- $scope.RepoTags = image.RepoTags;
- }
- });
- });
- }
-
- Image.get({id: $routeParams.id}, function (d) {
- $scope.image = d;
- $scope.id = d.Id;
- if (d.RepoTags) {
- $scope.RepoTags = d.RepoTags;
- } else {
- getRepoTags($scope.id);
- }
-
- getContainersFromImage($q, Container, $scope.id).then(function (containers) {
- LineChart.build('#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();
- }]);
+ Image.get({id: $stateParams.id}, function (d) {
+ $scope.image = d;
+ $scope.id = d.Id;
+ if (d.RepoTags) {
+ $scope.RepoTags = d.RepoTags;
+ } else {
+ getRepoTags($scope.id);
+ }
+ }, function (e) {
+ if (e.status === 404) {
+ $('.detail').hide();
+ $scope.error = "Image not found. " + $stateParams.id;
+ } else {
+ $scope.error = e.data;
+ }
+ $('#error-message').show();
+ });
+}]);
diff --git a/app/components/images/images.html b/app/components/images/images.html
index 94e9e0c5e..dff6ab6e7 100644
--- a/app/components/images/images.html
+++ b/app/components/images/images.html
@@ -1,64 +1,67 @@
-
-Images:
-
-
-
+
+
+
+
diff --git a/app/components/images/imagesController.js b/app/components/images/imagesController.js
index 3f68dbae0..113e7d718 100644
--- a/app/components/images/imagesController.js
+++ b/app/components/images/imagesController.js
@@ -1,60 +1,75 @@
angular.module('images', [])
- .controller('ImagesController', ['$scope', 'Image', 'ViewSpinner', 'Messages',
- function ($scope, Image, ViewSpinner, Messages) {
- $scope.sortType = 'Created';
- $scope.sortReverse = true;
- $scope.toggle = false;
+.controller('ImagesController', ['$scope', 'Image', 'ViewSpinner', 'Messages',
+function ($scope, Image, ViewSpinner, Messages) {
+ $scope.state = {};
+ $scope.sortType = 'Created';
+ $scope.sortReverse = true;
+ $scope.state.toggle = false;
+ $scope.state.selectedItemCount = 0;
- $scope.order = function(sortType) {
- $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
- $scope.sortType = sortType;
- };
+ $scope.order = function(sortType) {
+ $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
+ $scope.sortType = sortType;
+ };
- $scope.showBuilder = function () {
- $('#build-modal').modal('show');
- };
+ $scope.toggleSelectAll = function () {
+ angular.forEach($scope.state.filteredImages, function (i) {
+ i.Checked = $scope.state.toggle;
+ });
+ if ($scope.state.toggle) {
+ $scope.state.selectedItemCount = $scope.state.filteredImages.length;
+ } else {
+ $scope.state.selectedItemCount = 0;
+ }
+ };
- $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.selectItem = function (item) {
+ if (item.Checked) {
+ $scope.state.selectedItemCount++;
+ } else {
+ $scope.state.selectedItemCount--;
+ }
+ };
- $scope.toggleSelectAll = function () {
- angular.forEach($scope.filteredImages, function (i) {
- i.Checked = $scope.toggle;
- });
- };
+ $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();
+ });
+ }
+ });
+ };
- 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();
- });
- }]);
+ function fetchImages() {
+ 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();
+ });
+ }
+
+ fetchImages();
+}]);
diff --git a/app/components/info/info.html b/app/components/info/info.html
deleted file mode 100644
index 7c335d6c8..000000000
--- a/app/components/info/info.html
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
Docker Information
-
-
-
- API Endpoint: {{ endpoint }}
- API Version: {{ docker.ApiVersion }}
- Docker version: {{ docker.Version }}
- Git Commit: {{ docker.GitCommit }}
- Go Version: {{ docker.GoVersion }}
-
-
-
-
-
-
- Containers:
- {{ info.Containers }}
-
-
- Images:
- {{ info.Images }}
-
-
- Debug:
- {{ info.Debug }}
-
-
- CPUs:
- {{ info.NCPU }}
-
-
- Total Memory:
- {{ info.MemTotal|humansize }}
-
-
- Operating System:
- {{ info.OperatingSystem }}
-
-
- Kernel Version:
- {{ info.KernelVersion }}
-
-
- ID:
- {{ info.ID }}
-
-
- Labels:
- {{ info.Labels }}
-
-
- File Descriptors:
- {{ info.NFd }}
-
-
- Goroutines:
- {{ info.NGoroutines }}
-
-
- Storage Driver:
- {{ info.Driver }}
-
-
- Storage Driver Status:
-
-
- {{ val[0] }}: {{ val[1] }}
-
-
-
-
- Execution Driver:
- {{ info.ExecutionDriver }}
-
-
- Events:
- Events
-
-
- IPv4 Forwarding:
- {{ info.IPv4Forwarding }}
-
-
- Index Server Address:
- {{ info.IndexServerAddress }}
-
-
- Init Path:
- {{ info.InitPath }}
-
-
- Docker Root Directory:
- {{ info.DockerRootDir }}
-
-
- Init SHA1
- {{ info.InitSha1 }}
-
-
- Memory Limit:
- {{ info.MemoryLimit }}
-
-
- Swap Limit:
- {{ info.SwapLimit }}
-
-
-
-
diff --git a/app/components/info/infoController.js b/app/components/info/infoController.js
deleted file mode 100644
index 794e03e13..000000000
--- a/app/components/info/infoController.js
+++ /dev/null
@@ -1,14 +0,0 @@
-angular.module('info', [])
- .controller('InfoController', ['$scope', 'Info', 'Version', 'Settings',
- function ($scope, Info, Version, Settings) {
- $scope.info = {};
- $scope.docker = {};
- $scope.endpoint = Settings.endpoint;
-
- Version.get({}, function (d) {
- $scope.docker = d;
- });
- Info.get({}, function (d) {
- $scope.info = d;
- });
- }]);
diff --git a/app/components/masthead/masthead.html b/app/components/masthead/masthead.html
deleted file mode 100644
index 09cdcf93d..000000000
--- a/app/components/masthead/masthead.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
diff --git a/app/components/masthead/mastheadController.js b/app/components/masthead/mastheadController.js
deleted file mode 100644
index 579ef6e5a..000000000
--- a/app/components/masthead/mastheadController.js
+++ /dev/null
@@ -1,15 +0,0 @@
-angular.module('masthead', [])
- .controller('MastheadController', ['$scope', 'Version', function ($scope, Version) {
- $scope.template = 'app/components/masthead/masthead.html';
- $scope.showNetworksVolumes = false;
-
- Version.get(function(d) {
- if (d.ApiVersion >= 1.21) {
- $scope.showNetworksVolumes = true;
- }
- });
-
- $scope.refresh = function() {
- location.reload();
- };
- }]);
diff --git a/app/components/network/network.html b/app/components/network/network.html
index 46412b329..d8e38e719 100644
--- a/app/components/network/network.html
+++ b/app/components/network/network.html
@@ -1,110 +1,120 @@
-
-
-
Network: {{ network.Name }}
-
-
-
-
- Name:
- {{ network.Name }}
-
-
- Id:
- {{ network.Id }}
-
-
- Scope:
- {{ network.Scope }}
-
-
- Driver:
- {{ network.Driver }}
-
-
- IPAM:
-
+
+
+
+
+
+
+
+ {{ network.Name }}
+
+
+
+
+
+
+
+
+
+
+
+
+ Connect container...
+ Remove
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Id
+ {{ network.Id }}
+
+
+ Scope
+ {{ network.Scope }}
+
+
+ Driver
+ {{ network.Driver }}
+
+
+ IPAM
+
-
- Driver:
- {{ network.IPAM.Driver }}
-
-
- Subnet:
- {{ network.IPAM.Config[0].Subnet }}
-
-
- Gateway:
- {{ network.IPAM.Config[0].Gateway }}
-
+
+ Driver
+ {{ network.IPAM.Driver }}
+
+
+ Subnet
+ {{ network.IPAM.Config[0].Subnet }}
+
+
+ Gateway
+ {{ network.IPAM.Config[0].Gateway }}
+
-
-
-
- Containers:
-
+
+
+
+ Containers
+
-
- Id:
- {{ Id }}
-
-
- Disconnect from network
-
-
-
-
- EndpointID:
- {{ container.EndpointID}}
-
-
- MacAddress:
- {{ container.MacAddress}}
-
-
- IPv4Address:
- {{ container.IPv4Address}}
-
-
- IPv6Address:
- {{ container.IPv6Address}}
-
+
+ Id
+ {{ Id }}
+
+
+ EndpointID
+ {{ container.EndpointID}}
+
+
+ MacAddress
+ {{ container.MacAddress}}
+
+
+ IPv4Address
+ {{ container.IPv4Address}}
+
+
+ IPv6Address
+ {{ container.IPv6Address}}
+
+
+
+
+ Disconnect from network
+
+
+
-
-
-
-
- Options:
-
+
+
+
+ Options
+
-
- Key
- Value
-
-
- {{ k }}
- {{ v }}
-
+
+ {{ k }}
+ {{ v }}
+
-
-
-
-
-
-
-
-
-
-
- Remove Network
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
diff --git a/app/components/network/networkController.js b/app/components/network/networkController.js
index cb3cca7d4..19af7874f 100644
--- a/app/components/network/networkController.js
+++ b/app/components/network/networkController.js
@@ -1,56 +1,37 @@
angular.module('network', []).config(['$routeProvider', function ($routeProvider) {
- $routeProvider.when('/networks/:id/', {
- templateUrl: 'app/components/network/network.html',
- controller: 'NetworkController'
+}]).controller('NetworkController', ['$scope', 'Network', 'ViewSpinner', 'Messages', '$state', '$stateParams', 'errorMsgFilter',
+function ($scope, Network, ViewSpinner, Messages, $state, $stateParams, errorMsgFilter) {
+
+ $scope.disconnect = function disconnect(networkId, containerId) {
+ ViewSpinner.spin();
+ Network.disconnect({id: $stateParams.id}, {Container: containerId}, function (d) {
+ ViewSpinner.stop();
+ Messages.send("Container disconnected", containerId);
+ $state.go('network', {id: $stateParams.id}, {reload: true});
+ }, function (e) {
+ ViewSpinner.stop();
+ Messages.error("Failure", e.data);
});
-}]).controller('NetworkController', ['$scope', 'Network', 'ViewSpinner', 'Messages', '$routeParams', '$location', 'errorMsgFilter',
- function ($scope, Network, ViewSpinner, Messages, $routeParams, $location, errorMsgFilter) {
+ };
- $scope.disconnect = function disconnect(networkId, containerId) {
- ViewSpinner.spin();
- Network.disconnect({id: $routeParams.id}, {Container: containerId}, function (d) {
- ViewSpinner.stop();
- Messages.send("Container disconnected", containerId);
- $location.path('/networks/' + $routeParams.id); // Refresh the current page.
- }, function (e) {
- ViewSpinner.stop();
- Messages.error("Failure", e.data);
- });
- };
- $scope.connect = function connect(networkId, containerId) {
- ViewSpinner.spin();
- Network.connect({id: $routeParams.id}, {Container: containerId}, function (d) {
- ViewSpinner.stop();
- var errmsg = errorMsgFilter(d);
- if (errmsg) {
- Messages.error('Error', errmsg);
- } else {
- Messages.send("Container connected", d);
- }
- $location.path('/networks/' + $routeParams.id); // Refresh the current page.
- }, function (e) {
- ViewSpinner.stop();
- Messages.error("Failure", e.data);
- });
- };
- $scope.remove = function remove(networkId) {
- ViewSpinner.spin();
- Network.remove({id: $routeParams.id}, function (d) {
- ViewSpinner.stop();
- Messages.send("Network removed", d);
- $location.path('/networks'); // Go to the networks page
- }, function (e) {
- ViewSpinner.stop();
- Messages.error("Failure", e.data);
- });
- };
+ $scope.remove = function remove(networkId) {
+ ViewSpinner.spin();
+ Network.remove({id: $stateParams.id}, function (d) {
+ ViewSpinner.stop();
+ Messages.send("Network removed", "");
+ $state.go('networks', {});
+ }, function (e) {
+ ViewSpinner.stop();
+ Messages.error("Failure", e.data);
+ });
+ };
- ViewSpinner.spin();
- Network.get({id: $routeParams.id}, function (d) {
- $scope.network = d;
- ViewSpinner.stop();
- }, function (e) {
- Messages.error("Failure", e.data);
- ViewSpinner.stop();
- });
- }]);
+ ViewSpinner.spin();
+ Network.get({id: $stateParams.id}, function (d) {
+ $scope.network = d;
+ ViewSpinner.stop();
+ }, function (e) {
+ Messages.error("Failure", e.data);
+ ViewSpinner.stop();
+ });
+}]);
diff --git a/app/components/networks/networks.html b/app/components/networks/networks.html
index 8a85a0dc8..fb8fb9e2e 100644
--- a/app/components/networks/networks.html
+++ b/app/components/networks/networks.html
@@ -1,121 +1,91 @@
-
Networks:
+
-
-
-
-
- Filter
-
+
+
+
+
+
+
+
+ Remove
+ Create new network...
+
+
+
+
+
+
+
+
+
+
-
-
\ No newline at end of file
diff --git a/app/components/networks/networksController.js b/app/components/networks/networksController.js
index 6afd3a167..c3e8dbc8b 100644
--- a/app/components/networks/networksController.js
+++ b/app/components/networks/networksController.js
@@ -1,87 +1,71 @@
-angular.module('networks', []).config(['$routeProvider', function ($routeProvider) {
- $routeProvider.when('/networks/', {
- templateUrl: 'app/components/networks/networks.html',
- controller: 'NetworksController'
+angular.module('networks', [])
+.controller('NetworksController', ['$scope', 'Network', 'ViewSpinner', 'Messages', 'errorMsgFilter',
+function ($scope, Network, ViewSpinner, Messages, errorMsgFilter) {
+
+ $scope.state = {};
+ $scope.state.toggle = false;
+ $scope.state.selectedItemCount = 0;
+ $scope.sortType = 'Name';
+ $scope.sortReverse = true;
+
+ $scope.order = function(sortType) {
+ $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
+ $scope.sortType = sortType;
+ };
+
+ $scope.toggleSelectAll = function () {
+ angular.forEach($scope.state.filteredNetworks, function (i) {
+ i.Checked = $scope.state.toggle;
});
-}]).controller('NetworksController', ['$scope', 'Network', 'ViewSpinner', 'Messages', '$route', 'errorMsgFilter',
- function ($scope, Network, ViewSpinner, Messages, $route, errorMsgFilter) {
- $scope.sortType = 'Name';
- $scope.sortReverse = true;
- $scope.toggle = false;
- $scope.order = function(sortType) {
- $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
- $scope.sortType = sortType;
- };
- $scope.createNetworkConfig = {
- "Name": '',
- "Driver": '',
- "IPAM": {
- "Config": [{
- "Subnet": '',
- "IPRange": '',
- "Gateway": ''
- }]
- }
- };
+ if ($scope.state.toggle) {
+ $scope.state.selectedItemCount = $scope.state.filteredNetworks.length;
+ } else {
+ $scope.state.selectedItemCount = 0;
+ }
+ };
+ $scope.selectItem = function (item) {
+ if (item.Checked) {
+ $scope.state.selectedItemCount++;
+ } else {
+ $scope.state.selectedItemCount--;
+ }
+ };
+ $scope.removeAction = function () {
+ ViewSpinner.spin();
+ var counter = 0;
+ var complete = function () {
+ counter = counter - 1;
+ if (counter === 0) {
+ ViewSpinner.stop();
+ }
+ };
+ angular.forEach($scope.networks, function (network) {
+ if (network.Checked) {
+ counter = counter + 1;
+ Network.remove({id: network.Id}, function (d) {
+ Messages.send("Network deleted", network.Id);
+ var index = $scope.networks.indexOf(network);
+ $scope.networks.splice(index, 1);
+ complete();
+ }, function (e) {
+ Messages.error("Failure", e.data);
+ complete();
+ });
+ }
+ });
+ };
- $scope.removeAction = function () {
- ViewSpinner.spin();
- var counter = 0;
- var complete = function () {
- counter = counter - 1;
- if (counter === 0) {
- ViewSpinner.stop();
- }
- };
- angular.forEach($scope.networks, function (network) {
- if (network.Checked) {
- counter = counter + 1;
- Network.remove({id: network.Id}, function (d) {
- Messages.send("Network deleted", network.Id);
- var index = $scope.networks.indexOf(network);
- $scope.networks.splice(index, 1);
- complete();
- }, function (e) {
- Messages.error("Failure", e.data);
- complete();
- });
- }
- });
- };
-
- $scope.toggleSelectAll = function () {
- angular.forEach($scope.filteredNetworks, function (i) {
- i.Checked = $scope.toggle;
- });
- };
-
- $scope.addNetwork = function addNetwork(createNetworkConfig) {
- ViewSpinner.spin();
- Network.create(createNetworkConfig, function (d) {
- if (d.Id) {
- Messages.send("Network created", d.Id);
- } else {
- Messages.error('Failure', errorMsgFilter(d));
- }
- ViewSpinner.stop();
- fetchNetworks();
- }, function (e) {
- Messages.error("Failure", e.data);
- ViewSpinner.stop();
- });
- };
-
- function fetchNetworks() {
- ViewSpinner.spin();
- Network.query({}, function (d) {
- $scope.networks = d;
- ViewSpinner.stop();
- }, function (e) {
- Messages.error("Failure", e.data);
- ViewSpinner.stop();
- });
- }
- fetchNetworks();
- }]);
+ function fetchNetworks() {
+ ViewSpinner.spin();
+ Network.query({}, function (d) {
+ $scope.networks = d;
+ ViewSpinner.stop();
+ }, function (e) {
+ Messages.error("Failure", e.data);
+ ViewSpinner.stop();
+ });
+ }
+ fetchNetworks();
+}]);
diff --git a/app/components/pullImage/pullImage.html b/app/components/pullImage/pullImage.html
index 39e1cca52..777a6390e 100644
--- a/app/components/pullImage/pullImage.html
+++ b/app/components/pullImage/pullImage.html
@@ -1,44 +1,35 @@
-
-
-
-
-
- {{ error }}
-
-
-
+
diff --git a/app/components/pullImage/pullImageController.js b/app/components/pullImage/pullImageController.js
index d53fe9c2c..a9aae1c97 100644
--- a/app/components/pullImage/pullImageController.js
+++ b/app/components/pullImage/pullImageController.js
@@ -1,56 +1,56 @@
angular.module('pullImage', [])
- .controller('PullImageController', ['$scope', '$log', 'Messages', 'Image', 'ViewSpinner',
- function ($scope, $log, Messages, Image, ViewSpinner) {
- $scope.template = 'app/components/pullImage/pullImage.html';
+.controller('PullImageController', ['$scope', '$state', 'Messages', 'Image', 'ViewSpinner',
+function ($scope, $state, Messages, Image, ViewSpinner) {
+ $scope.template = 'app/components/pullImage/pullImage.html';
- $scope.init = function () {
- $scope.config = {
- registry: '',
- repo: '',
- fromImage: '',
- tag: 'latest'
- };
- };
+ $scope.init = function () {
+ $scope.config = {
+ registry: '',
+ fromImage: '',
+ tag: 'latest'
+ };
+ };
- $scope.init();
+ $scope.init();
- function failedRequestHandler(e, Messages) {
- Messages.error('Error', errorMsgFilter(e));
- }
+ function failedRequestHandler(e, Messages) {
+ Messages.error('Error', errorMsgFilter(e));
+ }
- $scope.pull = function () {
- $('#error-message').hide();
- var config = angular.copy($scope.config);
- var imageName = (config.registry ? config.registry + '/' : '' ) +
- (config.repo ? config.repo + '/' : '') +
- (config.fromImage) +
- (config.tag ? ':' + config.tag : '');
+ $scope.pull = function () {
+ $('#error-message').hide();
+ var config = angular.copy($scope.config);
+ var imageName = (config.registry ? config.registry + '/' : '' ) +
+ (config.fromImage) +
+ (config.tag ? ':' + config.tag : '');
- ViewSpinner.spin();
- $('#pull-modal').modal('hide');
- Image.create(config, function (data) {
- ViewSpinner.stop();
- if (data.constructor === Array) {
- var f = data.length > 0 && data[data.length - 1].hasOwnProperty('error');
- //check for error
- if (f) {
- var d = data[data.length - 1];
- $scope.error = "Cannot pull image " + imageName + " Reason: " + d.error;
- $('#pull-modal').modal('show');
- $('#error-message').show();
- } else {
- Messages.send("Image Added", imageName);
- $scope.init();
- }
- } else {
- Messages.send("Image Added", imageName);
- $scope.init();
- }
- }, function (e) {
- ViewSpinner.stop();
- $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data;
- $('#pull-modal').modal('show');
- $('#error-message').show();
- });
- };
- }]);
+ ViewSpinner.spin();
+ $('#pull-modal').modal('hide');
+ Image.create(config, function (data) {
+ ViewSpinner.stop();
+ if (data.constructor === Array) {
+ var f = data.length > 0 && data[data.length - 1].hasOwnProperty('error');
+ //check for error
+ if (f) {
+ var d = data[data.length - 1];
+ $scope.error = "Cannot pull image " + imageName + " Reason: " + d.error;
+ $('#pull-modal').modal('show');
+ $('#error-message').show();
+ } else {
+ Messages.send("Image Added", imageName);
+ $scope.init();
+ $state.go('images', {}, {reload: true});
+ }
+ } else {
+ Messages.send("Image Added", imageName);
+ $scope.init();
+ $state.go('images', {}, {reload: true});
+ }
+ }, function (e) {
+ ViewSpinner.stop();
+ $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data;
+ $('#pull-modal').modal('show');
+ $('#error-message').show();
+ });
+ };
+}]);
diff --git a/app/components/sidebar/sidebar.html b/app/components/sidebar/sidebar.html
deleted file mode 100644
index b93b8e5e3..000000000
--- a/app/components/sidebar/sidebar.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
Running containers:
-
-
Endpoint: {{ endpoint }}
-
-
diff --git a/app/components/sidebar/sidebarController.js b/app/components/sidebar/sidebarController.js
deleted file mode 100644
index 3f58d675e..000000000
--- a/app/components/sidebar/sidebarController.js
+++ /dev/null
@@ -1,11 +0,0 @@
-angular.module('sidebar', [])
- .controller('SideBarController', ['$scope', 'Container', 'Settings',
- function ($scope, Container, Settings) {
- $scope.template = 'partials/sidebar.html';
- $scope.containers = [];
- $scope.endpoint = Settings.endpoint;
-
- Container.query({all: 0}, function (d) {
- $scope.containers = d;
- });
- }]);
diff --git a/app/components/startContainer/startContainerController.js b/app/components/startContainer/startContainerController.js
index bc7527be8..fd2d3723e 100644
--- a/app/components/startContainer/startContainerController.js
+++ b/app/components/startContainer/startContainerController.js
@@ -1,159 +1,163 @@
angular.module('startContainer', ['ui.bootstrap'])
- .controller('StartContainerController', ['$scope', '$routeParams', '$location', 'Container', 'Messages', 'containernameFilter', 'errorMsgFilter',
- function ($scope, $routeParams, $location, Container, Messages, containernameFilter, errorMsgFilter) {
- $scope.template = 'app/components/startContainer/startcontainer.html';
+.controller('StartContainerController', ['$scope', '$state', 'Container', 'Messages', 'containernameFilter', 'errorMsgFilter', 'ViewSpinner',
+function ($scope, $state, Container, Messages, containernameFilter, errorMsgFilter, ViewSpinner) {
+ $scope.template = 'app/components/startContainer/startcontainer.html';
- Container.query({all: 1}, function (d) {
- $scope.containerNames = d.map(function (container) {
- return containernameFilter(container);
- });
+ Container.query({all: 1}, function (d) {
+ $scope.containerNames = d.map(function (container) {
+ return containernameFilter(container);
+ });
+ });
+
+ $scope.config = {
+ Env: [],
+ Labels: [],
+ Volumes: [],
+ SecurityOpts: [],
+ HostConfig: {
+ PortBindings: [],
+ Binds: [],
+ Links: [],
+ Dns: [],
+ DnsSearch: [],
+ VolumesFrom: [],
+ CapAdd: [],
+ CapDrop: [],
+ Devices: [],
+ LxcConf: [],
+ ExtraHosts: []
+ }
+ };
+
+ $scope.menuStatus = {
+ containerOpen: true,
+ hostConfigOpen: false
+ };
+
+ function failedRequestHandler(e, Messages) {
+ Messages.error('Error', errorMsgFilter(e));
+ }
+
+ function rmEmptyKeys(col) {
+ for (var key in col) {
+ if (col[key] === null || col[key] === undefined || col[key] === '' || ($.isPlainObject(col[key]) && $.isEmptyObject(col[key])) || col[key].length === 0) {
+ delete col[key];
+ }
+ }
+ }
+
+ function getNames(arr) {
+ return arr.map(function (item) {
+ return item.name;
+ });
+ }
+
+ $scope.create = function () {
+ // Copy the config before transforming fields to the remote API format
+ $('#create-modal').modal('hide');
+ ViewSpinner.spin();
+
+ var config = angular.copy($scope.config);
+
+ if (config.Cmd && config.Cmd[0] === "[") {
+ config.Cmd = angular.fromJson(config.Cmd);
+ } else if (config.Cmd) {
+ config.Cmd = config.Cmd.split(' ');
+ }
+
+ config.Env = config.Env.map(function (envar) {
+ return envar.name + '=' + envar.value;
+ });
+ var labels = {};
+ config.Labels = config.Labels.forEach(function(label) {
+ labels[label.key] = label.value;
+ });
+ config.Labels = labels;
+
+ config.Volumes = getNames(config.Volumes);
+ config.SecurityOpts = getNames(config.SecurityOpts);
+
+ config.HostConfig.VolumesFrom = getNames(config.HostConfig.VolumesFrom);
+ config.HostConfig.Binds = getNames(config.HostConfig.Binds);
+ config.HostConfig.Links = getNames(config.HostConfig.Links);
+ config.HostConfig.Dns = getNames(config.HostConfig.Dns);
+ config.HostConfig.DnsSearch = getNames(config.HostConfig.DnsSearch);
+ config.HostConfig.CapAdd = getNames(config.HostConfig.CapAdd);
+ config.HostConfig.CapDrop = getNames(config.HostConfig.CapDrop);
+ config.HostConfig.LxcConf = config.HostConfig.LxcConf.reduce(function (prev, cur, idx) {
+ prev[cur.name] = cur.value;
+ return prev;
+ }, {});
+ config.HostConfig.ExtraHosts = config.HostConfig.ExtraHosts.map(function (entry) {
+ return entry.host + ':' + entry.ip;
+ });
+
+ var ExposedPorts = {};
+ var PortBindings = {};
+ config.HostConfig.PortBindings.forEach(function (portBinding) {
+ var intPort = portBinding.intPort + "/tcp";
+ if (portBinding.protocol === "udp") {
+ intPort = portBinding.intPort + "/udp";
+ }
+ var binding = {
+ HostIp: portBinding.ip,
+ HostPort: portBinding.extPort
+ };
+ if (portBinding.intPort) {
+ ExposedPorts[intPort] = {};
+ if (intPort in PortBindings) {
+ PortBindings[intPort].push(binding);
+ } else {
+ PortBindings[intPort] = [binding];
+ }
+ } else {
+ Messages.send('Warning', 'Internal port must be specified for PortBindings');
+ }
+ });
+ config.ExposedPorts = ExposedPorts;
+ config.HostConfig.PortBindings = PortBindings;
+
+ // Remove empty fields from the request to avoid overriding defaults
+ rmEmptyKeys(config.HostConfig);
+ rmEmptyKeys(config);
+
+ var ctor = Container;
+ var s = $scope;
+ Container.create(config, function (d) {
+ if (d.Id) {
+ var reqBody = config.HostConfig || {};
+ reqBody.id = d.Id;
+ ctor.start(reqBody, function (cd) {
+ if (cd.id) {
+ ViewSpinner.stop();
+ Messages.send('Container Started', d.Id);
+ $state.go('container', {id: d.Id}, {reload: true});
+ } else {
+ ViewSpinner.stop();
+ failedRequestHandler(cd, Messages);
+ ctor.remove({id: d.Id}, function () {
+ Messages.send('Container Removed', d.Id);
});
+ }
+ }, function (e) {
+ ViewSpinner.stop();
+ failedRequestHandler(e, Messages);
+ });
+ } else {
+ ViewSpinner.stop();
+ failedRequestHandler(d, Messages);
+ }
+ }, function (e) {
+ ViewSpinner.stop();
+ failedRequestHandler(e, Messages);
+ });
+ };
- $scope.config = {
- Env: [],
- Labels: [],
- Volumes: [],
- SecurityOpts: [],
- HostConfig: {
- PortBindings: [],
- Binds: [],
- Links: [],
- Dns: [],
- DnsSearch: [],
- VolumesFrom: [],
- CapAdd: [],
- CapDrop: [],
- Devices: [],
- LxcConf: [],
- ExtraHosts: []
- }
- };
-
- $scope.menuStatus = {
- containerOpen: true,
- hostConfigOpen: false
- };
-
- function failedRequestHandler(e, Messages) {
- Messages.error('Error', errorMsgFilter(e));
- }
-
- function rmEmptyKeys(col) {
- for (var key in col) {
- if (col[key] === null || col[key] === undefined || col[key] === '' || ($.isPlainObject(col[key]) && $.isEmptyObject(col[key])) || col[key].length === 0) {
- delete col[key];
- }
- }
- }
-
- function getNames(arr) {
- return arr.map(function (item) {
- return item.name;
- });
- }
-
- $scope.create = function () {
- // Copy the config before transforming fields to the remote API format
- var config = angular.copy($scope.config);
-
- config.Image = $routeParams.id;
-
- if (config.Cmd && config.Cmd[0] === "[") {
- config.Cmd = angular.fromJson(config.Cmd);
- } else if (config.Cmd) {
- config.Cmd = config.Cmd.split(' ');
- }
-
- config.Env = config.Env.map(function (envar) {
- return envar.name + '=' + envar.value;
- });
- var labels = {};
- config.Labels = config.Labels.forEach(function(label) {
- labels[label.key] = label.value;
- });
- config.Labels = labels;
-
- config.Volumes = getNames(config.Volumes);
- config.SecurityOpts = getNames(config.SecurityOpts);
-
- config.HostConfig.VolumesFrom = getNames(config.HostConfig.VolumesFrom);
- config.HostConfig.Binds = getNames(config.HostConfig.Binds);
- config.HostConfig.Links = getNames(config.HostConfig.Links);
- config.HostConfig.Dns = getNames(config.HostConfig.Dns);
- config.HostConfig.DnsSearch = getNames(config.HostConfig.DnsSearch);
- config.HostConfig.CapAdd = getNames(config.HostConfig.CapAdd);
- config.HostConfig.CapDrop = getNames(config.HostConfig.CapDrop);
- config.HostConfig.LxcConf = config.HostConfig.LxcConf.reduce(function (prev, cur, idx) {
- prev[cur.name] = cur.value;
- return prev;
- }, {});
- config.HostConfig.ExtraHosts = config.HostConfig.ExtraHosts.map(function (entry) {
- return entry.host + ':' + entry.ip;
- });
-
- var ExposedPorts = {};
- var PortBindings = {};
- config.HostConfig.PortBindings.forEach(function (portBinding) {
- var intPort = portBinding.intPort + "/tcp";
- if (portBinding.protocol === "udp") {
- intPort = portBinding.intPort + "/udp";
- }
- var binding = {
- HostIp: portBinding.ip,
- HostPort: portBinding.extPort
- };
- if (portBinding.intPort) {
- ExposedPorts[intPort] = {};
- if (intPort in PortBindings) {
- PortBindings[intPort].push(binding);
- } else {
- PortBindings[intPort] = [binding];
- }
- } else {
- Messages.send('Warning', 'Internal port must be specified for PortBindings');
- }
- });
- config.ExposedPorts = ExposedPorts;
- config.HostConfig.PortBindings = PortBindings;
-
- // Remove empty fields from the request to avoid overriding defaults
- rmEmptyKeys(config.HostConfig);
- rmEmptyKeys(config);
-
- var ctor = Container;
- var loc = $location;
- var s = $scope;
- Container.create(config, function (d) {
- if (d.Id) {
- var reqBody = config.HostConfig || {};
- reqBody.id = d.Id;
- ctor.start(reqBody, function (cd) {
- if (cd.id) {
- Messages.send('Container Started', d.Id);
- $('#create-modal').modal('hide');
- loc.path('/containers/' + d.Id + '/');
- } else {
- failedRequestHandler(cd, Messages);
- ctor.remove({id: d.Id}, function () {
- Messages.send('Container Removed', d.Id);
- });
- }
- }, function (e) {
- failedRequestHandler(e, Messages);
- });
- } else {
- failedRequestHandler(d, Messages);
- }
- }, function (e) {
- failedRequestHandler(e, Messages);
- });
- };
-
- $scope.addEntry = function (array, entry) {
- array.push(entry);
- };
- $scope.rmEntry = function (array, entry) {
- var idx = array.indexOf(entry);
- array.splice(idx, 1);
- };
- }]);
+ $scope.addEntry = function (array, entry) {
+ array.push(entry);
+ };
+ $scope.rmEntry = function (array, entry) {
+ var idx = array.indexOf(entry);
+ array.splice(idx, 1);
+ };
+}]);
diff --git a/app/components/startContainer/startcontainer.html b/app/components/startContainer/startcontainer.html
index 26b3f1767..9891c9e58 100644
--- a/app/components/startContainer/startcontainer.html
+++ b/app/components/startContainer/startcontainer.html
@@ -3,7 +3,7 @@
@@ -137,16 +141,15 @@
placeholder="value"/>
-
Add environment
- variable
-
+
+
+
Labels:
@@ -164,15 +167,15 @@
placeholder="value"/>