@@ -39,6 +39,8 @@ import {
3939import { PaginationService } from 'src/app/core/pagination/pagination.service' ;
4040
4141import { AuthService } from '../../../core/auth/auth.service' ;
42+ import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service' ;
43+ import { FeatureID } from '../../../core/data/feature-authorization/feature-id' ;
4244import { DSONameService } from '../../../core/breadcrumbs/dso-name.service' ;
4345import { FindListOptions } from '../../../core/data/find-list-options.model' ;
4446import { PaginatedList } from '../../../core/data/paginated-list.model' ;
@@ -166,11 +168,13 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
166168 protected router : Router ,
167169 protected auth : AuthService ,
168170 private translateService : TranslateService ,
171+ protected authorizationService : AuthorizationDataService ,
169172 @Inject ( PLATFORM_ID ) protected platformId : object ,
170173 ) {
171174 }
172175
173176 ngOnInit ( ) {
177+ const isAdmin$ = this . isCurrentUserAdmin ( ) ;
174178 // Only auto refresh on browsers
175179 if ( ! isPlatformBrowser ( this . platformId ) ) {
176180 this . useAutoRefreshingSearchBy = false ;
@@ -216,8 +220,16 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
216220 this . processOverviewService . getFindListOptions ( paginationOptions , this . sortField ) ) ,
217221 // Use the findListOptions to retrieve the relevant processes every interval
218222 switchMap ( ( findListOptions : FindListOptions ) =>
219- this . processOverviewService . getProcessesByProcessStatus (
220- this . processStatus , findListOptions , this . useAutoRefreshingSearchBy ? this . autoRefreshInterval : null ) ,
223+ isAdmin$ . pipe (
224+ switchMap ( ( isAdmin : boolean ) => {
225+ const autoRefreshInterval = this . useAutoRefreshingSearchBy ? this . autoRefreshInterval : null ;
226+ if ( isAdmin ) {
227+ return this . processOverviewService . getProcessesByProcessStatus ( this . processStatus , findListOptions , autoRefreshInterval ) ;
228+ } else {
229+ return this . processOverviewService . getOwnProcessesByProcessStatus ( this . processStatus , findListOptions , autoRefreshInterval ) ;
230+ }
231+ } )
232+ )
221233 ) ,
222234 // Redirect the user when he is logged out
223235 redirectOn4xx ( this . router , this . auth ) ,
@@ -310,4 +322,8 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
310322 this . processOverviewService . stopAutoRefreshing ( this . processStatus ) ;
311323 }
312324
325+ isCurrentUserAdmin ( ) : Observable < boolean > {
326+ return this . authorizationService . isAuthorized ( FeatureID . AdministratorOf , undefined , undefined ) ;
327+ }
328+
313329}
0 commit comments