Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {HttpClient} from "@angular/common/http";
3
import {EnvironmentSpecificService} from "../../openaireLibrary/utils/properties/environment-specific.service";
4
import {Observable} from "rxjs";
5

    
6

    
7
@Injectable()
8
export class StatisticsService {
9

    
10
    numberSources: Map<string, string> = new Map<string, string>();
11
    chartSources: Map<string, string> = new Map<string, string>();
12

    
13
    constructor(private http:HttpClient, private environmentSpecificService: EnvironmentSpecificService) {
14
        this.environmentSpecificService.subscribeEnvironment().subscribe(properties => {
15
            this.numberSources.set('statistics', properties.statisticsAPIURL);
16
            this.numberSources.set('search', properties.searchAPIURLLAst);
17
            this.numberSources.set('metrics', properties.metricsAPIURL);
18
            this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL);
19
            this.chartSources.set('old', properties.statisticsFrameAPIURL);
20
            this.chartSources.set('metrics', properties.metricsAPIURL);
21
            this.chartSources.set('fake', '');
22
        })
23
    }
24

    
25
    getNumbers(source: string, url: string): Observable<any> {
26
        return this.http.get<any>(this.numberSources.get(source) + url);
27
    }
28

    
29
    getChartUrl(source: string, url: string): string {
30
        return this.chartSources.get(source) + url;
31
    }
32
}
    (1-1/1)