diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts index 7fdd5996..18bbd39a 100644 --- a/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { AdminLoginGuard} from'../../login/adminLoginGuard.guard'; import { ClaimsAdminComponent } from './claimsAdmin.component'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: ClaimsAdminComponent, canActivate: [AdminLoginGuard]}, + { path: '', component: ClaimsAdminComponent, canActivate: [AdminLoginGuard],canDeactivate: [PreviousRouteRecorder]}, ]) ] diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts index d1fd96b4..451236f0 100644 --- a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts @@ -6,6 +6,7 @@ import { ClaimsAdminRoutingModule } from './claimsAdmin-routing.module'; // import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; import { AdminLoginGuard} from'../../login/adminLoginGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -15,7 +16,7 @@ import { AdminLoginGuard} from'../../login/adminLoginGuard.guard'; DisplayClaimsModule ], - providers:[AdminLoginGuard], + providers:[AdminLoginGuard, PreviousRouteRecorder], declarations: [ ClaimsAdminComponent ] diff --git a/portal-2/src/app/claims/claimsByToken/claimsByToken-routing.module.ts b/portal-2/src/app/claims/claimsByToken/claimsByToken-routing.module.ts index 9c0f4180..c24309ec 100644 --- a/portal-2/src/app/claims/claimsByToken/claimsByToken-routing.module.ts +++ b/portal-2/src/app/claims/claimsByToken/claimsByToken-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { LoginGuard} from'../../login/loginGuard.guard'; import { ClaimsByTokenComponent } from './claimsByToken.component'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: ClaimsByTokenComponent, canActivate: [LoginGuard]} + { path: '', component: ClaimsByTokenComponent, canActivate: [LoginGuard],canDeactivate: [PreviousRouteRecorder]} ]) ] diff --git a/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts b/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts index cb350a08..c2ee6a5a 100644 --- a/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts +++ b/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts @@ -17,6 +17,7 @@ import {LoginGuard} from'../../login/loginGuard.guard'; import {PagingModule} from '../../utils/paging.module'; import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ @@ -35,7 +36,7 @@ import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe'; ], providers:[ ClaimsByTokenService, - LoginGuard + LoginGuard, PreviousRouteRecorder ], declarations: [ ClaimsByTokenComponent, ClaimsDatatablePipe diff --git a/portal-2/src/app/claims/directLinking/directLinking-routing.module.ts b/portal-2/src/app/claims/directLinking/directLinking-routing.module.ts index cf42c202..d9b5c466 100644 --- a/portal-2/src/app/claims/directLinking/directLinking-routing.module.ts +++ b/portal-2/src/app/claims/directLinking/directLinking-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { LoginGuard} from'../../login/loginGuard.guard'; import { DirectLinkingComponent } from './directLinking.component'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DirectLinkingComponent, canActivate: [LoginGuard]}, + { path: '', component: DirectLinkingComponent, canActivate: [LoginGuard], canDeactivate: [PreviousRouteRecorder]}, ]) ] diff --git a/portal-2/src/app/claims/directLinking/directLinking.module.ts b/portal-2/src/app/claims/directLinking/directLinking.module.ts index bc216b8f..e869b667 100644 --- a/portal-2/src/app/claims/directLinking/directLinking.module.ts +++ b/portal-2/src/app/claims/directLinking/directLinking.module.ts @@ -14,6 +14,7 @@ import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entity import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {LoginGuard} from'../../login/loginGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @@ -25,7 +26,7 @@ import {LoginGuard} from'../../login/loginGuard.guard'; ], - providers:[LoginGuard], + providers:[LoginGuard, PreviousRouteRecorder], declarations: [ DirectLinkingComponent ], exports:[DirectLinkingComponent] diff --git a/portal-2/src/app/claims/linking/linking-routing.module.ts b/portal-2/src/app/claims/linking/linking-routing.module.ts index 315f4502..887f0583 100644 --- a/portal-2/src/app/claims/linking/linking-routing.module.ts +++ b/portal-2/src/app/claims/linking/linking-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { LoginGuard} from'../../login/loginGuard.guard'; import { LinkingGenericComponent } from './linkingGeneric.component'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: LinkingGenericComponent, canActivate: [LoginGuard]}, + { path: '', component: LinkingGenericComponent, canActivate: [LoginGuard], canDeactivate: [PreviousRouteRecorder]}, ]) ] diff --git a/portal-2/src/app/claims/linking/linkingGeneric.module.ts b/portal-2/src/app/claims/linking/linkingGeneric.module.ts index 4c260b22..6443833c 100644 --- a/portal-2/src/app/claims/linking/linkingGeneric.module.ts +++ b/portal-2/src/app/claims/linking/linkingGeneric.module.ts @@ -12,6 +12,7 @@ import {DatasetsServiceModule} from '../../services/datasetsService.module'; import { LinkingRoutingModule } from './linking-routing.module'; import {StartOverModule} from '../claim-utils/startOver.module'; import {LoginGuard} from'../../login/loginGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -20,7 +21,7 @@ import {LoginGuard} from'../../login/loginGuard.guard'; InsertClaimsModule, EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule, LinkingRoutingModule, StartOverModule, ], - providers:[LoginGuard], + providers:[LoginGuard, PreviousRouteRecorder], declarations: [ LinkingGenericComponent ], exports:[ diff --git a/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts b/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts index 287797a5..31708786 100644 --- a/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts +++ b/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { LoginGuard} from'../../login/loginGuard.guard'; import { MyClaimsComponent } from './myClaims.component'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: MyClaimsComponent, canActivate: [LoginGuard]}, + { path: '', component: MyClaimsComponent, canActivate: [LoginGuard], canDeactivate: [PreviousRouteRecorder]}, ]) ] diff --git a/portal-2/src/app/claims/myClaims/myClaims.module.ts b/portal-2/src/app/claims/myClaims/myClaims.module.ts index b3ea8b07..9f109887 100644 --- a/portal-2/src/app/claims/myClaims/myClaims.module.ts +++ b/portal-2/src/app/claims/myClaims/myClaims.module.ts @@ -6,6 +6,7 @@ import { MyClaimsRoutingModule } from './myClaims-routing.module'; // import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; import {LoginGuard} from'../../login/loginGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -15,7 +16,7 @@ import {LoginGuard} from'../../login/loginGuard.guard'; DisplayClaimsModule ], - providers:[LoginGuard], + providers:[LoginGuard, PreviousRouteRecorder], declarations: [ MyClaimsComponent ] diff --git a/portal-2/src/app/deposit/datasets/depositBySubjectResult-routing.module.ts b/portal-2/src/app/deposit/datasets/depositBySubjectResult-routing.module.ts index 58615174..2d3f57b9 100644 --- a/portal-2/src/app/deposit/datasets/depositBySubjectResult-routing.module.ts +++ b/portal-2/src/app/deposit/datasets/depositBySubjectResult-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { DepositBySubjectResultComponent } from './depositBySubjectResult.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositBySubjectResultComponent, canActivate: [FreeGuard] } + { path: '', component: DepositBySubjectResultComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts b/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts index 3de1bee9..32b1df35 100644 --- a/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts +++ b/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts @@ -10,6 +10,7 @@ import {OrganizationService} from '../../services/organization.service'; import { Meta} from '../../../angular2-meta'; import {RouterHelper} from '../../utils/routerHelper.class'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'deposit-by-subject-result', @@ -94,6 +95,7 @@ export class DepositBySubjectResultComponent { sub: any; subDataproviders: any; + piwiksub: any; public fetchDataproviders : FetchDataproviders; public routerHelper:RouterHelper = new RouterHelper(); @@ -107,7 +109,7 @@ export class DepositBySubjectResultComponent { constructor (private _router: Router, private route: ActivatedRoute, - private _searchDataprovidersService: SearchDataprovidersService, private _meta: Meta) { + private _searchDataprovidersService: SearchDataprovidersService, private _meta: Meta, private _piwikService:PiwikService) { this.zenodo = OpenaireProperties.getZenodoURL(); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); @@ -116,6 +118,9 @@ export class DepositBySubjectResultComponent { this.updateTitle("Deposit "+this.requestFor); this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor); this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe(); + } } updateDescription(description:string){ this._meta.updateMeta("description", description); @@ -141,6 +146,7 @@ export class DepositBySubjectResultComponent { this.searchDataproviders(); }); } + totalPages(): number { let totalPages:any = this.fetchDataproviders.searchUtils.totalResults/(this.fetchDataproviders.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -161,6 +167,9 @@ export class DepositBySubjectResultComponent { if(this.subDataproviders != undefined) { this.subDataproviders.unsubscribe(); } + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } public searchDataproviders() { diff --git a/portal-2/src/app/deposit/datasets/depositBySubjectResults.module.ts b/portal-2/src/app/deposit/datasets/depositBySubjectResults.module.ts index 24c1eab3..7c1c4598 100644 --- a/portal-2/src/app/deposit/datasets/depositBySubjectResults.module.ts +++ b/portal-2/src/app/deposit/datasets/depositBySubjectResults.module.ts @@ -7,16 +7,12 @@ import { DepositBySubjectResultComponent } from './depositBySubjectResult.compon import {DepositBySubjectResultsRoutingModule} from './depositBySubjectResult-routing.module'; import {DepoditModule} from '../deposit.module'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; import {PagingModule } from '../../utils/paging.module'; - - - import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; - import {SearchResultsModule } from '../../searchPages/searchUtils/searchResults.module'; - @NgModule({ imports: [ CommonModule, FormsModule, @@ -31,6 +27,6 @@ import {SearchResultsModule } from '../../searchPages/searchUtils/searchResults. exports: [ DepositBySubjectResultComponent, ], - providers: [FreeGuard ] + providers: [FreeGuard,PreviousRouteRecorder ] }) export class DepositBySubjectResultsModule { } diff --git a/portal-2/src/app/deposit/datasets/depositDatasets.module.ts b/portal-2/src/app/deposit/datasets/depositDatasets.module.ts index abf46750..40c2be1f 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasets.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasets.module.ts @@ -10,7 +10,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen import {DepositDatasetsRoutingModule} from './depositDatasets-routing.module'; import {DepoditModule} from '../deposit.module'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ CommonModule, FormsModule, @@ -25,7 +25,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; exports: [ DepositDatasetsComponent, ], - providers: [FreeGuard + providers: [FreeGuard,PreviousRouteRecorder ] }) export class DepositDatasetsModule { } diff --git a/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts b/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts index 158810f0..a13df5ec 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts @@ -1,13 +1,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; - +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositDatasetsResultComponent, canActivate: [FreeGuard] } + { path: '', component: DepositDatasetsResultComponent, canActivate: [FreeGuard] ,canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts b/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts index d4704b5b..deacbfbf 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts @@ -7,6 +7,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-routing.module'; import {DepoditModule} from '../deposit.module'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -22,7 +23,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; exports: [ DepositDatasetsResultComponent, ], - providers: [FreeGuard + providers: [FreeGuard,PreviousRouteRecorder ] }) export class DepositDatasetsResultsModule { } diff --git a/portal-2/src/app/deposit/deposit.component.ts b/portal-2/src/app/deposit/deposit.component.ts index b209efad..fa23389d 100644 --- a/portal-2/src/app/deposit/deposit.component.ts +++ b/portal-2/src/app/deposit/deposit.component.ts @@ -3,6 +3,7 @@ import {Observable} from 'rxjs/Observable'; import { Router } from '@angular/router'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import { Meta} from '../../angular2-meta'; +import {PiwikService} from '../utils/piwik/piwik.service'; @Component({ @@ -65,8 +66,9 @@ export class DepositComponent { public errorCodes:ErrorCodes = new ErrorCodes(); public selectedId: string = ""; public warningMessage: string = ""; + piwiksub:any; - constructor (private _router: Router, private _meta: Meta) { + constructor (private _router: Router, private _meta: Meta, private _piwikService:PiwikService) { this.openAccess = OpenaireProperties.getOpenAccess(); this.openAccessRepo = OpenaireProperties.getOpenAccessRepo(); @@ -77,6 +79,12 @@ export class DepositComponent { this.updateTitle("Deposit "+this.requestFor); this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor); this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); + this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe(); + } + ngOnDestroy() { + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } updateDescription(description:string){ this._meta.updateMeta("description", description); diff --git a/portal-2/src/app/deposit/deposit.module.ts b/portal-2/src/app/deposit/deposit.module.ts index 85ff6657..fa06f812 100644 --- a/portal-2/src/app/deposit/deposit.module.ts +++ b/portal-2/src/app/deposit/deposit.module.ts @@ -11,6 +11,8 @@ import {EntitiesAutocompleteModule} from '../utils/entitiesAutoComplete/entities import {DataProvidersServiceModule} from '../services/dataProvidersService.module'; import {OrganizationServiceModule} from '../services/organizationService.module'; import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.module'; +import {PiwikServiceModule} from '../utils/piwik/piwikService.module'; + @NgModule({ @@ -20,7 +22,8 @@ import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.mod EntitiesAutocompleteModule, DataProvidersServiceModule, OrganizationServiceModule, - SearchResultsModule + SearchResultsModule, + PiwikServiceModule ], declarations: [ DepositComponent, diff --git a/portal-2/src/app/deposit/depositResult.component.ts b/portal-2/src/app/deposit/depositResult.component.ts index 7a92f56f..2466e5c5 100644 --- a/portal-2/src/app/deposit/depositResult.component.ts +++ b/portal-2/src/app/deposit/depositResult.component.ts @@ -10,6 +10,7 @@ import {OrganizationService} from '../services/organization.service'; import { Meta} from '../../angular2-meta'; import {RouterHelper} from '../utils/routerHelper.class'; +import {PiwikService} from '../utils/piwik/piwik.service'; @Component({ selector: 'deposit-result', @@ -132,7 +133,7 @@ export class DepositResultComponent { public status: number; public errorCodes:ErrorCodes = new ErrorCodes(); - sub: any; + sub: any; piwiksub: any; subDataproviders: any; public routerHelper:RouterHelper = new RouterHelper(); @@ -145,7 +146,7 @@ export class DepositResultComponent { constructor (private _router: Router, private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService, - private _organizationService: OrganizationService, private _meta: Meta) { + private _organizationService: OrganizationService, private _meta: Meta, private _piwikService:PiwikService) { this.zenodo = OpenaireProperties.getZenodoURL(); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); @@ -154,6 +155,7 @@ export class DepositResultComponent { this.updateTitle("Deposit "+this.requestFor); this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor); this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); + this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe(); } updateDescription(description:string){ this._meta.updateMeta("description", description); @@ -192,6 +194,9 @@ export class DepositResultComponent { ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} if(this.subDataproviders != undefined) { this.subDataproviders.unsubscribe(); } diff --git a/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts b/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts index e7fbcc84..c5134f39 100644 --- a/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts @@ -1,13 +1,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; - +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; import { DepositPublicationsComponent } from './depositPublications.component'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositPublicationsComponent, canActivate: [FreeGuard] } + { path: '', component: DepositPublicationsComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/deposit/publications/depositPublications.module.ts b/portal-2/src/app/deposit/publications/depositPublications.module.ts index 77ccc00e..4c927688 100644 --- a/portal-2/src/app/deposit/publications/depositPublications.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublications.module.ts @@ -8,6 +8,7 @@ import {DepositPublicationsRoutingModule} from './depositPublications-routing.mo import {DepoditModule} from '../deposit.module'; import {IFrameModule} from '../../utils/iframe.module'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -23,7 +24,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; exports: [ DepositPublicationsComponent, ], - providers: [FreeGuard + providers: [FreeGuard,PreviousRouteRecorder ] }) export class DepositPublicationsModule { } diff --git a/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts b/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts index bdd8a8f2..89f21b2c 100644 --- a/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts @@ -1,13 +1,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; - +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; import { DepositPublicationsResultComponent } from './depositPublicationsResult.component'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositPublicationsResultComponent, canActivate: [FreeGuard] } + { path: '', component: DepositPublicationsResultComponent, canActivate: [FreeGuard] ,canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts b/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts index d5f5bb90..71b25241 100644 --- a/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts @@ -7,6 +7,7 @@ import { DepositPublicationsResultComponent } from './depositPublicationsResult. import {DepositPublicationsResultRoutingModule} from './depositPublicationsResult-routing.module'; import {DepoditModule} from '../deposit.module'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ @@ -22,7 +23,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; exports: [ DepositPublicationsResultComponent, ], - providers: [FreeGuard + providers: [FreeGuard,PreviousRouteRecorder ] }) export class DepositPublicationsResultsModule { } diff --git a/portal-2/src/app/error/error-routing.module.ts b/portal-2/src/app/error/error-routing.module.ts index e3dc1986..1dca0f73 100644 --- a/portal-2/src/app/error/error-routing.module.ts +++ b/portal-2/src/app/error/error-routing.module.ts @@ -2,12 +2,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { ErrorPageComponent } from './errorPage.component'; +import {PreviousRouteRecorder} from'../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: 'error', component: ErrorPageComponent}, - { path: '**', component: ErrorPageComponent}, + { path: 'error', component: ErrorPageComponent,canDeactivate: [PreviousRouteRecorder] }, + { path: '**', component: ErrorPageComponent,canDeactivate: [PreviousRouteRecorder] }, ]) ] diff --git a/portal-2/src/app/error/error.module.ts b/portal-2/src/app/error/error.module.ts index d1905ce6..9b1fe824 100644 --- a/portal-2/src/app/error/error.module.ts +++ b/portal-2/src/app/error/error.module.ts @@ -4,13 +4,14 @@ import { FormsModule } from '@angular/forms'; import { ErrorPageComponent } from './errorPage.component'; import { ErrorRoutingModule } from './error-routing.module'; +import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ CommonModule, FormsModule, ErrorRoutingModule - ], + ],providers:[PreviousRouteRecorder], declarations: [ ErrorPageComponent diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts index 5911e19e..5e79b43a 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { DataProviderComponent } from './dataProvider.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DataProviderComponent, canActivate: [FreeGuard] } + { path: '', component: DataProviderComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] }) diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts index 4d322cac..861a7931 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts @@ -14,6 +14,8 @@ import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDatapr import { SearchDataprovidersService } from '../../services/searchDataproviders.service'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {RouterHelper} from '../../utils/routerHelper.class'; +import {PiwikService} from '../../utils/piwik/piwik.service'; + @Component({ selector: 'dataprovider', templateUrl: 'dataProvider.component.html', @@ -22,6 +24,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; export class DataProviderComponent { sub: any; + piwiksub: any; datasourceId: string; public dataProviderInfo: DataProviderInfo; @@ -77,6 +80,7 @@ export class DataProviderComponent { constructor (private element: ElementRef, private _dataproviderService: DataProviderService, + private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, private _router: Router, @@ -112,6 +116,9 @@ export class DataProviderComponent { ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } getDataProviderInfo(id:string) { this.warningMessage = ''; @@ -130,6 +137,9 @@ export class DataProviderComponent { this.showTabs = true ; this.updateTitle(this.dataProviderInfo.title.name); this.updateDescription("Data provider, search, repositories, open access,"+this.dataProviderInfo.title.name); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.dataProviderInfo.title.name).subscribe(); + } this.showLoading = false; diff --git a/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts b/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts index 9a8ce7d5..71284237 100644 --- a/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts +++ b/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { DatasetComponent } from './dataset.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DatasetComponent, canActivate: [FreeGuard] } + { path: '', component: DatasetComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] }) diff --git a/portal-2/src/app/landingPages/dataset/dataset.component.ts b/portal-2/src/app/landingPages/dataset/dataset.component.ts index c7576dce..b211e755 100644 --- a/portal-2/src/app/landingPages/dataset/dataset.component.ts +++ b/portal-2/src/app/landingPages/dataset/dataset.component.ts @@ -6,6 +6,7 @@ import {ActivatedRoute, Router} from '@angular/router'; import {OpenaireProperties} from '../../utils/properties/openaireProperties' import {RouterHelper} from '../../utils/routerHelper.class'; import { Meta} from '../../../angular2-meta'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'dataset', @@ -27,7 +28,7 @@ export class DatasetComponent { private showAllBioentities: boolean = false; private datasetId : string ; private result ; - sub: any; + sub: any; piwiksub: any; private activeTab: string = "Related Research Results"; private metricsClicked: boolean; @@ -47,6 +48,7 @@ export class DatasetComponent { constructor (private element: ElementRef, private _datasetService: DatasetService, + private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, private _router: Router) { @@ -87,6 +89,9 @@ export class DatasetComponent { ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } getDatasetInfo(id:string) { @@ -99,6 +104,10 @@ export class DatasetComponent { this.datasetInfo = data; this.updateTitle(this.datasetInfo.title.name); this.updateDescription("Dataset, search, repositories, open access,"+this.datasetInfo.title.name); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.datasetInfo.title.name).subscribe(); + } + this.result = [] this.result = {id: id, type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.title.accessMode, embargoEndDate: ''}; diff --git a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts index 8d7db9ef..0e6472e0 100644 --- a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts +++ b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { HtmlProjectReportComponent } from './htmlProjectReport.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard]} + { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder]} ]) ] }) diff --git a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts index 099509ff..999ead9b 100644 --- a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts +++ b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -6,6 +6,7 @@ import {HtmlProjectReportService} from './htmlProjectReport.service'; import {ProjectService} from '../project/project.service'; import {OpenaireProperties} from '../../utils/properties/openaireProperties'; import { Meta} from '../../../angular2-meta'; +import {PiwikService} from '../../utils/piwik/piwik.service'; declare var UIkit: any; @@ -38,7 +39,7 @@ declare var UIkit: any; - + ` }) export class HtmlProjectReportComponent{ @@ -50,7 +51,7 @@ export class HtmlProjectReportComponent{ public header2: string = ""; public htmlResult: string = ""; - public sub; + public sub; piwiksub: any; public subHTML; public subHTMLInfo; @@ -60,6 +61,7 @@ export class HtmlProjectReportComponent{ constructor ( private route: ActivatedRoute, private htmlService: HtmlProjectReportService, + private _piwikService:PiwikService, private _projectService: ProjectService, private _meta: Meta, private _router: Router) { this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); @@ -97,7 +99,11 @@ export class HtmlProjectReportComponent{ }); } - ngOnDestroy() {} + ngOnDestroy() { + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} + } createHeaders() { this._projectService.getHTMLInfo(this.projectId).subscribe( @@ -108,6 +114,9 @@ export class HtmlProjectReportComponent{ } else if(data.title){ this.updateTitle(data.title+" "+this.resultsType+" report"); } + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(((data.acronym)?data.acronym:data.title)+" "+this.resultsType+" report").subscribe(); + } }, err => { console.log(err); diff --git a/portal-2/src/app/landingPages/landing.module.ts b/portal-2/src/app/landingPages/landing.module.ts index 56632800..5ac0e990 100644 --- a/portal-2/src/app/landingPages/landing.module.ts +++ b/portal-2/src/app/landingPages/landing.module.ts @@ -7,15 +7,18 @@ import { FormsModule } from '@angular/forms'; import {TabPagingComponent} from './tabPaging.component'; import {ShowTitleComponent} from './showTitle.component'; import {AddThisComponent} from './addThis.component'; +import {PiwikServiceModule} from '../utils/piwik/piwikService.module'; +import {PreviousRouteRecorder} from'../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ - CommonModule, FormsModule + CommonModule, FormsModule, PiwikServiceModule ], declarations: [ TabPagingComponent, ShowTitleComponent, AddThisComponent ], providers:[ + PreviousRouteRecorder ], exports: [ TabPagingComponent, ShowTitleComponent, AddThisComponent diff --git a/portal-2/src/app/landingPages/organization/organization-routing.module.ts b/portal-2/src/app/landingPages/organization/organization-routing.module.ts index aaf1fa89..34c340ab 100644 --- a/portal-2/src/app/landingPages/organization/organization-routing.module.ts +++ b/portal-2/src/app/landingPages/organization/organization-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { OrganizationComponent } from './organization.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: OrganizationComponent, canActivate: [FreeGuard] } + { path: '', component: OrganizationComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] }) diff --git a/portal-2/src/app/landingPages/organization/organization.component.ts b/portal-2/src/app/landingPages/organization/organization.component.ts index 66c8d444..547dc116 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.ts +++ b/portal-2/src/app/landingPages/organization/organization.component.ts @@ -18,6 +18,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; import {ModalLoading} from '../../utils/modal/loading.component'; import {AlertModal} from '../../utils/modal/alert'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'organization', @@ -42,6 +43,7 @@ export class OrganizationComponent { public csvParamsTail: string; sub: any; + piwiksub: any; public activeTab: string = "Publications"; public reloadDataproviders: boolean = true; @@ -69,6 +71,7 @@ export class OrganizationComponent { constructor (private element: ElementRef, private _organizationService: OrganizationService, + private _piwikService:PiwikService, private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService, private _reportsService: ReportsService, @@ -116,6 +119,9 @@ export class OrganizationComponent { ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } private getOrganizationInfo () { @@ -133,7 +139,9 @@ export class OrganizationComponent { this.organizationInfo = data; this.updateTitle(this.organizationInfo.title.name); this.updateDescription("Organization, country, projects, search, repositories, open access"+this.organizationInfo.title.name); - + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.organizationInfo.title.name).subscribe(); + } var refineFields:string [] = ["funder"]; this.searchPublications(); @@ -242,6 +250,9 @@ export class OrganizationComponent { data => { this.closeLoading(); window.open(window.URL.createObjectURL(data)); + // if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + // this._piwikService.trackDownload(url).subscribe(); + // } }, error => { console.log("Error downloading the file."); @@ -290,6 +301,9 @@ export class OrganizationComponent { } this.closeLoading(); window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); + // if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + // this._piwikService.trackDownload(url).subscribe(); + // } } } else { title = true; @@ -308,6 +322,9 @@ export class OrganizationComponent { } this.closeLoading(); window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); + // if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + // this._piwikService.trackDownload(url).subscribe(); + // } } }, error => { diff --git a/portal-2/src/app/landingPages/project/project-routing.module.ts b/portal-2/src/app/landingPages/project/project-routing.module.ts index 1a419d3f..0d475223 100644 --- a/portal-2/src/app/landingPages/project/project-routing.module.ts +++ b/portal-2/src/app/landingPages/project/project-routing.module.ts @@ -2,11 +2,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { ProjectComponent } from './project.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: ProjectComponent } + { path: '', component: ProjectComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] }) diff --git a/portal-2/src/app/landingPages/project/project.component.ts b/portal-2/src/app/landingPages/project/project.component.ts index 7e57fb51..38542774 100644 --- a/portal-2/src/app/landingPages/project/project.component.ts +++ b/portal-2/src/app/landingPages/project/project.component.ts @@ -16,6 +16,7 @@ import {ReportsService} from '../../services/reports.service'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import { Meta} from '../../../angular2-meta'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'project', @@ -50,7 +51,7 @@ export class ProjectComponent{ public errorMessage = ""; public showLoading: boolean = true; - sub: any; + sub: any;piwiksub: any; public activeTab: string = "Publications"; public reloadDatasets: boolean = true; @@ -66,6 +67,7 @@ export class ProjectComponent{ constructor ( private element: ElementRef, private _projectService: ProjectService, + private _piwikService:PiwikService, private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService, private _searchDatasetsService: SearchDatasetsService, @@ -78,7 +80,6 @@ export class ProjectComponent{ this.sub = this.route.queryParams.subscribe(params => { this.metricsClicked = false; this.statsClicked = false; - this.fetchPublications = new FetchPublications( this._searchPublicationsService); this.fetchDatasets = new FetchDatasets(this._searchDatasetsService); @@ -130,6 +131,9 @@ export class ProjectComponent{ ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } createClipboard() { @@ -186,6 +190,10 @@ console.info(this.projectInfo.title); } this.updateTitle(this.projectName); this.updateDescription("project, funding, open access, publications, datasets, "+this.projectName+ ","+this.projectInfo.funder); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.projectName).subscribe(); + } + this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate }; this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; diff --git a/portal-2/src/app/landingPages/project/project.module.ts b/portal-2/src/app/landingPages/project/project.module.ts index cbbea93e..ee71b286 100644 --- a/portal-2/src/app/landingPages/project/project.module.ts +++ b/portal-2/src/app/landingPages/project/project.module.ts @@ -17,6 +17,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import { LandingModule } from '../landing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -30,6 +31,7 @@ import { LandingModule } from '../landing.module'; providers:[ // ProjectService, // HtmlProgressReportService + FreeGuard ], exports: [ ProjectComponent diff --git a/portal-2/src/app/landingPages/publication/publication-routing.module.ts b/portal-2/src/app/landingPages/publication/publication-routing.module.ts index d2d40638..a45ef386 100644 --- a/portal-2/src/app/landingPages/publication/publication-routing.module.ts +++ b/portal-2/src/app/landingPages/publication/publication-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { PublicationComponent } from './publication.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: PublicationComponent, canActivate: [FreeGuard] } + { path: '', component: PublicationComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] }) diff --git a/portal-2/src/app/landingPages/publication/publication.component.ts b/portal-2/src/app/landingPages/publication/publication.component.ts index 654cb02f..2a87d917 100644 --- a/portal-2/src/app/landingPages/publication/publication.component.ts +++ b/portal-2/src/app/landingPages/publication/publication.component.ts @@ -5,6 +5,8 @@ import {PublicationInfo} from '../../utils/entities/publicationInfo'; import {ActivatedRoute, Router} from '@angular/router'; import {OpenaireProperties} from '../../utils/properties/openaireProperties'; import {RouterHelper} from '../../utils/routerHelper.class'; +import {PiwikService} from '../../utils/piwik/piwik.service'; + import { Meta} from '../../../angular2-meta'; @@ -22,7 +24,7 @@ export class PublicationComponent { public showAllFundedBy: boolean = false; public showAllPublishedIn: boolean = false; - sub: any; + sub: any;piwiksub: any; articleId: string; public publicationInfo: PublicationInfo; private metricsClicked: boolean; @@ -64,6 +66,7 @@ export class PublicationComponent { constructor ( private element: ElementRef, private _publicationService: PublicationService, + private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, private _router: Router) { this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); @@ -107,6 +110,9 @@ export class PublicationComponent { ngOnDestroy() { this.sub.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } getPublicationInfo(id:string) { @@ -122,6 +128,9 @@ export class PublicationComponent { // this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''}; this.updateTitle(this.publicationInfo.title.name); this.updateDescription("Dataset, search, repositories, open access,"+this.publicationInfo.title.name); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.publicationInfo.title.name).subscribe(); + } let bioentitiesNum = 0; if(this.publicationInfo.bioentities != undefined) { diff --git a/portal-2/src/app/login/user-routing.module.ts b/portal-2/src/app/login/user-routing.module.ts index 5ec9f8a1..6bbadb82 100644 --- a/portal-2/src/app/login/user-routing.module.ts +++ b/portal-2/src/app/login/user-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { UserComponent } from './user.component'; +import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: UserComponent}, + { path: '', component: UserComponent, canDeactivate: [PreviousRouteRecorder]}, ]) ] diff --git a/portal-2/src/app/login/user.module.ts b/portal-2/src/app/login/user.module.ts index c97ced2d..f306984c 100644 --- a/portal-2/src/app/login/user.module.ts +++ b/portal-2/src/app/login/user.module.ts @@ -4,6 +4,8 @@ import { FormsModule } from '@angular/forms'; import {UserComponent } from './user.component'; import { UserRoutingModule } from './user-routing.module'; +import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; + // import {LoginService} from './login.service'; @NgModule({ imports: [ @@ -11,7 +13,7 @@ import { UserRoutingModule } from './user-routing.module'; UserRoutingModule ], - // providers:[LoginService], + providers:[PreviousRouteRecorder], declarations: [ UserComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts index 4c3fb074..091abbbb 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts @@ -1,13 +1,13 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchDataProvidersComponent, canActivate: [FreeGuard] } + { path: '', component: AdvancedSearchDataProvidersComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts index 700d65f3..f5d0bbea 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchDatasetsComponent, canActivate: [FreeGuard] } + { path: '', component: AdvancedSearchDatasetsComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts index c04401bc..2163be14 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchOrganizationsComponent , canActivate: [FreeGuard]} + { path: '', component: AdvancedSearchOrganizationsComponent , canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder]} ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts index edf916e8..46df98c2 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchProjectsComponent, canActivate: [FreeGuard] } + { path: '', component: AdvancedSearchProjectsComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts index f56f4348..204d7544 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchPublicationsComponent, canActivate: [FreeGuard] } + { path: '', component: AdvancedSearchPublicationsComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts index 58111a67..8e14f10f 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchCompatibleDataprovidersComponent, canActivate: [FreeGuard] } + { path: '', component: SearchCompatibleDataprovidersComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable-routing.module.ts index db9d5128..972846b9 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchCompatibleDataprovidersTableComponent} from './compatibleDataProvidersTable.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchCompatibleDataprovidersTableComponent, canActivate: [FreeGuard] } + { path: '', component: SearchCompatibleDataprovidersTableComponent, canActivate: [FreeGuard] , canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts index 46ea5b44..f48c3475 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchEntityRegistriesComponent} from './entityRegistries.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchEntityRegistriesComponent, canActivate: [FreeGuard] } + { path: '', component: SearchEntityRegistriesComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable-routing.module.ts index d355963d..db1d512c 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchEntityRegistriesTableComponent} from './entityRegistriesTable.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchEntityRegistriesTableComponent, canActivate: [FreeGuard] } + { path: '', component: SearchEntityRegistriesTableComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/journals-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/journals-routing.module.ts index fb1549f1..de33b1b7 100644 --- a/portal-2/src/app/searchPages/dataProviders/journals-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/journals-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchJournalsComponent} from './journals.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchJournalsComponent, canActivate: [FreeGuard] } + { path: '', component: SearchJournalsComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/journalsTable-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/journalsTable-routing.module.ts index 2f92f754..af6dcfd6 100644 --- a/portal-2/src/app/searchPages/dataProviders/journalsTable-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/journalsTable-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchJournalsTableComponent} from './journalsTable.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchJournalsTableComponent, canActivate: [FreeGuard] } + { path: '', component: SearchJournalsTableComponent, canActivate: [FreeGuard] , canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts b/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts index ab4c3d22..69df52f5 100644 --- a/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts +++ b/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import{SearchComponent} from './search.component'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchComponent, canActivate: [FreeGuard] } + { path: '', component: SearchComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/find/mainSearch.module.ts b/portal-2/src/app/searchPages/find/mainSearch.module.ts index dc10e764..3f368f5e 100644 --- a/portal-2/src/app/searchPages/find/mainSearch.module.ts +++ b/portal-2/src/app/searchPages/find/mainSearch.module.ts @@ -17,19 +17,21 @@ import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; //import {SearchFilterModalModule} from '../searchUtils/searchFilterModal.module'; import {FreeGuard} from'../../login/freeGuard.guard'; +import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule, OrganizationsServiceModule, - BrowseEntitiesModule, SearchFormModule, SearchResultsModule, MainSearchRoutingModule//, SearchFilterModalModule + BrowseEntitiesModule, SearchFormModule, SearchResultsModule, MainSearchRoutingModule, PiwikServiceModule//, SearchFilterModalModule ], declarations: [ SearchComponent ], - providers:[FreeGuard + providers:[FreeGuard, PreviousRouteRecorder ], exports: [ SearchComponent diff --git a/portal-2/src/app/searchPages/find/search.component.ts b/portal-2/src/app/searchPages/find/search.component.ts index 86112df9..39e63635 100644 --- a/portal-2/src/app/searchPages/find/search.component.ts +++ b/portal-2/src/app/searchPages/find/search.component.ts @@ -23,6 +23,7 @@ import {ErrorCodes} from '../../utils/properties/openaireProperties'; import {RouterHelper} from '../../utils/routerHelper.class'; import {NumberUtils} from '../../utils/number-utils.class'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -309,7 +310,7 @@ import {RefineFieldResultsService} from '../../services/refineFieldResults.servi ` }) export class SearchComponent { - public sub: any; + public sub: any; piwiksub: any; public subfunders: any; public reloadPublications: boolean; public reloadDatasets: boolean; @@ -358,22 +359,25 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; private _searchDatasetsService: SearchDatasetsService, private _searchOrganizationsService: SearchOrganizationsService, private _refineFieldResultsService:RefineFieldResultsService, - private location: Location, private _meta: Meta ) { - this.fetchPublications = new FetchPublications(this._searchPublicationsService); - this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); - this.fetchProjects = new FetchProjects(this._searchProjectsService); - this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); - this.fetchOrganizations = new FetchOrganizations( this._searchOrganizationsService); + private location: Location, private _meta: Meta,private _piwikService:PiwikService ) { + this.fetchPublications = new FetchPublications(this._searchPublicationsService); + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + this.fetchProjects = new FetchProjects(this._searchProjectsService); + this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); + this.fetchOrganizations = new FetchOrganizations( this._searchOrganizationsService); - var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects "; - var title = "Search publications, datasets, projects... | OpenAIRE"; - var url = OpenaireProperties.getBaseLink()+this._router.url; - this._meta.setTitle(title); - this._meta.updateMeta("description", description); - this._meta.updateProperty("og:description", description); - this._meta.updateProperty("og:title", title); - this._meta.updateProperty("og:url", url); - this.getNumbers(); + var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects "; + var title = "Search publications, datasets, projects... | OpenAIRE"; + var url = OpenaireProperties.getBaseLink()+this._router.url; + this._meta.setTitle(title); + this._meta.updateMeta("description", description); + this._meta.updateProperty("og:description", description); + this._meta.updateProperty("og:title", title); + this._meta.updateProperty("og:url", url); + this.getNumbers(); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView("Search publications, datasets, projects... | OpenAIRE").subscribe(); + } } @@ -392,6 +396,9 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; public ngOnDestroy() { this.sub.unsubscribe(); this.subfunders.unsubscribe(); + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} if(this.keyword !=null && this.keyword.length > 0){ if(this.subPub){ this.subPub.unsubscribe(); diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts index 279324e5..52e4316a 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -1,6 +1,7 @@ import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {Location} from '@angular/common'; +import { Router} from '@angular/router'; import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; import {SearchResult} from '../../utils/entities/searchResult'; import {SearchFields} from '../../utils/properties/searchFields'; @@ -9,6 +10,7 @@ import {ModalLoading} from '../../utils/modal/loading.component'; import {StringUtils, Dates} from '../../utils/string-utils.class'; import { Meta} from '../../../angular2-meta'; import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'advanced-search-page', @@ -67,7 +69,7 @@ export class AdvancedSearchPageComponent { @Input() csvPath: string; @Input() simpleSearchLink: string = ""; @Input() disableForms:boolean = false; - + piwiksub: any; public parameterNames:string[] =[]; public parameterValues:string[] =[]; @@ -75,7 +77,7 @@ export class AdvancedSearchPageComponent { public baseURLWithParameters:string = ''; @Output() queryChange = new EventEmitter(); - constructor (private location: Location, private _meta: Meta) { + constructor (private location: Location, private _meta: Meta, private _piwikService:PiwikService, private router: Router) { } ngOnInit() { @@ -88,6 +90,15 @@ export class AdvancedSearchPageComponent { this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; this.updateBaseUrlWithParameters(); this.defineUrlParam(); + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe(); + } + } + + ngOnDestroy() { + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } updateDescription(description:string){ this._meta.updateMeta("description", description); @@ -249,7 +260,15 @@ export class AdvancedSearchPageComponent { this.queryChange.emit({ value: queryParameters }); - + /* Code For Piwik*/ + if (typeof localStorage !== 'undefined') { + console.log("In PreviousRouteRecorder : "+this.router.url ); + localStorage.setItem('previousRoute', this.router.url); + } + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe(); + } + /* End Piwik Code */ } queryChanged($event) { diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.module.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.module.ts index 6d84f1c6..f4811758 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.module.ts @@ -11,16 +11,19 @@ import {SearchDownloadModule} from './searchDownload.module'; import{SearchPagingModule} from './searchPaging.module'; import {AdvancedSearchFormModule} from '../searchUtils/advancedSearchForm.module'; +import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ - CommonModule, FormsModule, RouterModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, AdvancedSearchFormModule, SearchDownloadModule + CommonModule, FormsModule, RouterModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, AdvancedSearchFormModule, SearchDownloadModule, PiwikServiceModule ], declarations: [ AdvancedSearchPageComponent, ], providers:[ + PreviousRouteRecorder ], exports: [ AdvancedSearchPageComponent, diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts index 08dc4b67..c6568ba7 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts @@ -1,6 +1,8 @@ import {Component, Input, ViewChild, Output, EventEmitter,ElementRef} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {Location} from '@angular/common'; +import { Router} from '@angular/router'; + import { Filter, Value} from './searchHelperClasses.class'; import {SearchResult} from '../../utils/entities/searchResult'; import {SearchFields} from '../../utils/properties/searchFields'; @@ -12,6 +14,7 @@ import{SearchFilterComponent} from './searchFilter.component'; import {SearchFilterModalComponent} from './searchFilterModal.component'; import {OpenaireProperties} from '../../utils/properties/openaireProperties'; import { ErrorCodes} from '../../utils/properties/openaireProperties'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ @@ -136,13 +139,12 @@ export class SearchPageComponent { @Input() disableForms: boolean = false; @Input() tableView: boolean = false; @Input() searchFormClass: string = "searchForm"; - @ViewChild (ModalLoading) loading : ModalLoading ; public fieldIdsMap;//: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }}; private searchFieldsHelper:SearchFields = new SearchFields(); private queryParameters: Map = new Map(); private baseURLWithParameters:string = ''; - private sub: any; + private sub: any; piwiksub: any; public countFilters= 0; public urlParam: string; public parameterNames:string[] =[]; @@ -151,7 +153,7 @@ export class SearchPageComponent { //@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; public currentFilter: Filter; - constructor (private location: Location , private _meta: Meta,private element: ElementRef) { + constructor (private location: Location , private _meta: Meta,private element: ElementRef,private _piwikService:PiwikService, private router: Router) { } ngOnInit() { @@ -165,12 +167,19 @@ export class SearchPageComponent { if(typeof window !== 'undefined') { this.updateUrl(OpenaireProperties.getBaseLink()+location.pathname); } + if(typeof document !== 'undefined' && OpenaireProperties.isPiwikTrackEnabled()){ + this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe(); + } // console.info(this.entityType + " " + this.urlParam + this.type); } ngAfterViewChecked(){ } - + ngOnDestroy() { + if(this.piwiksub){ + this.piwiksub.unsubscribe(); + } + } toggleModal($event) { this.currentFilter = $event.value; //this.searchFilterModal.open(); @@ -337,6 +346,7 @@ export class SearchPageComponent { */ public updateBaseUrlWithParameters(filters:Filter[]){ this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(filters,false); + } /* * @@ -509,7 +519,15 @@ export class SearchPageComponent { var indexQuery = this.createIndexQueryParameters(this.filters); this.location.go(location.pathname,urlParameters); - +/* Code For Piwik*/ + if (typeof localStorage !== 'undefined') { + console.log("In PreviousRouteRecorder : "+this.router.url ); + localStorage.setItem('previousRoute', this.router.url); + } + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe(); + } + /* End Piwik Code */ this.queryChange.emit({ value: queryParameters, index:indexQuery diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.module.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.module.ts index aca9c561..fde1b144 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.module.ts @@ -15,27 +15,25 @@ import {ReportsServiceModule} from '../../services/reportsService.module'; import{SearchPagingModule} from './searchPaging.module'; import {SearchDownloadModule} from './searchDownload.module'; import {ModalModule} from '../../utils/modal/modal.module'; +import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule, - /*DatasourceTableViewModule,*/ LoadingModalModule, ReportsServiceModule, - SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule + LoadingModalModule, ReportsServiceModule, + SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule ], declarations: [ - SearchPageComponent//, - //SearchFilterComponent, - //SearchFilterModalComponent - , + SearchPageComponent ], providers:[ + PreviousRouteRecorder ], exports: [ - SearchPageComponent//, - //SearchFilterComponent, - //SearchFilterModalComponent + SearchPageComponent ] }) export class SearchPageModule { } diff --git a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.ts index f5d4f2bf..8128d092 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.ts @@ -13,6 +13,7 @@ import {SearchFilterModalComponent} from './searchFilterModal.component'; import { ErrorCodes} from '../../utils/properties/openaireProperties'; import {OpenaireProperties} from '../../utils/properties/openaireProperties'; import {ContentProvidersDatatablePipe} from '../../utils/pipes/contentProvidersDatatable.pipe'; +import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'search-page-table', @@ -178,8 +179,8 @@ export class SearchPageTableViewComponent { @ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; public currentFilter: Filter; public errorCodes:ErrorCodes = new ErrorCodes(); - - constructor (private location: Location , private _meta: Meta) { + piwiksub: any; + constructor (private location: Location , private _meta: Meta, private _piwikService:PiwikService) { } ngOnInit() { @@ -188,8 +189,15 @@ export class SearchPageTableViewComponent { if(typeof window !== 'undefined') { this.updateUrl(OpenaireProperties.getBaseLink()+location.pathname); } + if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){ + this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe(); + } + } + ngOnDestroy() { + if(this.piwiksub){ + this.piwiksub.unsubscribe(); +} } - public sortByOrganization = (dataprovider: any) => { if(dataprovider.organizations && dataprovider.organizations.length > 0) { return dataprovider.organizations[0].name.toUpperCase(); diff --git a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts index b02c898d..98fb7eaf 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts @@ -19,11 +19,13 @@ import {PagingModule} from '../../utils/paging.module'; import {DataTableModule} from "angular2-datatable"; import {ContentProvidersDatatablePipe} from '../../utils/pipes/contentProvidersDatatable.pipe'; +import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule, /*DatasourceTableViewModule,*/ LoadingModalModule, - ReportsServiceModule, SearchPagingModule, SearchDownloadModule, ModalModule, PagingModule, DataTableModule, SearchFilterModule + ReportsServiceModule, SearchPagingModule, SearchDownloadModule, ModalModule, PagingModule, DataTableModule, SearchFilterModule, PiwikServiceModule ], declarations: [ SearchPageTableViewComponent//, @@ -34,6 +36,7 @@ import {ContentProvidersDatatablePipe} from '../../utils/pipes/contentProvidersD ], providers:[ + PreviousRouteRecorder ], exports: [ SearchPageTableViewComponent//, diff --git a/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts b/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts index fefe1cc3..0712f8d5 100644 --- a/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchDataprovidersComponent} from './searchDataproviders.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchDataprovidersComponent, canActivate: [FreeGuard] } + { path: '', component: SearchDataprovidersComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts b/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts index a3f3e976..57548af8 100644 --- a/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchDatasetsComponent} from './searchDatasets.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchDatasetsComponent, canActivate: [FreeGuard] } + { path: '', component: SearchDatasetsComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts b/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts index cb8ff00d..fc51cb82 100644 --- a/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchOrganizationsComponent} from './searchOrganizations.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchOrganizationsComponent, canActivate: [FreeGuard] } + { path: '', component: SearchOrganizationsComponent, canActivate: [FreeGuard] , canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts b/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts index 11f2e575..6c5d9ab2 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchProjectsComponent} from './searchProjects.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchProjectsComponent, canActivate: [FreeGuard] } + { path: '', component: SearchProjectsComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts b/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts index ace89403..507114e1 100644 --- a/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts @@ -3,11 +3,11 @@ import { RouterModule } from '@angular/router'; import{SearchPublicationsComponent} from './searchPublications.component'; import {FreeGuard} from'../../login/freeGuard.guard'; - +import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchPublicationsComponent, canActivate: [FreeGuard] } + { path: '', component: SearchPublicationsComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/portal-2/src/app/sharedComponents/feedback/feedback.component.ts b/portal-2/src/app/sharedComponents/feedback/feedback.component.ts index 2b2b4444..8277bd82 100644 --- a/portal-2/src/app/sharedComponents/feedback/feedback.component.ts +++ b/portal-2/src/app/sharedComponents/feedback/feedback.component.ts @@ -25,7 +25,7 @@ export class FeedbackComponent { constructor(private route: ActivatedRoute) {} ngOnInit() { - this.feedbackmail = OpenaireProperties.getFeedbackMail(); + // this.feedbackmail = OpenaireProperties.getFeedbackMail(); this.initialize(); this.sub = this.route.queryParams.subscribe(params => { this.initialize(); diff --git a/portal-2/src/app/sharedComponents/sharedComponents.module.ts b/portal-2/src/app/sharedComponents/sharedComponents.module.ts index 329e4dbe..f13e3d7a 100644 --- a/portal-2/src/app/sharedComponents/sharedComponents.module.ts +++ b/portal-2/src/app/sharedComponents/sharedComponents.module.ts @@ -11,6 +11,7 @@ import {FeedbackComponent} from './feedback/feedback.component'; import {UserMiniComponent} from '../login/userMini.component'; + @NgModule({ imports: [ CommonModule, FormsModule, diff --git a/portal-2/src/app/utils/piwik/piwik.service.ts b/portal-2/src/app/utils/piwik/piwik.service.ts new file mode 100644 index 00000000..85087760 --- /dev/null +++ b/portal-2/src/app/utils/piwik/piwik.service.ts @@ -0,0 +1,70 @@ +import {Injectable} from '@angular/core'; +import {Http, Response, Headers, RequestOptions, URLSearchParams} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import {Location} from '@angular/common'; + +import {OpenaireProperties} from '../properties/openaireProperties'; +import {StringUtils} from '../string-utils.class'; + + +@Injectable() +export class PiwikService { + private piwikbaseUrl:string = ""; + constructor(private http: Http, private location: Location ) {} + + trackView (title):any { + + var ua = this.getUserAgent(); + var referrer = this.getReferrer(); + if(typeof location !== 'undefined'){ + var url = OpenaireProperties.getPiwikBaseURL()+"&rec=1&url="+StringUtils.URIEncode(location.href)+"&action_name="+StringUtils.URIEncode(title)+ + ((ua != null && ua.length > 0)?('&ua='+StringUtils.URIEncode(ua)):'')+ + ((referrer != null && referrer.length > 0)?('&urlref='+StringUtils.URIEncode(referrer)):''); + console.log("Piwik - trackDownload: " + url); + + return this.http.get( url); + // .do(request => console.info("Piwik request completed" )); + + } + } + trackDownload (downloadURL):any { + var ua = this.getUserAgent(); + var referrer = this.getReferrer(); + var url = OpenaireProperties.getPiwikBaseURL()+"&rec=1&url="+StringUtils.URIEncode(downloadURL)+"&download="+StringUtils.URIEncode(downloadURL)+ + ((ua != null && ua.length > 0)?('&ua='+StringUtils.URIEncode(ua)):'')+ + ((referrer != null && referrer.length > 0)?('&urlref='+StringUtils.URIEncode(referrer)):''); + console.log("Piwik - trackDownload: "+url); + + return this.http.get( url) + .do(request => console.info("Piwik request completed" )); + + } + private getUserAgent(){ + if (typeof navigator !== 'undefined') { + console.log("navigator.userAgent:" + navigator.userAgent); + return navigator.userAgent; + + }else{ + return null; + } + } + private getReferrer(){ + var referrer = ""; + if (typeof document !== 'undefined') { + console.log("document.referrer:" + document.referrer); + referrer = document.referrer; + + } + if((referrer == null || referrer.length == 0)&&typeof localStorage !== 'undefined'){ + + referrer =localStorage.getItem('previousRoute'); + } + return referrer; + } + parse(data:any){ + } + +} diff --git a/portal-2/src/app/utils/piwik/piwikService.module.ts b/portal-2/src/app/utils/piwik/piwikService.module.ts new file mode 100644 index 00000000..0cfe47e3 --- /dev/null +++ b/portal-2/src/app/utils/piwik/piwikService.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {PiwikService} from './piwik.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + ], + declarations: [ + + ], + providers: [ PiwikService ], + exports: [ + + ] +}) +export class PiwikServiceModule{ } diff --git a/portal-2/src/app/utils/piwik/previousRouteRecorder.guard.ts b/portal-2/src/app/utils/piwik/previousRouteRecorder.guard.ts new file mode 100644 index 00000000..ae62b524 --- /dev/null +++ b/portal-2/src/app/utils/piwik/previousRouteRecorder.guard.ts @@ -0,0 +1,17 @@ + +import { Injectable } from '@angular/core'; +import { CanDeactivate, Router} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; + +@Injectable() // do not forget to register this class as a provider +export class PreviousRouteRecorder implements CanDeactivate { + constructor(private router: Router) { + } + canDeactivate(component: any): Observable | boolean { + if (typeof localStorage !== 'undefined') { + console.log("In PreviousRouteRecorder : "+this.router.url ); + localStorage.setItem('previousRoute', this.router.url); + } + return true; + } +} diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index 35065aa4..7f341de4 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -90,6 +90,9 @@ export class OpenaireProperties { private static vocabulariesAPI ="https://beta.services.openaire.eu/provision/mvc/vocabularies/"; + private static piwikBaseUrl =" https://analytics.openaire.eu/piwik.php?idsite=6"; + private static enablePiwikTrack:boolean = false; + private static loginUrl ="http://mpagasas.di.uoa.gr:8080/uoa-user-management-1.0.0-SNAPSHOT/openid_connect_login"; private static loginUrl_pm ="https://beta.services.openaire.eu/uoa-user-management/openid_connect_login"; @@ -312,12 +315,17 @@ export class OpenaireProperties { }else{ return this.uploadService; } - // return this.uploadService; } //vocabularies API public static getVocabulariesAPI():string{ return this.vocabulariesAPI; } + public static getPiwikBaseURL():string{ + return this.piwikBaseUrl; + } + public static isPiwikTrackEnabled():boolean{ + return this.enablePiwikTrack; + } public static getLoginURL():string{ if(this.productionMode){ return this.loginUrl_pm;