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

105 lines
12 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";
@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>
<!-- <ng-container *ngIf="(fetchPublications.searchUtils.status == errorCodes.DONE -->
<!-- || fetchDatasets.searchUtils.status == errorCodes.DONE-->
<!-- || fetchSoftware.searchUtils.status == errorCodes.DONE-->
<!-- || fetchOther.searchUtils.status == errorCodes.DONE)">-->
<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 *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Produced research outcomes per year</div>
<i-frame [url]=docsTimelineUrl ></i-frame>
</div>
<div class="uk-padding uk-padding-remove-top">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Research outcomes Types</div>
<i-frame [url]=docsTypesUrl ></i-frame>
</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 *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Research outcomes per funder</div>
<i-frame [url]=docsFunderUrl ></i-frame>
</div>
<div *ngIf="fetchPublications.searchUtils.totalResults > 0 "
class="uk-padding uk-padding-remove-top">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Projects with most Publications</div>
<i-frame [url]=pubsProjectsUrl ></i-frame>
</div>
<div *ngIf="(fetchDatasets.searchUtils.totalResults > 0)"
class="uk-padding uk-padding-remove-top">
<div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Projects with most Research Data</div>
<i-frame [url]=dataProjectsUrl></i-frame>
</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;
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":"Research outcomes","type":"column","query":{"name":"dtsrcYear","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Produced research outcomes per year"},"subtitle":{},"yAxis":{"title":{"text":"Research outcomes"}},"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":"Research outcomes ","type":"pie","query":{"name":"dtsrcPubs","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Research outcomes 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":"Research outcomes","type":"pie","query":{"name":"dtsrcPubsFund","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Research outcomes 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":"Publications","type":"bar","query":{"name":"dtsrcProjPubs","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":" Projects with most publications"},"subtitle":{},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{"text":"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":"Research data","type":"bar","query":{"name":"dtsrcProjData","parameters":["'+this.datasourceId+'"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Projects with most research data"},"subtitle":{},"yAxis":{"title":{"text":"Research data"}},"xAxis":{"title":{"text":"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": ["Research Outcomes"], "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": ["Research Outcomes"], "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": ["Research Outcomes"], "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": ["Research Data"], "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": ["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();
}
}}