1- import { filter , map } from 'rxjs/operators' ;
1+ import { filter , map , tap } from 'rxjs/operators' ;
22import { ChangeDetectionStrategy , Component , Inject , OnDestroy , OnInit , PLATFORM_ID } from '@angular/core' ;
33import { ActivatedRoute , Data , Router } from '@angular/router' ;
44
@@ -19,6 +19,7 @@ import { AuthorizationDataService } from '../../core/data/feature-authorization/
1919import { ServerResponseService } from '../../core/services/server-response.service' ;
2020import { SignpostingDataService } from '../../core/data/signposting-data.service' ;
2121import { LinkHeadService } from '../../core/services/link-head.service' ;
22+ import { APP_CONFIG , AppConfig } from '../../../config/app-config.interface' ;
2223
2324/**
2425 * This component renders a full item page.
@@ -38,6 +39,10 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
3839
3940 metadata$ : Observable < MetadataMap > ;
4041
42+ metadataMapLimit$ : BehaviorSubject < Map < string , number > > = new BehaviorSubject < Map < string , number > > ( new Map < string , number > ( ) ) ;
43+
44+ limitSize = this . appConfig . item . metadataLimit ;
45+
4146 /**
4247 * True when the itemRD has been originated from its workspaceite/workflowitem, false otherwise.
4348 */
@@ -56,6 +61,7 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
5661 protected signpostingDataService : SignpostingDataService ,
5762 protected linkHeadService : LinkHeadService ,
5863 @Inject ( PLATFORM_ID ) protected platformId : string ,
64+ @Inject ( APP_CONFIG ) private appConfig : AppConfig ,
5965 ) {
6066 super ( route , router , items , authService , authorizationService , responseService , signpostingDataService , linkHeadService , platformId ) ;
6167 }
@@ -66,7 +72,9 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
6672 this . metadata$ = this . itemRD$ . pipe (
6773 map ( ( rd : RemoteData < Item > ) => rd . payload ) ,
6874 filter ( ( item : Item ) => hasValue ( item ) ) ,
69- map ( ( item : Item ) => item . metadata ) , ) ;
75+ map ( ( item : Item ) => item . metadata ) ,
76+ tap ( ( metadataMap : MetadataMap ) => this . nextMetadataMapLimit ( metadataMap ) )
77+ ) ;
7078
7179 this . subs . push ( this . route . data . subscribe ( ( data : Data ) => {
7280 this . fromSubmissionObject = hasValue ( data . wfi ) || hasValue ( data . wsi ) ;
@@ -84,4 +92,18 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
8492 ngOnDestroy ( ) {
8593 this . subs . filter ( ( sub ) => hasValue ( sub ) ) . forEach ( ( sub ) => sub . unsubscribe ( ) ) ;
8694 }
95+
96+ protected increaseLimit ( metadataKey : string ) {
97+ const newMetadataMap : Map < string , number > = new Map ( this . metadataMapLimit$ . value ) ;
98+ const newMetadataSize = newMetadataMap . get ( metadataKey ) + this . limitSize ;
99+ newMetadataMap . set ( metadataKey , newMetadataSize ) ;
100+ this . metadataMapLimit$ . next ( newMetadataMap ) ;
101+ }
102+
103+ protected nextMetadataMapLimit ( metadataMap : MetadataMap ) {
104+ const metadataMapLimit : Map < string , number > = new Map ( this . metadataMapLimit$ . value ) ;
105+ Object . keys ( metadataMap ) . forEach ( ( key : string ) => metadataMapLimit . set ( key , this . limitSize ) ) ;
106+ this . metadataMapLimit$ . next ( metadataMapLimit ) ;
107+ }
108+
87109}
0 commit comments