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:
softwarefactory-project-zuul[bot] 2019-03-16 12:46:17 +00:00 committed by GitHub
commit 8f1c20423b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 7 deletions

View File

@ -17,7 +17,8 @@ class CustomEmailBackend(EmailBackend):
"use_tls": {"label": "Use TLS", "type": "bool"},
"use_ssl": {"label": "Use SSL", "type": "bool"},
"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"
sender_parameter = "sender"

View File

@ -122,7 +122,6 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
$scope.notification_template_form[subFldName].$setPristine();
}
} else {
$scope[fld] = null;
$scope.notification_template_form[fld].$setPristine();
}
}
@ -200,10 +199,12 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
if (field.type === 'number') {
$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] = "";
}
if (field.type === 'sensitive' && value === null) {
if (field.type === 'sensitive' && (value === null || !value
)) {
$scope[i] = "";
}
return $scope[i];

View File

@ -117,7 +117,7 @@
$scope.testNotification = function() {
var name = $filter('sanitize')(this.notification_template.name),
pending_retries = 10;
pending_retries = 25;
Rest.setUrl(defaultUrl + this.notification_template.id + '/test/');
Rest.post({})
@ -131,7 +131,7 @@
} else {
ProcessErrors($scope, data, status, null, {
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.`
});
$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") {
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();
} else if (res && res.data && res.data.status && res.data.status === "pending" && pending_retries > 0) {

View File

@ -132,6 +132,26 @@ export default ['i18n', function(i18n) {
subForm: 'typeSubForm',
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: {
label: i18n._('Destination Channels'),
type: 'textarea',