mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Merge pull request #2397 from jaredevantabor/notifications
Check status of test notifications.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*************************************************
|
/*************************************************
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
*
|
*
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
@@ -150,11 +150,40 @@ export default
|
|||||||
var name = this.notification_template.name;
|
var name = this.notification_template.name;
|
||||||
Rest.setUrl(defaultUrl + this.notification_template.id +'/test/');
|
Rest.setUrl(defaultUrl + this.notification_template.id +'/test/');
|
||||||
Rest.post({})
|
Rest.post({})
|
||||||
.then(function () {
|
.then(function (data) {
|
||||||
ngToast.success({
|
if(data && data.data && data.data.notification){
|
||||||
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification Succeeded.`,
|
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(){
|
||||||
|
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: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification sent.`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(res && res.data && res.data.status && res.data.status === "failed"){
|
||||||
|
ngToast.danger({
|
||||||
|
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> 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 () {
|
.catch(function () {
|
||||||
ngToast.danger({
|
ngToast.danger({
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
color: @default-bg;
|
color: @default-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert-danger{
|
||||||
|
background-color: @default-err;
|
||||||
|
color: @default-bg;
|
||||||
|
}
|
||||||
|
|
||||||
.Toast-successIcon{
|
.Toast-successIcon{
|
||||||
font-size: x-large;
|
font-size: x-large;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|||||||
Reference in New Issue
Block a user