fix bugs when switching NTs to Webhook type

This commit is contained in:
Keith Grant 2019-09-11 13:59:24 -07:00
parent 4e1fbb3e91
commit 55244834a3
2 changed files with 12 additions and 3 deletions

View File

@ -222,7 +222,9 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
function processValue(value, i, field) {
if (field.type === 'textarea') {
if (field.name === 'headers') {
$scope[i] = JSON.parse($scope[i]);
if (typeof $scope[i] === 'string') {
$scope[i] = JSON.parse($scope[i]);
}
}
else if (field.name === 'annotation_tags' && $scope.notification_type.value === "grafana" && value === null) {
$scope[i] = null;

View File

@ -310,7 +310,9 @@ export default ['Rest', 'Wait',
function processValue(value, i, field) {
if (field.type === 'textarea') {
if (field.name === 'headers') {
$scope[i] = JSON.parse($scope[i]);
if (typeof $scope[i] === 'string') {
$scope[i] = JSON.parse($scope[i]);
}
}
else if (field.name === 'annotation_tags' && $scope.notification_type.value === "grafana" && value === null) {
$scope[i] = null;
@ -325,7 +327,12 @@ export default ['Rest', 'Wait',
if (field.type === 'number') {
$scope[i] = Number($scope[i]);
}
if (i === "username" && $scope.notification_type.value === "email" && (value === null || value === undefined)) {
const isUsernameIncluded = (
$scope.notification_type.value === 'email' ||
$scope.notification_type.value === 'webhook'
)
if (i === "username" && isUsernameIncluded &&
(value === null || value === undefined)) {
$scope[i] = "";
}
if (field.type === 'sensitive' && (value === null || value === undefined)) {