refactor(app): upgrade to the latest version of ui-router (#1219)

* refactor(app): upgrade to the latest version of ui-router

* fix(app): define optional from parameter in action.create.container state

* refactor(app): replace $uiRouterGlobals with $transition$
pull/1221/head
Anthony Lapenna 2017-09-21 16:00:53 +02:00 committed by GitHub
parent 819d0f6a16
commit ff628bb438
25 changed files with 118 additions and 115 deletions

View File

@ -1,6 +1,6 @@
angular.module('auth', []) angular.module('auth', [])
.controller('AuthenticationController', ['$scope', '$state', '$stateParams', '$window', '$timeout', '$sanitize', 'Authentication', 'Users', 'UserService', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications', 'SettingsService', .controller('AuthenticationController', ['$scope', '$state', '$transition$', '$window', '$timeout', '$sanitize', 'Authentication', 'Users', 'UserService', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications', 'SettingsService',
function ($scope, $state, $stateParams, $window, $timeout, $sanitize, Authentication, Users, UserService, EndpointService, StateManager, EndpointProvider, Notifications, SettingsService) { function ($scope, $state, $transition$, $window, $timeout, $sanitize, Authentication, Users, UserService, EndpointService, StateManager, EndpointProvider, Notifications, SettingsService) {
$scope.logo = StateManager.getState().application.logo; $scope.logo = StateManager.getState().application.logo;
@ -88,9 +88,9 @@ function ($scope, $state, $stateParams, $window, $timeout, $sanitize, Authentica
}; };
function initView() { function initView() {
if ($stateParams.logout || $stateParams.error) { if ($transition$.params().logout || $transition$.params().error) {
Authentication.logout(); Authentication.logout();
$scope.state.AuthenticationError = $stateParams.error; $scope.state.AuthenticationError = $transition$.params().error;
return; return;
} }

View File

@ -1,6 +1,6 @@
angular.module('container', []) angular.module('container', [])
.controller('ContainerController', ['$q', '$scope', '$state','$stateParams', '$filter', 'Container', 'ContainerCommit', 'ContainerHelper', 'ContainerService', 'ImageHelper', 'Network', 'NetworkService', 'Notifications', 'Pagination', 'ModalService', 'ResourceControlService', 'RegistryService', 'ImageService', .controller('ContainerController', ['$q', '$scope', '$state','$transition$', '$filter', 'Container', 'ContainerCommit', 'ContainerHelper', 'ContainerService', 'ImageHelper', 'Network', 'NetworkService', 'Notifications', 'Pagination', 'ModalService', 'ResourceControlService', 'RegistryService', 'ImageService',
function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit, ContainerHelper, ContainerService, ImageHelper, Network, NetworkService, Notifications, Pagination, ModalService, ResourceControlService, RegistryService, ImageService) { function ($q, $scope, $state, $transition$, $filter, Container, ContainerCommit, ContainerHelper, ContainerService, ImageHelper, Network, NetworkService, Notifications, Pagination, ModalService, ResourceControlService, RegistryService, ImageService) {
$scope.activityTime = 0; $scope.activityTime = 0;
$scope.portBindings = []; $scope.portBindings = [];
$scope.config = { $scope.config = {
@ -16,7 +16,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
var update = function () { var update = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.get({id: $stateParams.id}, function (d) { Container.get({id: $transition$.params().id}, function (d) {
var container = new ContainerDetailsViewModel(d); var container = new ContainerDetailsViewModel(d);
$scope.container = container; $scope.container = container;
$scope.container.edit = false; $scope.container.edit = false;
@ -52,7 +52,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.start({id: $scope.container.Id}, {}, function (d) { Container.start({id: $scope.container.Id}, {}, function (d) {
update(); update();
Notifications.success('Container started', $stateParams.id); Notifications.success('Container started', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to start container'); Notifications.error('Failure', e, 'Unable to start container');
@ -61,9 +61,9 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.stop = function () { $scope.stop = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.stop({id: $stateParams.id}, function (d) { Container.stop({id: $transition$.params().id}, function (d) {
update(); update();
Notifications.success('Container stopped', $stateParams.id); Notifications.success('Container stopped', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to stop container'); Notifications.error('Failure', e, 'Unable to stop container');
@ -72,9 +72,9 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.kill = function () { $scope.kill = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.kill({id: $stateParams.id}, function (d) { Container.kill({id: $transition$.params().id}, function (d) {
update(); update();
Notifications.success('Container killed', $stateParams.id); Notifications.success('Container killed', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to kill container'); Notifications.error('Failure', e, 'Unable to kill container');
@ -86,10 +86,10 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
var image = $scope.config.Image; var image = $scope.config.Image;
var registry = $scope.config.Registry; var registry = $scope.config.Registry;
var imageConfig = ImageHelper.createImageConfigForCommit(image, registry.URL); var imageConfig = ImageHelper.createImageConfigForCommit(image, registry.URL);
ContainerCommit.commit({id: $stateParams.id, tag: imageConfig.tag, repo: imageConfig.repo}, function (d) { ContainerCommit.commit({id: $transition$.params().id, tag: imageConfig.tag, repo: imageConfig.repo}, function (d) {
$('#createImageSpinner').hide(); $('#createImageSpinner').hide();
update(); update();
Notifications.success('Container commited', $stateParams.id); Notifications.success('Container commited', $transition$.params().id);
}, function (e) { }, function (e) {
$('#createImageSpinner').hide(); $('#createImageSpinner').hide();
update(); update();
@ -99,9 +99,9 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.pause = function () { $scope.pause = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.pause({id: $stateParams.id}, function (d) { Container.pause({id: $transition$.params().id}, function (d) {
update(); update();
Notifications.success('Container paused', $stateParams.id); Notifications.success('Container paused', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to pause container'); Notifications.error('Failure', e, 'Unable to pause container');
@ -110,9 +110,9 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.unpause = function () { $scope.unpause = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.unpause({id: $stateParams.id}, function (d) { Container.unpause({id: $transition$.params().id}, function (d) {
update(); update();
Notifications.success('Container unpaused', $stateParams.id); Notifications.success('Container unpaused', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to unpause container'); Notifications.error('Failure', e, 'Unable to unpause container');
@ -154,9 +154,9 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.restart = function () { $scope.restart = function () {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.restart({id: $stateParams.id}, function (d) { Container.restart({id: $transition$.params().id}, function (d) {
update(); update();
Notifications.success('Container restarted', $stateParams.id); Notifications.success('Container restarted', $transition$.params().id);
}, function (e) { }, function (e) {
update(); update();
Notifications.error('Failure', e, 'Unable to restart container'); Notifications.error('Failure', e, 'Unable to restart container');
@ -165,7 +165,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.renameContainer = function () { $scope.renameContainer = function () {
var container = $scope.container; var container = $scope.container;
Container.rename({id: $stateParams.id, 'name': container.newContainerName}, function (d) { Container.rename({id: $transition$.params().id, 'name': container.newContainerName}, function (d) {
if (d.message) { if (d.message) {
container.newContainerName = container.Name; container.newContainerName = container.Name;
Notifications.error('Unable to rename container', {}, d.message); Notifications.error('Unable to rename container', {}, d.message);
@ -181,14 +181,14 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.containerLeaveNetwork = function containerLeaveNetwork(container, networkId) { $scope.containerLeaveNetwork = function containerLeaveNetwork(container, networkId) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Network.disconnect({id: networkId}, { Container: $stateParams.id, Force: false }, function (d) { Network.disconnect({id: networkId}, { Container: $transition$.params().id, Force: false }, function (d) {
if (container.message) { if (container.message) {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.error('Error', d, 'Unable to disconnect container from network'); Notifications.error('Error', d, 'Unable to disconnect container from network');
} else { } else {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.success('Container left network', $stateParams.id); Notifications.success('Container left network', $transition$.params().id);
$state.go('container', {id: $stateParams.id}, {reload: true}); $state.go('container', {id: $transition$.params().id}, {reload: true});
} }
}, function (e) { }, function (e) {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
@ -199,7 +199,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.duplicate = function() { $scope.duplicate = function() {
ModalService.confirmExperimentalFeature(function (experimental) { ModalService.confirmExperimentalFeature(function (experimental) {
if(!experimental) { return; } if(!experimental) { return; }
$state.go('actions.create.container', {from: $stateParams.id}, {reload: true}); $state.go('actions.create.container', {from: $transition$.params().id}, {reload: true});
}); });
}; };
@ -280,14 +280,14 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerCommit,
$scope.containerJoinNetwork = function containerJoinNetwork(container, networkId) { $scope.containerJoinNetwork = function containerJoinNetwork(container, networkId) {
$('#joinNetworkSpinner').show(); $('#joinNetworkSpinner').show();
Network.connect({id: networkId}, { Container: $stateParams.id }, function (d) { Network.connect({id: networkId}, { Container: $transition$.params().id }, function (d) {
if (container.message) { if (container.message) {
$('#joinNetworkSpinner').hide(); $('#joinNetworkSpinner').hide();
Notifications.error('Error', d, 'Unable to connect container to network'); Notifications.error('Error', d, 'Unable to connect container to network');
} else { } else {
$('#joinNetworkSpinner').hide(); $('#joinNetworkSpinner').hide();
Notifications.success('Container joined network', $stateParams.id); Notifications.success('Container joined network', $transition$.params().id);
$state.go('container', {id: $stateParams.id}, {reload: true}); $state.go('container', {id: $transition$.params().id}, {reload: true});
} }
}, function (e) { }, function (e) {
$('#joinNetworkSpinner').hide(); $('#joinNetworkSpinner').hide();

View File

@ -1,6 +1,6 @@
angular.module('containerConsole', []) angular.module('containerConsole', [])
.controller('ContainerConsoleController', ['$scope', '$stateParams', 'Container', 'Image', 'EndpointProvider', 'Notifications', 'ContainerHelper', 'ContainerService', 'ExecService', .controller('ContainerConsoleController', ['$scope', '$transition$', 'Container', 'Image', 'EndpointProvider', 'Notifications', 'ContainerHelper', 'ContainerService', 'ExecService',
function ($scope, $stateParams, Container, Image, EndpointProvider, Notifications, ContainerHelper, ContainerService, ExecService) { function ($scope, $transition$, Container, Image, EndpointProvider, Notifications, ContainerHelper, ContainerService, ExecService) {
$scope.state = {}; $scope.state = {};
$scope.state.loaded = false; $scope.state.loaded = false;
$scope.state.connected = false; $scope.state.connected = false;
@ -15,7 +15,7 @@ function ($scope, $stateParams, Container, Image, EndpointProvider, Notification
} }
}); });
Container.get({id: $stateParams.id}, function(d) { Container.get({id: $transition$.params().id}, function(d) {
$scope.container = d; $scope.container = d;
if (d.message) { if (d.message) {
Notifications.error('Error', d, 'Unable to retrieve container details'); Notifications.error('Error', d, 'Unable to retrieve container details');
@ -43,7 +43,7 @@ function ($scope, $stateParams, Container, Image, EndpointProvider, Notification
var command = $scope.formValues.isCustomCommand ? var command = $scope.formValues.isCustomCommand ?
$scope.formValues.customCommand : $scope.formValues.command; $scope.formValues.customCommand : $scope.formValues.command;
var execConfig = { var execConfig = {
id: $stateParams.id, id: $transition$.params().id,
AttachStdin: true, AttachStdin: true,
AttachStdout: true, AttachStdout: true,
AttachStderr: true, AttachStderr: true,

View File

@ -1,6 +1,6 @@
angular.module('containerLogs', []) angular.module('containerLogs', [])
.controller('ContainerLogsController', ['$scope', '$stateParams', '$anchorScroll', 'ContainerLogs', 'Container', .controller('ContainerLogsController', ['$scope', '$transition$', '$anchorScroll', 'ContainerLogs', 'Container',
function ($scope, $stateParams, $anchorScroll, ContainerLogs, Container) { function ($scope, $transition$, $anchorScroll, ContainerLogs, Container) {
$scope.state = {}; $scope.state = {};
$scope.state.displayTimestampsOut = false; $scope.state.displayTimestampsOut = false;
$scope.state.displayTimestampsErr = false; $scope.state.displayTimestampsErr = false;
@ -9,7 +9,7 @@ function ($scope, $stateParams, $anchorScroll, ContainerLogs, Container) {
$scope.tailLines = 2000; $scope.tailLines = 2000;
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Container.get({id: $stateParams.id}, function (d) { Container.get({id: $transition$.params().id}, function (d) {
$scope.container = d; $scope.container = d;
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
}, function (e) { }, function (e) {
@ -25,7 +25,7 @@ function ($scope, $stateParams, $anchorScroll, ContainerLogs, Container) {
} }
function getLogsStderr() { function getLogsStderr() {
ContainerLogs.get($stateParams.id, { ContainerLogs.get($transition$.params().id, {
stdout: 0, stdout: 0,
stderr: 1, stderr: 1,
timestamps: $scope.state.displayTimestampsErr, timestamps: $scope.state.displayTimestampsErr,
@ -41,7 +41,7 @@ function ($scope, $stateParams, $anchorScroll, ContainerLogs, Container) {
} }
function getLogsStdout() { function getLogsStdout() {
ContainerLogs.get($stateParams.id, { ContainerLogs.get($transition$.params().id, {
stdout: 1, stdout: 1,
stderr: 0, stderr: 0,
timestamps: $scope.state.displayTimestampsOut, timestamps: $scope.state.displayTimestampsOut,

View File

@ -1,6 +1,6 @@
angular.module('containerStats', []) angular.module('containerStats', [])
.controller('ContainerStatsController', ['$q', '$scope', '$stateParams', '$document', '$interval', 'ContainerService', 'ChartService', 'Notifications', 'Pagination', .controller('ContainerStatsController', ['$q', '$scope', '$transition$', '$document', '$interval', 'ContainerService', 'ChartService', 'Notifications', 'Pagination',
function ($q, $scope, $stateParams, $document, $interval, ContainerService, ChartService, Notifications, Pagination) { function ($q, $scope, $transition$, $document, $interval, ContainerService, ChartService, Notifications, Pagination) {
$scope.state = { $scope.state = {
refreshRate: '5' refreshRate: '5'
@ -79,8 +79,8 @@ function ($q, $scope, $stateParams, $document, $interval, ContainerService, Char
function startChartUpdate(networkChart, cpuChart, memoryChart) { function startChartUpdate(networkChart, cpuChart, memoryChart) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
$q.all({ $q.all({
stats: ContainerService.containerStats($stateParams.id), stats: ContainerService.containerStats($transition$.params().id),
top: ContainerService.containerTop($stateParams.id) top: ContainerService.containerTop($transition$.params().id)
}) })
.then(function success(data) { .then(function success(data) {
var stats = data.stats; var stats = data.stats;
@ -103,8 +103,8 @@ function ($q, $scope, $stateParams, $document, $interval, ContainerService, Char
var refreshRate = $scope.state.refreshRate; var refreshRate = $scope.state.refreshRate;
$scope.repeater = $interval(function() { $scope.repeater = $interval(function() {
$q.all({ $q.all({
stats: ContainerService.containerStats($stateParams.id), stats: ContainerService.containerStats($transition$.params().id),
top: ContainerService.containerTop($stateParams.id) top: ContainerService.containerTop($transition$.params().id)
}) })
.then(function success(data) { .then(function success(data) {
var stats = data.stats; var stats = data.stats;
@ -139,7 +139,7 @@ function ($q, $scope, $stateParams, $document, $interval, ContainerService, Char
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
ContainerService.container($stateParams.id) ContainerService.container($transition$.params().id)
.then(function success(data) { .then(function success(data) {
$scope.container = data; $scope.container = data;
}) })

View File

@ -1,8 +1,8 @@
// @@OLD_SERVICE_CONTROLLER: this service should be rewritten to use services. // @@OLD_SERVICE_CONTROLLER: this service should be rewritten to use services.
// See app/components/templates/templatesController.js as a reference. // See app/components/templates/templatesController.js as a reference.
angular.module('createContainer', []) angular.module('createContainer', [])
.controller('CreateContainerController', ['$q', '$scope', '$state', '$stateParams', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService', .controller('CreateContainerController', ['$q', '$scope', '$state', '$transition$', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService',
function ($q, $scope, $state, $stateParams, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService) { function ($q, $scope, $state, $transition$, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService) {
$scope.formValues = { $scope.formValues = {
alwaysPull: true, alwaysPull: true,
@ -418,7 +418,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerHelper,
function loadFromContainerSpec() { function loadFromContainerSpec() {
// Get container // Get container
Container.get({ id: $stateParams.from }).$promise Container.get({ id: $transition$.params().from }).$promise
.then(function success(d) { .then(function success(d) {
var fromContainer = new ContainerDetailsViewModel(d); var fromContainer = new ContainerDetailsViewModel(d);
if (!fromContainer.ResourceControl) { if (!fromContainer.ResourceControl) {
@ -472,7 +472,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerHelper,
Container.query({}, function (d) { Container.query({}, function (d) {
var containers = d; var containers = d;
$scope.runningContainers = containers; $scope.runningContainers = containers;
if ($stateParams.from !== '') { if ($transition$.params().from !== '') {
loadFromContainerSpec(); loadFromContainerSpec();
} else { } else {
$scope.fromContainer = {}; $scope.fromContainer = {};

View File

@ -1,6 +1,6 @@
angular.module('endpoint', []) angular.module('endpoint', [])
.controller('EndpointController', ['$scope', '$state', '$stateParams', '$filter', 'EndpointService', 'Notifications', .controller('EndpointController', ['$scope', '$state', '$transition$', '$filter', 'EndpointService', 'Notifications',
function ($scope, $state, $stateParams, $filter, EndpointService, Notifications) { function ($scope, $state, $transition$, $filter, EndpointService, Notifications) {
if (!$scope.applicationState.application.endpointManagement) { if (!$scope.applicationState.application.endpointManagement) {
$state.go('endpoints'); $state.go('endpoints');
@ -51,7 +51,7 @@ function ($scope, $state, $stateParams, $filter, EndpointService, Notifications)
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
EndpointService.endpoint($stateParams.id) EndpointService.endpoint($transition$.params().id)
.then(function success(data) { .then(function success(data) {
var endpoint = data; var endpoint = data;
endpoint.URL = $filter('stripprotocol')(endpoint.URL); endpoint.URL = $filter('stripprotocol')(endpoint.URL);

View File

@ -1,14 +1,14 @@
angular.module('endpointAccess', []) angular.module('endpointAccess', [])
.controller('EndpointAccessController', ['$scope', '$stateParams', 'EndpointService', 'Notifications', .controller('EndpointAccessController', ['$scope', '$transition$', 'EndpointService', 'Notifications',
function ($scope, $stateParams, EndpointService, Notifications) { function ($scope, $transition$, EndpointService, Notifications) {
$scope.updateAccess = function(authorizedUsers, authorizedTeams) { $scope.updateAccess = function(authorizedUsers, authorizedTeams) {
return EndpointService.updateAccess($stateParams.id, authorizedUsers, authorizedTeams); return EndpointService.updateAccess($transition$.params().id, authorizedUsers, authorizedTeams);
}; };
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
EndpointService.endpoint($stateParams.id) EndpointService.endpoint($transition$.params().id)
.then(function success(data) { .then(function success(data) {
$scope.endpoint = data; $scope.endpoint = data;
}) })

View File

@ -1,6 +1,6 @@
angular.module('image', []) angular.module('image', [])
.controller('ImageController', ['$q', '$scope', '$stateParams', '$state', '$timeout', 'ImageService', 'RegistryService', 'Notifications', .controller('ImageController', ['$q', '$scope', '$transition$', '$state', '$timeout', 'ImageService', 'RegistryService', 'Notifications',
function ($q, $scope, $stateParams, $state, $timeout, ImageService, RegistryService, Notifications) { function ($q, $scope, $transition$, $state, $timeout, ImageService, RegistryService, Notifications) {
$scope.formValues = { $scope.formValues = {
Image: '', Image: '',
Registry: '' Registry: ''
@ -25,10 +25,10 @@ function ($q, $scope, $stateParams, $state, $timeout, ImageService, RegistryServ
var image = $scope.formValues.Image; var image = $scope.formValues.Image;
var registry = $scope.formValues.Registry; var registry = $scope.formValues.Registry;
ImageService.tagImage($stateParams.id, image, registry.URL) ImageService.tagImage($transition$.params().id, image, registry.URL)
.then(function success(data) { .then(function success(data) {
Notifications.success('Image successfully tagged'); Notifications.success('Image successfully tagged');
$state.go('image', {id: $stateParams.id}, {reload: true}); $state.go('image', {id: $transition$.params().id}, {reload: true});
}) })
.catch(function error(err) { .catch(function error(err) {
Notifications.error('Failure', err, 'Unable to tag image'); Notifications.error('Failure', err, 'Unable to tag image');
@ -83,7 +83,7 @@ function ($q, $scope, $stateParams, $state, $timeout, ImageService, RegistryServ
$state.go('images', {}, {reload: true}); $state.go('images', {}, {reload: true});
} else { } else {
Notifications.success('Tag successfully deleted', repository); Notifications.success('Tag successfully deleted', repository);
$state.go('image', {id: $stateParams.id}, {reload: true}); $state.go('image', {id: $transition$.params().id}, {reload: true});
} }
}) })
.catch(function error(err) { .catch(function error(err) {
@ -113,8 +113,8 @@ function ($q, $scope, $stateParams, $state, $timeout, ImageService, RegistryServ
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
var endpointProvider = $scope.applicationState.endpoint.mode.provider; var endpointProvider = $scope.applicationState.endpoint.mode.provider;
$q.all({ $q.all({
image: ImageService.image($stateParams.id), image: ImageService.image($transition$.params().id),
history: endpointProvider !== 'VMWARE_VIC' ? ImageService.history($stateParams.id) : [] history: endpointProvider !== 'VMWARE_VIC' ? ImageService.history($transition$.params().id) : []
}) })
.then(function success(data) { .then(function success(data) {
$scope.image = data.image; $scope.image = data.image;

View File

@ -1,16 +1,16 @@
angular.module('network', []) angular.module('network', [])
.controller('NetworkController', ['$scope', '$state', '$stateParams', '$filter', 'Network', 'NetworkService', 'Container', 'ContainerHelper', 'Notifications', .controller('NetworkController', ['$scope', '$state', '$transition$', '$filter', 'Network', 'NetworkService', 'Container', 'ContainerHelper', 'Notifications',
function ($scope, $state, $stateParams, $filter, Network, NetworkService, Container, ContainerHelper, Notifications) { function ($scope, $state, $transition$, $filter, Network, NetworkService, Container, ContainerHelper, Notifications) {
$scope.removeNetwork = function removeNetwork(networkId) { $scope.removeNetwork = function removeNetwork(networkId) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Network.remove({id: $stateParams.id}, function (d) { Network.remove({id: $transition$.params().id}, function (d) {
if (d.message) { if (d.message) {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.error('Error', d, 'Unable to remove network'); Notifications.error('Error', d, 'Unable to remove network');
} else { } else {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.success('Network removed', $stateParams.id); Notifications.success('Network removed', $transition$.params().id);
$state.go('networks', {}); $state.go('networks', {});
} }
}, function (e) { }, function (e) {
@ -21,13 +21,13 @@ function ($scope, $state, $stateParams, $filter, Network, NetworkService, Contai
$scope.containerLeaveNetwork = function containerLeaveNetwork(network, containerId) { $scope.containerLeaveNetwork = function containerLeaveNetwork(network, containerId) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Network.disconnect({id: $stateParams.id}, { Container: containerId, Force: false }, function (d) { Network.disconnect({id: $transition$.params().id}, { Container: containerId, Force: false }, function (d) {
if (d.message) { if (d.message) {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.error('Error', d, 'Unable to disconnect container from network'); Notifications.error('Error', d, 'Unable to disconnect container from network');
} else { } else {
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
Notifications.success('Container left network', $stateParams.id); Notifications.success('Container left network', $transition$.params().id);
$state.go('network', {id: network.Id}, {reload: true}); $state.go('network', {id: network.Id}, {reload: true});
} }
}, function (e) { }, function (e) {
@ -68,7 +68,7 @@ function ($scope, $state, $stateParams, $filter, Network, NetworkService, Contai
}); });
} else { } else {
Container.query({ Container.query({
filters: {network: [$stateParams.id]} filters: {network: [$transition$.params().id]}
}, function success(data) { }, function success(data) {
filterContainersInNetwork(network, data); filterContainersInNetwork(network, data);
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
@ -82,7 +82,7 @@ function ($scope, $state, $stateParams, $filter, Network, NetworkService, Contai
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
NetworkService.network($stateParams.id) NetworkService.network($transition$.params().id)
.then(function success(data) { .then(function success(data) {
$scope.network = data; $scope.network = data;
var endpointProvider = $scope.applicationState.endpoint.mode.provider; var endpointProvider = $scope.applicationState.endpoint.mode.provider;

View File

@ -1,8 +1,8 @@
// @@OLD_SERVICE_CONTROLLER: this service should be rewritten to use services. // @@OLD_SERVICE_CONTROLLER: this service should be rewritten to use services.
// See app/components/templates/templatesController.js as a reference. // See app/components/templates/templatesController.js as a reference.
angular.module('node', []) angular.module('node', [])
.controller('NodeController', ['$scope', '$state', '$stateParams', 'LabelHelper', 'Node', 'NodeHelper', 'Task', 'Pagination', 'Notifications', .controller('NodeController', ['$scope', '$state', '$transition$', 'LabelHelper', 'Node', 'NodeHelper', 'Task', 'Pagination', 'Notifications',
function ($scope, $state, $stateParams, LabelHelper, Node, NodeHelper, Task, Pagination, Notifications) { function ($scope, $state, $transition$, LabelHelper, Node, NodeHelper, Task, Pagination, Notifications) {
$scope.state = {}; $scope.state = {};
$scope.state.pagination_count = Pagination.getPaginationCount('node_tasks'); $scope.state.pagination_count = Pagination.getPaginationCount('node_tasks');
@ -80,7 +80,7 @@ function ($scope, $state, $stateParams, LabelHelper, Node, NodeHelper, Task, Pag
function loadNodeAndTasks() { function loadNodeAndTasks() {
$scope.loading = true; $scope.loading = true;
if ($scope.applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE') { if ($scope.applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE') {
Node.get({ id: $stateParams.id}, function(d) { Node.get({ id: $transition$.params().id}, function(d) {
if (d.message) { if (d.message) {
Notifications.error('Failure', e, 'Unable to inspect the node'); Notifications.error('Failure', e, 'Unable to inspect the node');
} else { } else {

View File

@ -1,6 +1,6 @@
angular.module('registry', []) angular.module('registry', [])
.controller('RegistryController', ['$scope', '$state', '$stateParams', '$filter', 'RegistryService', 'Notifications', .controller('RegistryController', ['$scope', '$state', '$transition$', '$filter', 'RegistryService', 'Notifications',
function ($scope, $state, $stateParams, $filter, RegistryService, Notifications) { function ($scope, $state, $transition$, $filter, RegistryService, Notifications) {
$scope.updateRegistry = function() { $scope.updateRegistry = function() {
$('#updateRegistrySpinner').show(); $('#updateRegistrySpinner').show();
@ -20,7 +20,7 @@ function ($scope, $state, $stateParams, $filter, RegistryService, Notifications)
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
var registryID = $stateParams.id; var registryID = $transition$.params().id;
RegistryService.registry(registryID) RegistryService.registry(registryID)
.then(function success(data) { .then(function success(data) {
$scope.registry = data; $scope.registry = data;

View File

@ -1,14 +1,14 @@
angular.module('registryAccess', []) angular.module('registryAccess', [])
.controller('RegistryAccessController', ['$scope', '$stateParams', 'RegistryService', 'Notifications', .controller('RegistryAccessController', ['$scope', '$transition$', 'RegistryService', 'Notifications',
function ($scope, $stateParams, RegistryService, Notifications) { function ($scope, $transition$, RegistryService, Notifications) {
$scope.updateAccess = function(authorizedUsers, authorizedTeams) { $scope.updateAccess = function(authorizedUsers, authorizedTeams) {
return RegistryService.updateAccess($stateParams.id, authorizedUsers, authorizedTeams); return RegistryService.updateAccess($transition$.params().id, authorizedUsers, authorizedTeams);
}; };
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
RegistryService.registry($stateParams.id) RegistryService.registry($transition$.params().id)
.then(function success(data) { .then(function success(data) {
$scope.registry = data; $scope.registry = data;
}) })

View File

@ -1,6 +1,6 @@
angular.module('secret', []) angular.module('secret', [])
.controller('SecretController', ['$scope', '$stateParams', '$state', 'SecretService', 'Notifications', .controller('SecretController', ['$scope', '$transition$', '$state', 'SecretService', 'Notifications',
function ($scope, $stateParams, $state, SecretService, Notifications) { function ($scope, $transition$, $state, SecretService, Notifications) {
$scope.removeSecret = function removeSecret(secretId) { $scope.removeSecret = function removeSecret(secretId) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
@ -19,7 +19,7 @@ function ($scope, $stateParams, $state, SecretService, Notifications) {
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
SecretService.secret($stateParams.id) SecretService.secret($transition$.params().id)
.then(function success(data) { .then(function success(data) {
$scope.secret = data; $scope.secret = data;
}) })

View File

@ -1,6 +1,6 @@
angular.module('secrets', []) angular.module('secrets', [])
.controller('SecretsController', ['$scope', '$stateParams', '$state', 'SecretService', 'Notifications', 'Pagination', .controller('SecretsController', ['$scope', '$transition$', '$state', 'SecretService', 'Notifications', 'Pagination',
function ($scope, $stateParams, $state, SecretService, Notifications, Pagination) { function ($scope, $transition$, $state, SecretService, Notifications, Pagination) {
$scope.state = {}; $scope.state = {};
$scope.state.selectedItemCount = 0; $scope.state.selectedItemCount = 0;
$scope.state.pagination_count = Pagination.getPaginationCount('secrets'); $scope.state.pagination_count = Pagination.getPaginationCount('secrets');

View File

@ -1,6 +1,6 @@
angular.module('service', []) angular.module('service', [])
.controller('ServiceController', ['$q', '$scope', '$stateParams', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'SecretService', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService', .controller('ServiceController', ['$q', '$scope', '$transition$', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'SecretService', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService',
function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll, ServiceService, SecretService, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) { function ($q, $scope, $transition$, $state, $location, $timeout, $anchorScroll, ServiceService, SecretService, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) {
$scope.state = {}; $scope.state = {};
$scope.state.pagination_count = Pagination.getPaginationCount('service_tasks'); $scope.state.pagination_count = Pagination.getPaginationCount('service_tasks');
@ -307,7 +307,7 @@ function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll,
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
var apiVersion = $scope.applicationState.endpoint.apiVersion; var apiVersion = $scope.applicationState.endpoint.apiVersion;
ServiceService.service($stateParams.id) ServiceService.service($transition$.params().id)
.then(function success(data) { .then(function success(data) {
var service = data; var service = data;
$scope.isUpdating = $scope.lastVersion >= service.Version; $scope.isUpdating = $scope.lastVersion >= service.Version;

View File

@ -1,6 +1,6 @@
angular.module('serviceLogs', []) angular.module('serviceLogs', [])
.controller('ServiceLogsController', ['$scope', '$stateParams', '$anchorScroll', 'ServiceLogs', 'Service', .controller('ServiceLogsController', ['$scope', '$transition$', '$anchorScroll', 'ServiceLogs', 'Service',
function ($scope, $stateParams, $anchorScroll, ServiceLogs, Service) { function ($scope, $transition$, $anchorScroll, ServiceLogs, Service) {
$scope.state = {}; $scope.state = {};
$scope.state.displayTimestampsOut = false; $scope.state.displayTimestampsOut = false;
$scope.state.displayTimestampsErr = false; $scope.state.displayTimestampsErr = false;
@ -16,7 +16,7 @@ function ($scope, $stateParams, $anchorScroll, ServiceLogs, Service) {
} }
function getLogsStderr() { function getLogsStderr() {
ServiceLogs.get($stateParams.id, { ServiceLogs.get($transition$.params().id, {
stdout: 0, stdout: 0,
stderr: 1, stderr: 1,
timestamps: $scope.state.displayTimestampsErr, timestamps: $scope.state.displayTimestampsErr,
@ -32,7 +32,7 @@ function ($scope, $stateParams, $anchorScroll, ServiceLogs, Service) {
} }
function getLogsStdout() { function getLogsStdout() {
ServiceLogs.get($stateParams.id, { ServiceLogs.get($transition$.params().id, {
stdout: 1, stdout: 1,
stderr: 0, stderr: 0,
timestamps: $scope.state.displayTimestampsOut, timestamps: $scope.state.displayTimestampsOut,
@ -49,7 +49,7 @@ function ($scope, $stateParams, $anchorScroll, ServiceLogs, Service) {
function getService() { function getService() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Service.get({id: $stateParams.id}, function (d) { Service.get({id: $transition$.params().id}, function (d) {
$scope.service = d; $scope.service = d;
$('#loadingViewSpinner').hide(); $('#loadingViewSpinner').hide();
}, function (e) { }, function (e) {

View File

@ -1,6 +1,6 @@
angular.module('services', []) angular.module('services', [])
.controller('ServicesController', ['$q', '$scope', '$stateParams', '$state', 'Service', 'ServiceService', 'ServiceHelper', 'Notifications', 'Pagination', 'Task', 'Node', 'NodeHelper', 'ModalService', 'ResourceControlService', .controller('ServicesController', ['$q', '$scope', '$transition$', '$state', 'Service', 'ServiceService', 'ServiceHelper', 'Notifications', 'Pagination', 'Task', 'Node', 'NodeHelper', 'ModalService', 'ResourceControlService',
function ($q, $scope, $stateParams, $state, Service, ServiceService, ServiceHelper, Notifications, Pagination, Task, Node, NodeHelper, ModalService, ResourceControlService) { function ($q, $scope, $transition$, $state, Service, ServiceService, ServiceHelper, Notifications, Pagination, Task, Node, NodeHelper, ModalService, ResourceControlService) {
$scope.state = {}; $scope.state = {};
$scope.state.selectedItemCount = 0; $scope.state.selectedItemCount = 0;
$scope.state.pagination_count = Pagination.getPaginationCount('services'); $scope.state.pagination_count = Pagination.getPaginationCount('services');

View File

@ -1,10 +1,10 @@
angular.module('task', []) angular.module('task', [])
.controller('TaskController', ['$scope', '$stateParams', 'TaskService', 'Service', 'Notifications', .controller('TaskController', ['$scope', '$transition$', 'TaskService', 'Service', 'Notifications',
function ($scope, $stateParams, TaskService, Service, Notifications) { function ($scope, $transition$, TaskService, Service, Notifications) {
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
TaskService.task($stateParams.id) TaskService.task($transition$.params().id)
.then(function success(data) { .then(function success(data) {
var task = data; var task = data;
$scope.task = task; $scope.task = task;

View File

@ -1,6 +1,6 @@
angular.module('team', []) angular.module('team', [])
.controller('TeamController', ['$q', '$scope', '$state', '$stateParams', 'TeamService', 'UserService', 'TeamMembershipService', 'ModalService', 'Notifications', 'Pagination', 'Authentication', .controller('TeamController', ['$q', '$scope', '$state', '$transition$', 'TeamService', 'UserService', 'TeamMembershipService', 'ModalService', 'Notifications', 'Pagination', 'Authentication',
function ($q, $scope, $state, $stateParams, TeamService, UserService, TeamMembershipService, ModalService, Notifications, Pagination, Authentication) { function ($q, $scope, $state, $transition$, TeamService, UserService, TeamMembershipService, ModalService, Notifications, Pagination, Authentication) {
$scope.state = { $scope.state = {
pagination_count_users: Pagination.getPaginationCount('team_available_users'), pagination_count_users: Pagination.getPaginationCount('team_available_users'),
@ -208,9 +208,9 @@ function ($q, $scope, $state, $stateParams, TeamService, UserService, TeamMember
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
$scope.isAdmin = Authentication.getUserDetails().role === 1 ? true: false; $scope.isAdmin = Authentication.getUserDetails().role === 1 ? true: false;
$q.all({ $q.all({
team: TeamService.team($stateParams.id), team: TeamService.team($transition$.params().id),
users: UserService.users(false), users: UserService.users(false),
memberships: TeamService.userMemberships($stateParams.id) memberships: TeamService.userMemberships($transition$.params().id)
}) })
.then(function success(data) { .then(function success(data) {
var users = data.users; var users = data.users;

View File

@ -1,10 +1,10 @@
angular.module('templates', []) angular.module('templates', [])
.controller('TemplatesController', ['$scope', '$q', '$state', '$stateParams', '$anchorScroll', '$filter', 'ContainerService', 'ContainerHelper', 'ImageService', 'NetworkService', 'TemplateService', 'TemplateHelper', 'VolumeService', 'Notifications', 'Pagination', 'ResourceControlService', 'Authentication', 'FormValidator', .controller('TemplatesController', ['$scope', '$q', '$state', '$transition$', '$anchorScroll', '$filter', 'ContainerService', 'ContainerHelper', 'ImageService', 'NetworkService', 'TemplateService', 'TemplateHelper', 'VolumeService', 'Notifications', 'Pagination', 'ResourceControlService', 'Authentication', 'FormValidator',
function ($scope, $q, $state, $stateParams, $anchorScroll, $filter, ContainerService, ContainerHelper, ImageService, NetworkService, TemplateService, TemplateHelper, VolumeService, Notifications, Pagination, ResourceControlService, Authentication, FormValidator) { function ($scope, $q, $state, $transition$, $anchorScroll, $filter, ContainerService, ContainerHelper, ImageService, NetworkService, TemplateService, TemplateHelper, VolumeService, Notifications, Pagination, ResourceControlService, Authentication, FormValidator) {
$scope.state = { $scope.state = {
selectedTemplate: null, selectedTemplate: null,
showAdvancedOptions: false, showAdvancedOptions: false,
hideDescriptions: $stateParams.hide_descriptions, hideDescriptions: $transition$.params().hide_descriptions,
formValidationError: '', formValidationError: '',
filters: { filters: {
Categories: '!', Categories: '!',
@ -145,7 +145,7 @@ function ($scope, $q, $state, $stateParams, $anchorScroll, $filter, ContainerSer
} }
function initTemplates() { function initTemplates() {
var templatesKey = $stateParams.key; var templatesKey = $transition$.params().key;
var provider = $scope.applicationState.endpoint.mode.provider; var provider = $scope.applicationState.endpoint.mode.provider;
var apiVersion = $scope.applicationState.endpoint.apiVersion; var apiVersion = $scope.applicationState.endpoint.apiVersion;

View File

@ -1,6 +1,6 @@
angular.module('user', []) angular.module('user', [])
.controller('UserController', ['$q', '$scope', '$state', '$stateParams', 'UserService', 'ModalService', 'Notifications', 'SettingsService', .controller('UserController', ['$q', '$scope', '$state', '$transition$', 'UserService', 'ModalService', 'Notifications', 'SettingsService',
function ($q, $scope, $state, $stateParams, UserService, ModalService, Notifications, SettingsService) { function ($q, $scope, $state, $transition$, UserService, ModalService, Notifications, SettingsService) {
$scope.state = { $scope.state = {
updatePasswordError: '' updatePasswordError: ''
@ -72,7 +72,7 @@ function ($q, $scope, $state, $stateParams, UserService, ModalService, Notificat
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
$q.all({ $q.all({
user: UserService.user($stateParams.id), user: UserService.user($transition$.params().id),
settings: SettingsService.publicSettings() settings: SettingsService.publicSettings()
}) })
.then(function success(data) { .then(function success(data) {

View File

@ -1,12 +1,12 @@
angular.module('volume', []) angular.module('volume', [])
.controller('VolumeController', ['$scope', '$state', '$stateParams', 'VolumeService', 'Notifications', .controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'Notifications',
function ($scope, $state, $stateParams, VolumeService, Notifications) { function ($scope, $state, $transition$, VolumeService, Notifications) {
$scope.removeVolume = function removeVolume() { $scope.removeVolume = function removeVolume() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
VolumeService.remove($scope.volume) VolumeService.remove($scope.volume)
.then(function success(data) { .then(function success(data) {
Notifications.success('Volume successfully removed', $stateParams.id); Notifications.success('Volume successfully removed', $transition$.params().id);
$state.go('volumes', {}); $state.go('volumes', {});
}) })
.catch(function error(err) { .catch(function error(err) {
@ -19,7 +19,7 @@ function ($scope, $state, $stateParams, VolumeService, Notifications) {
function initView() { function initView() {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
VolumeService.volume($stateParams.id) VolumeService.volume($transition$.params().id)
.then(function success(data) { .then(function success(data) {
var volume = data; var volume = data;
$scope.volume = volume; $scope.volume = volume;

View File

@ -154,6 +154,9 @@ function configureRoutes($stateProvider) {
templateUrl: 'app/components/sidebar/sidebar.html', templateUrl: 'app/components/sidebar/sidebar.html',
controller: 'SidebarController' controller: 'SidebarController'
} }
},
params: {
from: ''
} }
}) })
.state('actions.create.network', { .state('actions.create.network', {

View File

@ -27,7 +27,6 @@
"angular": "~1.5.0", "angular": "~1.5.0",
"angular-cookies": "~1.5.0", "angular-cookies": "~1.5.0",
"angular-bootstrap": "~2.5.0", "angular-bootstrap": "~2.5.0",
"angular-ui-router": "^0.2.15",
"angular-sanitize": "~1.5.0", "angular-sanitize": "~1.5.0",
"angular-mocks": "~1.5.0", "angular-mocks": "~1.5.0",
"angular-resource": "~1.5.0", "angular-resource": "~1.5.0",
@ -50,7 +49,8 @@
"toastr": "~2.1.3", "toastr": "~2.1.3",
"xterm.js": "~2.8.1", "xterm.js": "~2.8.1",
"chart.js": "~2.6.0", "chart.js": "~2.6.0",
"angularjs-slider": "^6.4.0" "angularjs-slider": "^6.4.0",
"angular-ui-router": "~1.0.6"
}, },
"resolutions": { "resolutions": {
"angular": "1.5.11" "angular": "1.5.11"