mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 18:37:39 -02:30
Add additional polling if test notification is "pending"
This commit is contained in:
@@ -147,7 +147,9 @@ export default
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.testNotification = function(){
|
scope.testNotification = function(){
|
||||||
var name = $filter('sanitize')(this.notification_template.name);
|
var name = $filter('sanitize')(this.notification_template.name),
|
||||||
|
pending_count = 10;
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + this.notification_template.id +'/test/');
|
Rest.setUrl(defaultUrl + this.notification_template.id +'/test/');
|
||||||
Rest.post({})
|
Rest.post({})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
@@ -156,31 +158,7 @@ export default
|
|||||||
// Using a setTimeout here to wait for the
|
// Using a setTimeout here to wait for the
|
||||||
// notification to be processed and for a status
|
// notification to be processed and for a status
|
||||||
// to be returned from the API.
|
// to be returned from the API.
|
||||||
setTimeout(function(){
|
retrieveStatus(data.data.notification);
|
||||||
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"){
|
|
||||||
scope.search(list.iterator);
|
|
||||||
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"){
|
|
||||||
scope.search(list.iterator);
|
|
||||||
ngToast.danger({
|
|
||||||
content: `<i class="fa fa-exclamation-triangle 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 {
|
else {
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
@@ -192,6 +170,40 @@ export default
|
|||||||
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification Failed.`,
|
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification Failed.`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function retrieveStatus(id){
|
||||||
|
setTimeout(function(){
|
||||||
|
var url = GetBasePath('notifications') + id;
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.get()
|
||||||
|
.then(function (res) {
|
||||||
|
if(res && res.data && res.data.status && res.data.status === "successful"){
|
||||||
|
scope.search(list.iterator);
|
||||||
|
ngToast.success({
|
||||||
|
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification sent.`
|
||||||
|
});
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
|
else if(res && res.data && res.data.status && res.data.status === "failed"){
|
||||||
|
scope.search(list.iterator);
|
||||||
|
ngToast.danger({
|
||||||
|
content: `<i class="fa fa-exclamation-triangle Toast-successIcon"></i> <b>${name}:</b> Notification failed.`
|
||||||
|
});
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
|
else if(res && res.data && res.data.status && res.data.status === "pending" && pending_count>0){
|
||||||
|
pending_count--;
|
||||||
|
retrieveStatus(id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(scope, null, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Call to test notifications failed.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} , 5000);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.addNotification = function(){
|
scope.addNotification = function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user