11import {
22 AsyncPipe ,
3- isPlatformServer ,
43 NgClass ,
54 NgIf ,
65} from '@angular/common' ;
76import {
87 Component ,
98 Inject ,
10- OnDestroy ,
119 OnInit ,
12- PLATFORM_ID ,
1310} from '@angular/core' ;
1411import { ActivatedRoute } from '@angular/router' ;
15- import { Observable } from 'rxjs' ;
16- import { Site } from '../core/shared/site.model' ;
17- import { isPlatformServer } from '@angular/common' ;
18- import { ServerResponseService } from '../core/services/server-response.service' ;
1912import { TranslateModule } from '@ngx-translate/core' ;
20- import {
21- EMPTY ,
22- Observable ,
23- } from 'rxjs' ;
24- import {
25- map ,
26- switchMap ,
27- } from 'rxjs/operators' ;
13+ import { Observable } from 'rxjs' ;
14+ import { map } from 'rxjs/operators' ;
2815import {
2916 APP_CONFIG ,
3017 AppConfig ,
3118} from 'src/config/app-config.interface' ;
3219
33- import { environment } from '../../environments/environment' ;
34- import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service' ;
35- import {
36- LinkDefinition ,
37- LinkHeadService ,
38- } from '../core/services/link-head.service' ;
39- import { ServerResponseService } from '../core/services/server-response.service' ;
4020import { Site } from '../core/shared/site.model' ;
4121import { SuggestionsPopupComponent } from '../notifications/suggestions-popup/suggestions-popup.component' ;
4222import { ConfigurationSearchPageComponent } from '../search-page/configuration-search-page.component' ;
43- import { isNotEmpty } from '../shared/empty.util' ;
44- import { APP_CONFIG , AppConfig } from 'src/config/app-config.interface' ;
23+ import { ThemedConfigurationSearchPageComponent } from '../search-page/themed-configuration-search-page.component' ;
4524import { HostWindowService } from '../shared/host-window.service' ;
46- import { SidebarService } from '../shared/sidebar/sidebar.service' ;
47-
4825import { ThemedSearchFormComponent } from '../shared/search-form/themed-search-form.component' ;
26+ import { PageWithSidebarComponent } from '../shared/sidebar/page-with-sidebar.component' ;
27+ import { SidebarService } from '../shared/sidebar/sidebar.service' ;
4928import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component' ;
29+ import { HomeCoarComponent } from './home-coar/home-coar.component' ;
5030import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component' ;
5131import { RecentItemListComponent } from './recent-item-list/recent-item-list.component' ;
5232import { ThemedTopLevelCommunityListComponent } from './top-level-community-list/themed-top-level-community-list.component' ;
@@ -56,47 +36,23 @@ import { ThemedTopLevelCommunityListComponent } from './top-level-community-list
5636 styleUrls : [ './home-page.component.scss' ] ,
5737 templateUrl : './home-page.component.html' ,
5838 standalone : true ,
59- imports : [ ThemedHomeNewsComponent , NgIf , ViewTrackerComponent , ThemedSearchFormComponent , ThemedTopLevelCommunityListComponent , RecentItemListComponent , AsyncPipe , TranslateModule , NgClass , ConfigurationSearchPageComponent , SuggestionsPopupComponent ] ,
39+ imports : [ ThemedHomeNewsComponent , NgIf , ViewTrackerComponent , ThemedSearchFormComponent , ThemedTopLevelCommunityListComponent , RecentItemListComponent , AsyncPipe , TranslateModule , NgClass , ConfigurationSearchPageComponent , SuggestionsPopupComponent , ThemedConfigurationSearchPageComponent , PageWithSidebarComponent , HomeCoarComponent ] ,
6040} )
61- export class HomePageComponent implements OnInit , OnDestroy {
41+ export class HomePageComponent implements OnInit {
6242
6343 site$ : Observable < Site > ;
6444 isXsOrSm$ : Observable < boolean > ;
6545 recentSubmissionspageSize : number ;
6646 showDiscoverFilters : boolean ;
67- /**
68- * An array of LinkDefinition objects representing inbox links for the home page.
69- */
70- inboxLinks : LinkDefinition [ ] = [ ] ;
7147
7248 constructor (
7349 @Inject ( APP_CONFIG ) protected appConfig : AppConfig ,
7450 protected route : ActivatedRoute ,
75- protected responseService : ServerResponseService ,
76- protected notifyInfoService : NotifyInfoService ,
77- protected linkHeadService : LinkHeadService ,
78- @Inject ( PLATFORM_ID ) private platformId : string ,
7951 protected sidebarService : SidebarService ,
8052 protected windowService : HostWindowService ,
81- @Inject ( PLATFORM_ID ) protected platformId : string ,
8253 ) {
8354 this . recentSubmissionspageSize = this . appConfig . homePage . recentSubmissions . pageSize ;
8455 this . showDiscoverFilters = this . appConfig . homePage . showDiscoverFilters ;
85- // Get COAR REST API URLs from REST configuration
86- // only if COAR configuration is enabled
87- this . notifyInfoService . isCoarConfigEnabled ( ) . pipe (
88- switchMap ( ( coarLdnEnabled : boolean ) => coarLdnEnabled ? this . notifyInfoService . getCoarLdnLocalInboxUrls ( ) : EMPTY , /*{
89- if (coarLdnEnabled) {
90- return this.notifyInfoService.getCoarLdnLocalInboxUrls();
91- } else {
92- return of([]);
93- }
94- }*/ ) ,
95- ) . subscribe ( ( coarRestApiUrls : string [ ] ) => {
96- if ( coarRestApiUrls ?. length > 0 ) {
97- this . initPageLinks ( coarRestApiUrls ) ;
98- }
99- } ) ;
10056 }
10157
10258 ngOnInit ( ) : void {
@@ -106,37 +62,4 @@ export class HomePageComponent implements OnInit, OnDestroy {
10662 ) ;
10763 }
10864
109- /**
110- * Initializes page links for COAR REST API URLs.
111- * @param coarRestApiUrls An array of COAR REST API URLs.
112- */
113- private initPageLinks ( coarRestApiUrls : string [ ] ) : void {
114- const rel = this . notifyInfoService . getInboxRelationLink ( ) ;
115- let links = '' ;
116- coarRestApiUrls . forEach ( ( coarRestApiUrl : string ) => {
117- // Add link to head
118- const tag : LinkDefinition = {
119- href : coarRestApiUrl ,
120- rel : rel ,
121- } ;
122- this . inboxLinks . push ( tag ) ;
123- this . linkHeadService . addTag ( tag ) ;
124-
125- links = links + ( isNotEmpty ( links ) ? ', ' : '' ) + `<${ coarRestApiUrl } > ; rel="${ rel } "` ;
126- } ) ;
127-
128- if ( isPlatformServer ( this . platformId ) ) {
129- // Add link to response header
130- this . responseService . setHeader ( 'Link' , links ) ;
131- }
132- }
133-
134- /**
135- * It removes the inbox links from the head of the html.
136- */
137- ngOnDestroy ( ) : void {
138- this . inboxLinks . forEach ( ( link : LinkDefinition ) => {
139- this . linkHeadService . removeTag ( `href='${ link . href } '` ) ;
140- } ) ;
141- }
14265}
0 commit comments