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'] styleUrls: ['displayClaims.component.less']
}) })
export class DisplayClaimsComponent implements OnInit, OnDestroy { export class DisplayClaimsComponent implements OnInit, OnDestroy {
@Input() piwikSiteId = null;
@Input() pageTitle: string = ""; @Input() pageTitle: string = "";
properties: EnvProperties; properties: EnvProperties;
public searchTermStream = new Subject<string>(); public searchTermStream = new Subject<string>();
@ -110,9 +109,7 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
this.updateTitle(this.pageTitle); this.updateTitle(this.pageTitle);
this.updateDescription(description); this.updateDescription(description);
this.updateUrl(this.url); 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._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;

View File

@ -1,6 +1,6 @@
<linking-generic *ngIf="validInput" [localStoragePrefix]="localStoragePrefix" [results]="results" [sources]="sources" <linking-generic *ngIf="validInput" [localStoragePrefix]="localStoragePrefix" [results]="results" [sources]="sources"
[communityId]="communityId" [inlineEntity]="inlineEntity" [showOptions]="showOptions" [communityId]="communityId" [inlineEntity]="inlineEntity" [showOptions]="showOptions"
[piwikSiteId]="piwikSiteId" pageTitle="Direct Linking"> pageTitle="Direct Linking">
</linking-generic> </linking-generic>
<div *ngIf="validInput== false" id="tm-main" class=" uk-section uk-padding-remove-top tm-middle"> <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' templateUrl: 'directLinking.component.html'
}) })
export class DirectLinkingComponent { export class DirectLinkingComponent {
@Input() piwikSiteId = null;
@ViewChild(LinkingGenericComponent) linking: LinkingGenericComponent; @ViewChild(LinkingGenericComponent) linking: LinkingGenericComponent;
results: ClaimEntity[] = []; results: ClaimEntity[] = [];

View File

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

View File

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

View File

@ -152,7 +152,6 @@ export class DepositFirstPageComponent {
public title: string = "Deposit or publish your research in Open Access"; public title: string = "Deposit or publish your research in Open Access";
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() piwikSiteId = null;
@Input() assetsPath: string = 'assets/common-assets/common'; @Input() assetsPath: string = 'assets/common-assets/common';
@Input() communityId = null; @Input() communityId = null;
@ -201,10 +200,7 @@ export class DepositFirstPageComponent {
if (!this.zenodoInformation.name) { if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo"; this.zenodoInformation.name = "Zenodo";
} }
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title).subscribe());
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}); 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 { export class SearchDataprovidersToDepositComponent {
private errorCodes: ErrorCodes; private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() searchForm: SearchForm = {class: null, dark: false}; @Input() searchForm: SearchForm = {class: null, dark: false};
public results =[]; public results =[];
public filters =[]; public filters =[];

View File

@ -27,8 +27,6 @@ export class FosComponent implements OnInit, OnDestroy {
public url: string = null; public url: string = null;
public pageTitle: string = "OpenAIRE | Fields of Science"; 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."; 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 fos: any[] = [];
public fosOptions: string[] = []; public fosOptions: string[] = [];
public activeSection: string; public activeSection: string;
@ -63,9 +61,7 @@ export class FosComponent implements OnInit, OnDestroy {
) {} ) {}
ngOnInit() { ngOnInit() {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.url = this.properties.domain + this.properties.baseLink + this._router.url; this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url); this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url); this.updateUrl(this.url);

View File

@ -46,7 +46,6 @@ export class DataProviderComponent {
@Input() type: string = "dataprovider"; @Input() type: string = "dataprovider";
private typeQueryPathParam: string = "datasources"; private typeQueryPathParam: string = "datasources";
@Input() piwikSiteId = null;
@Input() communityId = null; @Input() communityId = null;
public dataProviderInfo: DataProviderInfo; public dataProviderInfo: DataProviderInfo;
public datasourceId: string; public datasourceId: string;
@ -407,9 +406,7 @@ export class DataProviderComponent {
this.showTabs = true; this.showTabs = true;
this.updateTitle(this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName); 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))); 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.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name).subscribe());
}
this.showLoading = false; this.showLoading = false;

View File

@ -54,7 +54,6 @@ declare var UIkit: any;
` `
}) })
export class HtmlProjectReportComponent { export class HtmlProjectReportComponent {
@Input() piwikSiteId = null;
@Input() communityId = null; @Input() communityId = null;
private projectId: string; private projectId: string;
private totalResults: number = 10; private totalResults: number = 10;
@ -170,9 +169,7 @@ export class HtmlProjectReportComponent {
} else if (data.title) { } else if (data.title) {
this.updateTitle(data.title + " " + this.resultsType + " report"); 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());
this.subscriptions.push(this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report").subscribe());
}
}, },
err => { err => {
this.handleError("Error getting html information for project id: " + this.projectId, 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() result: any;
@Input() id: string; @Input() id: string;
@Input() type: string = "article"; @Input() type: string = "article";
@Input() piwikSiteId;
public data:CitationData; public data:CitationData;
public clipboard; public clipboard;
timeout; timeout;
@ -223,9 +222,7 @@ export class CiteThisComponent implements OnInit, OnDestroy {
a.click(); a.click();
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
a.remove(); // remove the element a.remove(); // remove the element
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.sub = this._piwikService.trackDownload(this.properties, "DownloadCitation"+this.selectedFormat).subscribe();
this.sub = this._piwikService.trackDownload(this.properties, "DownloadCitation"+this.selectedFormat, this.piwikSiteId).subscribe();
}
} }
} }

View File

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

View File

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

View File

@ -781,7 +781,7 @@
</modal-alert> </modal-alert>
<modal-alert *ngIf="resultLandingInfo" #citeModal> <modal-alert *ngIf="resultLandingInfo" #citeModal>
<citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id" <citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id"
[type]="title.toLowerCase()" [piwikSiteId]="piwikSiteId"></citeThis> [type]="title.toLowerCase()"></citeThis>
</modal-alert> </modal-alert>
<modal-alert *ngIf="resultLandingInfo" #addThisModal classBody="uk-flex uk-flex-center uk-flex-middle"> <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"> <fs-modal *ngIf="resultLandingInfo" #citeFsModal classTitle="uk-tile-default uk-border-bottom">
<citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id" <citeThis *ngIf="citeThisClicked" [result]="resultLandingInfo" [id]="id"
[type]="title.toLowerCase()" [piwikSiteId]="piwikSiteId"></citeThis> [type]="title.toLowerCase()"></citeThis>
</fs-modal> </fs-modal>
<fs-modal *ngIf="resultLandingInfo" #addThisFsModal classTitle="uk-tile-default uk-border-bottom" classBody="uk-flex uk-flex-center uk-flex-middle"> <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; public prevPath: string;
@Input() type: string = "publication"; @Input() type: string = "publication";
@Input() piwikSiteId = properties.piwikSiteId;
@Input() communityId = null; @Input() communityId = null;
enermapsId; enermapsId;
// @ViewChild('linkModal') linkModal; // @ViewChild('linkModal') linkModal;
@ -519,10 +519,7 @@ export class ResultLandingComponent {
this.updateTitle(this.resultLandingInfo.title); 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))); 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());
this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id).subscribe());
}
let bioentitiesNum = 0; let bioentitiesNum = 0;
if (this.resultLandingInfo.bioentities != undefined) { if (this.resultLandingInfo.bioentities != undefined) {
this.resultLandingInfo.bioentities.forEach(function (value, key, map) { this.resultLandingInfo.bioentities.forEach(function (value, key, map) {

View File

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

View File

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

View File

@ -22,7 +22,6 @@ export class SdgComponent implements OnInit, OnDestroy {
public url: string = null; public url: string = null;
public pageTitle: string = "OpenAIRE | Sustainable Development Goals"; 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."; 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 sdgs: any = [];
private sdgsResearchOutcomes: any = []; private sdgsResearchOutcomes: any = [];
@ -47,9 +46,7 @@ export class SdgComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.loading = true; this.loading = true;
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
}
this.url = this.properties.domain + this.properties.baseLink + this._router.url; this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url); this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url); this.updateUrl(this.url);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,14 +14,15 @@ import {properties} from "../../../../environments/environment";
@Component({ @Component({
selector: 'search-download', selector: 'search-download',
template: ` template: `
<button [attr.uk-tooltip]="'title: Download' + ((totalResults > csvLimit)?' the first 2000 ':' ') + 'results;'" <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"
(click)="downloadfile(downloadURLAPI+'?format=csv'+csvParams,type+'-report-'+((totalResults > csvLimit)?'2000 ':totalResults))"> [disabled]="isDisabled"
<icon name="download" [flex]="true"></icon> (click)="downloadfile(downloadURLAPI+'?format=csv'+csvParams,type+'-report-'+((totalResults > csvLimit)?'2000 ':totalResults))">
<span class="uk-margin-small-left">Download Results</span> <icon name="download" [flex]="true"></icon>
</button> <span class="uk-margin-small-left">Download Results</span>
<modal-loading></modal-loading> </button>
<modal-alert #AlertModalCsvError></modal-alert> <modal-loading></modal-loading>
<modal-alert #AlertModalCsvError></modal-alert>
` `
}) })
@ -30,29 +31,25 @@ export class SearchDownloadComponent {
@Input() totalResults: number = 0; @Input() totalResults: number = 0;
@Input() csvParams: string; @Input() csvParams: string;
@Input() type: string; @Input() type: string;
@Input() piwikSiteId = null;
@ViewChild(AlertModal) alertApplyAll: AlertModal; @ViewChild(AlertModal) alertApplyAll: AlertModal;
downloadURLAPI: string; downloadURLAPI: string;
public csvLimit: number = 0; public csvLimit: number = 0;
@ViewChild(ModalLoading) loading: ModalLoading; @ViewChild(ModalLoading) loading: ModalLoading;
// Alert box when something is wrong with CSV requests // Alert box when something is wrong with CSV requests
@ViewChild('AlertModalCsvError') alertCsvError; @ViewChild('AlertModalCsvError') alertCsvError;
public isPiwikEnabled;
public properties: EnvProperties; public properties: EnvProperties;
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
subscriptions = []; subscriptions = [];
constructor(private route: ActivatedRoute, private _reportsService: ReportsService, private _piwikService: PiwikService) { constructor(private route: ActivatedRoute, private _reportsService: ReportsService, private _piwikService: PiwikService) {
} }
ngOnInit() { ngOnInit() {
this.properties = properties;
this.properties = properties; this.csvLimit = this.properties.csvLimit;
this.csvLimit = this.properties.csvLimit; this.downloadURLAPI = this.properties.csvAPIURL;
this.downloadURLAPI = this.properties.csvAPIURL;
this.isPiwikEnabled = this.properties.enablePiwikTrack;
} }
ngOnDestroy() { ngOnDestroy() {
@ -62,7 +59,7 @@ export class SearchDownloadComponent {
} }
}); });
} }
denialOfDownload() { denialOfDownload() {
this.alertApplyAll.cancelButton = true; this.alertApplyAll.cancelButton = true;
this.alertApplyAll.okButton = false; this.alertApplyAll.okButton = false;
@ -70,11 +67,11 @@ export class SearchDownloadComponent {
this.alertApplyAll.message = "Sorry, but the results are too many! Use the api instead!"; this.alertApplyAll.message = "Sorry, but the results are too many! Use the api instead!";
this.alertApplyAll.cancelButtonText = "Ok"; this.alertApplyAll.cancelButtonText = "Ok";
this.alertApplyAll.open(); this.alertApplyAll.open();
console.error("Error downloading file. Results are too many!"); console.error("Error downloading file. Results are too many!");
//this.handleError("Error downloading file. Results are too many!", err); //this.handleError("Error downloading file. Results are too many!", err);
} }
downloadfile(url: string, filename: string) { downloadfile(url: string, filename: string) {
//var newWindow = window.open("", "_parent"); //var newWindow = window.open("", "_parent");
//var newWindow = window.open(); //var newWindow = window.open();
@ -83,63 +80,61 @@ export class SearchDownloadComponent {
this.setMessageLoading("Downloading CSV file"); this.setMessageLoading("Downloading CSV file");
this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe( this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe(
data => { data => {
this.closeLoading(); this.closeLoading();
//window.open(window.URL.createObjectURL(data),filename+".csv"); //window.open(window.URL.createObjectURL(data),filename+".csv");
//console.info("Fill window with data for csv"); //console.info("Fill window with data for csv");
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
var url = window.URL.createObjectURL(data); var url = window.URL.createObjectURL(data);
var a = window.document.createElement('a'); var a = window.document.createElement('a');
window.document.body.appendChild(a); window.document.body.appendChild(a);
a.setAttribute('style', 'display: none'); a.setAttribute('style', 'display: none');
a.href = url; a.href = url;
a.download = filename + ".csv"; a.download = filename + ".csv";
a.click(); a.click();
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
a.remove(); // remove the element a.remove(); // remove the element
} }
//newWindow.location.assign(window.URL.createObjectURL(data)); //newWindow.location.assign(window.URL.createObjectURL(data));
//window.location.href = window.URL.createObjectURL(data); //window.location.href = window.URL.createObjectURL(data);
if (this.isPiwikEnabled && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackDownload(this.properties, "searchDownload").subscribe());
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "searchDownload", this.piwikSiteId).subscribe()); },
} error => {
}, //console.error("Error downloading the file.");
error => { this.handleError("Error downloading file: " + filename, error);
//console.error("Error downloading the file.");
this.handleError("Error downloading file: " + filename, error); //newWindow.close();
this.closeLoading();
//newWindow.close(); this.confirmOpenCsvError();
this.closeLoading(); }/*,
this.confirmOpenCsvError();
}/*,
() => { () => {
console.log('Completed file download.'); console.log('Completed file download.');
//setTimeout(function(){ newWindow.close(); }, 500); //setTimeout(function(){ newWindow.close(); }, 500);
}*/ }*/
)); ));
} }
public openLoading() { public openLoading() {
if (this.loading) { if (this.loading) {
this.loading.open(); this.loading.open();
} }
} }
public closeLoading() { public closeLoading() {
if (this.loading) { if (this.loading) {
this.loading.close(); this.loading.close();
} }
} }
public setMessageLoading(message: string) { public setMessageLoading(message: string) {
if (this.loading) { if (this.loading) {
this.loading.message = message; this.loading.message = message;
} }
} }
public confirmOpenCsvError() { public confirmOpenCsvError() {
this.alertCsvError.cancelButton = false; this.alertCsvError.cancelButton = false;
this.alertCsvError.okButton = true; this.alertCsvError.okButton = true;
@ -148,7 +143,7 @@ export class SearchDownloadComponent {
this.alertCsvError.okButtonText = "OK"; this.alertCsvError.okButtonText = "OK";
this.alertCsvError.open(); this.alertCsvError.open();
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Search Download (component): " + message, error); console.error("Search Download (component): " + message, error);
} }

View File

@ -47,10 +47,6 @@ export class ConfigurationService {
return this.portal.asObservable(); 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) { async isPageEnabledAsync(properties: EnvProperties, portal: string, page_route: string) {
if (!this.promise || (this.portal && this.portal.getValue() && portal !== this.portal.getValue().pid)) { if (!this.promise || (this.portal && this.portal.getValue() && portal !== this.portal.getValue().pid)) {
this.initPortal(properties, portal); this.initPortal(properties, portal);

View File

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

View File

@ -3,8 +3,9 @@ import {HttpClient} from "@angular/common/http";
import {StringUtils} from '../string-utils.class'; import {StringUtils} from '../string-utils.class';
import {EnvProperties} from '../properties/env-properties'; import {EnvProperties} from '../properties/env-properties';
import {Observable} from "rxjs"; import {Observable, of} from "rxjs";
import {ConfigurationService} from "../configuration/configuration.service"; import {ConfigurationService} from "../configuration/configuration.service";
import {map, take} from "rxjs/operators";
@Injectable() @Injectable()
@ -13,21 +14,39 @@ export class PiwikService {
} }
trackViewForCustomUrl(properties: EnvProperties, title, pageparams): any { trackViewForCustomUrl(properties: EnvProperties, title, pageparams): any {
let piwikId = this.configurationService.piwik; if(typeof location !== 'undefined' && properties.enablePiwikTrack) {
if (typeof location !== 'undefined' && piwikId) { return this.configurationService.portalAsObservable.pipe(take(1), map(portal => {
return this.doTrackView(properties, title, piwikId, location.href.split("?")[0] + "?" + pageparams); 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 { trackView(properties: EnvProperties, title): any {
let piwikId = this.configurationService.piwik; if(typeof location !== 'undefined' && properties.enablePiwikTrack) {
if (typeof location !== 'undefined' && piwikId) { return this.configurationService.portalAsObservable.pipe(take(1), map(portal => {
return this.doTrackView(properties, title, piwikId, location.href); 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 { private doTrackView(properties: EnvProperties, title, siteId, pageURL): any {
let ua = this.getUserAgent(); let ua = this.getUserAgent();
let referrer = this.getReferrer(); let referrer = this.getReferrer();
let piwikId = ((siteId != null) ? siteId : properties.piwikSiteId); let piwikId = ((siteId != null) ? siteId : properties.piwikSiteId);
@ -40,11 +59,11 @@ export class PiwikService {
// return Observable.of(new Object()); // for testing // return Observable.of(new Object()); // for testing
return this.http.get(url, {responseType: 'blob'}); return this.http.get(url, {responseType: 'blob'});
// .do(request => console.info("Piwik request completed" )); // .do(request => console.info("Piwik request completed" ));
} }
} }
trackDownload(properties: EnvProperties, type = "", siteId = null): any { doTrackDownload(properties: EnvProperties, type = "", siteId): any {
var ua = this.getUserAgent(); var ua = this.getUserAgent();
var referrer = this.getReferrer(); 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) + var url = properties.piwikBaseUrl + ((siteId != null) ? siteId : properties.piwikSiteId) + "&rec=1&url=" + StringUtils.URIEncode(location.href) + "&download=" + StringUtils.URIEncode(location.href + "#" + type) +
@ -56,7 +75,7 @@ export class PiwikService {
//.do(request => console.info("Piwik request completed" )); //.do(request => console.info("Piwik request completed" ));
} }
private getUserAgent() { private getUserAgent() {
if (typeof navigator !== 'undefined') { if (typeof navigator !== 'undefined') {
//console.log("navigator.userAgent:" + navigator.userAgent); //console.log("navigator.userAgent:" + navigator.userAgent);