Revision 57363
Added by Konstantinos Triantafyllou over 4 years ago
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 |
} |
Also available in: Unified diff
[Monitor]: Add indicators.