mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
handle message validation errors
This commit is contained in:
@@ -7,13 +7,13 @@
|
|||||||
export default ['Rest', 'Wait', 'NotificationsFormObject',
|
export default ['Rest', 'Wait', 'NotificationsFormObject',
|
||||||
'ProcessErrors', 'GetBasePath', 'Alert',
|
'ProcessErrors', 'GetBasePath', 'Alert',
|
||||||
'GenerateForm', '$scope', '$state', 'CreateSelect2', 'GetChoices',
|
'GenerateForm', '$scope', '$state', 'CreateSelect2', 'GetChoices',
|
||||||
'NotificationsTypeChange', 'ParseTypeChange', 'i18n', 'MessageUtils',
|
'NotificationsTypeChange', 'ParseTypeChange', 'i18n', 'MessageUtils', '$filter',
|
||||||
function(
|
function(
|
||||||
Rest, Wait, NotificationsFormObject,
|
Rest, Wait, NotificationsFormObject,
|
||||||
ProcessErrors, GetBasePath, Alert,
|
ProcessErrors, GetBasePath, Alert,
|
||||||
GenerateForm, $scope, $state, CreateSelect2, GetChoices,
|
GenerateForm, $scope, $state, CreateSelect2, GetChoices,
|
||||||
NotificationsTypeChange, ParseTypeChange, i18n,
|
NotificationsTypeChange, ParseTypeChange, i18n,
|
||||||
MessageUtils
|
MessageUtils, $filter
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var generator = GenerateForm,
|
var generator = GenerateForm,
|
||||||
@@ -267,10 +267,14 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
|
|||||||
$state.go('notifications', {}, { reload: true });
|
$state.go('notifications', {}, { reload: true });
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({ data, status }) => {
|
||||||
|
let description = 'POST returned status: ' + status;
|
||||||
|
if (data && data.messages && data.messages.length > 0) {
|
||||||
|
description = _.uniq(data.messages).join(', ');
|
||||||
|
}
|
||||||
ProcessErrors($scope, data, status, form, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to add new notifier. POST returned status: ' + status
|
msg: $filter('sanitize')('Failed to add new notifier. ' + description + '.')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default ['Rest', 'Wait',
|
|||||||
'notification_template',
|
'notification_template',
|
||||||
'$scope', '$state', 'GetChoices', 'CreateSelect2', 'Empty',
|
'$scope', '$state', 'GetChoices', 'CreateSelect2', 'Empty',
|
||||||
'NotificationsTypeChange', 'ParseTypeChange', 'i18n',
|
'NotificationsTypeChange', 'ParseTypeChange', 'i18n',
|
||||||
'MessageUtils',
|
'MessageUtils', '$filter',
|
||||||
function(
|
function(
|
||||||
Rest, Wait,
|
Rest, Wait,
|
||||||
NotificationsFormObject, ProcessErrors, GetBasePath,
|
NotificationsFormObject, ProcessErrors, GetBasePath,
|
||||||
@@ -18,7 +18,7 @@ export default ['Rest', 'Wait',
|
|||||||
notification_template,
|
notification_template,
|
||||||
$scope, $state, GetChoices, CreateSelect2, Empty,
|
$scope, $state, GetChoices, CreateSelect2, Empty,
|
||||||
NotificationsTypeChange, ParseTypeChange, i18n,
|
NotificationsTypeChange, ParseTypeChange, i18n,
|
||||||
MessageUtils
|
MessageUtils, $filter
|
||||||
) {
|
) {
|
||||||
var generator = GenerateForm,
|
var generator = GenerateForm,
|
||||||
id = notification_template.id,
|
id = notification_template.id,
|
||||||
@@ -350,10 +350,14 @@ export default ['Rest', 'Wait',
|
|||||||
$state.go('notifications', {}, { reload: true });
|
$state.go('notifications', {}, { reload: true });
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({ data, status }) => {
|
||||||
|
let description = 'PUT returned status: ' + status;
|
||||||
|
if (data && data.messages && data.messages.length > 0) {
|
||||||
|
description = _.uniq(data.messages).join(', ');
|
||||||
|
}
|
||||||
ProcessErrors($scope, data, status, form, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to add new notification template. POST returned status: ' + status
|
msg: $filter('sanitize')('Failed to update notifier. ' + description + '.')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user