From 80815305c5c14022eaa59990a116f590b61849b1 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 14 Jun 2016 00:00:41 -0700 Subject: [PATCH 1/2] Check status of test notifications. The response from the PUT call to the notifications_templates//test endpoint contains an ID to be used to perform a lookup off of the notifications endpoint in order to obtain the status. --- .../list.controller.js | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index 0167b32d3f..ec6574afb7 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -1,4 +1,4 @@ -/************************************************* + /************************************************* * Copyright (c) 2015 Ansible, Inc. * * All Rights Reserved @@ -150,11 +150,33 @@ export default var name = this.notification_template.name; Rest.setUrl(defaultUrl + this.notification_template.id +'/test/'); Rest.post({}) - .then(function () { - ngToast.success({ - content: ` ${name}: Notification Succeeded.`, - }); + .then(function (data) { + if(data && data.data && data.data.notification){ + Wait('start'); + setTimeout(function(){ + console.log('in set timeout'); + var id = data.data.notification, + url = GetBasePath('notifications') + id; + Rest.setUrl(url); + Rest.get() + .then(function (res) { + Wait('stop'); + if(res && res.data && res.data.status && res.data.status === "successful"){ + ngToast.success({ + content: ` ${name}: Notification Succeeded.`, + dismissOnTimeout: false + }); + } + else if(res && res.data && res.data.status && res.data.status === "failed"){ + ngToast.danger({ + content: ` ${name}: Notification Failed.`, + dismissOnTimeout: false + }); + } + }); + } , 5000); + } }) .catch(function () { ngToast.danger({ From 4d7bc6e1011ad35376a828bb872fc651f189f244 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 14 Jun 2016 10:05:11 -0700 Subject: [PATCH 2/2] Changing wording and styling of notification toaster message and adding some better error handling for failed notifications. --- .../list.controller.js | 19 +++++++++++++------ .../notifications/notifications.block.less | 5 +++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index ec6574afb7..c62050cdb4 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -153,8 +153,10 @@ export default .then(function (data) { if(data && data.data && data.data.notification){ Wait('start'); + // Using a setTimeout here to wait for the + // notification to be processed and for a status + // to be returned from the API. setTimeout(function(){ - console.log('in set timeout'); var id = data.data.notification, url = GetBasePath('notifications') + id; Rest.setUrl(url); @@ -163,19 +165,24 @@ export default Wait('stop'); if(res && res.data && res.data.status && res.data.status === "successful"){ ngToast.success({ - content: ` ${name}: Notification Succeeded.`, - dismissOnTimeout: false + content: ` ${name}: Notification sent.` }); } else if(res && res.data && res.data.status && res.data.status === "failed"){ ngToast.danger({ - content: ` ${name}: Notification Failed.`, - dismissOnTimeout: false + content: ` ${name}: Notification failed.` }); } + else { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + url + ' failed. Notification returned status: ' + status }); + } }); } , 5000); - + } + else { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Call to notifcatin templates failed. Notification returned status: ' + status }); } }) .catch(function () { diff --git a/awx/ui/client/src/notifications/notifications.block.less b/awx/ui/client/src/notifications/notifications.block.less index d3ebf96651..eb767b5230 100644 --- a/awx/ui/client/src/notifications/notifications.block.less +++ b/awx/ui/client/src/notifications/notifications.block.less @@ -13,6 +13,11 @@ color: @default-bg; } +.alert-danger{ + background-color: @default-err; + color: @default-bg; +} + .Toast-successIcon{ font-size: x-large; vertical-align: middle;