mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 09:57:33 -02:30
Added generic error handling to promises in relaunch button component
This commit is contained in:
@@ -117,6 +117,11 @@ function atRelaunchCtrl (
|
|||||||
const relaunchType = launchRes.data.type === 'job' ? 'playbook' : launchRes.data.type;
|
const relaunchType = launchRes.data.type === 'job' ? 'playbook' : launchRes.data.type;
|
||||||
$state.go('jobz', { id: launchRes.data.id, type: relaunchType }, { reload: true });
|
$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')) {
|
if (!$state.includes('jobs')) {
|
||||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'inventory' }, { reload: true });
|
$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 {
|
} else {
|
||||||
Alert(
|
Alert(
|
||||||
@@ -184,6 +194,11 @@ function atRelaunchCtrl (
|
|||||||
if (!$state.includes('jobs')) {
|
if (!$state.includes('jobs')) {
|
||||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'project' }, { reload: true });
|
$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 {
|
} else {
|
||||||
Alert(
|
Alert(
|
||||||
@@ -201,6 +216,11 @@ function atRelaunchCtrl (
|
|||||||
if (!$state.includes('jobs')) {
|
if (!$state.includes('jobs')) {
|
||||||
$state.go('workflowResults', { id: launchRes.data.id }, { reload: true });
|
$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') {
|
} else if (vm.job.type === 'ad_hoc_command') {
|
||||||
const adHocCommand = new AdHocCommand();
|
const adHocCommand = new AdHocCommand();
|
||||||
@@ -220,6 +240,11 @@ function atRelaunchCtrl (
|
|||||||
if (!$state.includes('jobs')) {
|
if (!$state.includes('jobs')) {
|
||||||
$state.go('jobz', { id: launchRes.data.id, type: 'command' }, { reload: true });
|
$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) {
|
} else if (typeof data === 'object' && data !== null) {
|
||||||
if (Object.keys(data).length > 0) {
|
if (Object.keys(data).length > 0) {
|
||||||
keys = Object.keys(data);
|
keys = Object.keys(data);
|
||||||
if (Array.isArray(data[keys[0]])) {
|
msg = "";
|
||||||
msg = data[keys[0]][0];
|
_.forOwn(data, function(value, key) {
|
||||||
} else {
|
if (Array.isArray(data[key])) {
|
||||||
msg = "";
|
msg += `${key}: ${data[key][0]}`;
|
||||||
_.forOwn(data, function(value, key) {
|
} else {
|
||||||
msg += `${key} : ${value} `;
|
msg += `${key} : ${value} `;
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
Alert(defaultMsg.hdr, msg);
|
Alert(defaultMsg.hdr, msg);
|
||||||
} else {
|
} else {
|
||||||
Alert(defaultMsg.hdr, defaultMsg.msg);
|
Alert(defaultMsg.hdr, defaultMsg.msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user