monitor/src/app/utils/services/statistics.service.ts

33 lines
1.4 KiB
TypeScript

import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {EnvironmentSpecificService} from "../../openaireLibrary/utils/properties/environment-specific.service";
import {Observable} from "rxjs";
@Injectable()
export class StatisticsService {
numberSources: Map<string, string> = new Map<string, string>();
chartSources: Map<string, string> = new Map<string, string>();
constructor(private http:HttpClient, private environmentSpecificService: EnvironmentSpecificService) {
this.environmentSpecificService.subscribeEnvironment().subscribe(properties => {
this.numberSources.set('statistics', properties.statisticsAPIURL);
this.numberSources.set('search', properties.searchAPIURLLAst);
this.numberSources.set('metrics', properties.metricsAPIURL);
this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL);
this.chartSources.set('old', properties.statisticsFrameAPIURL);
this.chartSources.set('metrics', properties.metricsAPIURL);
this.chartSources.set('fake', '');
})
}
getNumbers(source: string, url: string): Observable<any> {
return this.http.get<any>(this.numberSources.get(source) + url);
}
getChartUrl(source: string, url: string): string {
return this.chartSources.get(source) + url;
}
}