forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'w2p-112185_Fix-show-more-search-list' into 'atmire-base…
…-7.6' 112185: Add support to use next page to atmireshowmore See merge request templates/dspace-angular-7!153
- Loading branch information
Showing
9 changed files
with
170 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/app-atmire/core/shared/search/atmire-search.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE_ATMIRE and NOTICE_ATMIRE files at the root of the source | ||
* tree and available online at | ||
* | ||
* https://www.atmire.com/software-license/ | ||
*/ | ||
import { SearchService } from '../../../../app/core/shared/search/search.service'; | ||
import { Injectable } from '@angular/core'; | ||
import { RouteService } from '../../../../app/core/services/route.service'; | ||
import { RequestService } from '../../../../app/core/data/request.service'; | ||
import { RemoteDataBuildService } from '../../../../app/core/cache/builders/remote-data-build.service'; | ||
import { LinkService } from '../../../../app/core/cache/builders/link.service'; | ||
import { HALEndpointService } from '../../../../app/core/shared/hal-endpoint.service'; | ||
import { CommunityDataService } from '../../../../app/core/data/community-data.service'; | ||
import { DSpaceObjectDataService } from '../../../../app/core/data/dspace-object-data.service'; | ||
import { PaginationService } from '../../../../app/core/pagination/pagination.service'; | ||
import { SearchConfigurationService } from '../../../../app/core/shared/search/search-configuration.service'; | ||
import { PaginatedSearchOptions } from '../../../../app/shared/search/models/paginated-search-options.model'; | ||
import { Observable } from 'rxjs'; | ||
import { map, switchMap, take } from 'rxjs/operators'; | ||
import { hasValue, isNotEmpty } from '../../../../app/shared/empty.util'; | ||
import { Angulartics2 } from 'angulartics2'; | ||
import { DSpaceObject } from '../../../../app/core/shared/dspace-object.model'; | ||
import { FollowLinkConfig } from '../../../../app/shared/utils/follow-link-config.model'; | ||
import { RemoteData } from '../../../../app/core/data/remote-data'; | ||
import { SearchObjects } from '../../../../app/shared/search/models/search-objects.model'; | ||
import { URLCombiner } from '../../../../app/core/url-combiner/url-combiner'; | ||
import { GenericConstructor } from '../../../../app/core/shared/generic-constructor'; | ||
import { ResponseParsingService } from '../../../../app/core/data/parsing.service'; | ||
|
||
@Injectable() | ||
export class AtmireSearchService extends SearchService { | ||
constructor( | ||
protected routeService: RouteService, | ||
protected requestService: RequestService, | ||
protected rdb: RemoteDataBuildService, | ||
protected linkService: LinkService, | ||
protected halService: HALEndpointService, | ||
protected communityService: CommunityDataService, | ||
protected dspaceObjectService: DSpaceObjectDataService, | ||
protected paginationService: PaginationService, | ||
protected searchConfigurationService: SearchConfigurationService, | ||
protected angulartics2: Angulartics2, | ||
) { | ||
super(routeService, requestService, rdb, halService, dspaceObjectService, paginationService, searchConfigurationService, angulartics2); | ||
} | ||
|
||
|
||
/** | ||
* Overridden method to split up into searchByHref() to allow for searches with just a raw href | ||
*/ | ||
search<T extends DSpaceObject>(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<SearchObjects<T>>> { | ||
return this.searchByHref(this.getEndpoint(searchOptions), responseMsToLive, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); | ||
} | ||
|
||
/** | ||
* Search by href | ||
*/ | ||
searchByHref<T extends DSpaceObject>(href$: Observable<string>, responseMsToLive?: number, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<SearchObjects<T>>> { | ||
href$.pipe( | ||
take(1), | ||
map((href: string) => { | ||
const args = this.searchDataService.addEmbedParams(href, [], ...linksToFollow); | ||
if (isNotEmpty(args)) { | ||
return new URLCombiner(href, `?${args.join('&')}`).toString(); | ||
} else { | ||
return href; | ||
} | ||
}) | ||
).subscribe((url: string) => { | ||
const request = new this.request(this.requestService.generateRequestId(), url); | ||
|
||
const getResponseParserFn: () => GenericConstructor<ResponseParsingService> = () => { | ||
return this.parser; | ||
}; | ||
|
||
Object.assign(request, { | ||
responseMsToLive: hasValue(responseMsToLive) ? responseMsToLive : request.responseMsToLive, | ||
getResponseParser: getResponseParserFn, | ||
}); | ||
|
||
this.requestService.send(request, useCachedVersionIfAvailable); | ||
}); | ||
|
||
const sqr$ = href$.pipe( | ||
switchMap((href: string) => this.rdb.buildFromHref<SearchObjects<T>>(href)) | ||
); | ||
|
||
return this.directlyAttachIndexableObjects(sqr$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters