Simplify piwik logic: All work is done in piwik.service.

This commit is contained in:
Konstantinos Triantafyllou 2023-07-12 15:05:25 +03:00
parent 50422c0ab3
commit 37b7423e7f
30 changed files with 120 additions and 200 deletions

View File

@ -27,7 +27,6 @@ import {DropdownFilterComponent} from "../../../utils/dropdown-filter/dropdown-f
styleUrls: ['displayClaims.component.less']
})
export class DisplayClaimsComponent implements OnInit, OnDestroy {
@Input() piwikSiteId = null;
@Input() pageTitle: string = "";
properties: EnvProperties;
public searchTermStream = new Subject<string>();
@ -110,9 +109,7 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
this.updateTitle(this.pageTitle);
this.updateDescription(description);
this.updateUrl(this.url);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents;

View File

@ -1,6 +1,6 @@
<linking-generic *ngIf="validInput" [localStoragePrefix]="localStoragePrefix" [results]="results" [sources]="sources"
[communityId]="communityId" [inlineEntity]="inlineEntity" [showOptions]="showOptions"
[piwikSiteId]="piwikSiteId" pageTitle="Direct Linking">
pageTitle="Direct Linking">
</linking-generic>
<div *ngIf="validInput== false" id="tm-main" class=" uk-section uk-padding-remove-top tm-middle">

View File

@ -18,8 +18,6 @@ import {ClaimProjectsSearchFormComponent} from "../claim-utils/claimProjectSearc
templateUrl: 'directLinking.component.html'
})
export class DirectLinkingComponent {
@Input() piwikSiteId = null;
@ViewChild(LinkingGenericComponent) linking: LinkingGenericComponent;
results: ClaimEntity[] = [];

View File

@ -22,7 +22,6 @@ import { Location } from '@angular/common';
templateUrl: 'linkingGeneric.component.html'
})
export class LinkingGenericComponent {
@Input() piwikSiteId = null;
@Input() pageTitle: string = "Create links between research objects";
piwiksub:any;
@ -79,9 +78,7 @@ export class LinkingGenericComponent {
this.seoService.createLinkForCanonicalURL(this.url, false);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents;

View File

@ -19,7 +19,7 @@ import {Subscriber} from "rxjs";
<div class="uk-margin-top">
<displayClaims *ngIf="user" [user]="user" [enableDelete]=true [myClaims]=true [isAdmin]=false [showUserEmail]=false
[claimsInfoURL]=claimsInfoURL [communityId]=communityId
[piwikSiteId]="piwikSiteId" pageTitle="My links">
pageTitle="My links">
</displayClaims>
</div>
</div>
@ -30,7 +30,6 @@ import {Subscriber} from "rxjs";
export class MyClaimsComponent {
@Input() claimsInfoURL: string;
@Input() communityId:string;
@Input() piwikSiteId = null;
@Input() userInfoURL: string;
public user: User = null;

View File

@ -152,7 +152,6 @@ export class DepositFirstPageComponent {
public title: string = "Deposit or publish your research in Open Access";
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() piwikSiteId = null;
@Input() assetsPath: string = 'assets/common-assets/common';
@Input() communityId = null;
@ -201,10 +200,7 @@ export class DepositFirstPageComponent {
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title).subscribe());
}
this.breadcrumbs.push({name: 'home', route: '/'}, {name: "Deposit", route: null});
}

View File

@ -53,7 +53,6 @@ import {SearchForm} from "../searchPages/searchUtils/newSearchPage.component";
export class SearchDataprovidersToDepositComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() searchForm: SearchForm = {class: null, dark: false};
public results =[];
public filters =[];

View File

@ -27,8 +27,6 @@ export class FosComponent implements OnInit, OnDestroy {
public url: string = null;
public pageTitle: string = "OpenAIRE | Fields of Science";
public pageDescription: string = "We have integrated a Field-of-Science (FoS) taxonomy into our dataset to organize and discover research more effectively. Using the full capabilities of the OpenAIRE Graph (full-texts, citations, references, venues) we apply AI and bring forward any multidisciplinarity potential.";
@Input() piwikSiteId = null;
public fos: any[] = [];
public fosOptions: string[] = [];
public activeSection: string;
@ -63,9 +61,7 @@ export class FosComponent implements OnInit, OnDestroy {
) {}
ngOnInit() {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url);

View File

@ -46,7 +46,6 @@ export class DataProviderComponent {
@Input() type: string = "dataprovider";
private typeQueryPathParam: string = "datasources";
@Input() piwikSiteId = null;
@Input() communityId = null;
public dataProviderInfo: DataProviderInfo;
public datasourceId: string;
@ -407,9 +406,7 @@ export class DataProviderComponent {
this.showTabs = true;
this.updateTitle(this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName);
this.updateDescription((this.dataProviderInfo.description ? (this.dataProviderInfo.description.substr(0,157) + (this.dataProviderInfo.description.substr(0,157).length == 157?"...":"")) : (this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName)));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name).subscribe());
}
this.showLoading = false;

View File

@ -54,7 +54,6 @@ declare var UIkit: any;
`
})
export class HtmlProjectReportComponent {
@Input() piwikSiteId = null;
@Input() communityId = null;
private projectId: string;
private totalResults: number = 10;
@ -170,9 +169,7 @@ export class HtmlProjectReportComponent {
} else if (data.title) {
this.updateTitle(data.title + " " + this.resultsType + " report");
}
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report").subscribe());
}
},
err => {
this.handleError("Error getting html information for project id: " + this.projectId, err);

View File

@ -57,7 +57,6 @@ export class CiteThisComponent implements OnInit, OnDestroy {
@Input() result: any;
@Input() id: string;
@Input() type: string = "article";
@Input() piwikSiteId;
public data:CitationData;
public clipboard;
timeout;
@ -223,9 +222,7 @@ export class CiteThisComponent implements OnInit, OnDestroy {
a.click();
window.URL.revokeObjectURL(url);
a.remove(); // remove the element
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.sub = this._piwikService.trackDownload(this.properties, "DownloadCitation"+this.selectedFormat, this.piwikSiteId).subscribe();
}
this.sub = this._piwikService.trackDownload(this.properties, "DownloadCitation"+this.selectedFormat).subscribe();
}
}

View File

@ -38,8 +38,6 @@ declare var ResizeObserver;
export class OrganizationComponent {
public referrer: string;
public prevPath: string;
@Input() piwikSiteId = null;
@Input() communityId = null;
public organizationInfo: OrganizationInfo;
@ -409,9 +407,7 @@ export class OrganizationComponent {
(this.organizationInfo.title.name?this.organizationInfo.title.name:'No title available') +
((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (', ') : '') +
(this.organizationInfo.name?this.organizationInfo.name:''));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.organizationInfo.title.name).subscribe());
}
var refineFields: string [] = ["funder"];
if (typeof document !== 'undefined') {
@ -464,9 +460,7 @@ export class OrganizationComponent {
a.remove(); // remove the element
//window.open(window.URL.createObjectURL(data));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename).subscribe());
},
err => {
//console.log("Error downloading the file.");
@ -527,9 +521,7 @@ export class OrganizationComponent {
a.click();
window.URL.revokeObjectURL(csvurl);
a.remove(); // remove the element
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename).subscribe());
}
} else {
let url: string;
@ -570,9 +562,7 @@ export class OrganizationComponent {
a.click();
window.URL.revokeObjectURL(csvurl);
a.remove(); // remove the element
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename).subscribe());
}
},
err => {

View File

@ -44,8 +44,6 @@ declare var ResizeObserver;
export class ProjectComponent {
public referrer: string;
public prevPath: string;
@Input() piwikSiteId = null;
@Input() communityId = null;
public projectInfo: ProjectInfo;
public projectId: string;
@ -525,10 +523,7 @@ export class ProjectComponent {
this.updateTitle(this.projectName);
// this.updateDescription(this.projectInfo.description?this.projectInfo.description: ("project" + (this.projectInfo.title?"," + this.projectInfo.title:"") + (this.projectInfo.funding && this.projectInfo.funding.funderName?", funder: " + this.projectInfo.funding.funderName:"") + (this.projectInfo.acronym?"," + this.projectInfo.acronym:"")));
this.updateDescription((this.projectInfo.description ? (this.projectInfo.description.substr(0,157) + (this.projectInfo.description.substr(0,157).length == 157?"...":"")) : (this.projectInfo.title)));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.projectName).subscribe());
}
this.project = {
funderId: "",
funderName: ((this.projectInfo.funding) ? this.projectInfo.funding.funderShortName: ''),
@ -593,10 +588,7 @@ export class ProjectComponent {
let url = window.URL.createObjectURL(data);
this.download(url, filename+".csv");
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV"+filename, this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV"+filename).subscribe());
},
error => {
//console.log("Error downloading the file.");
@ -743,9 +735,7 @@ export class ProjectComponent {
let url = window.URL.createObjectURL(new Blob([this.htmlResultDownload], { type: 'text/html' }));
this.download(url, filename+".html");
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadHTML"+filename, this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadHTML"+filename).subscribe());
},
err => {
this.handleError("Error getting html for id: " + this.projectId, err);

View File

@ -781,7 +781,7 @@
</modal-alert>
<modal-alert *ngIf="resultLandingInfo" #citeModal>
<citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id"
[type]="title.toLowerCase()" [piwikSiteId]="piwikSiteId"></citeThis>
[type]="title.toLowerCase()"></citeThis>
</modal-alert>
<modal-alert *ngIf="resultLandingInfo" #addThisModal classBody="uk-flex uk-flex-center uk-flex-middle">
@ -1229,7 +1229,7 @@
<fs-modal *ngIf="resultLandingInfo" #citeFsModal classTitle="uk-tile-default uk-border-bottom">
<citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id"
[type]="title.toLowerCase()" [piwikSiteId]="piwikSiteId"></citeThis>
[type]="title.toLowerCase()"></citeThis>
</fs-modal>
<fs-modal *ngIf="resultLandingInfo" #addThisFsModal classTitle="uk-tile-default uk-border-bottom" classBody="uk-flex uk-flex-center uk-flex-middle">

View File

@ -40,7 +40,7 @@ export class ResultLandingComponent {
public prevPath: string;
@Input() type: string = "publication";
@Input() piwikSiteId = properties.piwikSiteId;
@Input() communityId = null;
enermapsId;
// @ViewChild('linkModal') linkModal;
@ -519,10 +519,7 @@ export class ResultLandingComponent {
this.updateTitle(this.resultLandingInfo.title);
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description.substr(0,157) + (this.resultLandingInfo.description.substr(0,157).length == 157?"...":"")) : (this.resultLandingInfo.title)));
}
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id).subscribe());
}
let bioentitiesNum = 0;
if (this.resultLandingInfo.bioentities != undefined) {
this.resultLandingInfo.bioentities.forEach(function (value, key, map) {

View File

@ -103,7 +103,7 @@ export class MyOrcidLinksComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
public results =[];
public currentResults = [];
public totalResults:number = 0 ;
@ -186,11 +186,7 @@ export class MyOrcidLinksComponent {
this.updateTitle("My ORCID Links");
this.updateDescription(description);
this.updateUrl( properties.domain + properties.baseLink + this.route.url);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.subscriptions.push(this._piwikService.trackView(this.properties, "My ORCID links").subscribe());
}
this.typeQuery = "&type=results";
this.getLocalWorks();
this.getPersonalDetails();

View File

@ -65,7 +65,6 @@ import {Identifier} from "../../utils/string-utils.class";
export class SearchRecommendedResultsForOrcidComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
public results =[];
public totalResults:number = 0 ;
public baseUrl:string;

View File

@ -22,7 +22,6 @@ export class SdgComponent implements OnInit, OnDestroy {
public url: string = null;
public pageTitle: string = "OpenAIRE | Sustainable Development Goals";
public pageDescription: string = "Laying the foundation for new approaches and solutions. We have developed a classification scheme for UN Sustainable Development Goals, to view contributions of research towards complex challenges for humanity such as climate change, biodiversity loss, pollution and poverty reduction.";
@Input() piwikSiteId = null;
private sdgs: any = [];
private sdgsResearchOutcomes: any = [];
@ -47,9 +46,7 @@ export class SdgComponent implements OnInit, OnDestroy {
ngOnInit() {
this.loading = true;
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url);

View File

@ -88,7 +88,7 @@ export class SearchAllComponent {
@Input() logoURL;
@Input() name;
@Input() customFilter: SearchCustomFilter = null;
@Input() piwikSiteId = null;
@Input() formPlaceholderText = "Search in Explore"
// @Input() formPlaceholderText = "Search for "+OpenaireEntities.RESULTS+", "+OpenaireEntities.PROJECTS+", "+OpenaireEntities.DATASOURCES+" & "+OpenaireEntities.ORGANIZATIONS+" in OpenAIRE";
@Input() searchForm: SearchForm = {class: 'search-form', dark: true}
@ -158,12 +158,7 @@ export class SearchAllComponent {
this._meta.updateTag({content: title}, "property='og:title'");
this._meta.updateTag({content: url}, "property='og:url'");
this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url, false);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subs.push(this._piwikService.trackView(this.properties, title).subscribe());
}
if ((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity) {
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
this.subs.push(this.config.portalAsObservable.subscribe(data => {

View File

@ -32,8 +32,7 @@ import {properties} from "../../../environments/environment";
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [hasPrefix]="hasPrefix"
[searchForm]="searchForm"
[entitiesSelection]="false" [showSwitchSearchLink]="showSwitchSearchLink"
[filters]="filters"
@ -50,7 +49,6 @@ import {properties} from "../../../environments/environment";
export class SearchDataProvidersComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() customFilter:SearchCustomFilter= null;
@Input() tableViewLink;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
@ -70,7 +68,6 @@ export class SearchDataProvidersComponent {
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
public pagingLimit: number = 0;
public isPiwikEnabled;
properties:EnvProperties;
public openaireEntities = OpenaireEntities;
@Input() type: "all" | "registries" | "journals" | "compatible" | "deposit" | "services" = "all";
@ -117,8 +114,6 @@ export class SearchDataProvidersComponent {
this.advancedSearchLink = this.entityType == "service" ? this.properties.searchLinkToAdvancedServices : this.properties.searchLinkToAdvancedDataProviders;
this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
this.pagingLimit = properties.pagingLimit;
this.isPiwikEnabled = properties.enablePiwikTrack;
let firstLoad = true;
this.subs.push(this.route.queryParams.subscribe(params => {
this.loadPaging = true;

View File

@ -28,8 +28,7 @@ import {properties} from "../../../environments/environment";
[disableRefineForms]="disableRefineForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[openaireLink]=openaireLink [hasPrefix]="hasPrefix"
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[searchForm]="searchForm"
[sort]="false"
@ -47,7 +46,6 @@ export class SearchOrganizationsComponent {
private errorMessages: ErrorMessagesComponent;
properties:EnvProperties;
public openaireEntities = OpenaireEntities;
@Input() piwikSiteId = null;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results =[];
public filters =[];
@ -63,8 +61,6 @@ export class SearchOrganizationsComponent {
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
public pagingLimit: number = 0;
public isPiwikEnabled;
@Input() customFilter:SearchCustomFilter= null;
public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS;
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
@ -100,8 +96,6 @@ export class SearchOrganizationsComponent {
this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations;
this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
this.pagingLimit = properties.pagingLimit;
this.isPiwikEnabled = properties.enablePiwikTrack;
this.searchUtils.status = this.errorCodes.LOADING;
var firstLoad = true;

View File

@ -28,8 +28,7 @@ import {properties} from "../../../environments/environment";
[disableRefineForms]="disableRefineForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[openaireLink]=openaireLink [hasPrefix]="hasPrefix"
[searchForm]="searchForm"
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[filters]="filters"
@ -46,7 +45,6 @@ import {properties} from "../../../environments/environment";
export class SearchProjectsComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() customFilter: SearchCustomFilter = null;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results = [];
@ -70,7 +68,6 @@ export class SearchProjectsComponent {
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
public pagingLimit: number = 0;
public isPiwikEnabled;
public refineFields: string[] = this.searchFields.PROJECT_REFINE_FIELDS;
@ViewChild(NewSearchPageComponent, {static: true}) searchPage: NewSearchPageComponent;
@Input() simpleView: boolean = true;
@ -105,8 +102,6 @@ export class SearchProjectsComponent {
this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;
this.searchUtils.baseUrl = (this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink;
this.pagingLimit = properties.pagingLimit;
this.isPiwikEnabled = properties.enablePiwikTrack;
this.searchUtils.status = this.errorCodes.LOADING;
var firstLoad = true;

View File

@ -30,8 +30,7 @@ import {StringUtils} from "../utils/string-utils.class";
[disableRefineForms]="disableRefineForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[openaireLink]=openaireLink [hasPrefix]="hasPrefix"
[searchForm]="searchForm"
[filters]="filters" [quickFilter]="quickFilter"
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
@ -52,7 +51,6 @@ export class SearchResearchResultsComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = properties.piwikSiteId;
@Input() hasPrefix: boolean = true;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results = [];
@ -75,7 +73,6 @@ export class SearchResearchResultsComponent {
@Input() openaireLink: string = null;
@Input() customFilter: SearchCustomFilter = null;
public pagingLimit: number = 0;
public isPiwikEnabled;
properties: EnvProperties = properties;
public openaireEntities = OpenaireEntities;
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
@ -124,8 +121,6 @@ export class SearchResearchResultsComponent {
ngOnInit() {
//TODO add checks about which result types are enabled!
this.pagingLimit = this.properties.pagingLimit;
this.isPiwikEnabled = this.properties.enablePiwikTrack;
if (!this.simpleSearchLink) {
this.simpleSearchLink = this.properties.searchLinkToResults;
}

View File

@ -318,8 +318,7 @@
<search-download
*ngIf="( entityType !='community' && entityType != 'stakeholder') && usedBy == 'search'"
[isDisabled]="disabled"
[type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults"
[piwikSiteId]="piwikSiteId">
[type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults">
</search-download>
</div>
</div>

View File

@ -48,7 +48,6 @@ declare var UIkit: any;
})
export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
@ViewChild('mobileFilters') mobileFilters: ElementRef;
@Input() piwikSiteId = null;
@Input() hasPrefix: boolean = true;
@Input() prefix: string = "OpenAIRE | ";
@Input() pageTitle = "";
@ -121,7 +120,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
public csvLimit: number = 0;
public pagingLimit: number = 0;
public resultsPerPage: number = 0;
isPiwikEnabled = false;
properties: EnvProperties = properties;
public pageContents = null;
public divContents = null;
@ -174,10 +172,9 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
this.pagingLimit = this.properties.pagingLimit;
this.resultsPerPage = this.properties.resultsPerPage;
this.csvLimit = this.properties.csvLimit;
this.isPiwikEnabled = this.properties.enablePiwikTrack;
this.updateUrl(this.properties.domain + this.properties.baseLink + this.router.url);
this.url = this.properties.domain + this.properties.baseLink + this.router.url;
if (typeof document !== 'undefined' && this.isPiwikEnabled && !this.includeOnlyResultsAndFilter && this.piwikSiteId) {
if (!this.includeOnlyResultsAndFilter) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.layoutService.isMobile.subscribe(isMobile => {
@ -354,9 +351,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
//console.log("In PreviousRouteRecorder : "+this.router.url );
localStorage.setItem('previousRoute', this.router.url);
}
if (this.isPiwikEnabled && (typeof document !== 'undefined') && this.piwikSiteId) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
/* End Piwik Code */
}

View File

@ -93,7 +93,7 @@ export class QuickSelectionsComponent {
//Allow all types
/* if(this.properties && !this.initialized) {
if(this.properties.adminToolsCommunity !== "monitor") {
this.subs.push(this.config.communityInformationState.subscribe(data => {
this.subs.push(this.config.portalAsObservable.subscribe(data => {
if(data) {
var showEntity = {};
for (var i = 0; i < data['entities'].length; i++) {

View File

@ -15,7 +15,8 @@ import {properties} from "../../../../environments/environment";
selector: 'search-download',
template: `
<button [attr.uk-tooltip]="'title: Download' + ((totalResults > csvLimit)?' the first 2000 ':' ') + 'results;'"
class="uk-button uk-button-link uk-flex uk-flex-middle" [class.uk-disabled]="isDisabled" [disabled]="isDisabled"
class="uk-button uk-button-link uk-flex uk-flex-middle" [class.uk-disabled]="isDisabled"
[disabled]="isDisabled"
(click)="downloadfile(downloadURLAPI+'?format=csv'+csvParams,type+'-report-'+((totalResults > csvLimit)?'2000 ':totalResults))">
<icon name="download" [flex]="true"></icon>
<span class="uk-margin-small-left">Download Results</span>
@ -30,7 +31,6 @@ export class SearchDownloadComponent {
@Input() totalResults: number = 0;
@Input() csvParams: string;
@Input() type: string;
@Input() piwikSiteId = null;
@ViewChild(AlertModal) alertApplyAll: AlertModal;
downloadURLAPI: string;
@ -39,20 +39,17 @@ export class SearchDownloadComponent {
@ViewChild(ModalLoading) loading: ModalLoading;
// Alert box when something is wrong with CSV requests
@ViewChild('AlertModalCsvError') alertCsvError;
public isPiwikEnabled;
public properties: EnvProperties;
public errorCodes: ErrorCodes = new ErrorCodes();
subscriptions = [];
constructor(private route: ActivatedRoute, private _reportsService: ReportsService, private _piwikService: PiwikService) {
}
ngOnInit() {
this.properties = properties;
this.csvLimit = this.properties.csvLimit;
this.downloadURLAPI = this.properties.csvAPIURL;
this.isPiwikEnabled = this.properties.enablePiwikTrack;
}
ngOnDestroy() {
@ -102,9 +99,7 @@ export class SearchDownloadComponent {
//window.location.href = window.URL.createObjectURL(data);
if (this.isPiwikEnabled && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "searchDownload", this.piwikSiteId).subscribe());
}
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "searchDownload").subscribe());
},
error => {
//console.error("Error downloading the file.");

View File

@ -47,10 +47,6 @@ export class ConfigurationService {
return this.portal.asObservable();
}
get piwik() {
return this.portal.value?.piwik ? this.portal.value.piwik : properties.piwikSiteId;
}
async isPageEnabledAsync(properties: EnvProperties, portal: string, page_route: string) {
if (!this.promise || (this.portal && this.portal.getValue() && portal !== this.portal.getValue().pid)) {
this.initPortal(properties, portal);

View File

@ -57,7 +57,7 @@ import {EnvProperties} from "../properties/env-properties";
</div>
<modal-alert *ngIf="cite" #citeModal>
<citeThis *ngIf="citeThisClicked" [result]="result" [id]="id"
[type]="getTypeName().toLowerCase()" [piwikSiteId]="properties.piwikSiteId"></citeThis>
[type]="getTypeName().toLowerCase()"></citeThis>
</modal-alert>
<modal-alert *ngIf="share" #addThisModal classBody="uk-flex uk-flex-center uk-flex-middle">
<addThis [url]="url"></addThis>

View File

@ -3,8 +3,9 @@ import {HttpClient} from "@angular/common/http";
import {StringUtils} from '../string-utils.class';
import {EnvProperties} from '../properties/env-properties';
import {Observable} from "rxjs";
import {Observable, of} from "rxjs";
import {ConfigurationService} from "../configuration/configuration.service";
import {map, take} from "rxjs/operators";
@Injectable()
@ -13,21 +14,39 @@ export class PiwikService {
}
trackViewForCustomUrl(properties: EnvProperties, title, pageparams): any {
let piwikId = this.configurationService.piwik;
if (typeof location !== 'undefined' && piwikId) {
return this.doTrackView(properties, title, piwikId, location.href.split("?")[0] + "?" + pageparams);
if(typeof location !== 'undefined' && properties.enablePiwikTrack) {
return this.configurationService.portalAsObservable.pipe(take(1), map(portal => {
let piwik = portal?portal.piwik:null;
return this.doTrackView(properties, title, piwik, location.href.split("?")[0] + "?" + pageparams);
}));
} else {
return of(null);
}
}
trackView(properties: EnvProperties, title): any {
let piwikId = this.configurationService.piwik;
if (typeof location !== 'undefined' && piwikId) {
return this.doTrackView(properties, title, piwikId, location.href);
if(typeof location !== 'undefined' && properties.enablePiwikTrack) {
return this.configurationService.portalAsObservable.pipe(take(1), map(portal => {
let piwik = portal?portal.piwik:null;
return this.doTrackView(properties, title, piwik, location.href);
}));
} else {
return of(null);
}
}
trackDownload(properties: EnvProperties, type = "") {
if(typeof location !== 'undefined' && properties.enablePiwikTrack) {
return this.configurationService.portalAsObservable.pipe(take(1), map(portal => {
let piwik = portal?portal.piwik:null;
return this.doTrackDownload(properties, type, piwik);
}));
} else {
return of(null);
}
}
private doTrackView(properties: EnvProperties, title, siteId, pageURL): any {
let ua = this.getUserAgent();
let referrer = this.getReferrer();
let piwikId = ((siteId != null) ? siteId : properties.piwikSiteId);
@ -44,7 +63,7 @@ export class PiwikService {
}
}
trackDownload(properties: EnvProperties, type = "", siteId = null): any {
doTrackDownload(properties: EnvProperties, type = "", siteId): any {
var ua = this.getUserAgent();
var referrer = this.getReferrer();
var url = properties.piwikBaseUrl + ((siteId != null) ? siteId : properties.piwikSiteId) + "&rec=1&url=" + StringUtils.URIEncode(location.href) + "&download=" + StringUtils.URIEncode(location.href + "#" + type) +