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

    
7
@Component({
8
    selector: 'statisticsTab',
9
    template: `
10
      <errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status]" [type]="'statistics'" tab_error_class=true></errorMessages>
11

    
12
      <ng-container *ngIf="(fetchPublications.searchUtils.status == errorCodes.DONE || fetchDatasets.searchUtils.status == errorCodes.DONE)">
13
        <div class="uk-padding uk-padding-remove-top">
14
          <span class="uk-text-bold uk-text-small">Research Results Timeline</span>
15
          <i-frame  [url]=docsTimelineUrl ></i-frame>
16
        </div>
17
        <div class="uk-padding uk-padding-remove-top">
18
          <span class="uk-text-bold uk-text-small">Research Results Types</span>
19
          <i-frame [url]=docsTypesUrl ></i-frame>
20
        </div>
21
      </ng-container>
22

    
23
      <div *ngIf="fetchPublications.searchUtils.totalResults > 0 || (fetchDatasets.searchUtils.totalResults > 0)"
24
            class="uk-padding uk-padding-remove-top">
25
        <span class="uk-text-bold uk-text-small">Funders in Research Results of content provider</span>
26
        <i-frame  [url]=docsFunderUrl ></i-frame>
27
      </div>
28

    
29
      <div *ngIf="fetchPublications.searchUtils.totalResults > 0 "
30
            class="uk-padding uk-padding-remove-top">
31
        <span class="uk-text-bold uk-text-small">Projects with most Publications</span>
32
        <i-frame [url]=pubsProjectsUrl ></i-frame>
33
      </div>
34

    
35
      <div *ngIf="(fetchDatasets.searchUtils.totalResults > 0)"
36
            class="uk-padding uk-padding-remove-top">
37
        <span class="uk-text-bold uk-text-small">Projects with most Research Data</span>
38
        <i-frame  [url]=dataProjectsUrl></i-frame>
39
      </div>
40
    `
41
})
42

    
43
export class StatisticsTabComponent {
44
    @Input() datasourceId;
45
    @Input() fetchPublications : FetchResearchResults;
46
    @Input() fetchDatasets : FetchResearchResults;
47

    
48
    private docsTimelineUrl: string;
49
    private docsTypesUrl:string;
50
    private docsFunderUrl:string;
51
    private dataProjectsUrl:string ;
52
    private pubsProjectsUrl:string;
53
    public  errorCodes:ErrorCodes = new ErrorCodes();
54

    
55
    constructor (private route: ActivatedRoute) {}
56

    
57
    ngOnInit() {
58
      this.route.data
59
        .subscribe((data: { envSpecific: EnvProperties }) => {
60
          var properties = data.envSpecific;
61

    
62
          this.docsTimelineUrl =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":30, "sort": "xaxis", "xStyle":{"r": -30, "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research 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%';
63
          this.docsTypesUrl = 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 Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
64
          this.docsFunderUrl =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 Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%';
65
          this.dataProjectsUrl =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%';
66
          this.pubsProjectsUrl =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%';
67
      });
68
    }
69

    
70
    ngOnDestroy() {}
71
}
(13-13/13)