@@ -18,7 +18,10 @@ import {
1818 RouterLink ,
1919} from '@angular/router' ;
2020import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap' ;
21- import { TranslateModule } from '@ngx-translate/core' ;
21+ import {
22+ TranslateModule ,
23+ TranslateService ,
24+ } from '@ngx-translate/core' ;
2225import {
2326 BehaviorSubject ,
2427 from as observableFrom ,
@@ -46,9 +49,12 @@ import { RouteService } from '../../../core/services/route.service';
4649import { redirectOn4xx } from '../../../core/shared/authorized.operators' ;
4750import {
4851 getAllCompletedRemoteData ,
49- getFirstSucceededRemoteDataPayload ,
52+ getFirstCompletedRemoteData ,
5053} from '../../../core/shared/operators' ;
51- import { hasValue } from '../../../shared/empty.util' ;
54+ import {
55+ hasValue ,
56+ isNotEmpty ,
57+ } from '../../../shared/empty.util' ;
5258import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component' ;
5359import { PaginationComponent } from '../../../shared/pagination/pagination.component' ;
5460import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model' ;
@@ -153,12 +159,13 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
153159
154160 constructor ( protected processOverviewService : ProcessOverviewService ,
155161 protected processBulkDeleteService : ProcessBulkDeleteService ,
156- protected ePersonDataService : EPersonDataService ,
157- protected dsoNameService : DSONameService ,
162+ public ePersonDataService : EPersonDataService ,
163+ public dsoNameService : DSONameService ,
158164 protected paginationService : PaginationService ,
159165 protected routeService : RouteService ,
160166 protected router : Router ,
161167 protected auth : AuthService ,
168+ private translateService : TranslateService ,
162169 @Inject ( PLATFORM_ID ) protected platformId : object ,
163170 ) {
164171 }
@@ -176,7 +183,7 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
176183 // Creates an ID from the first 2 characters of the process status.
177184 // Should two process status values ever start with the same substring,
178185 // increase the number of characters until the ids are distinct.
179- this . paginationId = this . processStatus . toLowerCase ( ) . substring ( 0 , 2 ) ;
186+ this . paginationId = this . processStatus . toLowerCase ( ) . substring ( 0 , 2 ) ;
180187
181188 const defaultPaginationOptions = Object . assign ( new PaginationComponentOptions ( ) , {
182189 id : this . paginationId ,
@@ -218,7 +225,7 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
218225 // Map RemoteData<PaginatedList<Process>> to RemoteData<PaginatedList<ProcessOverviewTableEntry>>
219226 switchMap ( ( processesRD : RemoteData < PaginatedList < Process > > ) => {
220227 // Create observable emitting all processes one by one
221- return observableFrom ( processesRD . payload . page ) . pipe (
228+ return observableFrom ( processesRD . payload . page ) . pipe (
222229 // Map every Process to ProcessOverviewTableEntry
223230 mergeMap ( ( process : Process ) => {
224231 return this . getEPersonName ( process . userId ) . pipe (
@@ -243,7 +250,6 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
243250 } ) ,
244251 ) ;
245252 } ) ,
246-
247253 ) . subscribe ( ( next : RemoteData < PaginatedList < ProcessOverviewTableEntry > > ) => {
248254 this . processesRD$ . next ( next ) ;
249255 } ) ) ;
@@ -267,10 +273,20 @@ export class ProcessOverviewTableComponent implements OnInit, OnDestroy {
267273 * @param id ID of the EPerson
268274 */
269275 getEPersonName ( id : string ) : Observable < string > {
270- return this . ePersonDataService . findById ( id ) . pipe (
271- getFirstSucceededRemoteDataPayload ( ) ,
272- map ( ( eperson : EPerson ) => this . dsoNameService . getName ( eperson ) ) ,
273- ) ;
276+ if ( isNotEmpty ( id ) ) {
277+ return this . ePersonDataService . findById ( id ) . pipe (
278+ getFirstCompletedRemoteData ( ) ,
279+ switchMap ( ( rd : RemoteData < EPerson > ) => {
280+ if ( rd . hasSucceeded ) {
281+ return [ this . dsoNameService . getName ( rd . payload ) ] ;
282+ } else {
283+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
284+ }
285+ } ) ,
286+ ) ;
287+ } else {
288+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
289+ }
274290 }
275291
276292 /**
0 commit comments