From e98ddc4fd5a7c9477151d066ca1f799a6eb3ed9e Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 23 Feb 2024 23:36:42 +0100 Subject: [PATCH 1/3] Fixed home news facets sidebar & home content section alignment when facets are disabled --- .../admin-search-page.component.html | 2 +- .../admin-workflow-page.component.html | 2 +- .../home-page.component.default.scss | 0 src/app/home-page/home-page.component.html | 27 +++-- src/app/home-page/home-page.component.scss | 7 +- src/app/home-page/home-page.component.ts | 21 ++-- .../related-entities-search.component.html | 4 +- ...med-configuration-search-page.component.ts | 107 ++++++++++++------ src/app/shared/search/search.component.html | 10 +- 9 files changed, 118 insertions(+), 62 deletions(-) delete mode 100644 src/app/home-page/home-page.component.default.scss diff --git a/src/app/admin/admin-search-page/admin-search-page.component.html b/src/app/admin/admin-search-page/admin-search-page.component.html index 69ff132fe3f..516799ddf90 100644 --- a/src/app/admin/admin-search-page/admin-search-page.component.html +++ b/src/app/admin/admin-search-page/admin-search-page.component.html @@ -1 +1 @@ - + diff --git a/src/app/admin/admin-workflow-page/admin-workflow-page.component.html b/src/app/admin/admin-workflow-page/admin-workflow-page.component.html index d12cefb3313..c16ed311681 100644 --- a/src/app/admin/admin-workflow-page/admin-workflow-page.component.html +++ b/src/app/admin/admin-workflow-page/admin-workflow-page.component.html @@ -1 +1 @@ - + diff --git a/src/app/home-page/home-page.component.default.scss b/src/app/home-page/home-page.component.default.scss deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/app/home-page/home-page.component.html b/src/app/home-page/home-page.component.html index c1d4b8a98c7..44a86b0e0e3 100644 --- a/src/app/home-page/home-page.component.html +++ b/src/app/home-page/home-page.component.html @@ -1,19 +1,28 @@ -
-
-
- -
-
+
+ +
+ + [searchPlaceholder]="'home.search-form.placeholder' | translate"> +
-
+
+ + +
+ + +
+
diff --git a/src/app/home-page/home-page.component.scss b/src/app/home-page/home-page.component.scss index 29a5e65b4c2..653de42b44b 100644 --- a/src/app/home-page/home-page.component.scss +++ b/src/app/home-page/home-page.component.scss @@ -1,2 +1,5 @@ -:host { -} \ No newline at end of file +:host ::ng-deep { + .container-fluid .container { + padding: 0; + } +} diff --git a/src/app/home-page/home-page.component.ts b/src/app/home-page/home-page.component.ts index b4dfd06c337..edb582f424d 100644 --- a/src/app/home-page/home-page.component.ts +++ b/src/app/home-page/home-page.component.ts @@ -3,14 +3,15 @@ import { map, switchMap } from 'rxjs/operators'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { Site } from '../core/shared/site.model'; -import { environment } from '../../environments/environment'; import { isPlatformServer } from '@angular/common'; import { ServerResponseService } from '../core/services/server-response.service'; import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service'; import { LinkDefinition, LinkHeadService } from '../core/services/link-head.service'; import { isNotEmpty } from '../shared/empty.util'; - import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface'; +import { HostWindowService } from '../shared/host-window.service'; +import { SidebarService } from '../shared/sidebar/sidebar.service'; + @Component({ selector: 'ds-home-page', styleUrls: ['./home-page.component.scss'], @@ -19,7 +20,9 @@ import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface'; export class HomePageComponent implements OnInit, OnDestroy { site$: Observable; + isXsOrSm$: Observable; recentSubmissionspageSize: number; + showDiscoverFilters: boolean; /** * An array of LinkDefinition objects representing inbox links for the home page. */ @@ -27,13 +30,16 @@ export class HomePageComponent implements OnInit, OnDestroy { constructor( @Inject(APP_CONFIG) protected appConfig: AppConfig, - private route: ActivatedRoute, - private responseService: ServerResponseService, - private notifyInfoService: NotifyInfoService, + protected route: ActivatedRoute, + protected responseService: ServerResponseService, + protected notifyInfoService: NotifyInfoService, protected linkHeadService: LinkHeadService, - @Inject(PLATFORM_ID) private platformId: string + protected sidebarService: SidebarService, + protected windowService: HostWindowService, + @Inject(PLATFORM_ID) protected platformId: string, ) { - this.recentSubmissionspageSize = environment.homePage.recentSubmissions.pageSize; + this.recentSubmissionspageSize = this.appConfig.homePage.recentSubmissions.pageSize; + this.showDiscoverFilters = this.appConfig.homePage.showDiscoverFilters; // Get COAR REST API URLs from REST configuration // only if COAR configuration is enabled this.notifyInfoService.isCoarConfigEnabled().pipe( @@ -50,6 +56,7 @@ export class HomePageComponent implements OnInit, OnDestroy { } ngOnInit(): void { + this.isXsOrSm$ = this.windowService.isXsOrSm(); this.site$ = this.route.data.pipe( map((data) => data.site as Site), ); diff --git a/src/app/item-page/simple/related-entities/related-entities-search/related-entities-search.component.html b/src/app/item-page/simple/related-entities/related-entities-search/related-entities-search.component.html index 36340bebfa0..939d502d99c 100644 --- a/src/app/item-page/simple/related-entities/related-entities-search/related-entities-search.component.html +++ b/src/app/item-page/simple/related-entities/related-entities-search/related-entities-search.component.html @@ -1,7 +1,7 @@ - - + diff --git a/src/app/search-page/themed-configuration-search-page.component.ts b/src/app/search-page/themed-configuration-search-page.component.ts index e367ee52387..4501760fdd8 100644 --- a/src/app/search-page/themed-configuration-search-page.component.ts +++ b/src/app/search-page/themed-configuration-search-page.component.ts @@ -1,60 +1,95 @@ import { Component, Input } from '@angular/core'; import { ThemedComponent } from '../shared/theme-support/themed.component'; import { ConfigurationSearchPageComponent } from './configuration-search-page.component'; -import { Observable } from 'rxjs'; import { Context } from '../core/shared/context.model'; +import { SearchConfigurationOption } from '../shared/search/search-switch-configuration/search-configuration-option.model'; +import { CollectionElementLinkType } from '../shared/object-collection/collection-element-link.type'; +import { SelectionConfig } from '../shared/search/search-results/search-results.component'; +import { ViewMode } from '../core/shared/view-mode.model'; /** * Themed wrapper for ConfigurationSearchPageComponent */ @Component({ selector: 'ds-themed-configuration-search-page', - styleUrls: [], templateUrl: '../shared/theme-support/themed.component.html', }) export class ThemedConfigurationSearchPageComponent extends ThemedComponent { - /** - * The configuration to use for the search options - * If empty, the configuration will be determined by the route parameter called 'configuration' - */ + + @Input() configurationList: SearchConfigurationOption[] = []; + + @Input() context: Context; + @Input() configuration: string; - /** - * The actual query for the fixed filter. - * If empty, the query will be determined by the route parameter called 'filter' - */ @Input() fixedFilterQuery: string; - /** - * True when the search component should show results on the current page - */ + @Input() useCachedVersionIfAvailable: boolean; + @Input() inPlaceSearch: boolean; - /** - * Whether or not the search bar should be visible - */ + @Input() linkType: CollectionElementLinkType; + + @Input() paginationId: string; + @Input() searchEnabled: boolean; - /** - * The width of the sidebar (bootstrap columns) - */ - @Input() - sideBarWidth: number; - - /** - * The currently applied configuration (determines title of search) - */ - @Input() - configuration$: Observable; - - /** - * The current context - */ - @Input() - context: Context; - - protected inAndOutputNames: (keyof ConfigurationSearchPageComponent & keyof this)[] = - ['context', 'configuration', 'fixedFilterQuery', 'inPlaceSearch', 'searchEnabled', 'sideBarWidth']; + @Input() sideBarWidth: number; + + @Input() searchFormPlaceholder: string; + + @Input() selectable: boolean; + + @Input() selectionConfig: SelectionConfig; + + @Input() showCsvExport: boolean; + + @Input() showSidebar: boolean; + + @Input() showThumbnails: boolean; + + @Input() showViewModes: boolean; + + @Input() useUniquePageId: boolean; + + @Input() viewModeList: ViewMode[]; + + @Input() showScopeSelector: boolean; + + @Input() trackStatistics: boolean; + + @Input() query: string; + + @Input() scope: string; + + @Input() hideScopeInUrl: boolean; + + protected inAndOutputNames: (keyof ConfigurationSearchPageComponent & keyof this)[] = [ + 'configurationList', + 'context', + 'configuration', + 'fixedFilterQuery', + 'useCachedVersionIfAvailable', + 'inPlaceSearch', + 'linkType', + 'paginationId', + 'searchEnabled', + 'sideBarWidth', + 'searchFormPlaceholder', + 'selectable', + 'selectionConfig', + 'showCsvExport', + 'showSidebar', + 'showThumbnails', + 'showViewModes', + 'useUniquePageId', + 'viewModeList', + 'showScopeSelector', + 'trackStatistics', + 'query', + 'scope', + 'hideScopeInUrl', + ]; protected getComponentName(): string { return 'ConfigurationSearchPageComponent'; diff --git a/src/app/shared/search/search.component.html b/src/app/shared/search/search.component.html index 6ee0bb3cb07..5b32ba20ddb 100644 --- a/src/app/shared/search/search.component.html +++ b/src/app/shared/search/search.component.html @@ -1,4 +1,4 @@ -
+
@@ -18,7 +18,9 @@
- + + +
@@ -83,7 +85,7 @@ -
- +
From 8d19e634c53e684ec118515c9d6ddc33ab372431 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 1 Mar 2024 00:30:59 +0100 Subject: [PATCH 2/3] Fixed COAR throwing a console error when disabled --- src/app/home-page/home-page.component.ts | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/home-page/home-page.component.ts b/src/app/home-page/home-page.component.ts index edb582f424d..8ccca19407f 100644 --- a/src/app/home-page/home-page.component.ts +++ b/src/app/home-page/home-page.component.ts @@ -1,7 +1,7 @@ import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; import { map, switchMap } from 'rxjs/operators'; import { ActivatedRoute } from '@angular/router'; -import { Observable } from 'rxjs'; +import { Observable, Subscription, of as observableOf } from 'rxjs'; import { Site } from '../core/shared/site.model'; import { isPlatformServer } from '@angular/common'; import { ServerResponseService } from '../core/services/server-response.service'; @@ -28,6 +28,8 @@ export class HomePageComponent implements OnInit, OnDestroy { */ inboxLinks: LinkDefinition[] = []; + subs: Subscription[] = []; + constructor( @Inject(APP_CONFIG) protected appConfig: AppConfig, protected route: ActivatedRoute, @@ -40,19 +42,6 @@ export class HomePageComponent implements OnInit, OnDestroy { ) { this.recentSubmissionspageSize = this.appConfig.homePage.recentSubmissions.pageSize; this.showDiscoverFilters = this.appConfig.homePage.showDiscoverFilters; - // Get COAR REST API URLs from REST configuration - // only if COAR configuration is enabled - this.notifyInfoService.isCoarConfigEnabled().pipe( - switchMap((coarLdnEnabled: boolean) => { - if (coarLdnEnabled) { - return this.notifyInfoService.getCoarLdnLocalInboxUrls(); - } - }) - ).subscribe((coarRestApiUrls: string[]) => { - if (coarRestApiUrls.length > 0) { - this.initPageLinks(coarRestApiUrls); - } - }); } ngOnInit(): void { @@ -60,6 +49,17 @@ export class HomePageComponent implements OnInit, OnDestroy { this.site$ = this.route.data.pipe( map((data) => data.site as Site), ); + // Get COAR REST API URLs from REST configuration + // only if COAR configuration is enabled + this.subs.push(this.notifyInfoService.isCoarConfigEnabled().pipe( + switchMap((coarLdnEnabled: boolean) => { + return coarLdnEnabled ? this.notifyInfoService.getCoarLdnLocalInboxUrls() : observableOf([]); + }), + ).subscribe((coarRestApiUrls: string[]) => { + if (coarRestApiUrls.length > 0) { + this.initPageLinks(coarRestApiUrls); + } + })); } /** @@ -91,6 +91,7 @@ export class HomePageComponent implements OnInit, OnDestroy { * It removes the inbox links from the head of the html. */ ngOnDestroy(): void { + this.subs.forEach((sub: Subscription) => sub.unsubscribe()); this.inboxLinks.forEach((link: LinkDefinition) => { this.linkHeadService.removeTag(`href='${link.href}'`); }); From 2123c3bbf5551bbfb95f5333604236afa2588dee Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Sun, 17 Mar 2024 23:09:02 +0100 Subject: [PATCH 3/3] Prevent /api/eperson/profiles/{userId} to be called when unauthenticated --- src/app/notifications/suggestions.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/notifications/suggestions.service.ts b/src/app/notifications/suggestions.service.ts index bcd3ac13424..a9e73cdc0e1 100644 --- a/src/app/notifications/suggestions.service.ts +++ b/src/app/notifications/suggestions.service.ts @@ -38,6 +38,7 @@ import { import { WorkspaceItem } from '../core/submission/models/workspaceitem.model'; import { WorkspaceitemDataService } from '../core/submission/workspaceitem-data.service'; import { + hasNoValue, hasValue, isNotEmpty, } from '../shared/empty.util'; @@ -165,6 +166,9 @@ export class SuggestionsService { * The EPerson id for which to retrieve suggestion targets */ public retrieveCurrentUserSuggestions(userUuid: string): Observable { + if (hasNoValue(userUuid)) { + return of([]); + } return this.researcherProfileService.findById(userUuid, true).pipe( getFirstCompletedRemoteData(), mergeMap((profile: RemoteData ) => {