mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Add typedocs and websvc.opensearch.svccontext
This commit is contained in:
@@ -29,8 +29,6 @@ export class LinkHeadService {
|
||||
});
|
||||
|
||||
const link = renderer.createElement('link');
|
||||
console.log(tag);
|
||||
console.log(link);
|
||||
const head = this.document.head;
|
||||
|
||||
if (head === null) {
|
||||
|
@@ -96,17 +96,17 @@ describe('RssComponent', () => {
|
||||
});
|
||||
|
||||
it('should formulate the correct url given params in url', () => {
|
||||
const route = comp.formulateRoute(uuid, options, query);
|
||||
const route = comp.formulateRoute(uuid, 'opensearch', options, query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&scope=2cfcf65e-0a51-4bcb-8592-b8db7b064790&sort=dc.title&sort_direction=DESC&query=test');
|
||||
});
|
||||
|
||||
it('should skip uuid if its null', () => {
|
||||
const route = comp.formulateRoute(null, options, query);
|
||||
const route = comp.formulateRoute(null, 'opensearch', options, query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=test');
|
||||
});
|
||||
|
||||
it('should default to query * if none provided', () => {
|
||||
const route = comp.formulateRoute(null, options, null);
|
||||
const route = comp.formulateRoute(null, 'opensearch', options, null);
|
||||
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=*');
|
||||
});
|
||||
});
|
||||
|
@@ -45,10 +45,17 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
private router: Router,
|
||||
protected paginationService: PaginationService) {
|
||||
}
|
||||
/**
|
||||
* Removes the linktag created when the component gets removed from the page.
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.linkHeadService.removeTag("rel='alternate'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the link tags and the url to opensearch when the component is loaded.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.configuration$ = this.searchConfigurationService.getCurrentConfiguration('default');
|
||||
|
||||
@@ -58,26 +65,36 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
const enabled = (result.payload.values[0] === 'true');
|
||||
this.isEnabled$.next(enabled);
|
||||
});
|
||||
|
||||
this.searchConfigurationService.getCurrentQuery('').subscribe((query) => {
|
||||
this.sortOption$ = this.paginationService.getCurrentSort(this.searchConfigurationService.paginationID, null, true);
|
||||
this.sortOption$.subscribe((sort) => {
|
||||
this.uuid = this.groupDataService.getUUIDFromString(this.router.url);
|
||||
|
||||
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, sort, query);
|
||||
this.addLinks(route);
|
||||
this.linkHeadService.addTag({
|
||||
href: environment.rest.baseUrl + '/opensearch/service',
|
||||
type: 'application/atom+xml',
|
||||
rel: 'search',
|
||||
title: 'Dspace'
|
||||
this.configurationService.findByPropertyName('websvc.opensearch.svccontext').pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
).subscribe((url) => {
|
||||
this.searchConfigurationService.getCurrentQuery('').subscribe((query) => {
|
||||
this.sortOption$ = this.paginationService.getCurrentSort(this.searchConfigurationService.paginationID, null, true);
|
||||
this.sortOption$.subscribe((sort) => {
|
||||
this.uuid = this.groupDataService.getUUIDFromString(this.router.url);
|
||||
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, url.payload.values[0], sort, query);
|
||||
this.addLinks(route);
|
||||
this.linkHeadService.addTag({
|
||||
href: environment.rest.baseUrl + '/' + url.payload.values[0] + '/service',
|
||||
type: 'application/atom+xml',
|
||||
rel: 'search',
|
||||
title: 'Dspace'
|
||||
});
|
||||
this.route$ = new BehaviorSubject<string>(route);
|
||||
});
|
||||
this.route$ = new BehaviorSubject<string>(route);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
formulateRoute(uuid: string, sort: SortOptions, query: string): string {
|
||||
/**
|
||||
* Function created a route given the different params available to opensearch
|
||||
* @param uuid The uuid if a scope is present
|
||||
* @param opensearch openSearch uri
|
||||
* @param sort The sort options for the opensearch request
|
||||
* @param query The query string that was provided in the search
|
||||
* @returns The combine URL to opensearch
|
||||
*/
|
||||
formulateRoute(uuid: string, opensearch: string, sort: SortOptions, query: string): string {
|
||||
let route = 'search?format=atom';
|
||||
if (uuid) {
|
||||
route += `&scope=${uuid}`;
|
||||
@@ -90,10 +107,14 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
route += `&query=*`;
|
||||
}
|
||||
route = '/opensearch/' + route;
|
||||
route = '/' + opensearch +'/' + route;
|
||||
return route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates <link> tags in the header of the page
|
||||
* @param route The composed url to opensearch
|
||||
*/
|
||||
addLinks(route: string): void {
|
||||
this.linkHeadService.addTag({
|
||||
href: route,
|
||||
|
@@ -174,6 +174,7 @@ import { DsSelectComponent } from './ds-select/ds-select.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 { RSSComponent } from './rss-feed/rss.component';
|
||||
import { ExternalLinkMenuItemComponent } from './menu/menu-item/external-link-menu-item.component';
|
||||
|
||||
const MODULES = [
|
||||
CommonModule,
|
||||
|
@@ -1,17 +0,0 @@
|
||||
export const environment = {
|
||||
ui: {
|
||||
ssl: false,
|
||||
host: 'localhost',
|
||||
port: 18080,
|
||||
nameSpace: '/'
|
||||
},
|
||||
rest: {
|
||||
ssl: false,
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
nameSpace: '/server'
|
||||
},
|
||||
universal: {
|
||||
preboot: false
|
||||
}
|
||||
};
|
@@ -1,17 +0,0 @@
|
||||
export const environment = {
|
||||
ui: {
|
||||
ssl: false,
|
||||
host: 'localhost',
|
||||
port: 18080,
|
||||
nameSpace: '/'
|
||||
},
|
||||
rest: {
|
||||
ssl: false,
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
nameSpace: '/server'
|
||||
},
|
||||
universal: {
|
||||
preboot: true
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user