Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/app/app-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ import { reloadGuard } from './core/reload/reload.guard';
import { forgotPasswordCheckGuard } from './core/rest-property/forgot-password-check-guard.guard';
import { ServerCheckGuard } from './core/server-check/server-check.guard';
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
import { homePageResolver } from './home-page/home-page.resolver';
import { ITEM_MODULE_PATH } from './item-page/item-page-routing-paths';
import { menuResolver } from './menuResolver';
import { provideSuggestionNotificationsState } from './notifications/provide-suggestion-notifications-state';
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
import { PROCESS_MODULE_PATH } from './process-page/process-page-routing.paths';
import { viewTrackerResolver } from './statistics/angulartics/dspace/view-tracker.resolver';
import { provideSubmissionState } from './submission/provide-submission-state';
import { SUGGESTION_MODULE_PATH } from './suggestions-page/suggestions-page-routing-paths';

Expand All @@ -63,9 +65,16 @@ export const APP_ROUTES: Route[] = [
path: 'home',
loadChildren: () => import('./home-page/home-page-routes')
.then((m) => m.ROUTES),
data: { showBreadcrumbs: false },
data: {
showBreadcrumbs: false,
dsoPath: 'site',
},
providers: [provideSuggestionNotificationsState()],
canActivate: [endUserAgreementCurrentUserGuard],
resolve: {
site: homePageResolver,
tracking: viewTrackerResolver,
},
},
{
path: 'community-list',
Expand Down
2 changes: 2 additions & 0 deletions src/app/collection-page/collection-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-s
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { viewTrackerResolver } from '../statistics/angulartics/dspace/view-tracker.resolver';
import { collectionPageResolver } from './collection-page.resolver';
import { collectionPageAdministratorGuard } from './collection-page-administrator.guard';
import {
Expand Down Expand Up @@ -84,6 +85,7 @@ export const ROUTES: Route[] = [
component: ThemedCollectionPageComponent,
resolve: {
menu: dsoEditMenuResolver,
tracking: viewTrackerResolver,
},
children: [
{
Expand Down
1 change: 0 additions & 1 deletion src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*ngVar="(collectionRD$ | async) as collectionRD">
<div *ngIf="collectionRD?.hasSucceeded" @fadeInOut>
<div *ngIf="collectionRD?.payload as collection">
<ds-view-tracker [object]="collection"></ds-view-tracker>
<div class="d-flex flex-row border-bottom mb-4 pb-4">
<header class="comcol-header mr-auto">
<!-- Collection Name -->
Expand Down
2 changes: 0 additions & 2 deletions src/app/collection-page/collection-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import { ThemedLoadingComponent } from '../shared/loading/themed-loading.compone
import { ObjectCollectionComponent } from '../shared/object-collection/object-collection.component';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { VarDirective } from '../shared/utils/var.directive';
import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component';
import { getCollectionPageRoute } from './collection-page-routing-paths';

@Component({
Expand All @@ -68,7 +67,6 @@ import { getCollectionPageRoute } from './collection-page-routing-paths';
NgIf,
ThemedLoadingComponent,
TranslateModule,
ViewTrackerComponent,
VarDirective,
AsyncPipe,
ComcolPageHeaderComponent,
Expand Down
2 changes: 2 additions & 0 deletions src/app/community-page/community-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-s
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { viewTrackerResolver } from '../statistics/angulartics/dspace/view-tracker.resolver';
import { communityPageResolver } from './community-page.resolver';
import { communityPageAdministratorGuard } from './community-page-administrator.guard';
import {
Expand Down Expand Up @@ -71,6 +72,7 @@ export const ROUTES: Route[] = [
component: ThemedCommunityPageComponent,
resolve: {
menu: dsoEditMenuResolver,
tracking: viewTrackerResolver,
},
children: [
{
Expand Down
1 change: 0 additions & 1 deletion src/app/community-page/community-page.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="container" *ngVar="(communityRD$ | async) as communityRD">
<div class="community-page" *ngIf="communityRD?.hasSucceeded" @fadeInOut>
<div *ngIf="communityRD?.payload; let communityPayload">
<ds-view-tracker [object]="communityPayload"></ds-view-tracker>
<div class="d-flex flex-row border-bottom mb-4 pb-4">
<header class="comcol-header mr-auto">
<!-- Community name -->
Expand Down
2 changes: 0 additions & 2 deletions src/app/community-page/community-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { hasValue } from '../shared/empty.util';
import { ErrorComponent } from '../shared/error/error.component';
import { ThemedLoadingComponent } from '../shared/loading/themed-loading.component';
import { VarDirective } from '../shared/utils/var.directive';
import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component';
import { getCommunityPageRoute } from './community-page-routing-paths';
import { ThemedCollectionPageSubCollectionListComponent } from './sections/sub-com-col-section/sub-collection-list/themed-community-page-sub-collection-list.component';
import { ThemedCommunityPageSubCommunityListComponent } from './sections/sub-com-col-section/sub-community-list/themed-community-page-sub-community-list.component';
Expand All @@ -66,7 +65,6 @@ import { ThemedCommunityPageSubCommunityListComponent } from './sections/sub-com
ComcolPageLogoComponent,
ComcolPageHeaderComponent,
AsyncPipe,
ViewTrackerComponent,
VarDirective,
RouterOutlet,
RouterModule,
Expand Down
4 changes: 0 additions & 4 deletions src/app/home-page/home-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Route } from '@angular/router';

import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { homePageResolver } from './home-page.resolver';
import { ThemedHomePageComponent } from './themed-home-page.component';

export const ROUTES: Route[] = [
Expand All @@ -26,8 +25,5 @@ export const ROUTES: Route[] = [
}],
},
},
resolve: {
site: homePageResolver,
},
},
];
3 changes: 0 additions & 3 deletions src/app/home-page/home-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<ds-suggestions-popup></ds-suggestions-popup>

<ng-template #homeContent>
<ng-container *ngIf="(site$ | async) as site">
<ds-view-tracker [object]="site"></ds-view-tracker>
</ng-container>
<ds-search-form [inPlaceSearch]="false"
[searchPlaceholder]="'home.search-form.placeholder' | translate">
</ds-search-form>
Expand Down
3 changes: 1 addition & 2 deletions src/app/home-page/home-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { SuggestionsPopupComponent } from '../notifications/suggestions-popup/su
import { ThemedConfigurationSearchPageComponent } from '../search-page/themed-configuration-search-page.component';
import { ThemedSearchFormComponent } from '../shared/search-form/themed-search-form.component';
import { PageWithSidebarComponent } from '../shared/sidebar/page-with-sidebar.component';
import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component';
import { HomeCoarComponent } from './home-coar/home-coar.component';
import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component';
import { RecentItemListComponent } from './recent-item-list/recent-item-list.component';
Expand All @@ -34,7 +33,7 @@ import { ThemedTopLevelCommunityListComponent } from './top-level-community-list
styleUrls: ['./home-page.component.scss'],
templateUrl: './home-page.component.html',
standalone: true,
imports: [ThemedHomeNewsComponent, NgTemplateOutlet, NgIf, ViewTrackerComponent, ThemedSearchFormComponent, ThemedTopLevelCommunityListComponent, RecentItemListComponent, AsyncPipe, TranslateModule, NgClass, SuggestionsPopupComponent, ThemedConfigurationSearchPageComponent, PageWithSidebarComponent, HomeCoarComponent],
imports: [ThemedHomeNewsComponent, NgTemplateOutlet, NgIf, ThemedSearchFormComponent, ThemedTopLevelCommunityListComponent, RecentItemListComponent, AsyncPipe, TranslateModule, NgClass, SuggestionsPopupComponent, ThemedConfigurationSearchPageComponent, PageWithSidebarComponent, HomeCoarComponent],
})
export class HomePageComponent implements OnInit {

Expand Down
1 change: 0 additions & 1 deletion src/app/item-page/full/full-item-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div *ngIf="itemRD?.payload as item">
<ds-item-alerts [item]="item"></ds-item-alerts>
<ds-item-versions-notice [item]="item"></ds-item-versions-notice>
<ds-view-tracker [object]="item"></ds-view-tracker>
<div *ngIf="!item.isWithdrawn || (isAdmin$|async)" class="full-item-info">
<div class="d-flex flex-row">
<ds-item-page-title-field class="mr-auto" [item]="item"></ds-item-page-title-field>
Expand Down
4 changes: 2 additions & 2 deletions src/app/item-page/full/full-item-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { createPaginatedList } from '../../shared/testing/utils.test';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { TruncatePipe } from '../../shared/utils/truncate.pipe';
import { VarDirective } from '../../shared/utils/var.directive';
import { ViewTrackerComponent } from '../../statistics/angulartics/dspace/view-tracker.component';
import { ViewTrackerResolverService } from '../../statistics/angulartics/dspace/view-tracker-resolver.service';
import { ThemedItemAlertsComponent } from '../alerts/themed-item-alerts.component';
import { CollectionsComponent } from '../field-components/collections/collections.component';
import { ThemedItemPageTitleFieldComponent } from '../simple/field-components/specific-field/title/themed-item-page-field.component';
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('FullItemPageComponent', () => {
ThemedLoadingComponent,
ThemedItemPageTitleFieldComponent,
DsoEditMenuComponent,
ViewTrackerComponent,
ViewTrackerResolverService,
ThemedItemAlertsComponent,
CollectionsComponent,
ThemedFullFileSectionComponent,
Expand Down
2 changes: 0 additions & 2 deletions src/app/item-page/full/full-item-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { hasValue } from '../../shared/empty.util';
import { ErrorComponent } from '../../shared/error/error.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { VarDirective } from '../../shared/utils/var.directive';
import { ViewTrackerComponent } from '../../statistics/angulartics/dspace/view-tracker.component';
import { ThemedItemAlertsComponent } from '../alerts/themed-item-alerts.component';
import { CollectionsComponent } from '../field-components/collections/collections.component';
import { ThemedItemPageTitleFieldComponent } from '../simple/field-components/specific-field/title/themed-item-page-field.component';
Expand Down Expand Up @@ -79,7 +78,6 @@ import { ThemedFullFileSectionComponent } from './field-components/file-section/
ThemedItemPageTitleFieldComponent,
DsoEditMenuComponent,
ItemVersionsNoticeComponent,
ViewTrackerComponent,
ThemedItemAlertsComponent,
VarDirective,
],
Expand Down
3 changes: 3 additions & 0 deletions src/app/item-page/item-page-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { itemBreadcrumbResolver } from '../core/breadcrumbs/item-breadcrumb.reso
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { viewTrackerResolver } from '../statistics/angulartics/dspace/view-tracker.resolver';
import { BitstreamRequestACopyPageComponent } from './bitstreams/request-a-copy/bitstream-request-a-copy-page.component';
import { UploadBitstreamComponent } from './bitstreams/upload/upload-bitstream.component';
import { ThemedFullItemPageComponent } from './full/themed-full-item-page.component';
Expand Down Expand Up @@ -36,13 +37,15 @@ export const ROUTES: Route[] = [
pathMatch: 'full',
resolve: {
menu: dsoEditMenuResolver,
tracking: viewTrackerResolver,
},
},
{
path: 'full',
component: ThemedFullItemPageComponent,
resolve: {
menu: dsoEditMenuResolver,
tracking: viewTrackerResolver,
},
},
{
Expand Down
1 change: 0 additions & 1 deletion src/app/item-page/simple/item-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<ds-qa-event-notification [item]="item"></ds-qa-event-notification>
<ds-notify-requests-status [itemUuid]="item.uuid"></ds-notify-requests-status>
<ds-item-versions-notice [item]="item"></ds-item-versions-notice>
<ds-view-tracker [object]="item"></ds-view-tracker>
<ds-listable-object-component-loader *ngIf="!item.isWithdrawn || (isAdmin$|async)" [object]="item" [viewMode]="viewMode"></ds-listable-object-component-loader>
<ds-item-versions class="mt-2" [item]="item" [displayActions]="false"></ds-item-versions>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/item-page/simple/item-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { createPaginatedList } from '../../shared/testing/utils.test';
import { VarDirective } from '../../shared/utils/var.directive';
import { ViewTrackerComponent } from '../../statistics/angulartics/dspace/view-tracker.component';
import { ViewTrackerResolverService } from '../../statistics/angulartics/dspace/view-tracker-resolver.service';
import { ThemedItemAlertsComponent } from '../alerts/themed-item-alerts.component';
import { ItemVersionsComponent } from '../versions/item-versions.component';
import { ItemVersionsNoticeComponent } from '../versions/notice/item-versions-notice.component';
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('ItemPageComponent', () => {
remove: { imports: [
ThemedItemAlertsComponent,
ItemVersionsNoticeComponent,
ViewTrackerComponent,
ViewTrackerResolverService,
ListableObjectComponentLoaderComponent,
ItemVersionsComponent,
ErrorComponent,
Expand Down
2 changes: 0 additions & 2 deletions src/app/item-page/simple/item-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import { ErrorComponent } from '../../shared/error/error.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { ListableObjectComponentLoaderComponent } from '../../shared/object-collection/shared/listable-object/listable-object-component-loader.component';
import { VarDirective } from '../../shared/utils/var.directive';
import { ViewTrackerComponent } from '../../statistics/angulartics/dspace/view-tracker.component';
import { ThemedItemAlertsComponent } from '../alerts/themed-item-alerts.component';
import { getItemPageRoute } from '../item-page-routing-paths';
import { ItemVersionsComponent } from '../versions/item-versions.component';
Expand All @@ -72,7 +71,6 @@ import { QaEventNotificationComponent } from './qa-event-notification/qa-event-n
VarDirective,
ThemedItemAlertsComponent,
ItemVersionsNoticeComponent,
ViewTrackerComponent,
ListableObjectComponentLoaderComponent,
ItemVersionsComponent,
ErrorComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
ResolveEnd,
Router,
RouterStateSnapshot,
} from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { switchMap } from 'rxjs';
import {
filter,
take,
} from 'rxjs/operators';

import { ReferrerService } from '../../../core/services/referrer.service';

/**
* This component triggers a page view statistic
*/
@Injectable({
providedIn: 'root',
})
export class ViewTrackerResolverService {

constructor(
public angulartics2: Angulartics2,
public referrerService: ReferrerService,
public router: Router,

Check warning on line 28 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L26-L28

Added lines #L26 - L28 were not covered by tests
) {
}

resolve(routeSnapshot: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
const dsoPath = routeSnapshot.data.dsoPath || 'dso.payload'; // Fetch the resolvers passed via the route data
this.router.events.pipe(
filter(event => event instanceof ResolveEnd),

Check warning on line 35 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L34-L35

Added lines #L34 - L35 were not covered by tests
take(1),
switchMap(() =>
this.referrerService.getReferrer().pipe(take(1))))

Check warning on line 38 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L38

Added line #L38 was not covered by tests
.subscribe((referrer: string) => {
this.angulartics2.eventTrack.next({

Check warning on line 40 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L40

Added line #L40 was not covered by tests
action: 'page_view',
properties: {
object: this.getNestedProperty(routeSnapshot.data, dsoPath),
referrer,
},
});
});
return true;

Check warning on line 48 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L48

Added line #L48 was not covered by tests
}

private getNestedProperty(obj: any, path: string) {
const keys = path.split('.');
let result = obj;

Check warning on line 53 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L52-L53

Added lines #L52 - L53 were not covered by tests

for (const key of keys) {

Check warning on line 55 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L55

Added line #L55 was not covered by tests
if (result && result.hasOwnProperty(key)) {
result = result[key];

Check warning on line 57 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L57

Added line #L57 was not covered by tests
} else {
return undefined;

Check warning on line 59 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L59

Added line #L59 was not covered by tests
}
}
return result;

Check warning on line 62 in src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/statistics/angulartics/dspace/view-tracker-resolver.service.ts#L62

Added line #L62 was not covered by tests
}
}

This file was deleted.

This file was deleted.

Loading
Loading