1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

Fix loading pending approval count on login

This commit is contained in:
mabashian 2019-08-23 10:31:23 -04:00 committed by Ryan Petrello
parent 703de8f3c0
commit 9f0307404e
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
4 changed files with 14 additions and 14 deletions

View File

@ -18,7 +18,6 @@ function AtApprovalsDrawerController (strings, Rest, GetBasePath, $rootScope) {
};
vm.emptyListReason = vm.strings.get('approvals.NONE');
// This will probably need to be expanded
vm.toolbarSortOptions = [
toolbarSortDefault,
{ label: `${vm.strings.get('sort.CREATED_DESCENDING')}`, value: '-created' }

View File

@ -112,6 +112,7 @@ export default
$rootScope.login_username = null;
$rootScope.login_password = null;
$rootScope.userLoggedOut = true;
$rootScope.pendingApprovalCount = 0;
if ($rootScope.sessionTimer) {
$rootScope.sessionTimer.clearTimers();
}

View File

@ -32,7 +32,7 @@ export default
timeout: null,
getSessionTime: function () {
if(Store('sessionTime')){
if(Store('sessionTime') && Store('sessionTime')[$rootScope.current_user.id]){
return Store('sessionTime')[$rootScope.current_user.id].time;
}
else {

View File

@ -132,6 +132,18 @@ export default ['$log', '$cookies', '$rootScope', 'ProcessErrors',
$rootScope.user_is_system_auditor = data.results[0].is_system_auditor;
scope.$emit('AuthorizationGetLicense');
});
Rest.setUrl(`${GetBasePath('workflow_approvals')}?status=pending&page_size=1`);
Rest.get()
.then(({data}) => {
$rootScope.pendingApprovalCount = data.count;
})
.catch(({data, status}) => {
ProcessErrors({}, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._('Failed to get workflow jobs pending approval. GET returned status: ') + status
});
});
})
.catch(({data, status}) => {
Authorization.logout().then( () => {
@ -139,18 +151,6 @@ export default ['$log', '$cookies', '$rootScope', 'ProcessErrors',
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', loginAgain);
});
});
Rest.setUrl(`${GetBasePath('workflow_approvals')}?status=pending&page_size=1`);
Rest.get()
.then(({data}) => {
$rootScope.pendingApprovalCount = data.count;
})
.catch(({data, status}) => {
ProcessErrors({}, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._('Failed to get workflow jobs pending approval. GET returned status: ') + status
});
});
});
// Call the API to get an auth token