mirror of
https://github.com/ansible/awx.git
synced 2026-04-06 18:49:21 -02:30
Merge pull request #3222 from beeankha/timeout_config
Add Timeout Feature to Email Notification Template Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -17,7 +17,8 @@ class CustomEmailBackend(EmailBackend):
|
|||||||
"use_tls": {"label": "Use TLS", "type": "bool"},
|
"use_tls": {"label": "Use TLS", "type": "bool"},
|
||||||
"use_ssl": {"label": "Use SSL", "type": "bool"},
|
"use_ssl": {"label": "Use SSL", "type": "bool"},
|
||||||
"sender": {"label": "Sender Email", "type": "string"},
|
"sender": {"label": "Sender Email", "type": "string"},
|
||||||
"recipients": {"label": "Recipient List", "type": "list"}}
|
"recipients": {"label": "Recipient List", "type": "list"},
|
||||||
|
"timeout": {"label": "Timeout", "type": "int"}}
|
||||||
recipient_parameter = "recipients"
|
recipient_parameter = "recipients"
|
||||||
sender_parameter = "sender"
|
sender_parameter = "sender"
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
|
|||||||
$scope.notification_template_form[subFldName].$setPristine();
|
$scope.notification_template_form[subFldName].$setPristine();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$scope[fld] = null;
|
|
||||||
$scope.notification_template_form[fld].$setPristine();
|
$scope.notification_template_form[fld].$setPristine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,10 +199,12 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
|
|||||||
if (field.type === 'number') {
|
if (field.type === 'number') {
|
||||||
$scope[i] = Number($scope[i]);
|
$scope[i] = Number($scope[i]);
|
||||||
}
|
}
|
||||||
if (i === "username" && $scope.notification_type.value === "email" && value === null) {
|
if (i === "username" && $scope.notification_type.value === "email" && (value === null || !value
|
||||||
|
)) {
|
||||||
$scope[i] = "";
|
$scope[i] = "";
|
||||||
}
|
}
|
||||||
if (field.type === 'sensitive' && value === null) {
|
if (field.type === 'sensitive' && (value === null || !value
|
||||||
|
)) {
|
||||||
$scope[i] = "";
|
$scope[i] = "";
|
||||||
}
|
}
|
||||||
return $scope[i];
|
return $scope[i];
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
|
|
||||||
$scope.testNotification = function() {
|
$scope.testNotification = function() {
|
||||||
var name = $filter('sanitize')(this.notification_template.name),
|
var name = $filter('sanitize')(this.notification_template.name),
|
||||||
pending_retries = 10;
|
pending_retries = 25;
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + this.notification_template.id + '/test/');
|
Rest.setUrl(defaultUrl + this.notification_template.id + '/test/');
|
||||||
Rest.post({})
|
Rest.post({})
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
} else {
|
} else {
|
||||||
ProcessErrors($scope, data, status, null, {
|
ProcessErrors($scope, data, status, null, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Call to notifcatin templates failed. Notification returned status: ' + status
|
msg: 'Call to notification templates failed. Notification returned status: ' + status
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -152,9 +152,14 @@
|
|||||||
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification sent.`
|
content: `<i class="fa fa-check-circle Toast-successIcon"></i> <b>${name}:</b> Notification sent.`
|
||||||
});
|
});
|
||||||
$state.reload();
|
$state.reload();
|
||||||
|
} else if (res && res.data && res.data.status && res.data.status === "failed" && res.data.error === "timed out") {
|
||||||
|
ngToast.danger({
|
||||||
|
content: `<div><i class="fa fa-exclamation-triangle Toast-successIcon"></i> <b>${name}:</b> ${i18n._("Notification timed out.")}</div>`
|
||||||
|
});
|
||||||
|
$state.reload();
|
||||||
} else if (res && res.data && res.data.status && res.data.status === "failed") {
|
} else if (res && res.data && res.data.status && res.data.status === "failed") {
|
||||||
ngToast.danger({
|
ngToast.danger({
|
||||||
content: `<i class="fa fa-exclamation-triangle Toast-successIcon"></i> <b>${name}:</b> Notification failed.`
|
content: `<div><i class="fa fa-exclamation-triangle Toast-successIcon"></i> <b>${name}:</b> Notification failed.</div><div>${res.data.error}</div>`
|
||||||
});
|
});
|
||||||
$state.reload();
|
$state.reload();
|
||||||
} else if (res && res.data && res.data.status && res.data.status === "pending" && pending_retries > 0) {
|
} else if (res && res.data && res.data.status && res.data.status === "pending" && pending_retries > 0) {
|
||||||
|
|||||||
@@ -132,6 +132,26 @@ export default ['i18n', function(i18n) {
|
|||||||
subForm: 'typeSubForm',
|
subForm: 'typeSubForm',
|
||||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
},
|
},
|
||||||
|
timeout: {
|
||||||
|
label: i18n._('Timeout'),
|
||||||
|
type: 'number',
|
||||||
|
integer: true,
|
||||||
|
default: 30,
|
||||||
|
min: 1,
|
||||||
|
max: 120,
|
||||||
|
spinner: true,
|
||||||
|
dataTitle: i18n._('Timeout'),
|
||||||
|
dataPlacement: 'right',
|
||||||
|
dataContainer: 'body',
|
||||||
|
awRequiredWhen: {
|
||||||
|
reqExpression: "email_required",
|
||||||
|
init: "false"
|
||||||
|
},
|
||||||
|
awPopOver: "<p>" + i18n._("The amount of time (in seconds) before the email notification stops trying to reach the host and times out. Ranges from 1 to 120 seconds.") + "</p>",
|
||||||
|
ngShow: "notification_type.value == 'email' ",
|
||||||
|
subForm: 'typeSubForm',
|
||||||
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
|
},
|
||||||
channels: {
|
channels: {
|
||||||
label: i18n._('Destination Channels'),
|
label: i18n._('Destination Channels'),
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
|
|||||||
Reference in New Issue
Block a user