mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Add error handling to stateDefinitions resolve block
This commit is contained in:
parent
550c6edb33
commit
41e432abf0
@ -209,9 +209,10 @@ function($injector, $stateExtender, $log, i18n) {
|
||||
FormDefinition: [params.form, function(definition) {
|
||||
return definition;
|
||||
}],
|
||||
resourceData: ['FormDefinition', 'Rest', '$stateParams', 'GetBasePath',
|
||||
function(FormDefinition, Rest, $stateParams, GetBasePath) {
|
||||
resourceData: ['FormDefinition', 'Rest', '$stateParams', 'GetBasePath', '$q', 'ProcessErrors',
|
||||
function(FormDefinition, Rest, $stateParams, GetBasePath, $q, ProcessErrors) {
|
||||
let form, path;
|
||||
let deferred = $q.defer();
|
||||
form = typeof(FormDefinition) === 'function' ?
|
||||
FormDefinition() : FormDefinition;
|
||||
if (GetBasePath(form.basePath) === undefined && GetBasePath(form.stateTree) === undefined ){
|
||||
@ -221,7 +222,18 @@ function($injector, $stateExtender, $log, i18n) {
|
||||
path = (GetBasePath(form.basePath) || GetBasePath(form.stateTree) || form.basePath) + $stateParams[`${form.name}_id`];
|
||||
}
|
||||
Rest.setUrl(path);
|
||||
return Rest.get();
|
||||
Rest.get()
|
||||
.then((response) => deferred.resolve(response))
|
||||
.catch(({ data, status }) => {
|
||||
ProcessErrors(null, data, status, null,
|
||||
{
|
||||
hdr: i18n._('Error!'),
|
||||
msg: i18n._('Unable to get resource: ') + status
|
||||
}
|
||||
);
|
||||
deferred.reject();
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -5,14 +5,15 @@
|
||||
*************************************************/
|
||||
|
||||
export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', 'OrgAdminLookup', 'resolvedModels',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', 'OrgAdminLookup', 'resolvedModels', 'resourceData',
|
||||
function($scope, $rootScope, $stateParams, TeamForm, Rest, ProcessErrors,
|
||||
GetBasePath, Wait, $state, OrgAdminLookup, models) {
|
||||
GetBasePath, Wait, $state, OrgAdminLookup, models, Dataset) {
|
||||
|
||||
const { me } = models;
|
||||
var form = TeamForm,
|
||||
id = $stateParams.team_id,
|
||||
defaultUrl = GetBasePath('teams') + id;
|
||||
const { data } = Dataset;
|
||||
const id = $stateParams.team_id;
|
||||
const defaultUrl = GetBasePath('teams') + id;
|
||||
let form = TeamForm;
|
||||
|
||||
init();
|
||||
|
||||
@ -20,26 +21,19 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0;
|
||||
$scope.team_id = id;
|
||||
Rest.setUrl(defaultUrl);
|
||||
Wait('start');
|
||||
Rest.get(defaultUrl).then(({data}) => {
|
||||
setScopeFields(data);
|
||||
$scope.organization_name = data.summary_fields.organization.name;
|
||||
setScopeFields(data);
|
||||
$scope.organization_name = data.summary_fields.organization.name;
|
||||
|
||||
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
||||
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
||||
.then(function(canEditOrg){
|
||||
$scope.canEditOrg = canEditOrg;
|
||||
});
|
||||
|
||||
$scope.team_obj = data;
|
||||
Wait('stop');
|
||||
});
|
||||
$scope.team_obj = data;
|
||||
|
||||
$scope.$watch('team_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||
$scope.canAdd = (val === false) ? false : true;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// @issue I think all this really want to do is _.forEach(form.fields, (field) =>{ $scope[field] = data[field]})
|
||||
|
Loading…
Reference in New Issue
Block a user