@@ -47,6 +47,7 @@ import { redirectOn4xx } from '../../../core/shared/authorized.operators';
4747import {
4848 getAllCompletedRemoteData ,
4949 getFirstSucceededRemoteDataPayload ,
50+ getAllCompletedRemoteData , getFirstCompletedRemoteData
5051} from '../../../core/shared/operators' ;
5152import { hasValue } from '../../../shared/empty.util' ;
5253import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component' ;
@@ -60,6 +61,17 @@ import {
6061 ProcessOverviewService ,
6162 ProcessSortField ,
6263} from '../process-overview.service' ;
64+ import { map , switchMap , toArray , take , filter } from 'rxjs/operators' ;
65+ import { EPerson } from '../../../core/eperson/models/eperson.model' ;
66+ import { PaginationService } from 'src/app/core/pagination/pagination.service' ;
67+ import { FindListOptions } from '../../../core/data/find-list-options.model' ;
68+ import { redirectOn4xx } from '../../../core/shared/authorized.operators' ;
69+ import { Router } from '@angular/router' ;
70+ import { AuthService } from '../../../core/auth/auth.service' ;
71+ import { isPlatformBrowser } from '@angular/common' ;
72+ import { RouteService } from '../../../core/services/route.service' ;
73+ import { hasValue , isNotEmpty } from '../../../shared/empty.util' ;
74+ import { TranslateService } from '@ngx-translate/core' ;
6375
6476const NEW_PROCESS_PARAM = 'new_process_id' ;
6577
@@ -159,6 +171,7 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
159171 protected routeService : RouteService ,
160172 protected router : Router ,
161173 protected auth : AuthService ,
174+ private translateService : TranslateService ,
162175 @Inject ( PLATFORM_ID ) protected platformId : object ,
163176 ) {
164177 }
@@ -176,7 +189,7 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
176189 // Creates an ID from the first 2 characters of the process status.
177190 // Should two process status values ever start with the same substring,
178191 // increase the number of characters until the ids are distinct.
179- this . paginationId = this . processStatus . toLowerCase ( ) . substring ( 0 , 2 ) ;
192+ this . paginationId = this . processStatus . toLowerCase ( ) . substring ( 0 , 2 ) ;
180193
181194 const defaultPaginationOptions = Object . assign ( new PaginationComponentOptions ( ) , {
182195 id : this . paginationId ,
@@ -218,7 +231,7 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
218231 // Map RemoteData<PaginatedList<Process>> to RemoteData<PaginatedList<ProcessOverviewTableEntry>>
219232 switchMap ( ( processesRD : RemoteData < PaginatedList < Process > > ) => {
220233 // Create observable emitting all processes one by one
221- return observableFrom ( processesRD . payload . page ) . pipe (
234+ return observableFrom ( processesRD . payload . page ) . pipe (
222235 // Map every Process to ProcessOverviewTableEntry
223236 mergeMap ( ( process : Process ) => {
224237 return this . getEPersonName ( process . userId ) . pipe (
@@ -243,7 +256,6 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
243256 } ) ,
244257 ) ;
245258 } ) ,
246-
247259 ) . subscribe ( ( next : RemoteData < PaginatedList < ProcessOverviewTableEntry > > ) => {
248260 this . processesRD$ . next ( next ) ;
249261 } ) ) ;
@@ -267,10 +279,20 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
267279 * @param id ID of the EPerson
268280 */
269281 getEPersonName ( id : string ) : Observable < string > {
270- return this . ePersonDataService . findById ( id ) . pipe (
271- getFirstSucceededRemoteDataPayload ( ) ,
272- map ( ( eperson : EPerson ) => this . dsoNameService . getName ( eperson ) ) ,
273- ) ;
282+ if ( isNotEmpty ( id ) ) {
283+ return this . ePersonDataService . findById ( id ) . pipe (
284+ getFirstCompletedRemoteData ( ) ,
285+ switchMap ( ( rd : RemoteData < EPerson > ) => {
286+ if ( rd . hasSucceeded ) {
287+ return observableFrom ( [ this . dsoNameService . getName ( rd . payload ) ] ) ;
288+ } else {
289+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
290+ }
291+ } )
292+ ) ;
293+ } else {
294+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
295+ }
274296 }
275297
276298 /**
0 commit comments