From cd8986ddad30b93fb72cd33f408d1a1ee89ad50d Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 27 Aug 2024 16:55:49 +0200 Subject: [PATCH 1/3] [DSC-1867] Optimize number of request for building the menu --- src/app/menu.resolver.ts | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/app/menu.resolver.ts b/src/app/menu.resolver.ts index 43693969d9b..ad2865e41cd 100644 --- a/src/app/menu.resolver.ts +++ b/src/app/menu.resolver.ts @@ -11,7 +11,7 @@ import { RemoteData } from './core/data/remote-data'; import { TextMenuItemModel } from './shared/menu/menu-item/models/text.model'; import { MenuService } from './shared/menu/menu.service'; import { filter, find, map, switchMap, take } from 'rxjs/operators'; -import { hasValue } from './shared/empty.util'; +import { hasValue, isNotEmpty } from './shared/empty.util'; import { FeatureID } from './core/data/feature-authorization/feature-id'; import { ThemedCreateCommunityParentSelectorComponent @@ -532,11 +532,11 @@ export class MenuResolver implements Resolve { ]; menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, menuSection)); - observableCombineLatest([ - this.authorizationService.isAuthorized(FeatureID.AdministratorOf), - this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME) - ]).pipe( - filter(([authorized, metadataExportScriptExists]: boolean[]) => authorized && metadataExportScriptExists), + this.authorizationService.isAuthorized(FeatureID.AdministratorOf).pipe( + filter((authorized: boolean) => authorized), + take(1), + switchMap(() => this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME)), + filter((metadataExportScriptExists: boolean) => metadataExportScriptExists), take(1) ).subscribe(() => { // Hides the export menu for unauthorised people @@ -617,12 +617,16 @@ export class MenuResolver implements Resolve { * Add the DL Exporter menu item to the admin menu */ createDLExporterMenuItem() { - observableCombineLatest([ - this.authorizationService.isAuthorized(FeatureID.AdministratorOf), - this.getDLExporterURL(), - this.getDLExporterAccessToken() - ]).subscribe(([authorized, url, accesstoken]) => { - console.log(accesstoken); + this.authorizationService.isAuthorized(FeatureID.AdministratorOf).pipe( + filter((authorized: boolean) => authorized), + take(1), + switchMap(() => observableCombineLatest([ + this.getDLExporterURL(), + this.getDLExporterAccessToken() + ])), + filter(([url, accesstoken]) => isNotEmpty(url) && isNotEmpty(accesstoken)), + take(1) + ).subscribe(([url, accesstoken]) => { const urlSegments = url.split('?'); const queryParamSegments = urlSegments[1].split('='); this.menuService.addSection(MenuID.ADMIN, @@ -630,7 +634,7 @@ export class MenuResolver implements Resolve { id: 'loginmiur_dlexporter_url', index: 15, active: false, - visible: authorized && (hasValue(url) && url.length > 0) && (hasValue(accesstoken) && accesstoken.length > 0), + visible: true, model: { type: MenuItemType.LINK, text: 'menu.section.loginmiur_dlexporter_url', @@ -655,11 +659,11 @@ export class MenuResolver implements Resolve { const menuList = []; menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, menuSection)); - observableCombineLatest([ - this.authorizationService.isAuthorized(FeatureID.AdministratorOf), - this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_IMPORT_SCRIPT_NAME) - ]).pipe( - filter(([authorized, metadataImportScriptExists]: boolean[]) => authorized && metadataImportScriptExists), + this.authorizationService.isAuthorized(FeatureID.AdministratorOf).pipe( + filter((authorized: boolean) => authorized), + take(1), + switchMap(() => this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_IMPORT_SCRIPT_NAME)), + filter((metadataImportScriptExists: boolean) => metadataImportScriptExists), take(1) ).subscribe(() => { // Hides the import menu for unauthorised people From 5abbcd9fd90b361c511b3087187c86fe23e5da2e Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 6 Aug 2024 13:23:07 +0200 Subject: [PATCH 2/3] [DSC-1867] set renderOnServerSide on false by default --- src/app/search-page/search-page.component.html | 2 +- src/app/shared/search/search.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/search-page/search-page.component.html b/src/app/search-page/search-page.component.html index 86ed2bff50d..ae9beb80d3f 100644 --- a/src/app/search-page/search-page.component.html +++ b/src/app/search-page/search-page.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index a9ceba31e00..72e99fb6624 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -236,9 +236,9 @@ export class SearchComponent implements OnInit, OnDestroy { @Input() showFilterToggle = false; /** - * Defines whether to show the toggle button to Show/Hide filter + * Defines whether to fetch search results during SSR execution */ - @Input() renderOnServerSide = true; + @Input() renderOnServerSide = false; /** * Defines whether to show the toggle button to Show/Hide chart From 640b37d7b421de7b02d971e5e1e5a7c8118fe1bd Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Fri, 9 Aug 2024 16:33:11 +0200 Subject: [PATCH 3/3] [DSC-1867] Optimize search results by including follow links --- .../browse-most-elements/abstract-browse-elements.component.ts | 2 +- .../default-browse-elements.component.ts | 2 +- src/app/shared/search/search.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shared/browse-most-elements/abstract-browse-elements.component.ts b/src/app/shared/browse-most-elements/abstract-browse-elements.component.ts index 926ef48b603..63a839234ad 100644 --- a/src/app/shared/browse-most-elements/abstract-browse-elements.component.ts +++ b/src/app/shared/browse-most-elements/abstract-browse-elements.component.ts @@ -55,7 +55,7 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang } ngOnInit() { - const followLinks = this.followThumbnailLink ? [followLink('thumbnail')] : []; + const followLinks = this.followThumbnailLink ? [followLink('thumbnail'), followLink('metrics')] : [followLink('metrics')]; this.paginatedSearchOptionsBS = new BehaviorSubject(this.paginatedSearchOptions); this.searchResults$ = this.paginatedSearchOptionsBS.asObservable().pipe( mergeMap((paginatedSearchOptions) => diff --git a/src/app/shared/browse-most-elements/default-browse-elements/default-browse-elements.component.ts b/src/app/shared/browse-most-elements/default-browse-elements/default-browse-elements.component.ts index 48c5f6ae712..ad78eed4fdd 100644 --- a/src/app/shared/browse-most-elements/default-browse-elements/default-browse-elements.component.ts +++ b/src/app/shared/browse-most-elements/default-browse-elements/default-browse-elements.component.ts @@ -20,5 +20,5 @@ export class DefaultBrowseElementsComponent extends AbstractBrowseElementsCompon @Input() showLabel: boolean; - protected followThumbnailLink = true; + protected followThumbnailLink = this.appConfig.browseBy.showThumbnails; } diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index 72e99fb6624..9e83992ce01 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -448,7 +448,7 @@ export class SearchComponent implements OnInit, OnDestroy { { configuration: searchOptionsConfiguration, sort: sortOption || searchOptions.sort, - forcedEmbeddedKeys: this.forcedEmbeddedKeys.get(searchOptionsConfiguration) + forcedEmbeddedKeys: this.forcedEmbeddedKeys.get(searchOptionsConfiguration) || this.forcedEmbeddedKeys.get('default') }); if (combinedOptions.query === '') { combinedOptions.query = this.query;