11import { Component , OnDestroy , OnInit } from '@angular/core' ;
2- import { Observable , Subscription } from 'rxjs' ;
2+ import { Observable , Subscription , from as observableFrom } from 'rxjs' ;
33import { RemoteData } from '../../core/data/remote-data' ;
44import { PaginatedList } from '../../core/data/paginated-list.model' ;
55import { Process } from '../processes/process.model' ;
66import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
77import { EPersonDataService } from '../../core/eperson/eperson-data.service' ;
8- import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators' ;
8+ import { getFirstCompletedRemoteData } from '../../core/shared/operators' ;
99import { EPerson } from '../../core/eperson/models/eperson.model' ;
10- import { map , switchMap } from 'rxjs/operators' ;
10+ import { switchMap } from 'rxjs/operators' ;
1111import { ProcessDataService } from '../../core/data/processes/process-data.service' ;
1212import { PaginationService } from '../../core/pagination/pagination.service' ;
1313import { FindListOptions } from '../../core/data/find-list-options.model' ;
1414import { ProcessBulkDeleteService } from './process-bulk-delete.service' ;
1515import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ;
16- import { hasValue } from '../../shared/empty.util' ;
16+ import { hasValue , isNotEmpty } from '../../shared/empty.util' ;
1717import { DSONameService } from '../../core/breadcrumbs/dso-name.service' ;
18+ import { TranslateService } from '@ngx-translate/core' ;
1819
1920@Component ( {
2021 selector : 'ds-process-overview' ,
@@ -61,6 +62,7 @@ export class ProcessOverviewComponent implements OnInit, OnDestroy {
6162 protected modalService : NgbModal ,
6263 public processBulkDeleteService : ProcessBulkDeleteService ,
6364 protected dsoNameService : DSONameService ,
65+ private translateService : TranslateService ,
6466 ) {
6567 }
6668
@@ -83,10 +85,20 @@ export class ProcessOverviewComponent implements OnInit, OnDestroy {
8385 * @param id ID of the EPerson
8486 */
8587 getEpersonName ( id : string ) : Observable < string > {
86- return this . ePersonService . findById ( id ) . pipe (
87- getFirstSucceededRemoteDataPayload ( ) ,
88- map ( ( eperson : EPerson ) => this . dsoNameService . getName ( eperson ) ) ,
89- ) ;
88+ if ( isNotEmpty ( id ) ) {
89+ return this . ePersonService . findById ( id ) . pipe (
90+ getFirstCompletedRemoteData ( ) ,
91+ switchMap ( ( rd : RemoteData < EPerson > ) => {
92+ if ( rd . hasSucceeded ) {
93+ return observableFrom ( [ this . dsoNameService . getName ( rd . payload ) ] ) ;
94+ } else {
95+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
96+ }
97+ } )
98+ ) ;
99+ } else {
100+ return this . translateService . get ( 'process.overview.unknown.user' ) ;
101+ }
90102 }
91103
92104 ngOnDestroy ( ) : void {
0 commit comments