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 -->
<li *ngIf="hasMetrics" class="uk-margin-medium-top">
<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"
[id]="datasourceId" [entityType]="'datasources'" [entity]="'Content Provider'"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -38,7 +38,7 @@ export class DataProviderComponent {
@Input() communityId = null;
public dataProviderInfo: DataProviderInfo;
public datasourceId: string;
// Message variables
public warningMessage = "";
public errorMessage = "";
@ -51,13 +51,13 @@ export class DataProviderComponent {
public totalViews: number;
public totalDownloads: number;
public pageViews: number;
// Statistics tab variables
public statsClicked: boolean = false;
@ViewChild('statisticsModal') statisticsModal;
@ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
// Variables for publications, research data, projects, content providers, related content providers tabs
public fetchPublications: FetchResearchResults;
public fetchDatasets: FetchResearchResults;
@ -67,23 +67,23 @@ export class DataProviderComponent {
public fetchDataproviders: FetchDataproviders;
public fetchAggregatorsResults: FetchResearchResults;
public searchNumber: number = 5;
public aggregationStatusIsInitialized: boolean = false;
public loadingRelatedDatasources: boolean = true;
// Active tab variable for responsiveness - show tabs only if main request is completed
public activeTab: string = "";
public showTabs: boolean = false;
public _numberOfTabs: number = 0;
public tabsAreInitialized: boolean = false;
public routerHelper: RouterHelper = new RouterHelper();
public errorCodes: ErrorCodes = new ErrorCodes();
public pageContents = null;
public divContents = null;
// Request results of each tab only the one time (first time tab is clicked)
private reloadPublications: boolean = true;
private reloadDatasets: boolean = true;
@ -92,26 +92,26 @@ export class DataProviderComponent {
private reloadProjects: boolean = true;
private reloadDataproviders: boolean = true;
private reloadRelatedDatasources: boolean = true;
// Organizations variables for view more/less functionality
public thresholdOrganizations: number = 20;
public showNumOrganizations: number = 20;
// Subjects variables for view more/less functionality
public thresholdSubjects: number = 20;
public showNumSubjects: number = 20;
// Description variables for view more/less functionality
public thresholdDescription: number = 670;
public showNumDescription: number = 670;
public indexUpdateDate: Date;
public showFeedback: boolean = false;
public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other'];
subscriptions = [];
properties: EnvProperties = properties;
constructor(private _dataproviderService: DataProviderService,
private _piwikService: PiwikService,
private route: ActivatedRoute,
@ -131,9 +131,9 @@ export class DataProviderComponent {
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
}
ngOnInit() {
if (typeof document !== 'undefined') {
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
@ -163,7 +163,7 @@ export class DataProviderComponent {
}
}));
}
public initializeValues() {
this._numberOfTabs = 0;
this.tabsAreInitialized = false;
@ -184,19 +184,19 @@ export class DataProviderComponent {
this.statsClicked = false;
this.metricsClicked = false;
}
private getPageContents() {
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents;
}));
}
private getDivContents() {
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.divContents = contents;
}));
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
@ -210,14 +210,14 @@ export class DataProviderComponent {
this.fetchDataproviders.clearSubscriptions();
this.fetchProjects.clearSubscriptions();
}
private getDataProviderInfo(id: string) {
this.warningMessage = '';
this.errorMessage = "";
this.showLoading = true;
this.dataProviderInfo = null;
this.showTabs = false;
if (this.datasourceId == null || this.datasourceId == '') {
this.showLoading = false;
@ -242,9 +242,9 @@ export class DataProviderComponent {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe());
}
this.showLoading = false;
// if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
// this.activeTab = this.dataProviderInfo.tabs[0].name;
// }
@ -267,7 +267,7 @@ export class DataProviderComponent {
));
}
}
private getDataProviderAggregationStatus(originalId: string) {
this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
data => {
@ -293,12 +293,12 @@ export class DataProviderComponent {
}
))
}
private updateDescription(description: string) {
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
}
private updateTitle(title: string) {
var _prefix = "";
// if(this.communityId) {
@ -308,13 +308,13 @@ export class DataProviderComponent {
this._title.setTitle(title);
this._meta.updateTag({content: title}, "property='og:title'");
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}
private initTabs() {
//if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
this.reloadPublications = true;
this.reloadDatasets = true;
@ -324,22 +324,22 @@ export class DataProviderComponent {
this.reloadDataproviders = true;
this.reloadRelatedDatasources = true;
this.statsClicked = false;
//this.search(this.dataProviderInfo.tabs[0].content, 1, 10);
this.count(1, 0);
this.metricsClicked = false;
//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.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.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';
//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.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":""}}}');
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=' +
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);
}
public getParamsForSearchLink(type: string = "") {
if (type) {
@ -348,7 +348,7 @@ export class DataProviderComponent {
return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId]);
}
}
private count(page: number, size: number) {
this.countPublications(page, size);
@ -359,7 +359,7 @@ export class DataProviderComponent {
this.countDatasources(page, size);
}
public search(content: string, page: number, size: number) {
if (content == 'publicationsTab') {
this.searchPublications(page, size);
@ -381,7 +381,7 @@ export class DataProviderComponent {
this.statsClicked = !this.statsClicked;
}
}
private searchPublications(page: number, size: number) {
if (this.reloadPublications &&
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
@ -392,11 +392,11 @@ export class DataProviderComponent {
}
this.reloadPublications = false;
}
private countPublications(page: number, size: number) {
this.fetchPublications.getResultsForDataproviders("publication", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
}
private searchDatasets(page: number, size: number) {
if (this.reloadDatasets &&
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
@ -407,11 +407,11 @@ export class DataProviderComponent {
}
this.reloadDatasets = false;
}
private countDatasets(page: number, size: number) {
this.fetchDatasets.getResultsForDataproviders("dataset", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
}
private searchSoftware(page: number, size: number) {
if (this.reloadSoftware &&
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
@ -422,11 +422,11 @@ export class DataProviderComponent {
}
this.reloadSoftware = false;
}
private countSoftware(page: number, size: number) {
this.fetchSoftware.getResultsForDataproviders("software", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
}
private searchOrps(page: number, size: number) {
if (this.reloadOrps &&
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
@ -437,11 +437,11 @@ export class DataProviderComponent {
}
this.reloadOrps = false;
}
private countOrps(page: number, size: number) {
this.fetchOrps.getResultsForDataproviders("other", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
}
private searchProjects(page: number, size: number) {
if (this.reloadProjects &&
(this.fetchProjects.searchUtils.status == this.errorCodes.LOADING ||
@ -452,11 +452,11 @@ export class DataProviderComponent {
}
this.reloadProjects = false;
}
private countProjects(page: number, size: number) {
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
}
private searchDatasources(page: number, size: number) {
if (this.reloadDataproviders &&
(this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING ||
@ -467,14 +467,14 @@ export class DataProviderComponent {
}
this.reloadDataproviders = false;
}
private countDatasources(page: number, size: number) {
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
}
private searchRelatedDatasources(page: number, size: number) {
// Currently no counting is done for this tab. Following condition is always false
// if (this.reloadRelatedDatasources &&
// (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE)
@ -519,16 +519,16 @@ export class DataProviderComponent {
this.loadingRelatedDatasources = false;
}
));
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
} else {
this.loadingRelatedDatasources = false;
}
this.reloadRelatedDatasources = false;
}
private countRelatedDatasources(page: number, size: number) {
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
}
@ -538,11 +538,11 @@ export class DataProviderComponent {
this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews;
}
public get hasMetrics(): boolean {
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
}
public openStatistics() {
this.statsClicked = true;
this.statisticsModal.cancelButton = false;
@ -550,7 +550,7 @@ export class DataProviderComponent {
this.statisticsModal.alertTitle = "Statistics of";
this.statisticsModal.open();
}
public openRelatedDatasources() {
this.searchRelatedDatasources(1, 0);
this.relatedDatasourcesModal.cancelButton = false;
@ -558,19 +558,19 @@ export class DataProviderComponent {
this.relatedDatasourcesModal.alertTitle = "Related content providers of";
this.relatedDatasourcesModal.open();
}
public scroll() {
HelperFunctions.scroll();
}
public removeUnknown(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== 'unknown');
}
private handleError(message: string, error) {
console.error("Content Provider Landing Page: " + message, error);
}
private getEntityName(entityType: string, plural: boolean, full: boolean): string {
if (entityType == "publication") {
return "publication" + (plural ? "s" : "");
@ -586,11 +586,11 @@ export class DataProviderComponent {
return entityType + (plural ? "s" : "");
}
}
public getResultPreview(result: SearchResult, type: string): ResultPreview {
return ResultPreview.searchResultConvert(result, type);
}
public onSelectActiveTab(activeTabId) {
if (this.activeTab != "activaTabId") { // tab really changed
if (activeTabId == 'summary') {
@ -622,7 +622,7 @@ export class DataProviderComponent {
}
}
}
public get hasAggregationStatusInfo(): boolean {
// return (!!this.dataProviderInfo.aggregationStatus &&
// ((!!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']));
//return true;
}
public get hasPrimaryInfo(): boolean {
return !!this.dataProviderInfo && (
!!this.dataProviderInfo.description ||
@ -650,7 +650,7 @@ export class DataProviderComponent {
!!this.dataProviderInfo.countries ||
(!!this.dataProviderInfo.subjects && this.dataProviderInfo.subjects.length > 0));
}
public get hasSecondaryInfo(): boolean {
return !!this.dataProviderInfo && (
(!!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 {ErrorCodes} from '../../../utils/properties/errorCodes';
import {Subscription} from 'rxjs';
import {Subscription, zip} from 'rxjs';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {animate, state, style, transition, trigger} from "@angular/animations";
@ -78,16 +78,16 @@ import {animate, state, style, transition, trigger} from "@angular/animations";
</table>
</li>
<!-- remove check for datasources when with the new charts -->
<li *ngIf="entityType == 'datasources'" #element>
<li #element>
<i-frame *ngIf="metricsClicked && metrics.totalViews > 0 && viewsFrameUrl"
[height]="200"
[url]=viewsFrameUrl>
[url]=viewsFrameUrl [addClass]="false">
</i-frame>
</li>
<li *ngIf="entityType == 'datasources'" #element>
<li #element>
<i-frame *ngIf="metricsClicked && metrics.totalDownloads > 0 && downloadsFrameUrl"
[height]="200"
[url]=downloadsFrameUrl>
[url]=downloadsFrameUrl [addClass]="false">
</i-frame>
</li>
</ul>
@ -195,20 +195,19 @@ export class MetricsComponent {
@Input() open = false;
@Input() viewsFrameUrl: string;
@Input() downloadsFrameUrl: string;
public metrics: Metrics;
public errorCodes: ErrorCodes;
private sub: Subscription;
private timeouts: any[] = [];
public metricsClicked: boolean = false;
public metricsClicked: boolean = true;
public status: number;
public state: number = -1;
constructor(private metricsService: MetricsService, private cdr: ChangeDetectorRef) {
}
ngOnInit() {
this.errorCodes = new ErrorCodes();
if (typeof document !== 'undefined') {
@ -216,45 +215,99 @@ export class MetricsComponent {
this.getMetrics();
}
}
ngOnDestroy() {
if(this.sub) {
this.sub.unsubscribe();
}
}
public get total(): number {
return +this.pageViews + +this.metrics.totalViews + +this.metrics.totalDownloads;
}
private getMetrics() {
this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe(
data => {
this.metrics = data;
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;
//queries from old API - replaced with queries to the stats tool
/* this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe(
data => {
this.metrics = data;
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
});
}
this.metricsResults.emit({
totalViews: 0,
totalDownloads: 0
});
);*/
let obs;
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) {
if(event.value && this.state !== -1) {
this.timeouts.forEach(timeout => {
@ -264,8 +317,8 @@ export class MetricsComponent {
this.timeouts = [];
}
}
public toggle(event) {
this.metricsClicked = true;
@ -293,7 +346,7 @@ export class MetricsComponent {
}
this.cdr.detectChanges();
}
public getKeys(map) {
return Array.from(map.keys());
}

View File

@ -399,7 +399,7 @@
<!-- Metrics -->
<li *ngIf="hasMetrics" class="uk-margin-medium-top">
<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"
[id]="projectId" [entityType]="'projects'" [entity]="'project'"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -288,7 +288,7 @@ export class ProjectComponent {
}
this.reloadPublications = false;
}
public searchDmps(page: number, size: number) {
if (this.reloadDmps &&
(this.fetchDmps.searchUtils.status == this.errorCodes.LOADING ||
@ -410,13 +410,13 @@ export class ProjectComponent {
endDate: this.projectInfo.endDate
};
//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.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.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';
//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.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":""}}}');
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=' +
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
if (this.properties.useNewStatistisTool) {
this.chartScientificResultsUrl = this.properties.statisticsFrameNewAPIURL +
@ -467,7 +467,7 @@ export class ProjectComponent {
this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews;
}
public get hasMetrics(): boolean {
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() {
this.closeDownloadReportModal();
if (this.loading) {
this.loading.open();
}
@ -769,7 +769,7 @@ export class ProjectComponent {
public getResultPreview(result: SearchResult, type: string): ResultPreview {
return ResultPreview.searchResultConvert(result, type);
}
public scroll() {
HelperFunctions.scroll();
}

View File

@ -125,7 +125,7 @@
<li *ngIf="hasAltMetrics || hasMetrics" class="uk-margin-medium-top">
<div uk-grid
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"
[id]="id" [entityType]="'results'" [entity]="title"
[viewsFrameUrl]="viewsFrameUrl" [downloadsFrameUrl]="downloadsFrameUrl"

View File

@ -23,6 +23,7 @@ import {Session} from "../../login/utils/helper.class";
import {AnnotationComponent} from "../annotation/annotation.component";
import {ParsingFunctions} from "../landing-utils/parsingFunctions.class";
import {ConnectHelper} from "../../connect/connectHelper";
import {$e} from "codelyzer/angular/styles/chars";
@Component({
@ -360,12 +361,12 @@ export class ResultLandingComponent {
this.resultLandingInfo = data;
this.id = this.resultLandingInfo.objIdentifier;
//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.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.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';
//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.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":""}}}');
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=' +
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);
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
this.updateUrlWithType(pid);

View File

@ -15,7 +15,74 @@ export class MetricsService {
hasAltMetrics(url: string, doi: string): Observable<boolean> {
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 {
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks";
let key = url;

View File

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