Project

General

Profile

1
import {Component, Input}  from '@angular/core';
2
import {ActivatedRoute}    from '@angular/router';
3
import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
4
import {ErrorCodes}        from '../../utils/properties/errorCodes';
5
import {EnvProperties}     from '../../utils/properties/env-properties';
6
import {StringUtils} from "../../utils/string-utils.class";
7
import {Subscriber} from "rxjs";
8

    
9
@Component({
10
    selector: 'statisticsTab',
11
    template: `
12
      <errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status,
13
                                fetchSoftware.searchUtils.status, fetchOther.searchUtils.status]" 
14
                     [type]="'statistics'" tab_error_class=true></errorMessages>
15

    
16
<!--      <ng-container *ngIf="(fetchPublications.searchUtils.status == errorCodes.DONE -->
17
<!--                            || fetchDatasets.searchUtils.status == errorCodes.DONE-->
18
<!--                            || fetchSoftware.searchUtils.status == errorCodes.DONE-->
19
<!--                            || fetchOther.searchUtils.status == errorCodes.DONE)">-->
20
      <div *ngIf="fetchPublications.searchUtils.totalResults > 0 || (fetchDatasets.searchUtils.totalResults > 0 || 
21
                            fetchSoftware.searchUtils.totalResults > 0 || fetchOther.searchUtils.totalResults > 0)"
22
            class="uk-grid uk-child-width-1-1 uk-child-width-1-2@m">
23
        <div class="uk-padding uk-padding-remove-top">
24
          <div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Produced research outcomes per year</div>
25
          <i-frame  [url]=docsTimelineUrl ></i-frame>
26
        </div>
27
        <div class="uk-padding uk-padding-remove-top">
28
          <div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Research outcomes Types</div>
29
          <i-frame [url]=docsTypesUrl ></i-frame>
30
        </div>
31
<!--      </ng-container>-->
32

    
33
<!--      <div *ngIf="fetchPublications.searchUtils.totalResults > 0 || (fetchDatasets.searchUtils.totalResults > 0-->
34
<!--                  || fetchSoftware.searchUtils.totalResults > 0 || fetchOther.searchUtils.totalResults > 0)"-->
35
        <div
36
              class="uk-padding uk-padding-remove-top">
37
          <div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Research outcomes per funder</div>
38
          <i-frame  [url]=docsFunderUrl ></i-frame>
39
        </div>
40

    
41
      <div *ngIf="fetchPublications.searchUtils.totalResults > 0 "
42
            class="uk-padding uk-padding-remove-top">
43
        <div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Projects with most Publications</div>
44
        <i-frame [url]=pubsProjectsUrl ></i-frame>
45
      </div>
46

    
47
      <div *ngIf="(fetchDatasets.searchUtils.totalResults > 0)"
48
            class="uk-padding uk-padding-remove-top">
49
        <div *ngIf=" properties && !properties.useNewStatistisTool" class="uk-text-center uk-text-large">Projects with most Research Data</div>
50
        <i-frame  [url]=dataProjectsUrl></i-frame>
51
      </div>
52
      </div>
53

    
54
    `
55
})
56

    
57
export class StatisticsTabComponent {
58
    @Input() datasourceId;
59
    @Input() fetchPublications : FetchResearchResults;
60
    @Input() fetchDatasets : FetchResearchResults;
61
    @Input() fetchSoftware: FetchResearchResults;
62
    @Input() fetchOther: FetchResearchResults;
63

    
64
    private docsTimelineUrl: string;
65
    private docsTypesUrl:string;
66
    private docsFunderUrl:string;
67
    private dataProjectsUrl:string ;
68
    private pubsProjectsUrl:string;
69
    public  errorCodes:ErrorCodes = new ErrorCodes();
70
    properties:EnvProperties;
71
    sub;
72
    constructor (private route: ActivatedRoute) {}
73

    
74
    ngOnInit() {
75
      this.sub = this.route.data
76
        .subscribe((data: { envSpecific: EnvProperties }) => {
77
          this.properties = data.envSpecific;
78

    
79
          if (this.properties.useNewStatistisTool) {
80
            this.docsTimelineUrl = this.properties.statisticsFrameNewAPIURL +
81
              '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"}}}');
82
            this.docsTypesUrl = this.properties.statisticsFrameNewAPIURL +
83
              '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"}}}');
84
            this.docsFunderUrl = this.properties.statisticsFrameNewAPIURL +
85
              '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"}}}');
86
            this.pubsProjectsUrl = this.properties.statisticsFrameNewAPIURL +
87
              '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"}}}');
88
            this.dataProjectsUrl = this.properties.statisticsFrameNewAPIURL +
89
              '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"}}}');
90
          } else {
91
            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%';
92
            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%';
93
            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%';
94
            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%';
95
            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%';
96
          }
97
      });
98
    }
99

    
100
  ngOnDestroy() {
101
    if (this.sub instanceof Subscriber) {
102
      this.sub.unsubscribe();
103
    }
104
  }}
(13-13/13)