Project

General

Profile

« Previous | Next » 

Revision 57363

[Monitor]: Add indicators.

View differences:

modules/uoa-monitor-portal/trunk/monitor/src/app/utils/entities/stakeholder.ts
49 49
  tags:string[];
50 50
  isActive: boolean;
51 51
  isPublic: boolean;
52
  urls:IndicatorPath[];
52
  indicatorPaths:IndicatorPath[];
53 53
}
54 54

  
55 55
export class IndicatorPath {
modules/uoa-monitor-portal/trunk/monitor/src/app/services/stakeholder.service.ts
1 1
import {Injectable} from "@angular/core";
2 2
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
3 3
import {Observable} from "rxjs";
4
import {Stakeholder} from "../utils/entities/stakeholder";
4
import {Indicator, Stakeholder} from "../utils/entities/stakeholder";
5 5
import {map} from "rxjs/operators";
6
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
7
import {response} from "express";
6 8

  
7 9
@Injectable()
8 10
export class StakeholderService {
......
26 28
      }
27 29
    }));
28 30
  }
31

  
32
  getIndicator(id: string): Observable<Indicator> {
33
    return this.http.get<any>('./assets/stakeholders.json').pipe(map(json => {
34
      return json.indicators.filter(indicator => indicator.id === id)[0];
35
    }))
36
  }
37

  
38
  getIndicators(ids: string[]): Observable<Indicator[]> {
39
    return this.http.get<any>('./assets/stakeholders.json').pipe(map(json => {
40
      return json.indicators.filter(indicator => ids.indexOf(indicator.id) !== -1);
41
    }))
42
  }
43

  
44
  getNumber(properties: EnvProperties, url: string, jsonPath: string[], stakeholder: Stakeholder): Observable<any> {
45
    const statsUrl = url.replace('{index_shortName}', stakeholder.index_shortName).
46
                   replace('{index_id}', stakeholder.index_id).
47
                   replace('{index_name}', stakeholder.index_name);
48
    return this.http.get<any>(properties.statisticsAPIURL + statsUrl).pipe(map(response => {
49
      jsonPath.forEach(field => {
50
        response = response[field];
51
      });
52
      return response;
53
    }));
54
  }
29 55
}
modules/uoa-monitor-portal/trunk/monitor/src/app/monitor/monitor.component.html
31 31
  </div>
32 32
  <div uk-grid>
33 33
    <sidebar [menuItems]="sideMenuItems" class="uk-width-1-5 sidebar"></sidebar>
34
    <div class="uk-width-expand uk-padding">
35
      <h5 class="uk-margin-bottom">Indicators</h5>
36
    </div>
34 37
  </div>
35 38
</div>
modules/uoa-monitor-portal/trunk/monitor/src/app/monitor/monitor.component.ts
11 11
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
12 12
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
13 13
import {StakeholderService} from "../services/stakeholder.service";
14
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
14
import {Category, Indicator, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
15 15
import {MenuItem, RootMenuItem, SideMenuItem} from "../openaireLibrary/sharedComponents/menu";
16 16

  
17 17
@Component({
......
30 30
  public sideMenuItems: SideMenuItem[] = null;
31 31
  public errorCodes: ErrorCodes;
32 32
  public stakeholder: Stakeholder;
33
  public numbers: Indicator[] = [];
34
  public charts: Indicator[] = [];
33 35
  private errorMessages: ErrorMessagesComponent;
34 36
  properties: EnvProperties;
35 37

  
......
115 117
          }
116 118
          if(this.activeSubCategory) {
117 119
            this.setSideBar();
120
            this.setIndicators();
118 121
            return;
119 122
          }
120 123
        }
......
152 155
    });
153 156
  }
154 157

  
158
  private setIndicators() {
159
    this.stakeholderService.getIndicators(this.activeSubCategory.numbers).subscribe( numbers => {
160
      this.numbers = numbers;
161
    });
162
    this.stakeholderService.getIndicators(this.activeSubCategory.charts).subscribe( charts => {
163
      this.charts = charts;
164
    });
165
  }
166

  
155 167
  public navigateToError() {
156 168
    this._router.navigate(['/error'],{queryParams: {'page': this._router.url}});
157 169
  }
modules/uoa-monitor-portal/trunk/monitor/src/assets/stakeholders.json
235 235
      "indicatorPaths": [
236 236
        {
237 237
          "type": "",
238
          "url": "/stats-api/funders/{index_shortname}",
238
          "url": "/funders/{index_shortName}",
239 239
          "jsonPath": [
240 240
            "statistics",
241 241
            "publications"
......
256 256
      "indicatorPaths": [
257 257
        {
258 258
          "type": "",
259
          "url": "/stats-api/funders/{index_shortname}",
259
          "url": "/funders/{index_shortName}",
260 260
          "jsonPath": [
261 261
            "statistics",
262 262
            "open"
......
277 277
      "indicatorPaths": [
278 278
        {
279 279
          "type": "",
280
          "url": "/stats-api/funders/{index_shortname}",
280
          "url": "/funders/{index_shortName}",
281 281
          "jsonPath": [
282 282
            "statistics",
283 283
            "embargo"
......
303 303
        },
304 304
        {
305 305
          "type": "table",
306
          "url": "https://www.openaire.eu/stats/gtable.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22pie%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_projects-project-title%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2230%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funder%22,%22values%22:[%22{index_name}%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22}],%22having%22:[],%22xStyle%22:{%22r%22:-90,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:10,%22wt%22:%22-%22},%22title%22:%22{index_shortname}%20Publications%20by%20project%20(top%2030)%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22project%22,%22order%22:%22d%22}",
306
          "url": "https://www.openaire.eu/stats/gtable.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22pie%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_projects-project-title%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2230%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funder%22,%22values%22:[%22{index_name}%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22}],%22having%22:[],%22xStyle%22:{%22r%22:-90,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:10,%22wt%22:%22-%22},%22title%22:%22{index_shortName}%20Publications%20by%20project%20(top%2030)%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22project%22,%22order%22:%22d%22}",
307 307
          "jsonPath": []
308 308
        }
309 309
      ]

Also available in: Unified diff