mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
fixes after merge + tslint changes
This commit is contained in:
@@ -11,14 +11,14 @@ import { Site } from '../core/shared/site.model';
|
|||||||
})
|
})
|
||||||
export class HomePageComponent implements OnInit {
|
export class HomePageComponent implements OnInit {
|
||||||
|
|
||||||
site$:Observable<Site>;
|
site$: Observable<Site>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route:ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit():void {
|
ngOnInit(): void {
|
||||||
this.site$ = this.route.data.pipe(
|
this.site$ = this.route.data.pipe(
|
||||||
map((data) => data.site as Site),
|
map((data) => data.site as Site),
|
||||||
);
|
);
|
||||||
|
@@ -10,7 +10,7 @@ import { take } from 'rxjs/operators';
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HomePageResolver implements Resolve<Site> {
|
export class HomePageResolver implements Resolve<Site> {
|
||||||
constructor(private siteService:SiteDataService) {
|
constructor(private siteService: SiteDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +19,7 @@ export class HomePageResolver implements Resolve<Site> {
|
|||||||
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
|
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
|
||||||
* @returns Observable<Site> Emits the found Site object, or an error if something went wrong
|
* @returns Observable<Site> Emits the found Site object, or an error if something went wrong
|
||||||
*/
|
*/
|
||||||
resolve(route:ActivatedRouteSnapshot, state:RouterStateSnapshot):Observable<Site> | Promise<Site> | Site {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Site> | Promise<Site> | Site {
|
||||||
return this.siteService.find().pipe(take(1));
|
return this.siteService.find().pipe(take(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ export class LookupGuard implements CanActivate {
|
|||||||
constructor(private dsoService: DsoRedirectDataService) {
|
constructor(private dsoService: DsoRedirectDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state:RouterStateSnapshot): Observable<boolean> {
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||||
const params = this.getLookupParams(route);
|
const params = this.getLookupParams(route);
|
||||||
return this.dsoService.findById(params.id, params.type).pipe(
|
return this.dsoService.findById(params.id, params.type).pipe(
|
||||||
map((response: RemoteData<FindByIDRequest>) => response.hasFailed)
|
map((response: RemoteData<FindByIDRequest>) => response.hasFailed)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { configureSearchComponentTestingModule } from './search.component.spec';
|
import { configureSearchComponentTestingModule } from './search.component.spec';
|
||||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||||
|
|
||||||
describe('FilteredSearchPageComponent', () => {
|
describe('FilteredSearchPageComponent', () => {
|
||||||
let comp: FilteredSearchPageComponent;
|
let comp: FilteredSearchPageComponent;
|
||||||
|
@@ -2,16 +2,17 @@ import { Component, Inject, OnInit } from '@angular/core';
|
|||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
import { filter, map, switchMap } from 'rxjs/operators';
|
import { filter, map, switchMap } from 'rxjs/operators';
|
||||||
import { SearchComponent } from './search.component';
|
import { SearchComponent } from './search.component';
|
||||||
import { SearchService } from './search-service/search.service';
|
|
||||||
import { SidebarService } from '../shared/sidebar/sidebar.service';
|
import { SidebarService } from '../shared/sidebar/sidebar.service';
|
||||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
|
||||||
import { HostWindowService } from '../shared/host-window.service';
|
import { HostWindowService } from '../shared/host-window.service';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||||
import { RouteService } from '../core/services/route.service';
|
import { RouteService } from '../core/services/route.service';
|
||||||
import { hasValue } from '../shared/empty.util';
|
import { hasValue } from '../shared/empty.util';
|
||||||
import { SearchQueryResponse } from './search-service/search-query-response.model';
|
|
||||||
import { SearchSuccessResponse } from '../core/cache/response.models';
|
import { SearchSuccessResponse } from '../core/cache/response.models';
|
||||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchService } from '../core/shared/search/search.service';
|
||||||
|
import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model';
|
||||||
|
import { SearchQueryResponse } from '../shared/search/search-query-response.model';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component triggers a page view statistic
|
* This component triggers a page view statistic
|
||||||
@@ -30,17 +31,18 @@ import { PaginatedSearchOptions } from './paginated-search-options.model';
|
|||||||
export class SearchTrackerComponent extends SearchComponent implements OnInit {
|
export class SearchTrackerComponent extends SearchComponent implements OnInit {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected service:SearchService,
|
protected service: SearchService,
|
||||||
protected sidebarService:SidebarService,
|
protected sidebarService: SidebarService,
|
||||||
protected windowService:HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService:SearchConfigurationService,
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||||
protected routeService:RouteService,
|
protected routeService: RouteService,
|
||||||
public angulartics2:Angulartics2
|
public angulartics2: Angulartics2,
|
||||||
|
protected router: Router
|
||||||
) {
|
) {
|
||||||
super(service, sidebarService, windowService, searchConfigService, routeService);
|
super(service, sidebarService, windowService, searchConfigService, routeService, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit():void {
|
ngOnInit(): void {
|
||||||
// super.ngOnInit();
|
// super.ngOnInit();
|
||||||
this.getSearchOptions().pipe(
|
this.getSearchOptions().pipe(
|
||||||
switchMap((options) => this.service.searchEntries(options)
|
switchMap((options) => this.service.searchEntries(options)
|
||||||
@@ -58,9 +60,9 @@ export class SearchTrackerComponent extends SearchComponent implements OnInit {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.subscribe((entry) => {
|
.subscribe((entry) => {
|
||||||
const config:PaginatedSearchOptions = entry.searchOptions;
|
const config: PaginatedSearchOptions = entry.searchOptions;
|
||||||
const searchQueryResponse:SearchQueryResponse = entry.response;
|
const searchQueryResponse: SearchQueryResponse = entry.response;
|
||||||
const filters:Array<{ filter:string, operator:string, value:string, label:string; }> = [];
|
const filters: Array<{ filter: string, operator: string, value: string, label: string; }> = [];
|
||||||
const appliedFilters = searchQueryResponse.appliedFilters || [];
|
const appliedFilters = searchQueryResponse.appliedFilters || [];
|
||||||
for (let i = 0, filtersLength = appliedFilters.length; i < filtersLength; i++) {
|
for (let i = 0, filtersLength = appliedFilters.length; i < filtersLength; i++) {
|
||||||
const appliedFilter = appliedFilters[i];
|
const appliedFilter = appliedFilters[i];
|
||||||
|
@@ -46,5 +46,9 @@
|
|||||||
[scopes]="(scopeListRD$ | async)"
|
[scopes]="(scopeListRD$ | async)"
|
||||||
[inPlaceSearch]="inPlaceSearch">
|
[inPlaceSearch]="inPlaceSearch">
|
||||||
</ds-search-form>
|
</ds-search-form>
|
||||||
<ds-search-labels *ngIf="searchEnabled" [inPlaceSearch]="inPlaceSearch"></ds-search-labels>
|
<div class="row mb-3 mb-md-1">
|
||||||
|
<div class="labels col-sm-9 offset-sm-3">
|
||||||
|
<ds-search-labels *ngIf="searchEnabled" [inPlaceSearch]="inPlaceSearch"></ds-search-labels>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@@ -6,15 +6,17 @@ import { RemoteData } from '../core/data/remote-data';
|
|||||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
||||||
import { pushInOut } from '../shared/animations/push';
|
import { pushInOut } from '../shared/animations/push';
|
||||||
import { HostWindowService } from '../shared/host-window.service';
|
import { HostWindowService } from '../shared/host-window.service';
|
||||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
|
||||||
import { SearchResult } from './search-result.model';
|
|
||||||
import { SearchService } from './search-service/search.service';
|
|
||||||
import { SidebarService } from '../shared/sidebar/sidebar.service';
|
import { SidebarService } from '../shared/sidebar/sidebar.service';
|
||||||
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
||||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
|
||||||
import { getSucceededRemoteData } from '../core/shared/operators';
|
import { getSucceededRemoteData } from '../core/shared/operators';
|
||||||
import { RouteService } from '../core/services/route.service';
|
import { RouteService } from '../core/services/route.service';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||||
|
import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model';
|
||||||
|
import { SearchResult } from '../shared/search/search-result.model';
|
||||||
|
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchService } from '../core/shared/search/search.service';
|
||||||
|
import { currentPath } from '../shared/utils/route.utils';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search',
|
selector: 'ds-search',
|
||||||
@@ -96,7 +98,8 @@ export class SearchComponent implements OnInit {
|
|||||||
protected sidebarService: SidebarService,
|
protected sidebarService: SidebarService,
|
||||||
protected windowService: HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||||
protected routeService: RouteService) {
|
protected routeService: RouteService,
|
||||||
|
protected router: Router) {
|
||||||
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +162,7 @@ export class SearchComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
private getSearchLink(): string {
|
private getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.service.getSearchLink();
|
return this.service.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
return http.url && http.url.endsWith('/authn/logout');
|
return http.url && http.url.endsWith('/authn/logout');
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeAuthStatusObject(authenticated:boolean, accessToken?: string, error?: string): AuthStatus {
|
private makeAuthStatusObject(authenticated: boolean, accessToken?: string, error?: string): AuthStatus {
|
||||||
const authStatus = new AuthStatus();
|
const authStatus = new AuthStatus();
|
||||||
authStatus.id = null;
|
authStatus.id = null;
|
||||||
authStatus.okay = true;
|
authStatus.okay = true;
|
||||||
|
@@ -17,5 +17,5 @@ export interface ChangeAnalyzer<T extends CacheableObject> {
|
|||||||
* @param {NormalizedObject} object2
|
* @param {NormalizedObject} object2
|
||||||
* The second object to compare
|
* The second object to compare
|
||||||
*/
|
*/
|
||||||
diff(object1: T | NormalizedObject<T>, object2: T | NormalizedObject<T>): Operation[];
|
diff(object1: T | NormalizedObject<T>, object2: T | NormalizedObject<T>): Operation[];
|
||||||
}
|
}
|
||||||
|
@@ -19,12 +19,12 @@ import { PaginatedList } from './paginated-list';
|
|||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from './remote-data';
|
||||||
|
|
||||||
describe('SiteDataService', () => {
|
describe('SiteDataService', () => {
|
||||||
let scheduler:TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
let service:SiteDataService;
|
let service: SiteDataService;
|
||||||
let halService:HALEndpointService;
|
let halService: HALEndpointService;
|
||||||
let requestService:RequestService;
|
let requestService: RequestService;
|
||||||
let rdbService:RemoteDataBuildService;
|
let rdbService: RemoteDataBuildService;
|
||||||
let objectCache:ObjectCacheService;
|
let objectCache: ObjectCacheService;
|
||||||
|
|
||||||
const testObject = Object.assign(new Site(), {
|
const testObject = Object.assign(new Site(), {
|
||||||
uuid: '9b4f22f4-164a-49db-8817-3316b6ee5746',
|
uuid: '9b4f22f4-164a-49db-8817-3316b6ee5746',
|
||||||
@@ -33,7 +33,7 @@ describe('SiteDataService', () => {
|
|||||||
const requestUUID = '34cfed7c-f597-49ef-9cbe-ea351f0023c2';
|
const requestUUID = '34cfed7c-f597-49ef-9cbe-ea351f0023c2';
|
||||||
const options = Object.assign(new FindAllOptions(), {});
|
const options = Object.assign(new FindAllOptions(), {});
|
||||||
|
|
||||||
const getRequestEntry$ = (successful:boolean, statusCode:number, statusText:string) => {
|
const getRequestEntry$ = (successful: boolean, statusCode: number, statusText: string) => {
|
||||||
return observableOf({
|
return observableOf({
|
||||||
response: new RestResponse(successful, statusCode, statusText)
|
response: new RestResponse(successful, statusCode, statusText)
|
||||||
} as RequestEntry);
|
} as RequestEntry);
|
||||||
|
@@ -22,47 +22,41 @@ import { getSucceededRemoteData } from '../shared/operators';
|
|||||||
* Service responsible for handling requests related to the Site object
|
* Service responsible for handling requests related to the Site object
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SiteDataService extends DataService<Site> {
|
export class SiteDataService extends DataService<Site> {
|
||||||
|
|
||||||
protected linkPath = 'sites';
|
protected linkPath = 'sites';
|
||||||
protected forceBypassCache = false;
|
protected forceBypassCache = false;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService:RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdbService:RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected dataBuildService:NormalizedObjectBuildService,
|
protected dataBuildService: NormalizedObjectBuildService,
|
||||||
protected store:Store<CoreState>,
|
protected store: Store<CoreState>,
|
||||||
protected objectCache:ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService:HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService:NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected http:HttpClient,
|
protected http: HttpClient,
|
||||||
protected comparator:DSOChangeAnalyzer<Site>,
|
protected comparator: DSOChangeAnalyzer<Site>,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the endpoint for browsing the site object
|
* Get the endpoint for browsing the site object
|
||||||
* @param {FindAllOptions} options
|
* @param {FindAllOptions} options
|
||||||
* @param {Observable<string>} linkPath
|
* @param {Observable<string>} linkPath
|
||||||
*/
|
*/
|
||||||
getBrowseEndpoint(options:FindAllOptions, linkPath?:string):Observable<string> {
|
getBrowseEndpoint(options: FindAllOptions, linkPath?: string): Observable<string> {
|
||||||
return this.halService.getEndpoint(this.linkPath);
|
return this.halService.getEndpoint(this.linkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the Site Object
|
* Retrieve the Site Object
|
||||||
*/
|
*/
|
||||||
find():Observable<Site> {
|
find(): Observable<Site> {
|
||||||
return this.findAll().pipe(
|
return this.findAll().pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
map((remoteData:RemoteData<PaginatedList<Site>>) => remoteData.payload),
|
map((remoteData: RemoteData<PaginatedList<Site>>) => remoteData.payload),
|
||||||
map((list:PaginatedList<Site>) => list.page[0])
|
map((list: PaginatedList<Site>) => list.page[0])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,9 +89,9 @@ export class SearchService implements OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getEndpoint(searchOptions?:PaginatedSearchOptions):Observable<string> {
|
getEndpoint(searchOptions?: PaginatedSearchOptions): Observable<string> {
|
||||||
return this.halService.getEndpoint(this.searchLinkPath).pipe(
|
return this.halService.getEndpoint(this.searchLinkPath).pipe(
|
||||||
map((url:string) => {
|
map((url: string) => {
|
||||||
if (hasValue(searchOptions)) {
|
if (hasValue(searchOptions)) {
|
||||||
return (searchOptions as PaginatedSearchOptions).toRestUrl(url);
|
return (searchOptions as PaginatedSearchOptions).toRestUrl(url);
|
||||||
} else {
|
} else {
|
||||||
@@ -117,16 +117,15 @@ export class SearchService implements OnDestroy {
|
|||||||
* @param responseMsToLive The amount of milliseconds for the response to live in cache
|
* @param responseMsToLive The amount of milliseconds for the response to live in cache
|
||||||
* @returns {Observable<RequestEntry>} Emits an observable with the request entries
|
* @returns {Observable<RequestEntry>} Emits an observable with the request entries
|
||||||
*/
|
*/
|
||||||
searchEntries(searchOptions?: PaginatedSearchOptions, responseMsToLive?:number)
|
searchEntries(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number): Observable<{searchOptions: PaginatedSearchOptions, requestEntry: RequestEntry}> {
|
||||||
:Observable<{searchOptions: PaginatedSearchOptions, requestEntry: RequestEntry}> {
|
|
||||||
|
|
||||||
const hrefObs = this.getEndpoint(searchOptions);
|
const hrefObs = this.getEndpoint(searchOptions);
|
||||||
|
|
||||||
const requestObs = hrefObs.pipe(
|
const requestObs = hrefObs.pipe(
|
||||||
map((url:string) => {
|
map((url: string) => {
|
||||||
const request = new this.request(this.requestService.generateRequestId(), url);
|
const request = new this.request(this.requestService.generateRequestId(), url);
|
||||||
|
|
||||||
const getResponseParserFn:() => GenericConstructor<ResponseParsingService> = () => {
|
const getResponseParserFn: () => GenericConstructor<ResponseParsingService> = () => {
|
||||||
return this.parser;
|
return this.parser;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,8 +138,8 @@ export class SearchService implements OnDestroy {
|
|||||||
configureRequest(this.requestService),
|
configureRequest(this.requestService),
|
||||||
);
|
);
|
||||||
return requestObs.pipe(
|
return requestObs.pipe(
|
||||||
switchMap((request:RestRequest) => this.requestService.getByHref(request.href)),
|
switchMap((request: RestRequest) => this.requestService.getByHref(request.href)),
|
||||||
map(((requestEntry:RequestEntry) => ({
|
map(((requestEntry: RequestEntry) => ({
|
||||||
searchOptions: searchOptions,
|
searchOptions: searchOptions,
|
||||||
requestEntry: requestEntry
|
requestEntry: requestEntry
|
||||||
})))
|
})))
|
||||||
@@ -152,16 +151,15 @@ export class SearchService implements OnDestroy {
|
|||||||
* @param searchEntries: The request entries from the search method
|
* @param searchEntries: The request entries from the search method
|
||||||
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
||||||
*/
|
*/
|
||||||
getPaginatedResults(searchEntries:Observable<{ searchOptions:PaginatedSearchOptions, requestEntry:RequestEntry }>)
|
getPaginatedResults(searchEntries: Observable<{ searchOptions: PaginatedSearchOptions, requestEntry: RequestEntry }>): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||||
:Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
const requestEntryObs: Observable<RequestEntry> = searchEntries.pipe(
|
||||||
const requestEntryObs:Observable<RequestEntry> = searchEntries.pipe(
|
|
||||||
map((entry) => entry.requestEntry),
|
map((entry) => entry.requestEntry),
|
||||||
);
|
);
|
||||||
|
|
||||||
// get search results from response cache
|
// get search results from response cache
|
||||||
const sqrObs:Observable<SearchQueryResponse> = requestEntryObs.pipe(
|
const sqrObs: Observable<SearchQueryResponse> = requestEntryObs.pipe(
|
||||||
filterSuccessfulResponses(),
|
filterSuccessfulResponses(),
|
||||||
map((response:SearchSuccessResponse) => response.results),
|
map((response: SearchSuccessResponse) => response.results),
|
||||||
);
|
);
|
||||||
|
|
||||||
// turn dspace href from search results to effective list of DSpaceObjects
|
// turn dspace href from search results to effective list of DSpaceObjects
|
||||||
|
@@ -1,16 +1,11 @@
|
|||||||
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { MetadataRepresentation } from '../../../../../core/shared/metadata-representation/metadata-representation.model';
|
import { MetadataRepresentation } from '../../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||||
import {
|
import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../../../../core/shared/operators';
|
||||||
getAllSucceededRemoteData,
|
|
||||||
getRemoteDataPayload,
|
|
||||||
getSucceededRemoteData
|
|
||||||
} from '../../../../../core/shared/operators';
|
|
||||||
import { hasValue, isNotEmpty } from '../../../../empty.util';
|
import { hasValue, isNotEmpty } from '../../../../empty.util';
|
||||||
import { of as observableOf, Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { filter, map } from 'rxjs/operators';
|
import { filter } from 'rxjs/operators';
|
||||||
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
|
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
|
||||||
import { combineLatest as observableCombineLatest, of } from 'rxjs';
|
|
||||||
import { MetadataValue } from '../../../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../../../core/shared/metadata.models';
|
||||||
import { ItemMetadataRepresentation } from '../../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
import { ItemMetadataRepresentation } from '../../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||||
import { RelationshipOptions } from '../../models/relationship-options.model';
|
import { RelationshipOptions } from '../../models/relationship-options.model';
|
||||||
|
@@ -78,7 +78,7 @@ describe('LangSwitchComponent', () => {
|
|||||||
}).compileComponents()
|
}).compileComponents()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
translate = TestBed.get(TranslateService);
|
translate = TestBed.get(TranslateService);
|
||||||
translate.addLangs(mockConfig.languages.filter((langConfig:LangConfig) => langConfig.active === true).map((a) => a.code));
|
translate.addLangs(mockConfig.languages.filter((langConfig: LangConfig) => langConfig.active === true).map((a) => a.code));
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
http = TestBed.get(HttpTestingController);
|
http = TestBed.get(HttpTestingController);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* tslint:disable:no-empty */
|
/* tslint:disable:no-empty */
|
||||||
export class AngularticsMock {
|
export class AngularticsMock {
|
||||||
public eventTrack(action, properties) { }
|
public eventTrack(action, properties) { }
|
||||||
public startTracking():void {}
|
public startTracking(): void {}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import { getSucceededRemoteData } from '../../../../../core/shared/operators';
|
|||||||
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
|
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
|
||||||
import { SearchOptions } from '../../../search-options.model';
|
import { SearchOptions } from '../../../search-options.model';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../../+my-dspace-page/my-dspace-page.component';
|
||||||
|
import { currentPath } from '../../../../utils/route.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-facet-filter',
|
selector: 'ds-search-facet-filter',
|
||||||
@@ -185,7 +186,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return '';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Params } from '@angular/router';
|
import { Params, Router } from '@angular/router';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { hasValue, isNotEmpty } from '../../../empty.util';
|
import { hasValue, isNotEmpty } from '../../../empty.util';
|
||||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||||
|
import { currentPath } from '../../../utils/route.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-label',
|
selector: 'ds-search-label',
|
||||||
@@ -25,7 +26,7 @@ export class SearchLabelComponent implements OnInit {
|
|||||||
* Initialize the instance variable
|
* Initialize the instance variable
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private searchService: SearchService) {
|
private searchService: SearchService, private router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -55,7 +56,7 @@ export class SearchLabelComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
private getSearchLink(): string {
|
private getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|||||||
* Represents a single selected option in a sidebar filter
|
* Represents a single selected option in a sidebar filter
|
||||||
*/
|
*/
|
||||||
export class SidebarFilterSelectedOptionComponent {
|
export class SidebarFilterSelectedOptionComponent {
|
||||||
@Input() label:string;
|
@Input() label: string;
|
||||||
@Output() click:EventEmitter<any> = new EventEmitter<any>();
|
@Output() click: EventEmitter<any> = new EventEmitter<any>();
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ export class FilterInitializeAction extends SidebarFilterAction {
|
|||||||
type = SidebarFilterActionTypes.INITIALIZE;
|
type = SidebarFilterActionTypes.INITIALIZE;
|
||||||
initiallyExpanded;
|
initiallyExpanded;
|
||||||
|
|
||||||
constructor(name:string, initiallyExpanded:boolean) {
|
constructor(name: string, initiallyExpanded: boolean) {
|
||||||
super(name);
|
super(name);
|
||||||
this.initiallyExpanded = initiallyExpanded;
|
this.initiallyExpanded = initiallyExpanded;
|
||||||
}
|
}
|
||||||
|
@@ -15,13 +15,13 @@ import { slide } from '../../animations/slide';
|
|||||||
*/
|
*/
|
||||||
export class SidebarFilterComponent implements OnInit {
|
export class SidebarFilterComponent implements OnInit {
|
||||||
|
|
||||||
@Input() name:string;
|
@Input() name: string;
|
||||||
@Input() type:string;
|
@Input() type: string;
|
||||||
@Input() label:string;
|
@Input() label: string;
|
||||||
@Input() expanded = true;
|
@Input() expanded = true;
|
||||||
@Input() singleValue = false;
|
@Input() singleValue = false;
|
||||||
@Input() selectedValues:Observable<string[]>;
|
@Input() selectedValues: Observable<string[]>;
|
||||||
@Output() removeValue:EventEmitter<any> = new EventEmitter<any>();
|
@Output() removeValue: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True when the filter is 100% collapsed in the UI
|
* True when the filter is 100% collapsed in the UI
|
||||||
@@ -31,10 +31,10 @@ export class SidebarFilterComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Emits true when the filter is currently collapsed in the store
|
* Emits true when the filter is currently collapsed in the store
|
||||||
*/
|
*/
|
||||||
collapsed$:Observable<boolean>;
|
collapsed$: Observable<boolean>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected filterService:SidebarFilterService,
|
protected filterService: SidebarFilterService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ export class SidebarFilterComponent implements OnInit {
|
|||||||
* Method to change this.collapsed to false when the slide animation ends and is sliding open
|
* Method to change this.collapsed to false when the slide animation ends and is sliding open
|
||||||
* @param event The animation event
|
* @param event The animation event
|
||||||
*/
|
*/
|
||||||
finishSlide(event:any):void {
|
finishSlide(event: any): void {
|
||||||
if (event.fromState === 'collapsed') {
|
if (event.fromState === 'collapsed') {
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,13 @@ export class SidebarFilterComponent implements OnInit {
|
|||||||
* Method to change this.collapsed to true when the slide animation starts and is sliding closed
|
* Method to change this.collapsed to true when the slide animation starts and is sliding closed
|
||||||
* @param event The animation event
|
* @param event The animation event
|
||||||
*/
|
*/
|
||||||
startSlide(event:any):void {
|
startSlide(event: any): void {
|
||||||
if (event.toState === 'collapsed') {
|
if (event.toState === 'collapsed') {
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit():void {
|
ngOnInit(): void {
|
||||||
this.closed = !this.expanded;
|
this.closed = !this.expanded;
|
||||||
this.initializeFilter();
|
this.initializeFilter();
|
||||||
this.collapsed$ = this.isCollapsed();
|
this.collapsed$ = this.isCollapsed();
|
||||||
@@ -82,7 +82,7 @@ export class SidebarFilterComponent implements OnInit {
|
|||||||
* Checks if the filter is currently collapsed
|
* Checks if the filter is currently collapsed
|
||||||
* @returns {Observable<boolean>} Emits true when the current state of the filter is collapsed, false when it's expanded
|
* @returns {Observable<boolean>} Emits true when the current state of the filter is collapsed, false when it's expanded
|
||||||
*/
|
*/
|
||||||
private isCollapsed():Observable<boolean> {
|
private isCollapsed(): Observable<boolean> {
|
||||||
return this.filterService.isCollapsed(this.name);
|
return this.filterService.isCollapsed(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,17 +8,17 @@ import {
|
|||||||
* Interface that represents the state for a single filters
|
* Interface that represents the state for a single filters
|
||||||
*/
|
*/
|
||||||
export interface SidebarFilterState {
|
export interface SidebarFilterState {
|
||||||
filterCollapsed:boolean,
|
filterCollapsed: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that represents the state for all available filters
|
* Interface that represents the state for all available filters
|
||||||
*/
|
*/
|
||||||
export interface SidebarFiltersState {
|
export interface SidebarFiltersState {
|
||||||
[name:string]:SidebarFilterState
|
[name: string]: SidebarFilterState
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState:SidebarFiltersState = Object.create(null);
|
const initialState: SidebarFiltersState = Object.create(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a filter action on the current state
|
* Performs a filter action on the current state
|
||||||
@@ -26,7 +26,7 @@ const initialState:SidebarFiltersState = Object.create(null);
|
|||||||
* @param {SidebarFilterAction} action The action that should be performed
|
* @param {SidebarFilterAction} action The action that should be performed
|
||||||
* @returns {SidebarFiltersState} The state after the action is performed
|
* @returns {SidebarFiltersState} The state after the action is performed
|
||||||
*/
|
*/
|
||||||
export function sidebarFilterReducer(state = initialState, action:SidebarFilterAction):SidebarFiltersState {
|
export function sidebarFilterReducer(state = initialState, action: SidebarFilterAction): SidebarFiltersState {
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ import { hasValue } from '../../empty.util';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SidebarFilterService {
|
export class SidebarFilterService {
|
||||||
|
|
||||||
constructor(private store:Store<SidebarFilterState>) {
|
constructor(private store: Store<SidebarFilterState>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +24,7 @@ export class SidebarFilterService {
|
|||||||
* @param {string} filter The filter for which the action is dispatched
|
* @param {string} filter The filter for which the action is dispatched
|
||||||
* @param {boolean} expanded If the filter should be open from the start
|
* @param {boolean} expanded If the filter should be open from the start
|
||||||
*/
|
*/
|
||||||
public initializeFilter(filter:string, expanded:boolean):void {
|
public initializeFilter(filter: string, expanded: boolean): void {
|
||||||
this.store.dispatch(new FilterInitializeAction(filter, expanded));
|
this.store.dispatch(new FilterInitializeAction(filter, expanded));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ export class SidebarFilterService {
|
|||||||
* Dispatches a collapse action to the store for a given filter
|
* Dispatches a collapse action to the store for a given filter
|
||||||
* @param {string} filterName The filter for which the action is dispatched
|
* @param {string} filterName The filter for which the action is dispatched
|
||||||
*/
|
*/
|
||||||
public collapse(filterName:string):void {
|
public collapse(filterName: string): void {
|
||||||
this.store.dispatch(new FilterCollapseAction(filterName));
|
this.store.dispatch(new FilterCollapseAction(filterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ export class SidebarFilterService {
|
|||||||
* Dispatches an expand action to the store for a given filter
|
* Dispatches an expand action to the store for a given filter
|
||||||
* @param {string} filterName The filter for which the action is dispatched
|
* @param {string} filterName The filter for which the action is dispatched
|
||||||
*/
|
*/
|
||||||
public expand(filterName:string):void {
|
public expand(filterName: string): void {
|
||||||
this.store.dispatch(new FilterExpandAction(filterName));
|
this.store.dispatch(new FilterExpandAction(filterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export class SidebarFilterService {
|
|||||||
* Dispatches a toggle action to the store for a given filter
|
* Dispatches a toggle action to the store for a given filter
|
||||||
* @param {string} filterName The filter for which the action is dispatched
|
* @param {string} filterName The filter for which the action is dispatched
|
||||||
*/
|
*/
|
||||||
public toggle(filterName:string):void {
|
public toggle(filterName: string): void {
|
||||||
this.store.dispatch(new FilterToggleAction(filterName));
|
this.store.dispatch(new FilterToggleAction(filterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +57,10 @@ export class SidebarFilterService {
|
|||||||
* @param {string} filterName The filtername for which the collapsed state is checked
|
* @param {string} filterName The filtername for which the collapsed state is checked
|
||||||
* @returns {Observable<boolean>} Emits the current collapsed state of the given filter, if it's unavailable, return false
|
* @returns {Observable<boolean>} Emits the current collapsed state of the given filter, if it's unavailable, return false
|
||||||
*/
|
*/
|
||||||
isCollapsed(filterName:string):Observable<boolean> {
|
isCollapsed(filterName: string): Observable<boolean> {
|
||||||
return this.store.pipe(
|
return this.store.pipe(
|
||||||
select(filterByNameSelector(filterName)),
|
select(filterByNameSelector(filterName)),
|
||||||
map((object:SidebarFilterState) => {
|
map((object: SidebarFilterState) => {
|
||||||
if (object) {
|
if (object) {
|
||||||
return object.filterCollapsed;
|
return object.filterCollapsed;
|
||||||
} else {
|
} else {
|
||||||
@@ -73,14 +73,14 @@ export class SidebarFilterService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterStateSelector = (state:SidebarFiltersState) => state.sidebarFilter;
|
const filterStateSelector = (state: SidebarFiltersState) => state.sidebarFilter;
|
||||||
|
|
||||||
function filterByNameSelector(name:string):MemoizedSelector<SidebarFiltersState, SidebarFilterState> {
|
function filterByNameSelector(name: string): MemoizedSelector<SidebarFiltersState, SidebarFilterState> {
|
||||||
return keySelector<SidebarFilterState>(name);
|
return keySelector<SidebarFilterState>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function keySelector<T>(key:string):MemoizedSelector<SidebarFiltersState, T> {
|
export function keySelector<T>(key: string): MemoizedSelector<SidebarFiltersState, T> {
|
||||||
return createSelector(filterStateSelector, (state:SidebarFilterState) => {
|
return createSelector(filterStateSelector, (state: SidebarFilterState) => {
|
||||||
if (hasValue(state)) {
|
if (hasValue(state)) {
|
||||||
return state[key];
|
return state[key];
|
||||||
} else {
|
} else {
|
||||||
|
@@ -7,8 +7,8 @@ import { HostWindowService } from '../host-window.service';
|
|||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
describe('PageWithSidebarComponent', () => {
|
describe('PageWithSidebarComponent', () => {
|
||||||
let comp:PageWithSidebarComponent;
|
let comp: PageWithSidebarComponent;
|
||||||
let fixture:ComponentFixture<PageWithSidebarComponent>;
|
let fixture: ComponentFixture<PageWithSidebarComponent>;
|
||||||
|
|
||||||
const sidebarService = {
|
const sidebarService = {
|
||||||
isCollapsed: observableOf(true),
|
isCollapsed: observableOf(true),
|
||||||
@@ -42,7 +42,7 @@ describe('PageWithSidebarComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when sidebarCollapsed is true in mobile view', () => {
|
describe('when sidebarCollapsed is true in mobile view', () => {
|
||||||
let menu:HTMLElement;
|
let menu: HTMLElement;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
menu = fixture.debugElement.query(By.css('#mock-id-sidebar-content')).nativeElement;
|
menu = fixture.debugElement.query(By.css('#mock-id-sidebar-content')).nativeElement;
|
||||||
@@ -58,7 +58,7 @@ describe('PageWithSidebarComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when sidebarCollapsed is false in mobile view', () => {
|
describe('when sidebarCollapsed is false in mobile view', () => {
|
||||||
let menu:HTMLElement;
|
let menu: HTMLElement;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
menu = fixture.debugElement.query(By.css('#mock-id-sidebar-content')).nativeElement;
|
menu = fixture.debugElement.query(By.css('#mock-id-sidebar-content')).nativeElement;
|
||||||
@@ -70,6 +70,5 @@ describe('PageWithSidebarComponent', () => {
|
|||||||
it('should open the menu', () => {
|
it('should open the menu', () => {
|
||||||
expect(menu.classList).toContain('active');
|
expect(menu.classList).toContain('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -18,13 +18,13 @@ import { map } from 'rxjs/operators';
|
|||||||
* the template outlet (inside the page-width-sidebar tags).
|
* the template outlet (inside the page-width-sidebar tags).
|
||||||
*/
|
*/
|
||||||
export class PageWithSidebarComponent implements OnInit {
|
export class PageWithSidebarComponent implements OnInit {
|
||||||
@Input() id:string;
|
@Input() id: string;
|
||||||
@Input() sidebarContent:TemplateRef<any>;
|
@Input() sidebarContent: TemplateRef<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits true if were on a small screen
|
* Emits true if were on a small screen
|
||||||
*/
|
*/
|
||||||
isXsOrSm$:Observable<boolean>;
|
isXsOrSm$: Observable<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the sidebar (bootstrap columns)
|
* The width of the sidebar (bootstrap columns)
|
||||||
@@ -35,16 +35,16 @@ export class PageWithSidebarComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Observable for whether or not the sidebar is currently collapsed
|
* Observable for whether or not the sidebar is currently collapsed
|
||||||
*/
|
*/
|
||||||
isSidebarCollapsed$:Observable<boolean>;
|
isSidebarCollapsed$: Observable<boolean>;
|
||||||
|
|
||||||
sidebarClasses:Observable<string>;
|
sidebarClasses: Observable<string>;
|
||||||
|
|
||||||
constructor(protected sidebarService:SidebarService,
|
constructor(protected sidebarService: SidebarService,
|
||||||
protected windowService:HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit():void {
|
ngOnInit(): void {
|
||||||
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
||||||
this.isSidebarCollapsed$ = this.isSidebarCollapsed();
|
this.isSidebarCollapsed$ = this.isSidebarCollapsed();
|
||||||
this.sidebarClasses = this.isSidebarCollapsed$.pipe(
|
this.sidebarClasses = this.isSidebarCollapsed$.pipe(
|
||||||
@@ -56,21 +56,21 @@ export class PageWithSidebarComponent implements OnInit {
|
|||||||
* Check if the sidebar is collapsed
|
* Check if the sidebar is collapsed
|
||||||
* @returns {Observable<boolean>} emits true if the sidebar is currently collapsed, false if it is expanded
|
* @returns {Observable<boolean>} emits true if the sidebar is currently collapsed, false if it is expanded
|
||||||
*/
|
*/
|
||||||
private isSidebarCollapsed():Observable<boolean> {
|
private isSidebarCollapsed(): Observable<boolean> {
|
||||||
return this.sidebarService.isCollapsed;
|
return this.sidebarService.isCollapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the sidebar to a collapsed state
|
* Set the sidebar to a collapsed state
|
||||||
*/
|
*/
|
||||||
public closeSidebar():void {
|
public closeSidebar(): void {
|
||||||
this.sidebarService.collapse()
|
this.sidebarService.collapse()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the sidebar to an expanded state
|
* Set the sidebar to an expanded state
|
||||||
*/
|
*/
|
||||||
public openSidebar():void {
|
public openSidebar(): void {
|
||||||
this.sidebarService.expand();
|
this.sidebarService.expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|||||||
* The options should still be provided in the content.
|
* The options should still be provided in the content.
|
||||||
*/
|
*/
|
||||||
export class SidebarDropdownComponent {
|
export class SidebarDropdownComponent {
|
||||||
@Input() id:string;
|
@Input() id: string;
|
||||||
@Input() label:string;
|
@Input() label: string;
|
||||||
@Output() change:EventEmitter<any> = new EventEmitter<number>();
|
@Output() change: EventEmitter<any> = new EventEmitter<number>();
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ export class ObjectKeysPipe implements PipeTransform {
|
|||||||
* @param value An object
|
* @param value An object
|
||||||
* @returns {any} Array with all keys the input object
|
* @returns {any} Array with all keys the input object
|
||||||
*/
|
*/
|
||||||
transform(value, args:string[]): any {
|
transform(value, args: string[]): any {
|
||||||
const keys = [];
|
const keys = [];
|
||||||
Object.keys(value).forEach((k) => keys.push(k));
|
Object.keys(value).forEach((k) => keys.push(k));
|
||||||
return keys;
|
return keys;
|
||||||
|
@@ -10,7 +10,7 @@ export class ObjectValuesPipe implements PipeTransform {
|
|||||||
* @param value An object
|
* @param value An object
|
||||||
* @returns {any} Array with all values of the input object
|
* @returns {any} Array with all values of the input object
|
||||||
*/
|
*/
|
||||||
transform(value, args:string[]): any {
|
transform(value, args: string[]): any {
|
||||||
const values = [];
|
const values = [];
|
||||||
Object.values(value).forEach((v) => values.push(v));
|
Object.values(value).forEach((v) => values.push(v));
|
||||||
return values;
|
return values;
|
||||||
|
@@ -5,9 +5,9 @@ import { filter } from 'rxjs/operators';
|
|||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
describe('Angulartics2DSpace', () => {
|
describe('Angulartics2DSpace', () => {
|
||||||
let provider:Angulartics2DSpace;
|
let provider: Angulartics2DSpace;
|
||||||
let angulartics2:Angulartics2;
|
let angulartics2: Angulartics2;
|
||||||
let statisticsService:jasmine.SpyObj<StatisticsService>;
|
let statisticsService: jasmine.SpyObj<StatisticsService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
angulartics2 = {
|
angulartics2 = {
|
||||||
|
@@ -9,15 +9,15 @@ import { StatisticsService } from '../statistics.service';
|
|||||||
export class Angulartics2DSpace {
|
export class Angulartics2DSpace {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private angulartics2:Angulartics2,
|
private angulartics2: Angulartics2,
|
||||||
private statisticsService:StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activates this plugin
|
* Activates this plugin
|
||||||
*/
|
*/
|
||||||
startTracking():void {
|
startTracking(): void {
|
||||||
this.angulartics2.eventTrack
|
this.angulartics2.eventTrack
|
||||||
.pipe(this.angulartics2.filterDeveloperMode())
|
.pipe(this.angulartics2.filterDeveloperMode())
|
||||||
.subscribe((event) => this.eventTrack(event));
|
.subscribe((event) => this.eventTrack(event));
|
||||||
|
@@ -11,14 +11,14 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
|||||||
templateUrl: './view-tracker.component.html',
|
templateUrl: './view-tracker.component.html',
|
||||||
})
|
})
|
||||||
export class ViewTrackerComponent implements OnInit {
|
export class ViewTrackerComponent implements OnInit {
|
||||||
@Input() object:DSpaceObject;
|
@Input() object: DSpaceObject;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public angulartics2:Angulartics2
|
public angulartics2: Angulartics2
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit():void {
|
ngOnInit(): void {
|
||||||
this.angulartics2.eventTrack.next({
|
this.angulartics2.eventTrack.next({
|
||||||
action: 'pageView',
|
action: 'pageView',
|
||||||
properties: {object: this.object},
|
properties: {object: this.object},
|
||||||
|
@@ -25,7 +25,7 @@ import { StatisticsService } from './statistics.service';
|
|||||||
* This module handles the statistics
|
* This module handles the statistics
|
||||||
*/
|
*/
|
||||||
export class StatisticsModule {
|
export class StatisticsModule {
|
||||||
static forRoot():ModuleWithProviders {
|
static forRoot(): ModuleWithProviders {
|
||||||
return {
|
return {
|
||||||
ngModule: StatisticsModule,
|
ngModule: StatisticsModule,
|
||||||
providers: [
|
providers: [
|
||||||
|
@@ -3,16 +3,15 @@ import { RequestService } from '../core/data/request.service';
|
|||||||
import { HALEndpointServiceStub } from '../shared/testing/hal-endpoint-service-stub';
|
import { HALEndpointServiceStub } from '../shared/testing/hal-endpoint-service-stub';
|
||||||
import { getMockRequestService } from '../shared/mocks/mock-request.service';
|
import { getMockRequestService } from '../shared/mocks/mock-request.service';
|
||||||
import { TrackRequest } from './track-request.model';
|
import { TrackRequest } from './track-request.model';
|
||||||
import { ResourceType } from '../core/shared/resource-type';
|
|
||||||
import { SearchOptions } from '../+search-page/search-options.model';
|
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
|
import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
|
||||||
|
import { SearchOptions } from '../shared/search/search-options.model';
|
||||||
|
|
||||||
describe('StatisticsService', () => {
|
describe('StatisticsService', () => {
|
||||||
let service:StatisticsService;
|
let service: StatisticsService;
|
||||||
let requestService:jasmine.SpyObj<RequestService>;
|
let requestService: jasmine.SpyObj<RequestService>;
|
||||||
const restURL = 'https://rest.api';
|
const restURL = 'https://rest.api';
|
||||||
const halService:any = new HALEndpointServiceStub(restURL);
|
const halService: any = new HALEndpointServiceStub(restURL);
|
||||||
|
|
||||||
function initTestService() {
|
function initTestService() {
|
||||||
return new StatisticsService(
|
return new StatisticsService(
|
||||||
@@ -26,9 +25,9 @@ describe('StatisticsService', () => {
|
|||||||
service = initTestService();
|
service = initTestService();
|
||||||
|
|
||||||
it('should send a request to track an item view ', () => {
|
it('should send a request to track an item view ', () => {
|
||||||
const mockItem:any = {uuid: 'mock-item-uuid', type: 'item'};
|
const mockItem: any = {uuid: 'mock-item-uuid', type: 'item'};
|
||||||
service.trackViewEvent(mockItem);
|
service.trackViewEvent(mockItem);
|
||||||
const request:TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
const request: TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
||||||
expect(request.body).toBeDefined('request.body');
|
expect(request.body).toBeDefined('request.body');
|
||||||
const body = JSON.parse(request.body);
|
const body = JSON.parse(request.body);
|
||||||
expect(body.targetId).toBe('mock-item-uuid');
|
expect(body.targetId).toBe('mock-item-uuid');
|
||||||
@@ -40,7 +39,7 @@ describe('StatisticsService', () => {
|
|||||||
requestService = getMockRequestService();
|
requestService = getMockRequestService();
|
||||||
service = initTestService();
|
service = initTestService();
|
||||||
|
|
||||||
const mockSearch:any = new SearchOptions({
|
const mockSearch: any = new SearchOptions({
|
||||||
query: 'mock-query',
|
query: 'mock-query',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ describe('StatisticsService', () => {
|
|||||||
};
|
};
|
||||||
const sort = {by: 'search-field', order: 'ASC'};
|
const sort = {by: 'search-field', order: 'ASC'};
|
||||||
service.trackSearchEvent(mockSearch, page, sort);
|
service.trackSearchEvent(mockSearch, page, sort);
|
||||||
const request:TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
const request: TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
||||||
const body = JSON.parse(request.body);
|
const body = JSON.parse(request.body);
|
||||||
|
|
||||||
it('should specify the right query', () => {
|
it('should specify the right query', () => {
|
||||||
@@ -80,7 +79,7 @@ describe('StatisticsService', () => {
|
|||||||
requestService = getMockRequestService();
|
requestService = getMockRequestService();
|
||||||
service = initTestService();
|
service = initTestService();
|
||||||
|
|
||||||
const mockSearch:any = new SearchOptions({
|
const mockSearch: any = new SearchOptions({
|
||||||
query: 'mock-query',
|
query: 'mock-query',
|
||||||
configuration: 'mock-configuration',
|
configuration: 'mock-configuration',
|
||||||
dsoType: DSpaceObjectType.ITEM,
|
dsoType: DSpaceObjectType.ITEM,
|
||||||
@@ -109,7 +108,7 @@ describe('StatisticsService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
service.trackSearchEvent(mockSearch, page, sort, filters);
|
service.trackSearchEvent(mockSearch, page, sort, filters);
|
||||||
const request:TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
const request: TrackRequest = requestService.configure.calls.mostRecent().args[0];
|
||||||
const body = JSON.parse(request.body);
|
const body = JSON.parse(request.body);
|
||||||
|
|
||||||
it('should specify the dsoType', () => {
|
it('should specify the dsoType', () => {
|
||||||
|
@@ -3,10 +3,10 @@ import { Injectable } from '@angular/core';
|
|||||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
||||||
import { map, take } from 'rxjs/operators';
|
import { map, take } from 'rxjs/operators';
|
||||||
import { TrackRequest } from './track-request.model';
|
import { TrackRequest } from './track-request.model';
|
||||||
import { SearchOptions } from '../+search-page/search-options.model';
|
|
||||||
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
||||||
import { HALEndpointService } from '../core/shared/hal-endpoint.service';
|
import { HALEndpointService } from '../core/shared/hal-endpoint.service';
|
||||||
import { RestRequest } from '../core/data/request.models';
|
import { RestRequest } from '../core/data/request.models';
|
||||||
|
import { SearchOptions } from '../shared/search/search-options.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The statistics service
|
* The statistics service
|
||||||
@@ -15,24 +15,24 @@ import { RestRequest } from '../core/data/request.models';
|
|||||||
export class StatisticsService {
|
export class StatisticsService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService:RequestService,
|
protected requestService: RequestService,
|
||||||
protected halService:HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendEvent(linkPath:string, body:any) {
|
private sendEvent(linkPath: string, body: any) {
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
this.halService.getEndpoint(linkPath).pipe(
|
this.halService.getEndpoint(linkPath).pipe(
|
||||||
map((endpoint:string) => new TrackRequest(requestId, endpoint, JSON.stringify(body))),
|
map((endpoint: string) => new TrackRequest(requestId, endpoint, JSON.stringify(body))),
|
||||||
take(1) // otherwise the previous events will fire again
|
take(1) // otherwise the previous events will fire again
|
||||||
).subscribe((request:RestRequest) => this.requestService.configure(request));
|
).subscribe((request: RestRequest) => this.requestService.configure(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To track a page view
|
* To track a page view
|
||||||
* @param dso: The dso which was viewed
|
* @param dso: The dso which was viewed
|
||||||
*/
|
*/
|
||||||
trackViewEvent(dso:DSpaceObject) {
|
trackViewEvent(dso: DSpaceObject) {
|
||||||
this.sendEvent('/statistics/viewevents', {
|
this.sendEvent('/statistics/viewevents', {
|
||||||
targetId: dso.uuid,
|
targetId: dso.uuid,
|
||||||
targetType: (dso as any).type
|
targetType: (dso as any).type
|
||||||
@@ -47,10 +47,10 @@ export class StatisticsService {
|
|||||||
* @param filters: An array of search filters used to filter the result set
|
* @param filters: An array of search filters used to filter the result set
|
||||||
*/
|
*/
|
||||||
trackSearchEvent(
|
trackSearchEvent(
|
||||||
searchOptions:SearchOptions,
|
searchOptions: SearchOptions,
|
||||||
page:{ size:number, totalElements:number, totalPages:number, number:number },
|
page: { size: number, totalElements: number, totalPages: number, number: number },
|
||||||
sort:{ by:string, order:string },
|
sort: { by: string, order: string },
|
||||||
filters?:Array<{ filter:string, operator:string, value:string, label:string }>
|
filters?: Array<{ filter: string, operator: string, value: string, label: string }>
|
||||||
) {
|
) {
|
||||||
const body = {
|
const body = {
|
||||||
query: searchOptions.query,
|
query: searchOptions.query,
|
||||||
|
@@ -114,6 +114,13 @@
|
|||||||
"parameter": "nospace",
|
"parameter": "nospace",
|
||||||
"property-declaration": "nospace",
|
"property-declaration": "nospace",
|
||||||
"variable-declaration": "nospace"
|
"variable-declaration": "nospace"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"call-signature": "onespace",
|
||||||
|
"index-signature": "onespace",
|
||||||
|
"parameter": "onespace",
|
||||||
|
"property-declaration": "onespace",
|
||||||
|
"variable-declaration": "onespace"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"unified-signatures": true,
|
"unified-signatures": true,
|
||||||
|
Reference in New Issue
Block a user