mirror of
https://github.com/ansible/awx.git
synced 2026-03-29 06:45:09 -02:30
Merge pull request #1937 from marshmalien/fix/1619-statedefinition-error-handler
Add error handler to stateDefinitions resourceData resolve
This commit is contained in:
@@ -209,9 +209,10 @@ function($injector, $stateExtender, $log, i18n) {
|
|||||||
FormDefinition: [params.form, function(definition) {
|
FormDefinition: [params.form, function(definition) {
|
||||||
return definition;
|
return definition;
|
||||||
}],
|
}],
|
||||||
resourceData: ['FormDefinition', 'Rest', '$stateParams', 'GetBasePath',
|
resourceData: ['FormDefinition', 'Rest', '$stateParams', 'GetBasePath', '$q', 'ProcessErrors',
|
||||||
function(FormDefinition, Rest, $stateParams, GetBasePath) {
|
function(FormDefinition, Rest, $stateParams, GetBasePath, $q, ProcessErrors) {
|
||||||
let form, path;
|
let form, path;
|
||||||
|
let deferred = $q.defer();
|
||||||
form = typeof(FormDefinition) === 'function' ?
|
form = typeof(FormDefinition) === 'function' ?
|
||||||
FormDefinition() : FormDefinition;
|
FormDefinition() : FormDefinition;
|
||||||
if (GetBasePath(form.basePath) === undefined && GetBasePath(form.stateTree) === undefined ){
|
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`];
|
path = (GetBasePath(form.basePath) || GetBasePath(form.stateTree) || form.basePath) + $stateParams[`${form.name}_id`];
|
||||||
}
|
}
|
||||||
Rest.setUrl(path);
|
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',
|
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,
|
function($scope, $rootScope, $stateParams, TeamForm, Rest, ProcessErrors,
|
||||||
GetBasePath, Wait, $state, OrgAdminLookup, models) {
|
GetBasePath, Wait, $state, OrgAdminLookup, models, Dataset) {
|
||||||
|
|
||||||
const { me } = models;
|
const { me } = models;
|
||||||
var form = TeamForm,
|
const { data } = Dataset;
|
||||||
id = $stateParams.team_id,
|
const id = $stateParams.team_id;
|
||||||
defaultUrl = GetBasePath('teams') + id;
|
const defaultUrl = GetBasePath('teams') + id;
|
||||||
|
let form = TeamForm;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -20,26 +21,19 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
|||||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||||
$scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0;
|
$scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0;
|
||||||
$scope.team_id = id;
|
$scope.team_id = id;
|
||||||
Rest.setUrl(defaultUrl);
|
setScopeFields(data);
|
||||||
Wait('start');
|
$scope.organization_name = data.summary_fields.organization.name;
|
||||||
Rest.get(defaultUrl).then(({data}) => {
|
|
||||||
setScopeFields(data);
|
|
||||||
$scope.organization_name = data.summary_fields.organization.name;
|
|
||||||
|
|
||||||
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
||||||
.then(function(canEditOrg){
|
.then(function(canEditOrg){
|
||||||
$scope.canEditOrg = canEditOrg;
|
$scope.canEditOrg = canEditOrg;
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.team_obj = data;
|
$scope.team_obj = data;
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.$watch('team_obj.summary_fields.user_capabilities.edit', function(val) {
|
$scope.$watch('team_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||||
$scope.canAdd = (val === false) ? false : true;
|
$scope.canAdd = (val === false) ? false : true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @issue I think all this really want to do is _.forEach(form.fields, (field) =>{ $scope[field] = data[field]})
|
// @issue I think all this really want to do is _.forEach(form.fields, (field) =>{ $scope[field] = data[field]})
|
||||||
|
|||||||
Reference in New Issue
Block a user