diff --git a/src/app/shared/search/search-export-csv/search-export-csv.component.html b/src/app/shared/search/search-export-csv/search-export-csv.component.html index 7bf8704300..35ef89b728 100644 --- a/src/app/shared/search/search-export-csv/search-export-csv.component.html +++ b/src/app/shared/search/search-export-csv/search-export-csv.component.html @@ -1,7 +1,20 @@ + + + {{tooltipMsg | translate}} + + + + + + {{tooltipMsg | translate}} + {{exportLimitExceededMsg}} + + + - \ No newline at end of file + diff --git a/src/app/shared/search/search-export-csv/search-export-csv.component.ts b/src/app/shared/search/search-export-csv/search-export-csv.component.ts index 27c0e86205..a86e61bec1 100644 --- a/src/app/shared/search/search-export-csv/search-export-csv.component.ts +++ b/src/app/shared/search/search-export-csv/search-export-csv.component.ts @@ -14,6 +14,8 @@ import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; import { PaginatedSearchOptions } from '../models/paginated-search-options.model'; import { SearchFilter } from '../models/search-filter.model'; +import { ConfigurationDataService } from '../../../core/data/configuration-data.service'; +import { ConfigurationProperty } from '../../../core/shared/configuration-property.model'; @Component({ selector: 'ds-search-export-csv', @@ -30,6 +32,11 @@ export class SearchExportCsvComponent implements OnInit { */ @Input() searchConfig: PaginatedSearchOptions; + /** + * The total number of items in the search results which can be exported + */ + @Input() total: number; + /** * Observable used to determine whether the button should be shown */ @@ -40,12 +47,18 @@ export class SearchExportCsvComponent implements OnInit { */ tooltipMsg = 'metadata-export-search.tooltip'; + exportLimitExceededKey = 'metadata-export-search.submit.error.limit-exceeded'; + + exportLimitExceededMsg = ''; + + shouldShowWarning$: Observable; + constructor(private scriptDataService: ScriptDataService, private authorizationDataService: AuthorizationDataService, private notificationsService: NotificationsService, private translateService: TranslateService, - private router: Router - ) { + private router: Router, + private configurationService: ConfigurationDataService) { } ngOnInit(): void { @@ -55,6 +68,25 @@ export class SearchExportCsvComponent implements OnInit { map((canExecute: boolean) => canExecute), startWith(false), ); + this.shouldShowWarning$ = this.itemExceeds(); + } + + /** + * Checks if the export limit has been exceeded and updates the tooltip accordingly + */ + private itemExceeds(): Observable { + return this.configurationService.findByPropertyName('metadataexport.max.items').pipe( + getFirstCompletedRemoteData(), + map((response: RemoteData) => { + const limit = Number(response.payload?.values?.[0]); + if (response.hasSucceeded && limit < this.total) { + this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: response.payload?.values?.[0] }); + return true; + } else { + return false; + } + }), + ); } /** diff --git a/src/app/shared/search/search-results/search-results.component.html b/src/app/shared/search/search-results/search-results.component.html index c396fce5fb..ef8a69c8a8 100644 --- a/src/app/shared/search/search-results/search-results.component.html +++ b/src/app/shared/search/search-results/search-results.component.html @@ -1,6 +1,7 @@ {{ (configuration ? configuration + '.search.results.head' : 'search.results.head') | translate }} - + 0" @fadeIn>
{{tooltipMsg | translate}}
{{exportLimitExceededMsg}}