diff --git a/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js b/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js index d7e4a46..accde35 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js @@ -57,7 +57,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -66,16 +66,7 @@ ////////////// - // we define initScope so that the table controller - // will know when a new queue has been created - function initScope($scope) { - scope = $scope; - var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange); - var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange); - $scope.$on('$destroy', function destroy() { - queueWatcher(); - metadataWatcher(); - }); + function initAction() { } function onDetailChange(e, queue) { @@ -88,7 +79,15 @@ e.stopPropagation(); } - function perform() { + function perform(selected, $scope) { + scope = $scope; + var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange); + var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange); + $scope.$on('$destroy', function destroy() { + queueWatcher(); + metadataWatcher(); + }); + wizard.modal({ scope: scope, workflow: createQueueWorkflow, diff --git a/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js b/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js index e1de220..a10f120 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js @@ -58,7 +58,7 @@ var model = null; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -67,14 +67,7 @@ ////////////// - // we define initScope so that the table controller - // will know when a new subscription has been created - function initScope($scope) { - scope = $scope; - var subWatcher = $scope.$on(events.SUBSCRIPTION_CHANGED, onSubscriptionChange); - $scope.$on('$destroy', function destroy() { - subWatcher(); - }); + function initAction() { } function onSubscriptionChange(e, subscription) { @@ -82,7 +75,13 @@ e.stopPropagation(); } - function perform(queue) { + function perform(queue, $scope) { + scope = $scope; + var subWatcher = $scope.$on(events.SUBSCRIPTION_CHANGED, onSubscriptionChange); + $scope.$on('$destroy', function destroy() { + subWatcher(); + }); + model = { subscriber: null, ttl: null, options: {} }; model.queueName = queue.name; wizard.modal({ diff --git a/zaqar_ui/static/dashboard/project/queues/actions/delete-queue.service.js b/zaqar_ui/static/dashboard/project/queues/actions/delete-queue.service.js index 0cb0309..02a3aee 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/delete-queue.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/delete-queue.service.js @@ -51,9 +51,9 @@ function deleteQueueService( $q, policy, zaqar, events, gettext, $qExtensions, deleteModal, toast) { - var scope, context; + var context; var service = { - initScope: initScope, + initAction: initAction, allowed: allowed, perform: perform }; @@ -62,16 +62,24 @@ ////////////// - function initScope(newScope) { - scope = newScope; + function initAction() { context = { successEvent: events.DELETE_SUCCESS }; } - function perform(items) { + function perform(items, $scope) { var queues = angular.isArray(items) ? items : [items]; context.labels = labelize(queues.length); context.deleteEntity = deleteQueue; $qExtensions.allSettled(queues.map(checkPermission)).then(afterCheck); + + function afterCheck(result) { + if (result.fail.length > 0) { + toast.add('error', getMessage(result.fail)); + } + if (result.pass.length > 0) { + deleteModal.open($scope, result.pass.map(getEntity), context); + } + } } function allowed() { @@ -86,15 +94,6 @@ return { promise: allowed(queue), context: queue }; } - function afterCheck(result) { - if (result.fail.length > 0) { - toast.add('error', getMessage(result.fail)); - } - if (result.pass.length > 0) { - deleteModal.open(scope, result.pass.map(getEntity), context); - } - } - function getMessage(entities) { var message = gettext("You are not allowed to delete queues: %s"); return interpolate(message, [entities.map(getName).join(", ")]); diff --git a/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js b/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js index c018724..8d8108f 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js @@ -57,7 +57,7 @@ }; var service = { - initScope: initScope, + initAction: initAction, perform: perform, allowed: allowed }; @@ -66,16 +66,7 @@ ////////////// - // we define initScope so that the table controller - // will know when a queue has been updated - function initScope($scope) { - scope = $scope; - var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange); - var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange); - $scope.$on('$destroy', function destroy() { - queueWatcher(); - metadataWatcher(); - }); + function initAction() { } function onDetailChange(e, queue) { @@ -88,12 +79,20 @@ e.stopPropagation(); } - function perform(queue) { + function perform(queue, $scope) { + scope = $scope; + var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange); + var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange); + $scope.$on('$destroy', function destroy() { + queueWatcher(); + metadataWatcher(); + }); + model = queue; - scope.queue = model; + $scope.queue = model; model.queue_name = queue.name; wizard.modal({ - scope: scope, + scope: $scope, workflow: updateQueueWorkflow, submit: submit });