update metrics API: use the new stats tool for both numbers & charts

This commit is contained in:
argirok 2021-09-08 15:21:30 +03:00
parent 81195135c2
commit 9d65eaab72
9 changed files with 256 additions and 134 deletions

View File

@ -75,7 +75,7 @@
<!-- Metrics --> <!-- Metrics -->
<li *ngIf="hasMetrics" class="uk-margin-medium-top"> <li *ngIf="hasMetrics" class="uk-margin-medium-top">
<div class="uk-text-center uk-flex uk-flex-middle uk-flex-center"> <div class="uk-text-center uk-flex uk-flex-middle uk-flex-center">
<div [class.uk-hidden]="!(totalViews && totalDownloads && pageViews)"> <div [class.uk-hidden]="!(totalViews || totalDownloads || pageViews)">
<metrics [pageViews]="pageViews" <metrics [pageViews]="pageViews"
[id]="datasourceId" [entityType]="'datasources'" [entity]="'Content Provider'" [id]="datasourceId" [entityType]="'datasources'" [entity]="'Content Provider'"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl" [viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -38,7 +38,7 @@ export class DataProviderComponent {
@Input() communityId = null; @Input() communityId = null;
public dataProviderInfo: DataProviderInfo; public dataProviderInfo: DataProviderInfo;
public datasourceId: string; public datasourceId: string;
// Message variables // Message variables
public warningMessage = ""; public warningMessage = "";
public errorMessage = ""; public errorMessage = "";
@ -51,13 +51,13 @@ export class DataProviderComponent {
public totalViews: number; public totalViews: number;
public totalDownloads: number; public totalDownloads: number;
public pageViews: number; public pageViews: number;
// Statistics tab variables // Statistics tab variables
public statsClicked: boolean = false; public statsClicked: boolean = false;
@ViewChild('statisticsModal') statisticsModal; @ViewChild('statisticsModal') statisticsModal;
@ViewChild('relatedDatasourcesModal') relatedDatasourcesModal; @ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
// Variables for publications, research data, projects, content providers, related content providers tabs // Variables for publications, research data, projects, content providers, related content providers tabs
public fetchPublications: FetchResearchResults; public fetchPublications: FetchResearchResults;
public fetchDatasets: FetchResearchResults; public fetchDatasets: FetchResearchResults;
@ -67,23 +67,23 @@ export class DataProviderComponent {
public fetchDataproviders: FetchDataproviders; public fetchDataproviders: FetchDataproviders;
public fetchAggregatorsResults: FetchResearchResults; public fetchAggregatorsResults: FetchResearchResults;
public searchNumber: number = 5; public searchNumber: number = 5;
public aggregationStatusIsInitialized: boolean = false; public aggregationStatusIsInitialized: boolean = false;
public loadingRelatedDatasources: boolean = true; public loadingRelatedDatasources: boolean = true;
// Active tab variable for responsiveness - show tabs only if main request is completed // Active tab variable for responsiveness - show tabs only if main request is completed
public activeTab: string = ""; public activeTab: string = "";
public showTabs: boolean = false; public showTabs: boolean = false;
public _numberOfTabs: number = 0; public _numberOfTabs: number = 0;
public tabsAreInitialized: boolean = false; public tabsAreInitialized: boolean = false;
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
public pageContents = null; public pageContents = null;
public divContents = null; public divContents = null;
// Request results of each tab only the one time (first time tab is clicked) // Request results of each tab only the one time (first time tab is clicked)
private reloadPublications: boolean = true; private reloadPublications: boolean = true;
private reloadDatasets: boolean = true; private reloadDatasets: boolean = true;
@ -92,26 +92,26 @@ export class DataProviderComponent {
private reloadProjects: boolean = true; private reloadProjects: boolean = true;
private reloadDataproviders: boolean = true; private reloadDataproviders: boolean = true;
private reloadRelatedDatasources: boolean = true; private reloadRelatedDatasources: boolean = true;
// Organizations variables for view more/less functionality // Organizations variables for view more/less functionality
public thresholdOrganizations: number = 20; public thresholdOrganizations: number = 20;
public showNumOrganizations: number = 20; public showNumOrganizations: number = 20;
// Subjects variables for view more/less functionality // Subjects variables for view more/less functionality
public thresholdSubjects: number = 20; public thresholdSubjects: number = 20;
public showNumSubjects: number = 20; public showNumSubjects: number = 20;
// Description variables for view more/less functionality // Description variables for view more/less functionality
public thresholdDescription: number = 670; public thresholdDescription: number = 670;
public showNumDescription: number = 670; public showNumDescription: number = 670;
public indexUpdateDate: Date; public indexUpdateDate: Date;
public showFeedback: boolean = false; public showFeedback: boolean = false;
public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other']; public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other'];
subscriptions = []; subscriptions = [];
properties: EnvProperties = properties; properties: EnvProperties = properties;
constructor(private _dataproviderService: DataProviderService, constructor(private _dataproviderService: DataProviderService,
private _piwikService: PiwikService, private _piwikService: PiwikService,
private route: ActivatedRoute, private route: ActivatedRoute,
@ -131,9 +131,9 @@ export class DataProviderComponent {
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService); this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
this.fetchProjects = new FetchProjects(this._searchProjectsService); this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
} }
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
@ -163,7 +163,7 @@ export class DataProviderComponent {
} }
})); }));
} }
public initializeValues() { public initializeValues() {
this._numberOfTabs = 0; this._numberOfTabs = 0;
this.tabsAreInitialized = false; this.tabsAreInitialized = false;
@ -184,19 +184,19 @@ export class DataProviderComponent {
this.statsClicked = false; this.statsClicked = false;
this.metricsClicked = false; this.metricsClicked = false;
} }
private getPageContents() { private getPageContents() {
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;
})); }));
} }
private getDivContents() { private getDivContents() {
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
this.subscriptions.forEach(subscription => { this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) { if (subscription instanceof Subscriber) {
@ -210,14 +210,14 @@ export class DataProviderComponent {
this.fetchDataproviders.clearSubscriptions(); this.fetchDataproviders.clearSubscriptions();
this.fetchProjects.clearSubscriptions(); this.fetchProjects.clearSubscriptions();
} }
private getDataProviderInfo(id: string) { private getDataProviderInfo(id: string) {
this.warningMessage = ''; this.warningMessage = '';
this.errorMessage = ""; this.errorMessage = "";
this.showLoading = true; this.showLoading = true;
this.dataProviderInfo = null; this.dataProviderInfo = null;
this.showTabs = false; this.showTabs = false;
if (this.datasourceId == null || this.datasourceId == '') { if (this.datasourceId == null || this.datasourceId == '') {
this.showLoading = false; this.showLoading = false;
@ -242,9 +242,9 @@ export class DataProviderComponent {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe()); this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe());
} }
this.showLoading = false; this.showLoading = false;
// if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) { // if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
// this.activeTab = this.dataProviderInfo.tabs[0].name; // this.activeTab = this.dataProviderInfo.tabs[0].name;
// } // }
@ -267,7 +267,7 @@ export class DataProviderComponent {
)); ));
} }
} }
private getDataProviderAggregationStatus(originalId: string) { private getDataProviderAggregationStatus(originalId: string) {
this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe( this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
data => { data => {
@ -293,12 +293,12 @@ export class DataProviderComponent {
} }
)) ))
} }
private updateDescription(description: string) { private updateDescription(description: string) {
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'"); this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'"); this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
} }
private updateTitle(title: string) { private updateTitle(title: string) {
var _prefix = ""; var _prefix = "";
// if(this.communityId) { // if(this.communityId) {
@ -308,13 +308,13 @@ export class DataProviderComponent {
this._title.setTitle(title); this._title.setTitle(title);
this._meta.updateTag({content: title}, "property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
} }
private updateUrl(url: string) { private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'"); this._meta.updateTag({content: url}, "property='og:url'");
} }
private initTabs() { private initTabs() {
//if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) { //if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
this.reloadPublications = true; this.reloadPublications = true;
this.reloadDatasets = true; this.reloadDatasets = true;
@ -324,22 +324,22 @@ export class DataProviderComponent {
this.reloadDataproviders = true; this.reloadDataproviders = true;
this.reloadRelatedDatasources = true; this.reloadRelatedDatasources = true;
this.statsClicked = false; this.statsClicked = false;
//this.search(this.dataProviderInfo.tabs[0].content, 1, 10); //this.search(this.dataProviderInfo.tabs[0].content, 1, 10);
this.count(1, 0); this.count(1, 0);
this.metricsClicked = false; this.metricsClicked = false;
//old //old
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","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'; // this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","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';
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"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'; // this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"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';
//new //new
// this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"line","query":{"name":"usagestats.views.monthly", "parameters":["' + this.datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.views.monthly", "parameters":["' + this.datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
// this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
// encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.downloads.monthly", "parameters":["' + this.datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.downloads.monthly", "parameters":["' + this.datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
this.fetchAggregatorsResults = new FetchResearchResults(this._searchResearchResultsService); this.fetchAggregatorsResults = new FetchResearchResults(this._searchResearchResultsService);
} }
public getParamsForSearchLink(type: string = "") { public getParamsForSearchLink(type: string = "") {
if (type) { if (type) {
@ -348,7 +348,7 @@ export class DataProviderComponent {
return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId]); return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId]);
} }
} }
private count(page: number, size: number) { private count(page: number, size: number) {
this.countPublications(page, size); this.countPublications(page, size);
@ -359,7 +359,7 @@ export class DataProviderComponent {
this.countDatasources(page, size); this.countDatasources(page, size);
} }
public search(content: string, page: number, size: number) { public search(content: string, page: number, size: number) {
if (content == 'publicationsTab') { if (content == 'publicationsTab') {
this.searchPublications(page, size); this.searchPublications(page, size);
@ -381,7 +381,7 @@ export class DataProviderComponent {
this.statsClicked = !this.statsClicked; this.statsClicked = !this.statsClicked;
} }
} }
private searchPublications(page: number, size: number) { private searchPublications(page: number, size: number) {
if (this.reloadPublications && if (this.reloadPublications &&
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING || (this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
@ -392,11 +392,11 @@ export class DataProviderComponent {
} }
this.reloadPublications = false; this.reloadPublications = false;
} }
private countPublications(page: number, size: number) { private countPublications(page: number, size: number) {
this.fetchPublications.getResultsForDataproviders("publication", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties); this.fetchPublications.getResultsForDataproviders("publication", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
} }
private searchDatasets(page: number, size: number) { private searchDatasets(page: number, size: number) {
if (this.reloadDatasets && if (this.reloadDatasets &&
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING || (this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
@ -407,11 +407,11 @@ export class DataProviderComponent {
} }
this.reloadDatasets = false; this.reloadDatasets = false;
} }
private countDatasets(page: number, size: number) { private countDatasets(page: number, size: number) {
this.fetchDatasets.getResultsForDataproviders("dataset", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties); this.fetchDatasets.getResultsForDataproviders("dataset", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
} }
private searchSoftware(page: number, size: number) { private searchSoftware(page: number, size: number) {
if (this.reloadSoftware && if (this.reloadSoftware &&
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING || (this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
@ -422,11 +422,11 @@ export class DataProviderComponent {
} }
this.reloadSoftware = false; this.reloadSoftware = false;
} }
private countSoftware(page: number, size: number) { private countSoftware(page: number, size: number) {
this.fetchSoftware.getResultsForDataproviders("software", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties); this.fetchSoftware.getResultsForDataproviders("software", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
} }
private searchOrps(page: number, size: number) { private searchOrps(page: number, size: number) {
if (this.reloadOrps && if (this.reloadOrps &&
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING || (this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
@ -437,11 +437,11 @@ export class DataProviderComponent {
} }
this.reloadOrps = false; this.reloadOrps = false;
} }
private countOrps(page: number, size: number) { private countOrps(page: number, size: number) {
this.fetchOrps.getResultsForDataproviders("other", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties); this.fetchOrps.getResultsForDataproviders("other", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
} }
private searchProjects(page: number, size: number) { private searchProjects(page: number, size: number) {
if (this.reloadProjects && if (this.reloadProjects &&
(this.fetchProjects.searchUtils.status == this.errorCodes.LOADING || (this.fetchProjects.searchUtils.status == this.errorCodes.LOADING ||
@ -452,11 +452,11 @@ export class DataProviderComponent {
} }
this.reloadProjects = false; this.reloadProjects = false;
} }
private countProjects(page: number, size: number) { private countProjects(page: number, size: number) {
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties); this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
} }
private searchDatasources(page: number, size: number) { private searchDatasources(page: number, size: number) {
if (this.reloadDataproviders && if (this.reloadDataproviders &&
(this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING || (this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING ||
@ -467,14 +467,14 @@ export class DataProviderComponent {
} }
this.reloadDataproviders = false; this.reloadDataproviders = false;
} }
private countDatasources(page: number, size: number) { private countDatasources(page: number, size: number) {
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties); this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
} }
private searchRelatedDatasources(page: number, size: number) { private searchRelatedDatasources(page: number, size: number) {
// Currently no counting is done for this tab. Following condition is always false // Currently no counting is done for this tab. Following condition is always false
// if (this.reloadRelatedDatasources && // if (this.reloadRelatedDatasources &&
// (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING || // (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE) // this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE)
@ -519,16 +519,16 @@ export class DataProviderComponent {
this.loadingRelatedDatasources = false; this.loadingRelatedDatasources = false;
} }
)); ));
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties); this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
} else { } else {
this.loadingRelatedDatasources = false; this.loadingRelatedDatasources = false;
} }
this.reloadRelatedDatasources = false; this.reloadRelatedDatasources = false;
} }
private countRelatedDatasources(page: number, size: number) { private countRelatedDatasources(page: number, size: number) {
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties); this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
} }
@ -538,11 +538,11 @@ export class DataProviderComponent {
this.totalDownloads = $event.totalDownloads; this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews; this.pageViews = $event.pageViews;
} }
public get hasMetrics(): boolean { public get hasMetrics(): boolean {
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0; return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
} }
public openStatistics() { public openStatistics() {
this.statsClicked = true; this.statsClicked = true;
this.statisticsModal.cancelButton = false; this.statisticsModal.cancelButton = false;
@ -550,7 +550,7 @@ export class DataProviderComponent {
this.statisticsModal.alertTitle = "Statistics of"; this.statisticsModal.alertTitle = "Statistics of";
this.statisticsModal.open(); this.statisticsModal.open();
} }
public openRelatedDatasources() { public openRelatedDatasources() {
this.searchRelatedDatasources(1, 0); this.searchRelatedDatasources(1, 0);
this.relatedDatasourcesModal.cancelButton = false; this.relatedDatasourcesModal.cancelButton = false;
@ -558,19 +558,19 @@ export class DataProviderComponent {
this.relatedDatasourcesModal.alertTitle = "Related content providers of"; this.relatedDatasourcesModal.alertTitle = "Related content providers of";
this.relatedDatasourcesModal.open(); this.relatedDatasourcesModal.open();
} }
public scroll() { public scroll() {
HelperFunctions.scroll(); HelperFunctions.scroll();
} }
public removeUnknown(array: string[]): string[] { public removeUnknown(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== 'unknown'); return array.filter(value => value.toLowerCase() !== 'unknown');
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Content Provider Landing Page: " + message, error); console.error("Content Provider Landing Page: " + message, error);
} }
private getEntityName(entityType: string, plural: boolean, full: boolean): string { private getEntityName(entityType: string, plural: boolean, full: boolean): string {
if (entityType == "publication") { if (entityType == "publication") {
return "publication" + (plural ? "s" : ""); return "publication" + (plural ? "s" : "");
@ -586,11 +586,11 @@ export class DataProviderComponent {
return entityType + (plural ? "s" : ""); return entityType + (plural ? "s" : "");
} }
} }
public getResultPreview(result: SearchResult, type: string): ResultPreview { public getResultPreview(result: SearchResult, type: string): ResultPreview {
return ResultPreview.searchResultConvert(result, type); return ResultPreview.searchResultConvert(result, type);
} }
public onSelectActiveTab(activeTabId) { public onSelectActiveTab(activeTabId) {
if (this.activeTab != "activaTabId") { // tab really changed if (this.activeTab != "activaTabId") { // tab really changed
if (activeTabId == 'summary') { if (activeTabId == 'summary') {
@ -622,7 +622,7 @@ export class DataProviderComponent {
} }
} }
} }
public get hasAggregationStatusInfo(): boolean { public get hasAggregationStatusInfo(): boolean {
// return (!!this.dataProviderInfo.aggregationStatus && // return (!!this.dataProviderInfo.aggregationStatus &&
// ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1) // ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)
@ -641,7 +641,7 @@ export class DataProviderComponent {
!!this.dataProviderInfo.journal['start_page'] || !!this.dataProviderInfo.journal['end_page'])); !!this.dataProviderInfo.journal['start_page'] || !!this.dataProviderInfo.journal['end_page']));
//return true; //return true;
} }
public get hasPrimaryInfo(): boolean { public get hasPrimaryInfo(): boolean {
return !!this.dataProviderInfo && ( return !!this.dataProviderInfo && (
!!this.dataProviderInfo.description || !!this.dataProviderInfo.description ||
@ -650,7 +650,7 @@ export class DataProviderComponent {
!!this.dataProviderInfo.countries || !!this.dataProviderInfo.countries ||
(!!this.dataProviderInfo.subjects && this.dataProviderInfo.subjects.length > 0)); (!!this.dataProviderInfo.subjects && this.dataProviderInfo.subjects.length > 0));
} }
public get hasSecondaryInfo(): boolean { public get hasSecondaryInfo(): boolean {
return !!this.dataProviderInfo && ( return !!this.dataProviderInfo && (
(!!this.dataProviderInfo.organizations && this.dataProviderInfo.organizations.length > 0) (!!this.dataProviderInfo.organizations && this.dataProviderInfo.organizations.length > 0)

View File

@ -3,7 +3,7 @@ import {Metrics} from '../../../utils/entities/metrics';
import {MetricsService} from '../../../services/metrics.service'; import {MetricsService} from '../../../services/metrics.service';
import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {Subscription} from 'rxjs'; import {Subscription, zip} from 'rxjs';
import {EnvProperties} from '../../../utils/properties/env-properties'; import {EnvProperties} from '../../../utils/properties/env-properties';
import {animate, state, style, transition, trigger} from "@angular/animations"; import {animate, state, style, transition, trigger} from "@angular/animations";
@ -78,16 +78,16 @@ import {animate, state, style, transition, trigger} from "@angular/animations";
</table> </table>
</li> </li>
<!-- remove check for datasources when with the new charts --> <!-- remove check for datasources when with the new charts -->
<li *ngIf="entityType == 'datasources'" #element> <li #element>
<i-frame *ngIf="metricsClicked && metrics.totalViews > 0 && viewsFrameUrl" <i-frame *ngIf="metricsClicked && metrics.totalViews > 0 && viewsFrameUrl"
[height]="200" [height]="200"
[url]=viewsFrameUrl> [url]=viewsFrameUrl [addClass]="false">
</i-frame> </i-frame>
</li> </li>
<li *ngIf="entityType == 'datasources'" #element> <li #element>
<i-frame *ngIf="metricsClicked && metrics.totalDownloads > 0 && downloadsFrameUrl" <i-frame *ngIf="metricsClicked && metrics.totalDownloads > 0 && downloadsFrameUrl"
[height]="200" [height]="200"
[url]=downloadsFrameUrl> [url]=downloadsFrameUrl [addClass]="false">
</i-frame> </i-frame>
</li> </li>
</ul> </ul>
@ -195,20 +195,19 @@ export class MetricsComponent {
@Input() open = false; @Input() open = false;
@Input() viewsFrameUrl: string; @Input() viewsFrameUrl: string;
@Input() downloadsFrameUrl: string; @Input() downloadsFrameUrl: string;
public metrics: Metrics; public metrics: Metrics;
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
private sub: Subscription; private sub: Subscription;
private timeouts: any[] = []; private timeouts: any[] = [];
public metricsClicked: boolean = false; public metricsClicked: boolean = true;
public status: number; public status: number;
public state: number = -1; public state: number = -1;
constructor(private metricsService: MetricsService, private cdr: ChangeDetectorRef) { constructor(private metricsService: MetricsService, private cdr: ChangeDetectorRef) {
} }
ngOnInit() { ngOnInit() {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
@ -216,45 +215,99 @@ export class MetricsComponent {
this.getMetrics(); this.getMetrics();
} }
} }
ngOnDestroy() { ngOnDestroy() {
if(this.sub) { if(this.sub) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
public get total(): number { public get total(): number {
return +this.pageViews + +this.metrics.totalViews + +this.metrics.totalDownloads; return +this.pageViews + +this.metrics.totalViews + +this.metrics.totalDownloads;
} }
private getMetrics() { private getMetrics() {
this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe( //queries from old API - replaced with queries to the stats tool
data => { /* this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe(
this.metrics = data; data => {
this.cdr.detectChanges(); this.metrics = data;
this.status = this.errorCodes.DONE; this.cdr.detectChanges();
this.metricsResults.emit({ this.status = this.errorCodes.DONE;
totalViews: this.metrics.totalViews, this.metricsResults.emit({
totalDownloads: this.metrics.totalDownloads, totalViews: this.metrics.totalViews,
pageViews: this.metrics.pageViews totalDownloads: this.metrics.totalDownloads,
}); pageViews: this.metrics.pageViews
}, });
err => { },
if (err.status == '404') { err => {
this.status = this.errorCodes.NOT_FOUND; if (err.status == '404') {
} else if (err.status == '500') { this.status = this.errorCodes.NOT_FOUND;
this.status = this.errorCodes.ERROR; } else if (err.status == '500') {
} else { this.status = this.errorCodes.ERROR;
this.status = this.errorCodes.NOT_AVAILABLE; } else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
this.metricsResults.emit({
totalViews: 0,
totalDownloads: 0
});
} }
this.metricsResults.emit({ );*/
totalViews: 0, let obs;
totalDownloads: 0 if (this.entityType == "results") {
}); obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.results.views", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.results.downloads", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.results.views.openaire", this.properties),
this.metricsService.getMetricsNumbersByRepository(this.id, "usagestats.results.viewsdownloads.repository", this.properties)
);
} else if (this.entityType == "projects") {
obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.projects.views", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.projects.downloads", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.projects.views.openaire", this.properties));
} else if (this.entityType == "datasources") {
obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.views.repository.local", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.downloads.repository.local", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.views.openaire", this.properties),
// this.metricsService.getMetricsNumber(this.id, "usagestats.downloads.repository.openaire", this.properties)
);
} }
);
this.sub = obs.subscribe(
data => {
this.metrics = new Metrics();
this.metrics.infos = new Map<string, { "name": string, "url": string, "numOfDownloads": string, "numOfViews": string, "openaireDownloads": string, "openaireViews": string }>();
this.metrics.totalViews = data[0] ? data[0] : 0;
this.metrics.totalDownloads = data[1] ? data[1] : 0;
this.metrics.pageViews = data[2] ? data[2] : 0;
this.metrics.infos = data[3] ? data[3] : 0;
this.cdr.detectChanges();
this.status = this.errorCodes.DONE;
this.metricsResults.emit({
totalViews: this.metrics.totalViews,
totalDownloads: this.metrics.totalDownloads,
pageViews: this.metrics.pageViews
});
},
err => {
if (err.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
this.metricsResults.emit({
totalViews: 0,
totalDownloads: 0
});
}
);
} }
public close(event) { public close(event) {
if(event.value && this.state !== -1) { if(event.value && this.state !== -1) {
this.timeouts.forEach(timeout => { this.timeouts.forEach(timeout => {
@ -264,8 +317,8 @@ export class MetricsComponent {
this.timeouts = []; this.timeouts = [];
} }
} }
public toggle(event) { public toggle(event) {
this.metricsClicked = true; this.metricsClicked = true;
@ -293,7 +346,7 @@ export class MetricsComponent {
} }
this.cdr.detectChanges(); this.cdr.detectChanges();
} }
public getKeys(map) { public getKeys(map) {
return Array.from(map.keys()); return Array.from(map.keys());
} }

View File

@ -399,7 +399,7 @@
<!-- Metrics --> <!-- Metrics -->
<li *ngIf="hasMetrics" class="uk-margin-medium-top"> <li *ngIf="hasMetrics" class="uk-margin-medium-top">
<div class="uk-text-center uk-flex uk-flex-middle uk-flex-center"> <div class="uk-text-center uk-flex uk-flex-middle uk-flex-center">
<div [class.uk-hidden]="!(totalViews && totalDownloads && pageViews)"> <div [class.uk-hidden]="!(totalViews || totalDownloads || pageViews)">
<metrics [pageViews]="pageViews" <metrics [pageViews]="pageViews"
[id]="projectId" [entityType]="'projects'" [entity]="'project'" [id]="projectId" [entityType]="'projects'" [entity]="'project'"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl" [viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -288,7 +288,7 @@ export class ProjectComponent {
} }
this.reloadPublications = false; this.reloadPublications = false;
} }
public searchDmps(page: number, size: number) { public searchDmps(page: number, size: number) {
if (this.reloadDmps && if (this.reloadDmps &&
(this.fetchDmps.searchUtils.status == this.errorCodes.LOADING || (this.fetchDmps.searchUtils.status == this.errorCodes.LOADING ||
@ -410,13 +410,13 @@ export class ProjectComponent {
endDate: this.projectInfo.endDate endDate: this.projectInfo.endDate
}; };
//old //old
this.viewsFrameUrl = this.properties.framesAPIURL + '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":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","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'; // this.viewsFrameUrl = this.properties.framesAPIURL + '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":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","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';
//
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"projRepoDownloads","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":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"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'; // this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"projRepoDownloads","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":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"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';
//new //new
// this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"line","query":{"name":"usagestats.projects.views.monthly", "parameters":["' + this.projectId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.projects.views.monthly", "parameters":["' + this.projectId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
// this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
// encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.projects.downloads.monthly", "parameters":["' + this.projectId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.projects.downloads.monthly", "parameters":["' + this.projectId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
//stats tab charts //stats tab charts
if (this.properties.useNewStatistisTool) { if (this.properties.useNewStatistisTool) {
this.chartScientificResultsUrl = this.properties.statisticsFrameNewAPIURL + this.chartScientificResultsUrl = this.properties.statisticsFrameNewAPIURL +
@ -467,7 +467,7 @@ export class ProjectComponent {
this.totalDownloads = $event.totalDownloads; this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews; this.pageViews = $event.pageViews;
} }
public get hasMetrics(): boolean { public get hasMetrics(): boolean {
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0||this.pageViews > 0; return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0||this.pageViews > 0;
} }
@ -709,7 +709,7 @@ export class ProjectComponent {
private openLoading() { private openLoading() {
this.closeDownloadReportModal(); this.closeDownloadReportModal();
if (this.loading) { if (this.loading) {
this.loading.open(); this.loading.open();
} }
@ -769,7 +769,7 @@ export class ProjectComponent {
public getResultPreview(result: SearchResult, type: string): ResultPreview { public getResultPreview(result: SearchResult, type: string): ResultPreview {
return ResultPreview.searchResultConvert(result, type); return ResultPreview.searchResultConvert(result, type);
} }
public scroll() { public scroll() {
HelperFunctions.scroll(); HelperFunctions.scroll();
} }

View File

@ -125,7 +125,7 @@
<li *ngIf="hasAltMetrics || hasMetrics" class="uk-margin-medium-top"> <li *ngIf="hasAltMetrics || hasMetrics" class="uk-margin-medium-top">
<div uk-grid <div uk-grid
class="uk-child-width-1-3 uk-text-center uk-flex uk-flex-middle uk-flex-center uk-padding-remove-left"> class="uk-child-width-1-3 uk-text-center uk-flex uk-flex-middle uk-flex-center uk-padding-remove-left">
<div *ngIf="hasMetrics" [class.uk-hidden]="!(totalViews && totalDownloads && pageViews)"> <div *ngIf="hasMetrics" [class.uk-hidden]="!(totalViews || totalDownloads || pageViews)">
<metrics [pageViews]="pageViews" <metrics [pageViews]="pageViews"
[id]="id" [entityType]="'results'" [entity]="title" [id]="id" [entityType]="'results'" [entity]="title"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl" [viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -23,6 +23,7 @@ import {Session} from "../../login/utils/helper.class";
import {AnnotationComponent} from "../annotation/annotation.component"; import {AnnotationComponent} from "../annotation/annotation.component";
import {ParsingFunctions} from "../landing-utils/parsingFunctions.class"; import {ParsingFunctions} from "../landing-utils/parsingFunctions.class";
import {ConnectHelper} from "../../connect/connectHelper"; import {ConnectHelper} from "../../connect/connectHelper";
import {$e} from "codelyzer/angular/styles/chars";
@Component({ @Component({
@ -360,12 +361,12 @@ export class ResultLandingComponent {
this.resultLandingInfo = data; this.resultLandingInfo = data;
this.id = this.resultLandingInfo.objIdentifier; this.id = this.resultLandingInfo.objIdentifier;
//old //old
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&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(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'; // this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&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(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';
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&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(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'; // this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&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(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';
//new //new
// this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"line","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
// this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
// encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
let pid:Identifier = Identifier.getResultPIDFromIdentifiers(this.resultLandingInfo.identifiers); let pid:Identifier = Identifier.getResultPIDFromIdentifiers(this.resultLandingInfo.identifiers);
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
this.updateUrlWithType(pid); this.updateUrlWithType(pid);

View File

@ -15,7 +15,74 @@ export class MetricsService {
hasAltMetrics(url: string, doi: string): Observable<boolean> { hasAltMetrics(url: string, doi: string): Observable<boolean> {
return this.http.get(url + doi).pipe(map(res => !!(res))); return this.http.get(url + doi).pipe(map(res => !!(res)));
} }
getMetricsNumber (id: string, table: string, properties:EnvProperties):any {
let url =properties.statisticsFrameNewAPIURL + 'raw?json=' + encodeURIComponent('{"series":[{"query":{"name":"' + table + '", "parameters":["' + id + '"], "profile":"OpenAIRE All-inclusive"}}],"verbose":true}');
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.pipe(map(res => this.parseMetricsNumber(res)));
}
parseMetricsNumber(res){
try{
return +res["datasets"]["0"]["series"]["result"]["0"]["row"]["0"];
}catch(e){
return null;
}
}
getMetricsNumbersByRepository (id: string, table: string, properties:EnvProperties):any {
let url =properties.statisticsFrameNewAPIURL + 'raw?json=' + encodeURIComponent('{"series":[{"query":{"name":"' + table + '", "parameters":["' + id + '","' + id + '","' + id + '"], "profile":"OpenAIRE All-inclusive"}}],"verbose":true}');
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.pipe(map(res => this.parseMetricsNumbersByRepository(res,properties)));
}
parseMetricsNumbersByRepository(res,properties){
let map = new Map<string, {"name": string, "url": string, "numOfDownloads": string, "numOfViews": string, "openaireDownloads": string, "openaireViews": string}>();
try{
let results = res["datasets"]["0"]["series"]["result"];
for(let i=0; i<results.length; i++) {
let result = results[i]["row"];
let id: string = result[1];
console.log(id,result[0])
if(map.has(id)) {
if(result[0] == "views"){
map.get(id).numOfViews = result[3];
map.get(id).openaireViews = result[4];
}else if(result[0] == "downloads") {
map.get(id).numOfDownloads = result[3];
map.get(id).openaireDownloads = result[4];
}
} else {
let info;//: {"url": string, "numOfDownloads": string, "numOfViews": string};
info = {};
info.name = result[2];
info.url = properties.searchLinkToDataProvider+id;
info.numOfDownloads = "0";
info.openaireDownloads = "0";
info.numOfViews = "0";
info.openaireViews = "0";
if(result[0] == "views"){
info.numOfViews = result[3];
info.openaireViews = result[4];
}else if(result[0] == "downloads") {
info.numOfDownloads = result[3];
info.openaireDownloads = result[4];
}
if(info.numOfViews + info.openaireViews + info.numOfDownloads + info.openaireDownloads > 0) {
map.set(id, info);
}
}
}
}catch(e){
console.error(e)
}
console.log(map)
return map;
}
getMetrics (id: string, entityType: string, properties:EnvProperties):any { getMetrics (id: string, entityType: string, properties:EnvProperties):any {
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks"; let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks";
let key = url; let key = url;

View File

@ -4,10 +4,10 @@ import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
@Component({ @Component({
selector: 'i-frame', selector: 'i-frame',
template: ` template: `
<div *ngIf="!style" class="iframeContainer uk-height-large"> <div *ngIf="!style" class=" uk-height-large" [class.iframeContainer]="addClass">
<iframe allowtransparency="true" [src]="safeUrl"></iframe> <iframe allowtransparency="true" [src]="safeUrl"></iframe>
</div> </div>
<div *ngIf="style" class="iframeContainer" [ngStyle]="style"> <div *ngIf="style" [class.iframeContainer]="addClass" [ngStyle]="style">
<iframe [src]="safeUrl"></iframe> <iframe [src]="safeUrl"></iframe>
</div> </div>
` `
@ -18,8 +18,9 @@ export class IFrameComponent {
@Input() width: number; @Input() width: number;
@Input() height: number; @Input() height: number;
@Input() unit: string = 'px'; @Input() unit: string = 'px';
@Input() addClass: boolean= true;
public style: any; public style: any;
constructor(private sanitizer: DomSanitizer) { constructor(private sanitizer: DomSanitizer) {
} }
ngOnInit() { ngOnInit() {