diff --git a/src/app/search-page/configuration-search-page.component.ts b/src/app/search-page/configuration-search-page.component.ts index 768149de6a8..9196dda0251 100644 --- a/src/app/search-page/configuration-search-page.component.ts +++ b/src/app/search-page/configuration-search-page.component.ts @@ -8,6 +8,7 @@ import { SearchConfigurationService } from '../core/shared/search/search-configu import { RouteService } from '../core/services/route.service'; import { SearchService } from '../core/shared/search/search.service'; import { Router } from '@angular/router'; +import { APP_CONFIG, AppConfig } from '../../config/app-config.interface'; /** * This component renders a search page using a configuration as input. @@ -32,7 +33,9 @@ export class ConfigurationSearchPageComponent extends SearchComponent { protected windowService: HostWindowService, @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService, protected routeService: RouteService, - protected router: Router) { - super(service, sidebarService, windowService, searchConfigService, routeService, router); + protected router: Router, + @Inject(APP_CONFIG) protected appConfig: AppConfig, + ) { + super(service, sidebarService, windowService, searchConfigService, routeService, router, appConfig); } } diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts index e893fe807b7..e3d2ad64b12 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts @@ -1,18 +1,31 @@ import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component'; import { ListableObject } from '../listable-object.model'; import { GenericConstructor } from '../../../../core/shared/generic-constructor'; import { Context } from '../../../../core/shared/context.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; -import { - ItemListElementComponent -} from '../../../object-list/item-list-element/item-types/item/item-list-element.component'; import { ListableObjectDirective } from './listable-object.directive'; import { TranslateModule } from '@ngx-translate/core'; import { By } from '@angular/platform-browser'; -import { provideMockStore } from '@ngrx/store/testing'; import { ThemeService } from '../../../theme-support/theme.service'; +import { ItemSearchResultListElementComponent } from '../../../object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component'; +import { ActivatedRouteStub } from '../../../testing/active-router.stub'; +import { AuthServiceStub } from '../../../testing/auth-service.stub'; +import { AuthorizationDataServiceStub } from '../../../testing/authorization-service.stub'; +import { FileServiceStub } from '../../../testing/file-service.stub'; +import { TruncatableServiceStub } from '../../../testing/truncatable-service.stub'; +import { getMockThemeService } from '../../../mocks/theme-service.mock'; +import { APP_CONFIG } from '../../../../../config/app-config.interface'; +import { environment } from '../../../../../environments/environment.test'; +import { ActivatedRoute } from '@angular/router'; +import { AuthService } from '../../../../core/auth/auth.service'; +import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service'; +import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; +import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock'; +import { FileService } from '../../../../core/shared/file.service'; +import { TruncatableService } from '../../../truncatable/truncatable.service'; +import { ChangeDetectionStrategy } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../object-list/search-result-list-element/search-result-list-element.component'; const testType = 'TestType'; const testContext = Context.Search; @@ -28,24 +41,41 @@ describe('ListableObjectComponentLoaderComponent', () => { let comp: ListableObjectComponentLoaderComponent; let fixture: ComponentFixture; + let activatedRoute: ActivatedRouteStub; + let authService: AuthServiceStub; + let authorizationService: AuthorizationDataServiceStub; + let fileService: FileServiceStub; let themeService: ThemeService; + let truncatableService: TruncatableServiceStub; beforeEach(waitForAsync(() => { - themeService = jasmine.createSpyObj('themeService', { - getThemeName: 'dspace', - }); - TestBed.configureTestingModule({ + activatedRoute = new ActivatedRouteStub(); + authService = new AuthServiceStub(); + authorizationService = new AuthorizationDataServiceStub(); + fileService = new FileServiceStub(); + themeService = getMockThemeService(); + truncatableService = new TruncatableServiceStub(); + + void TestBed.configureTestingModule({ imports: [TranslateModule.forRoot()], - declarations: [ListableObjectComponentLoaderComponent, ItemListElementComponent, ListableObjectDirective], - schemas: [NO_ERRORS_SCHEMA], + declarations: [ + ItemSearchResultListElementComponent, + ListableObjectComponentLoaderComponent, + ListableObjectDirective, + ], providers: [ - provideMockStore({}), + { provide: APP_CONFIG, useValue: environment }, + { provide: ActivatedRoute, useValue: activatedRoute }, + { provide: AuthService, useValue: authService }, + { provide: AuthorizationDataService, useValue: authorizationService }, + { provide: DSONameService, useValue: new DSONameServiceMock() }, + { provide: FileService, useValue: fileService }, { provide: ThemeService, useValue: themeService }, + { provide: TruncatableService, useValue: truncatableService }, ] }).overrideComponent(ListableObjectComponentLoaderComponent, { set: { changeDetection: ChangeDetectionStrategy.Default, - entryComponents: [ItemListElementComponent] } }).compileComponents(); })); @@ -57,7 +87,7 @@ describe('ListableObjectComponentLoaderComponent', () => { comp.object = new TestType(); comp.viewMode = testViewMode; comp.context = testContext; - spyOn(comp, 'getComponent').and.returnValue(ItemListElementComponent as any); + spyOn(comp, 'getComponent').and.returnValue(SearchResultListElementComponent as any); spyOn(comp as any, 'connectInputsAndOutputs').and.callThrough(); fixture.detectChanges(); @@ -81,7 +111,7 @@ describe('ListableObjectComponentLoaderComponent', () => { spyOn((comp as any), 'instantiateComponent').and.returnValue(null); spyOn((comp as any).contentChange, 'emit').and.returnValue(null); - listableComponent = fixture.debugElement.query(By.css('ds-item-list-element')).componentInstance; + listableComponent = fixture.debugElement.query(By.css('ds-search-result-list-element')).componentInstance; reloadedObject = 'object'; }); diff --git a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.html index 3877e2f335b..8ab6fae9e61 100644 --- a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.html @@ -1 +1,5 @@ - + + diff --git a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.spec.ts index d75576e8ebc..a222c49871c 100644 --- a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.spec.ts @@ -1,13 +1,26 @@ -import { TestBed, waitForAsync } from '@angular/core/testing'; -import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { TestBed, waitForAsync, ComponentFixture } from '@angular/core/testing'; +import { ChangeDetectionStrategy } from '@angular/core'; import { By } from '@angular/platform-browser'; import { ItemListElementComponent } from './item-list-element.component'; import { Item } from '../../../../../core/shared/item.model'; -import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { of as observableOf } from 'rxjs'; -import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; -import { DSONameServiceMock } from '../../../../mocks/dso-name.service.mock'; +import { ListableObjectComponentLoaderComponent } from '../../../../object-collection/shared/listable-object/listable-object-component-loader.component'; +import { getMockThemeService } from '../../../../mocks/theme-service.mock'; +import { ThemeService } from '../../../../theme-support/theme.service'; +import { ListableObjectDirective } from '../../../../object-collection/shared/listable-object/listable-object.directive'; +import { APP_CONFIG } from '../../../../../../config/app-config.interface'; +import { environment } from '../../../../../../environments/environment.test'; +import { TranslateModule } from '@ngx-translate/core'; +import { ActivatedRouteStub } from '../../../../testing/active-router.stub'; +import { ActivatedRoute } from '@angular/router'; +import { AuthService } from '../../../../../core/auth/auth.service'; +import { AuthServiceStub } from '../../../../testing/auth-service.stub'; +import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service'; +import { AuthorizationDataServiceStub } from '../../../../testing/authorization-service.stub'; +import { FileService } from '../../../../../core/shared/file.service'; +import { FileServiceStub } from '../../../../testing/file-service.stub'; +import { TruncatableServiceStub } from '../../../../testing/truncatable-service.stub'; const mockItem: Item = Object.assign(new Item(), { bundles: observableOf({}), @@ -46,21 +59,42 @@ const mockItem: Item = Object.assign(new Item(), { }); describe('ItemListElementComponent', () => { - let comp; - let fixture; + let comp: ItemListElementComponent; + let fixture: ComponentFixture; - const truncatableServiceStub: any = { - isCollapsed: (id: number) => observableOf(true), - }; + let activatedRoute: ActivatedRouteStub; + let authService: AuthServiceStub; + let authorizationService: AuthorizationDataServiceStub; + let fileService: FileServiceStub; + let themeService: ThemeService; + let truncatableService: TruncatableServiceStub; beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ItemListElementComponent, TruncatePipe], + activatedRoute = new ActivatedRouteStub(); + authService = new AuthServiceStub(); + authorizationService = new AuthorizationDataServiceStub(); + fileService = new FileServiceStub(); + themeService = getMockThemeService(); + truncatableService = new TruncatableServiceStub(); + + void TestBed.configureTestingModule({ + imports: [ + TranslateModule.forRoot(), + ], + declarations: [ + ItemListElementComponent, + ListableObjectComponentLoaderComponent, + ListableObjectDirective, + ], providers: [ - { provide: DSONameService, useValue: new DSONameServiceMock() }, - { provide: TruncatableService, useValue: truncatableServiceStub }, + { provide: APP_CONFIG, useValue: environment }, + { provide: ActivatedRoute, useValue: activatedRoute }, + { provide: AuthService, useValue: authService }, + { provide: AuthorizationDataService, useValue: authorizationService }, + { provide: FileService, useValue: fileService }, + { provide: ThemeService, useValue: themeService }, + { provide: TruncatableService, useValue: truncatableService }, ], - schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(ItemListElementComponent, { set: { changeDetection: ChangeDetectionStrategy.Default } }).compileComponents(); @@ -74,6 +108,7 @@ describe('ItemListElementComponent', () => { describe(`when the publication is rendered`, () => { beforeEach(() => { comp.object = mockItem; + comp.ngOnChanges(); fixture.detectChanges(); }); diff --git a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.ts index a3bd2a1ce00..f338c5de680 100644 --- a/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/item/item-list-element.component.ts @@ -1,8 +1,14 @@ -import { Component } from '@angular/core'; +import { + Component, + OnChanges, +} from '@angular/core'; + import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { Item } from '../../../../../core/shared/item.model'; +import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; +import { hasValue } from '../../../../empty.util'; @listableObjectComponent('Publication', ViewMode.ListElement) @listableObjectComponent(Item, ViewMode.ListElement) @@ -14,5 +20,16 @@ import { Item } from '../../../../../core/shared/item.model'; /** * The component for displaying a list element for an item of the type Publication */ -export class ItemListElementComponent extends AbstractListableElementComponent { +export class ItemListElementComponent extends AbstractListableElementComponent implements OnChanges { + + itemSearchResult: ItemSearchResult; + + ngOnChanges(): void { + if (hasValue(this.object)) { + this.itemSearchResult = Object.assign(new ItemSearchResult(), { + indexableObject: this.object, + }); + } + } + } diff --git a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.spec.ts b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.spec.ts index 4469a124ce6..a6212ca9c5e 100644 --- a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.spec.ts +++ b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.spec.ts @@ -27,6 +27,8 @@ import { SearchConfigurationServiceStub } from '../../../../testing/search-confi import { VocabularyEntryDetail } from '../../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model'; import { FacetValue} from '../../../models/facet-value.model'; import { SearchFilterConfig } from '../../../models/search-filter-config.model'; +import { APP_CONFIG } from '../../../../../../config/app-config.interface'; +import { environment } from '../../../../../../environments/environment.test'; describe('SearchHierarchyFilterComponent', () => { @@ -34,7 +36,7 @@ describe('SearchHierarchyFilterComponent', () => { let showVocabularyTreeLink: DebugElement; const testSearchLink = 'test-search'; - const testSearchFilter = 'test-search-filter'; + const testSearchFilter = 'subject'; const VocabularyTreeViewComponent = { select: new EventEmitter(), }; @@ -73,6 +75,7 @@ describe('SearchHierarchyFilterComponent', () => { { provide: Router, useValue: router }, { provide: NgbModal, useValue: ngbModal }, { provide: VocabularyService, useValue: vocabularyService }, + { provide: APP_CONFIG, useValue: environment }, { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }, { provide: IN_PLACE_SEARCH, useValue: false }, { provide: FILTER_CONFIG, useValue: Object.assign(new SearchFilterConfig(), { name: testSearchFilter }) }, @@ -86,7 +89,7 @@ describe('SearchHierarchyFilterComponent', () => { function init() { fixture = TestBed.createComponent(SearchHierarchyFilterComponent); fixture.detectChanges(); - showVocabularyTreeLink = fixture.debugElement.query(By.css('a#show-test-search-filter-tree')); + showVocabularyTreeLink = fixture.debugElement.query(By.css(`a#show-${testSearchFilter}-tree`)); } describe('if the vocabulary doesn\'t exist', () => { diff --git a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.ts index d53fa37cf4b..18ddbbdf97e 100644 --- a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.ts @@ -24,9 +24,11 @@ import { filter, map, take } from 'rxjs/operators'; import { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service'; import { Observable, BehaviorSubject } from 'rxjs'; import { PageInfo } from '../../../../../core/shared/page-info.model'; -import { environment } from '../../../../../../environments/environment'; import { addOperatorToFilterValue } from '../../../search.utils'; import { VocabularyTreeviewModalComponent } from '../../../../form/vocabulary-treeview-modal/vocabulary-treeview-modal.component'; +import { hasValue } from '../../../../empty.util'; +import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface'; +import { FilterVocabularyConfig } from '../../../../../../config/filter-vocabulary-config'; @Component({ selector: 'ds-search-hierarchy-filter', @@ -47,6 +49,7 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i protected router: Router, protected modalService: NgbModal, protected vocabularyService: VocabularyService, + @Inject(APP_CONFIG) protected appConfig: AppConfig, @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService, @Inject(IN_PLACE_SEARCH) public inPlaceSearch: boolean, @Inject(FILTER_CONFIG) public filterConfig: SearchFilterConfig, @@ -67,17 +70,20 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i super.onSubmit(addOperatorToFilterValue(data, 'query')); } - ngOnInit() { + ngOnInit(): void { super.ngOnInit(); - this.vocabularyExists$ = this.vocabularyService.searchTopEntries( - this.getVocabularyEntry(), new PageInfo(), true, false, - ).pipe( - filter(rd => rd.hasCompleted), - take(1), - map(rd => { - return rd.hasSucceeded; - }), - ); + const vocabularyName: string = this.getVocabularyEntry(); + if (hasValue(vocabularyName)) { + this.vocabularyExists$ = this.vocabularyService.searchTopEntries( + vocabularyName, new PageInfo(), true, false, + ).pipe( + filter(rd => rd.hasCompleted), + take(1), + map(rd => { + return rd.hasSucceeded; + }), + ); + } } /** @@ -93,11 +99,11 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i name: this.getVocabularyEntry(), closed: true }; - modalRef.result.then((detail: VocabularyEntryDetail) => { - this.selectedValues$ + void modalRef.result.then((detail: VocabularyEntryDetail) => { + this.subs.push(this.selectedValues$ .pipe(take(1)) .subscribe((selectedValues) => { - this.router.navigate( + void this.router.navigate( [this.searchService.getSearchLink()], { queryParams: { @@ -107,16 +113,16 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i queryParamsHandling: 'merge', }, ); - }); - }).catch(); + })); + }); } /** * Returns the matching vocabulary entry for the given search filter. * These are configurable in the config file. */ - getVocabularyEntry() { - const foundVocabularyConfig = environment.vocabularies.filter((v) => v.filter === this.filterConfig.name); + getVocabularyEntry(): string { + const foundVocabularyConfig: FilterVocabularyConfig[] = this.appConfig.vocabularies.filter((v: FilterVocabularyConfig) => v.filter === this.filterConfig.name); if (foundVocabularyConfig.length > 0 && foundVocabularyConfig[0].enabled === true) { return foundVocabularyConfig[0].vocabulary; } diff --git a/src/app/shared/search/search.component.spec.ts b/src/app/shared/search/search.component.spec.ts index 9d069636a94..69f4dfd6aaa 100644 --- a/src/app/shared/search/search.component.spec.ts +++ b/src/app/shared/search/search.component.spec.ts @@ -33,6 +33,8 @@ import { SearchFilterConfig } from './models/search-filter-config.model'; import { FilterType } from './models/filter-type.model'; import { getCommunityPageRoute } from '../../community-page/community-page-routing-paths'; import { getCollectionPageRoute } from '../../collection-page/collection-page-routing-paths'; +import { environment } from '../../../environments/environment.test'; +import { APP_CONFIG } from '../../../config/app-config.interface'; let comp: SearchComponent; let fixture: ComponentFixture; @@ -209,7 +211,8 @@ export function configureSearchComponentTestingModule(compType, additionalDeclar { provide: SEARCH_CONFIG_SERVICE, useValue: searchConfigurationServiceStub - } + }, + { provide: APP_CONFIG, useValue: environment }, ], schemas: [NO_ERRORS_SCHEMA] }).overrideComponent(compType, { diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index fc07893d721..a2a89b53a38 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -31,13 +31,13 @@ import { ViewMode } from '../../core/shared/view-mode.model'; import { SelectionConfig } from './search-results/search-results.component'; import { ListableObject } from '../object-collection/shared/listable-object.model'; import { CollectionElementLinkType } from '../object-collection/collection-element-link.type'; -import { environment } from 'src/environments/environment'; import { SubmissionObject } from '../../core/submission/models/submission-object.model'; import { SearchFilterConfig } from './models/search-filter-config.model'; import { WorkspaceItem } from '../../core/submission/models/workspaceitem.model'; import { ITEM_MODULE_PATH } from '../../item-page/item-page-routing-paths'; import { COLLECTION_MODULE_PATH } from '../../collection-page/collection-page-routing-paths'; import { COMMUNITY_MODULE_PATH } from '../../community-page/community-page-routing-paths'; +import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface'; @Component({ selector: 'ds-search', @@ -278,7 +278,9 @@ export class SearchComponent implements OnDestroy, OnInit { protected windowService: HostWindowService, @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService, protected routeService: RouteService, - protected router: Router) { + protected router: Router, + @Inject(APP_CONFIG) protected appConfig: AppConfig, + ) { this.isXsOrSm$ = this.windowService.isXsOrSm(); } @@ -445,8 +447,10 @@ export class SearchComponent implements OnDestroy, OnInit { let followLinks = [ followLink('thumbnail', { isOptional: true }), followLink('item', { isOptional: true }, followLink('thumbnail', { isOptional: true })) as any, - followLink('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }), ]; + if (this.appConfig.item.showAccessStatuses) { + followLinks.push(followLink('accessStatus', { isOptional: true })); + } if (this.configuration === 'supervision') { followLinks.push(followLink('supervisionOrders', { isOptional: true }) as any); } diff --git a/src/app/shared/sidebar/page-with-sidebar.component.html b/src/app/shared/sidebar/page-with-sidebar.component.html index 9feb6c792ef..75f40ef8d63 100644 --- a/src/app/shared/sidebar/page-with-sidebar.component.html +++ b/src/app/shared/sidebar/page-with-sidebar.component.html @@ -3,10 +3,12 @@
-
+
diff --git a/src/app/shared/testing/truncatable-service.stub.ts b/src/app/shared/testing/truncatable-service.stub.ts new file mode 100644 index 00000000000..080cd98469a --- /dev/null +++ b/src/app/shared/testing/truncatable-service.stub.ts @@ -0,0 +1,21 @@ +import { Observable, of as observableOf } from 'rxjs'; + +export class TruncatableServiceStub { + + isCollapsed(_id: string): Observable { + return observableOf(false); + } + + // eslint-disable-next-line no-empty, @typescript-eslint/no-empty-function + public toggle(_id: string): void { + } + + // eslint-disable-next-line no-empty, @typescript-eslint/no-empty-function + public collapse(_id: string): void { + } + + // eslint-disable-next-line no-empty, @typescript-eslint/no-empty-function + public expand(_id: string): void { + } + +} diff --git a/src/app/statistics/angulartics/dspace-provider.ts b/src/app/statistics/angulartics/dspace-provider.ts index 86c16b5c011..957b09a0c8a 100644 --- a/src/app/statistics/angulartics/dspace-provider.ts +++ b/src/app/statistics/angulartics/dspace-provider.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Angulartics2 } from 'angulartics2'; +import { Angulartics2, EventTrack } from 'angulartics2'; import { StatisticsService } from '../statistics.service'; /** @@ -23,7 +23,7 @@ export class Angulartics2DSpace { .subscribe((event) => this.eventTrack(event)); } - private eventTrack(event) { + private eventTrack(event: Partial): void { if (event.action === 'page_view') { this.statisticsService.trackViewEvent(event.properties.object, event.properties.referrer); } else if (event.action === 'search') { @@ -32,7 +32,7 @@ export class Angulartics2DSpace { event.properties.page, event.properties.sort, event.properties.filters, - event.properties.clickedObject, + event.properties.clickedObject?.split('?')[0], ); } }