add notification webhook fields

This commit is contained in:
Jake McDermott
2019-06-24 11:59:26 -04:00
committed by beeankha
parent 52b01feafe
commit cc0310ccd4
4 changed files with 38 additions and 2 deletions

View File

@@ -87,6 +87,15 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
element: '#notification_template_color', element: '#notification_template_color',
multiple: false multiple: false
}); });
$scope.httpMethodChoices = [
{'id': 'post', 'name': i18n._('POST')},
{'id': 'put', 'name': i18n._('PUT')},
];
CreateSelect2({
element: '#notification_template_http_method',
multiple: false,
});
}); });
$scope.$watch('headers', function validate_headers(str) { $scope.$watch('headers', function validate_headers(str) {

View File

@@ -138,6 +138,16 @@ export default ['Rest', 'Wait',
element: '#notification_template_color', element: '#notification_template_color',
multiple: false multiple: false
}); });
$scope.httpMethodChoices = [
{'id': 'post', 'name': i18n._('POST')},
{'id': 'put', 'name': i18n._('PUT')},
];
CreateSelect2({
element: '#notification_template_http_method',
multiple: false,
});
NotificationsTypeChange.getDetailFields($scope.notification_type.value).forEach(function(field) { NotificationsTypeChange.getDetailFields($scope.notification_type.value).forEach(function(field) {
$scope[field[0]] = field[1]; $scope[field[0]] = field[1];
}); });

View File

@@ -63,7 +63,7 @@ export default ['i18n', function(i18n) {
username: { username: {
label: i18n._('Username'), label: i18n._('Username'),
type: 'text', type: 'text',
ngShow: "notification_type.value == 'email' ", ngShow: "notification_type.value == 'email' || notification_type.value == 'webhook' ",
subForm: 'typeSubForm', subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)' ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
}, },
@@ -75,7 +75,7 @@ export default ['i18n', function(i18n) {
reqExpression: "password_required" , reqExpression: "password_required" ,
init: "false" init: "false"
}, },
ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ", ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' || notification_type.value == 'webhook' ",
subForm: 'typeSubForm', subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)' ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
}, },
@@ -423,6 +423,21 @@ 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)'
}, },
http_method: {
label: i18n._('HTTP Method'),
dataTitle: i18n._('HTTP Method'),
type: 'select',
ngOptions: 'choice.id as choice.name for choice in httpMethodChoices',
default: 'post',
awPopOver: i18n._('Specify an HTTP method for the webhook. Acceptable choices are: POST or PATCH'),
awRequiredWhen: {
reqExpression: "webhook_required",
init: "false"
},
ngShow: "notification_type.value == 'webhook' ",
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
mattermost_url: { mattermost_url: {
label: i18n._('Target URL'), label: i18n._('Target URL'),
type: 'text', type: 'text',

View File

@@ -53,6 +53,8 @@ function (i18n) {
break; break;
case 'webhook': case 'webhook':
obj.webhook_required = true; obj.webhook_required = true;
obj.passwordLabel = ' ' + i18n._('Basic Auth Password');
obj.password_required = false;
break; break;
case 'mattermost': case 'mattermost':
obj.mattermost_required = true; obj.mattermost_required = true;