From a7c787af0274bb6bda57b687cc208fc7ff30e295 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Wed, 5 Jun 2019 11:00:36 -0400 Subject: [PATCH 1/2] Adds notify on start toggle --- .../src/notifications/notifications.list.js | 16 ++++++++++++++-- .../shared/notification-list-init.factory.js | 11 +++++++---- .../shared/toggle-notification.factory.js | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/notifications/notifications.list.js b/awx/ui/client/src/notifications/notifications.list.js index fb781e693b..e3f645a200 100644 --- a/awx/ui/client/src/notifications/notifications.list.js +++ b/awx/ui/client/src/notifications/notifications.list.js @@ -35,6 +35,18 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ excludeModal: true, columnClass: 'd-none d-sm-flex col-md-4 col-sm-3' }, + notification_templates_started: { + label: i18n._("Start"), + flag: 'notification_templates_started', + type: "toggle", + ngClick: "toggleNotification($event, notification.id, \"notification_templates_started\")", + ngDisabled: "!sufficientRoleForNotifToggle", + awToolTip: "{{ schedule.play_tip }}", + dataTipWatch: "schedule.play_tip", + dataPlacement: "right", + nosort: true, + columnClass: 'd-none d-md-flex justify-content-start col-md-1' + }, notification_templates_success: { label: i18n._('Success'), flag: 'notification_templates_success', @@ -45,11 +57,11 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ dataTipWatch: "schedule.play_tip", dataPlacement: "right", nosort: true, - columnClass: 'd-none d-md-flex justify-content-start col-md-2' + columnClass: 'd-none d-md-flex justify-content-start col-md-1' }, notification_templates_error: { label: i18n._('Failure'), - columnClass: 'd-none d-md-flex justify-content-start col-md-2 NotifierList-lastColumn', + columnClass: 'd-none d-md-flex justify-content-start col-md-1 NotifierList-lastColumn', flag: 'notification_templates_error', type: "toggle", ngClick: "toggleNotification($event, notification.id, \"notification_templates_error\")", diff --git a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js index 101519640a..45bbdc7f7e 100644 --- a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js +++ b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js @@ -49,7 +49,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', scope.relatednotificationsRemove(); } scope.relatednotificationsRemove = scope.$on('relatednotifications', function () { - var columns = ['/notification_templates_success/', '/notification_templates_error/']; + var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error']; GetChoices({ scope: scope, @@ -59,12 +59,15 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', callback: 'choicesReadyNotifierList' }); - _.map(columns, function(column){ - var notifier_url = url + id + column; + _.map(columns, function(column){ + var notifier_url = url + id + column; Rest.setUrl(notifier_url); Rest.get() .then(function(response) { - var type = (response.config.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error"; + let checkForSuccessOrError = response.config.url.indexOf('success')>0 ? "notification_templates_success" : "notification_templates_error"; + + let type = response.config.url.indexOf('started')>0? "notification_templates_started" : checkForSuccessOrError + if (response.data.results) { _.forEach(response.data.results, function(result){ _.forEach(scope.notifications, function(notification){ diff --git a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js index 03cb53e260..1cdb593577 100644 --- a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js +++ b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js @@ -21,7 +21,7 @@ export default ['Wait', 'ProcessErrors', 'Rest', notifier = params.notifier, notifier_id = params.notifier.id, callback = params.callback, - column = params.column, // notification_template_success/notification_template__error + column = params.column, // notification_template_success/notification_template__error/notification_template_started url = params.url + "/" + column + '/'; if(!notifier[column]){ @@ -45,7 +45,7 @@ export default ['Wait', 'ProcessErrors', 'Rest', notifier[column] = !notifier[column]; } // Hide the working spinner - Wait('stop'); + Wait('stop'); }) .catch(({data, status}) => { ProcessErrors(scope, data, status, null, { hdr: 'Error!', From b0249a9a8b3cfef59eebcdbacd32683cdcca91bd Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Thu, 20 Jun 2019 14:39:13 -0400 Subject: [PATCH 2/2] Addressed PR Issues --- .../shared/notification-list-init.factory.js | 10 +++++----- .../shared/toggle-notification.factory.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js index 45bbdc7f7e..03027feab9 100644 --- a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js +++ b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js @@ -49,7 +49,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', scope.relatednotificationsRemove(); } scope.relatednotificationsRemove = scope.$on('relatednotifications', function () { - var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error']; + var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error/']; GetChoices({ scope: scope, @@ -59,14 +59,14 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', callback: 'choicesReadyNotifierList' }); - _.map(columns, function(column){ - var notifier_url = url + id + column; + _.map(columns, function(column){ + var notifier_url = url + id + column; Rest.setUrl(notifier_url); Rest.get() .then(function(response) { - let checkForSuccessOrError = response.config.url.indexOf('success')>0 ? "notification_templates_success" : "notification_templates_error"; + let checkForSuccessOrError = response.config.url.indexOf('success') > 0 ? "notification_templates_success" : "notification_templates_error"; - let type = response.config.url.indexOf('started')>0? "notification_templates_started" : checkForSuccessOrError + let type = response.config.url.indexOf('started') > 0 ? "notification_templates_started" : checkForSuccessOrError; if (response.data.results) { _.forEach(response.data.results, function(result){ diff --git a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js index 1cdb593577..7f99e737fb 100644 --- a/awx/ui/client/src/notifications/shared/toggle-notification.factory.js +++ b/awx/ui/client/src/notifications/shared/toggle-notification.factory.js @@ -45,7 +45,7 @@ export default ['Wait', 'ProcessErrors', 'Rest', notifier[column] = !notifier[column]; } // Hide the working spinner - Wait('stop'); + Wait('stop'); }) .catch(({data, status}) => { ProcessErrors(scope, data, status, null, { hdr: 'Error!',