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
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'); vm.emptyListReason = vm.strings.get('approvals.NONE');
// This will probably need to be expanded
vm.toolbarSortOptions = [ vm.toolbarSortOptions = [
toolbarSortDefault, toolbarSortDefault,
{ label: `${vm.strings.get('sort.CREATED_DESCENDING')}`, value: '-created' } { label: `${vm.strings.get('sort.CREATED_DESCENDING')}`, value: '-created' }

View File

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

View File

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

View File

@@ -132,6 +132,18 @@ export default ['$log', '$cookies', '$rootScope', 'ProcessErrors',
$rootScope.user_is_system_auditor = data.results[0].is_system_auditor; $rootScope.user_is_system_auditor = data.results[0].is_system_auditor;
scope.$emit('AuthorizationGetLicense'); 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}) => { .catch(({data, status}) => {
Authorization.logout().then( () => { 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); 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 // Call the API to get an auth token