diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js index 910e624c..c05b6165 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js @@ -50,7 +50,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -59,15 +59,15 @@ ////////////// - function initScope($scope) { + function initAction() { + } + + function perform(selected, $scope) { scope = $scope; scope.workflow = createWorkflow; scope.model = model; scope.$on('$destroy', function() { }); - } - - function perform() { scope.model.init(); return wizardModalService.modal({ scope: scope, diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.spec.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.spec.js index c0e52773..a17c1eb9 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.spec.js @@ -56,8 +56,8 @@ it('open the modal and should destroy event watchers', function() { spyOn(wizardModalService, 'modal').and.callThrough(); - service.initScope($scope); - service.perform(); + service.initAction(); + service.perform(null, $scope); $scope.$emit('$destroy'); @@ -74,8 +74,8 @@ spyOn(wizardModalService, 'modal').and.callThrough(); - service.initScope($scope); - service.perform(); + service.initAction(); + service.perform(null, $scope); var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); $timeout.flush(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js index c24bfae8..cbd03d80 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js @@ -64,7 +64,7 @@ successEvent: events.DELETE_SUCCESS }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -76,8 +76,7 @@ // include this function in your service // if you plan to emit events to the parent controller - function initScope($scope) { - scope = $scope; + function initAction() { } function allowed() { @@ -85,7 +84,8 @@ } // delete selected resource objects - function perform(selected) { + function perform(selected, $scope) { + scope = $scope; selected = angular.isArray(selected) ? selected : [selected]; context.labels = labelize(selected.length); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.spec.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.spec.js index e220c8e9..04461aeb 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.spec.js @@ -90,7 +90,7 @@ beforeEach(function() { spyOn(deleteModalService, 'open').and.callThrough(); - service.initScope($scope, labelize); + service.initAction(labelize); }); function labelize(count) { @@ -117,7 +117,7 @@ function testDoubleObject() { var templates = generateTemplate(2); - service.perform(templates); + service.perform(templates, $scope); $scope.$apply(); expect(deleteModalService.open).toHaveBeenCalled(); @@ -129,7 +129,7 @@ spyOn(magnumAPI, 'deleteEntity'); var templates = generateTemplate(1); var template = templates[0]; - service.perform(templates); + service.perform(templates, $scope); $scope.$apply(); var contextArg = deleteModalService.open.calls.argsFor(0)[2]; diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.js b/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.js index 54352406..92c9bc6a 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.js @@ -49,7 +49,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -58,15 +58,15 @@ ////////////// - function initScope($scope) { + function initAction() { + } + + function perform(selected, $scope) { scope = $scope; scope.workflow = createWorkflow; scope.model = model; scope.$on('$destroy', function() { }); - } - - function perform(selected) { scope.model.init(); scope.selected = selected; return wizardModalService.modal({ diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.spec.js index e19eb541..973408fa 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/create.service.spec.js @@ -56,8 +56,8 @@ it('open the modal and should destroy event watchers', function() { spyOn(wizardModalService, 'modal').and.callThrough(); - service.initScope($scope); - service.perform(); + service.initAction(); + service.perform(null, $scope); $scope.$emit('$destroy'); @@ -74,8 +74,8 @@ spyOn(wizardModalService, 'modal').and.callThrough(); - service.initScope($scope); - service.perform(); + service.initAction(); + service.perform(null, $scope); var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); $timeout.flush(); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.js b/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.js index 5a3e883c..e108ae2d 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.js @@ -64,7 +64,7 @@ successEvent: events.DELETE_SUCCESS }; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -76,8 +76,7 @@ // include this function in your service // if you plan to emit events to the parent controller - function initScope($scope) { - scope = $scope; + function initAction() { } function allowed() { @@ -85,7 +84,8 @@ } // delete selected resource objects - function perform(selected) { + function perform(selected, $scope) { + scope = $scope; selected = angular.isArray(selected) ? selected : [selected]; context.labels = labelize(selected.length); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.spec.js index ba73b613..b3f3d165 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/delete/delete.service.spec.js @@ -90,7 +90,7 @@ beforeEach(function() { spyOn(deleteModalService, 'open').and.callThrough(); - service.initScope($scope, labelize); + service.initAction(labelize); }); function labelize(count) { @@ -107,7 +107,7 @@ function testSingleObject() { var clusters = generateCluster(1); - service.perform(clusters[0]); + service.perform(clusters[0], $scope); $scope.$apply(); expect(deleteModalService.open).toHaveBeenCalled(); @@ -117,7 +117,7 @@ function testDoubleObject() { var clusters = generateCluster(2); - service.perform(clusters); + service.perform(clusters, $scope); $scope.$apply(); expect(deleteModalService.open).toHaveBeenCalled(); @@ -129,7 +129,7 @@ spyOn(magnumAPI, 'deleteEntity'); var clusters = generateCluster(1); var cluster = clusters[0]; - service.perform(clusters); + service.perform(clusters, $scope); $scope.$apply(); var contextArg = deleteModalService.open.calls.argsFor(0)[2]; diff --git a/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.js b/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.js index 7afb3754..2f11a8a8 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.js @@ -36,7 +36,7 @@ ) { var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -45,7 +45,7 @@ ////////////// - function initScope() { + function initAction() { } function perform(selected) { diff --git a/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.spec.js index 27ea3225..23628a36 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/show-certificate/show-certificate.service.spec.js @@ -45,7 +45,7 @@ selected = { id: '1' }; - service.initScope(); + service.initAction(); service.perform(selected); expect(magnum.showCertificate).toHaveBeenCalled(); }); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.js b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.js index a8cb17e4..ea1905b6 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.js @@ -47,7 +47,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -56,7 +56,7 @@ ////////////// - function initScope() { + function initAction() { } function signCertificateModal(html, $modal) { diff --git a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.spec.js index 1fa0f935..a44505f7 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate.service.spec.js @@ -65,7 +65,7 @@ it('should pass submit() and success()', inject(function($timeout) { var selected = {id : 1}; - service.initScope(); + service.initAction(); service.perform(selected); $timeout.flush();