openaire-library/landingPages/dataProvider/statisticsTab.component.ts

116 lines
13 KiB
TypeScript
Raw Normal View History

import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
[Trunk | Library]: Merge services, fetchClasses, simple and advanced search pages for research results (publications, datasets, software, other): 1. advancedSearchResearchResults.component & advancedSearchResearchResults.module: New common advanced search page for research results. 2. searchResearchResults.component & searchResearchResults.module: New common simple search page for research results. 3. fetchResearchResults.class: New common fetch class for research results. 4. searchResearchResults.service: Update existing service to satisfy merge of research results services. 5. app.module.ts: Import one common simple and one common advanced search page for search results. 6. claimResultSearchForm & directLinking & advancedSearchDatasets & advancedSearchOrps & advancedSearchPublications & advancedSearchSoftware & searchDatasets & searchOrps & searchPublications & searchSoftware & fetchDatasets.class & fetchOrps.class & fetchPublications.class & fetchSoftware.class: Use common service for research results (searchResearchResults.service). 7. datasetsTab & orpsTab & publicationsTab & softwareTab & relatedDatasourcesTab & statisticsTab: Use common fetch class for research results (fetchResearchResults.class). 8. dataProvider & organization & project & search : Use common service and common fetch class for research results (searchResearchResults.service, fetchResearchResults.class). 9. linkingGeneric.component: Remove import of services for publications and datasets. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57027 d315682c-612b-4755-9ff5-7f18f6832af3
2019-09-11 11:45:54 +02:00
import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from "../../utils/string-utils.class";
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
import {OpenaireEntities} from "../../utils/properties/searchFields";
@Component({
selector: 'statisticsTab',
template: `
<errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status,
fetchSoftware.searchUtils.status, fetchOther.searchUtils.status]"
[type]="'statistics'" tab_error_class=true></errorMessages>
<div *ngIf="fetchPublications.searchUtils.totalResults > 0 || (fetchDatasets.searchUtils.totalResults > 0 ||
fetchSoftware.searchUtils.totalResults > 0 || fetchOther.searchUtils.totalResults > 0)"
class="uk-grid uk-child-width-1-1 uk-child-width-1-2@m">
<div class="uk-padding uk-padding-remove-top">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Produced {{openaireEntities.RESULTS}} per year</div>
<i-frame [url]=docsTimelineUrl
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
</div>
</div>
<div class="uk-padding uk-padding-remove-top">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">{{openaireEntities.RESULTS}} Types</div>
<i-frame [url]=docsTypesUrl
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
</div>
</div>
<!-- </ng-container>-->
<!-- <div *ngIf="fetchPublications.searchUtils.totalResults > 0 || (fetchDatasets.searchUtils.totalResults > 0-->
<!-- || fetchSoftware.searchUtils.totalResults > 0 || fetchOther.searchUtils.totalResults > 0)"-->
<div class="uk-padding uk-padding-remove-top">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">{{openaireEntities.RESULTS}} per funder</div>
<i-frame [url]=docsFunderUrl
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
</div>
</div>
<div *ngIf="fetchPublications.searchUtils.totalResults > 0 "
class="uk-padding uk-padding-remove-top">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">{{openaireEntities.PROJECTS}} with most {{openaireEntities.PUBLICATIONS}}</div>
<i-frame [url]=pubsProjectsUrl
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
</div>
</div>
<div *ngIf="(fetchDatasets.searchUtils.totalResults > 0)"
class="uk-padding uk-padding-remove-top">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">{{openaireEntities.PROJECTS}} with most {{openaireEntities.DATASETS}}</div>
<i-frame [url]=dataProjectsUrl
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
</div>
</div>
</div>
`
})
export class StatisticsTabComponent {
@Input() datasourceId;
[Trunk | Library]: Merge services, fetchClasses, simple and advanced search pages for research results (publications, datasets, software, other): 1. advancedSearchResearchResults.component & advancedSearchResearchResults.module: New common advanced search page for research results. 2. searchResearchResults.component & searchResearchResults.module: New common simple search page for research results. 3. fetchResearchResults.class: New common fetch class for research results. 4. searchResearchResults.service: Update existing service to satisfy merge of research results services. 5. app.module.ts: Import one common simple and one common advanced search page for search results. 6. claimResultSearchForm & directLinking & advancedSearchDatasets & advancedSearchOrps & advancedSearchPublications & advancedSearchSoftware & searchDatasets & searchOrps & searchPublications & searchSoftware & fetchDatasets.class & fetchOrps.class & fetchPublications.class & fetchSoftware.class: Use common service for research results (searchResearchResults.service). 7. datasetsTab & orpsTab & publicationsTab & softwareTab & relatedDatasourcesTab & statisticsTab: Use common fetch class for research results (fetchResearchResults.class). 8. dataProvider & organization & project & search : Use common service and common fetch class for research results (searchResearchResults.service, fetchResearchResults.class). 9. linkingGeneric.component: Remove import of services for publications and datasets. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57027 d315682c-612b-4755-9ff5-7f18f6832af3
2019-09-11 11:45:54 +02:00
@Input() fetchPublications : FetchResearchResults;
@Input() fetchDatasets : FetchResearchResults;
@Input() fetchSoftware: FetchResearchResults;
@Input() fetchOther: FetchResearchResults;
private docsTimelineUrl: string;
private docsTypesUrl:string;
private docsFunderUrl:string;
private dataProjectsUrl:string ;
private pubsProjectsUrl:string;
public errorCodes:ErrorCodes = new ErrorCodes();
properties:EnvProperties;
public openaireEntities = OpenaireEntities;
sub;
constructor (private route: ActivatedRoute) {}
ngOnInit() {
this.properties = properties;
if (this.properties.useNewStatistisTool) {
this.docsTimelineUrl = this.properties.statisticsFrameNewAPIURL +
'chart?json='+StringUtils.URIEncode('{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+this.openaireEntities.RESULTS+'","type":"column","query":{"name":"dtsrcYear","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Produced '+this.openaireEntities.RESULTS+' per year"},"subtitle":{},"yAxis":{"title":{"text":"'+this.openaireEntities.RESULTS+'"}},"xAxis":{"title":{"text":"Year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
this.docsTypesUrl = this.properties.statisticsFrameNewAPIURL +
'chart?json='+StringUtils.URIEncode('{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+this.openaireEntities.RESULTS+'","type":"pie","query":{"name":"dtsrcPubs","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+this.openaireEntities.RESULTS+' types"},"subtitle":{},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":true}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
this.docsFunderUrl = this.properties.statisticsFrameNewAPIURL +
'chart?json='+StringUtils.URIEncode('{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+this.openaireEntities.RESULTS+'","type":"pie","query":{"name":"dtsrcPubsFund","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+this.openaireEntities.RESULTS+' per funder"},"subtitle":{},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":true}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
this.pubsProjectsUrl = this.properties.statisticsFrameNewAPIURL +
'chart?json='+StringUtils.URIEncode('{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+this.openaireEntities.PUBLICATIONS+'","type":"bar","query":{"name":"dtsrcProjPubs","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":" '+this.openaireEntities.PROJECTS+' with most '+this.openaireEntities.PUBLICATIONS+'"},"subtitle":{},"yAxis":{"title":{"text":"'+this.openaireEntities.PUBLICATIONS+'"}},"xAxis":{"title":{"text":"'+this.openaireEntities.PROJECT+'"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
this.dataProjectsUrl = this.properties.statisticsFrameNewAPIURL +
'chart?json='+StringUtils.URIEncode('{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+this.openaireEntities.DATASETS+'","type":"bar","query":{"name":"dtsrcProjData","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+this.openaireEntities.PROJECTS+' with most '+this.openaireEntities.DATASETS+'"},"subtitle":{},"yAxis":{"title":{"text":"'+this.openaireEntities.DATASETS+'"}},"xAxis":{"title":{"text":"'+this.openaireEntities.PROJECT+'"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
} else {
this.docsTimelineUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"' + this.datasourceId + '","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":80, "sort": "xaxis", "xStyle":{"r": -30, "s": "6", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["'+this.openaireEntities.RESULTS+'"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=90%&h=90%';
this.docsTypesUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["'+this.openaireEntities.RESULTS+'"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
this.docsFunderUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["'+this.openaireEntities.RESULTS+'"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
this.dataProjectsUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["'+this.openaireEntities.DATASETS+'"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
this.pubsProjectsUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["'+this.openaireEntities.PUBLICATIONS+'"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
}
}
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}}