w2p-86403 fix opensearch is disabled, router issues and links

This commit is contained in:
Nathan Buckingham
2022-02-25 12:14:16 -05:00
parent b8a96e48a7
commit b5943b48b4
3 changed files with 32 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
import { Injectable, RendererFactory2, ViewEncapsulation, Inject } from '@angular/core'; import { Injectable, RendererFactory2, ViewEncapsulation, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common'; import { DOCUMENT } from '@angular/common';
/**
* LinkHead Service injects <link> tag into the head element during runtime.
*/
@Injectable() @Injectable()
export class LinkHeadService { export class LinkHeadService {
constructor( constructor(

View File

@@ -14,10 +14,11 @@ import { environment } from '../../../../src/environments/environment';
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service'; import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
import { SortOptions } from '../../core/cache/models/sort-options.model'; import { SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationService } from '../../core/pagination/pagination.service';
import { Router } from '@angular/router';
/** /**
* The default pagination controls component. * The Rss feed button componenet.
*/ */
@Component({ @Component({
exportAs: 'rssComponent', exportAs: 'rssComponent',
@@ -41,6 +42,7 @@ export class RSSComponent implements OnInit, OnDestroy {
private linkHeadService: LinkHeadService, private linkHeadService: LinkHeadService,
private configurationService: ConfigurationDataService, private configurationService: ConfigurationDataService,
private searchConfigurationService: SearchConfigurationService, private searchConfigurationService: SearchConfigurationService,
private router: Router,
protected paginationService: PaginationService) { protected paginationService: PaginationService) {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@@ -53,22 +55,22 @@ export class RSSComponent implements OnInit, OnDestroy {
this.configurationService.findByPropertyName('websvc.opensearch.enable').pipe( this.configurationService.findByPropertyName('websvc.opensearch.enable').pipe(
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
).subscribe((result) => { ).subscribe((result) => {
const enabled = Boolean(result.payload.values[0]); const enabled = (result.payload.values[0] === 'true');
this.isEnabled$.next(enabled); this.isEnabled$.next(enabled);
}); });
this.searchConfigurationService.getCurrentQuery('').subscribe((query) => { this.searchConfigurationService.getCurrentQuery('').subscribe((query) => {
this.sortOption$ = this.paginationService.getCurrentSort(this.searchConfigurationService.paginationID, null, true); this.sortOption$ = this.paginationService.getCurrentSort(this.searchConfigurationService.paginationID, null, true);
this.sortOption$.subscribe((sort) => { this.sortOption$.subscribe((sort) => {
this.uuid = this.groupDataService.getUUIDFromString(window.location.href); this.uuid = this.groupDataService.getUUIDFromString(this.router.url);
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, sort, query); const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, sort, query);
this.addLinks(route);
this.linkHeadService.addTag({ this.linkHeadService.addTag({
href: route, href: environment.rest.baseUrl + '/opensearch/service',
type: 'application/atom+xml', type: 'application/atom+xml',
rel: 'alternate', rel: 'search',
title: 'Sitewide Atom feed' title: 'Dspace'
}); });
this.route$ = new BehaviorSubject<string>(route); this.route$ = new BehaviorSubject<string>(route);
}); });
@@ -91,4 +93,20 @@ export class RSSComponent implements OnInit, OnDestroy {
route = '/opensearch/' + route; route = '/opensearch/' + route;
return route; return route;
} }
addLinks(route: string): void {
this.linkHeadService.addTag({
href: route,
type: 'application/atom+xml',
rel: 'alternate',
title: 'Sitewide Atom feed'
});
route = route.replace('format=atom', 'format=rss');
this.linkHeadService.addTag({
href: route,
type: 'application/rss+xml',
rel: 'alternate',
title: 'Sitewide RSS feed'
});
}
} }

View File

@@ -174,6 +174,10 @@ import { DsSelectComponent } from './ds-select/ds-select.component';
import { LogInOidcComponent } from './log-in/methods/oidc/log-in-oidc.component'; import { LogInOidcComponent } from './log-in/methods/oidc/log-in-oidc.component';
import { ThemedItemListPreviewComponent } from './object-list/my-dspace-result-list-element/item-list-preview/themed-item-list-preview.component'; import { ThemedItemListPreviewComponent } from './object-list/my-dspace-result-list-element/item-list-preview/themed-item-list-preview.component';
import { RSSComponent } from './rss-feed/rss.component'; import { RSSComponent } from './rss-feed/rss.component';
import { SearchObjects } from './search/models/search-objects.model';
import { FacetConfigResponse } from './search/models/facet-config-response.model';
import { SearchResult } from './search/models/search-result.model';
import { FacetValues } from './search/models/facet-values.model';
const MODULES = [ const MODULES = [
CommonModule, CommonModule,