mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Added generic error handling to promises in relaunch button component
This commit is contained in:
parent
aa464fdcc8
commit
0f07f4f956
@ -117,6 +117,11 @@ function atRelaunchCtrl (
|
||||
const relaunchType = launchRes.data.type === 'job' ? 'playbook' : launchRes.data.type;
|
||||
$state.go('jobz', { id: launchRes.data.id, type: relaunchType }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: `${config.url}`, status })
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -165,6 +170,11 @@ function atRelaunchCtrl (
|
||||
if (!$state.includes('jobs')) {
|
||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'inventory' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: `${config.url}`, status })
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Alert(
|
||||
@ -184,6 +194,11 @@ function atRelaunchCtrl (
|
||||
if (!$state.includes('jobs')) {
|
||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'project' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: `${config.url}`, status })
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Alert(
|
||||
@ -201,6 +216,11 @@ function atRelaunchCtrl (
|
||||
if (!$state.includes('jobs')) {
|
||||
$state.go('workflowResults', { id: launchRes.data.id }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: `${config.url}`, status })
|
||||
});
|
||||
});
|
||||
} else if (vm.job.type === 'ad_hoc_command') {
|
||||
const adHocCommand = new AdHocCommand();
|
||||
@ -220,6 +240,11 @@ function atRelaunchCtrl (
|
||||
if (!$state.includes('jobs')) {
|
||||
$state.go('jobz', { id: launchRes.data.id, type: 'command' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: `${config.url}`, status })
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -222,14 +222,14 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
} else if (typeof data === 'object' && data !== null) {
|
||||
if (Object.keys(data).length > 0) {
|
||||
keys = Object.keys(data);
|
||||
if (Array.isArray(data[keys[0]])) {
|
||||
msg = data[keys[0]][0];
|
||||
} else {
|
||||
msg = "";
|
||||
_.forOwn(data, function(value, key) {
|
||||
msg = "";
|
||||
_.forOwn(data, function(value, key) {
|
||||
if (Array.isArray(data[key])) {
|
||||
msg += `${key}: ${data[key][0]}`;
|
||||
} else {
|
||||
msg += `${key} : ${value} `;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Alert(defaultMsg.hdr, msg);
|
||||
} else {
|
||||
Alert(defaultMsg.hdr, defaultMsg.msg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user