48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
import { environment } from '../environments/environment';
|
|
import {
|
|
StatsResp,
|
|
StatsByDzResp,
|
|
StatsByAircraftResp,
|
|
StatsByJumpTypeResp,
|
|
StatsByRigResp,
|
|
StatsByYearResp
|
|
} from '../models/stats';
|
|
|
|
@Injectable()
|
|
export class StatsService {
|
|
|
|
private readonly headers = new HttpHeaders({
|
|
'Access-Control-Allow-Origin': environment.urlApi
|
|
});
|
|
|
|
constructor(private http: HttpClient) { }
|
|
|
|
public getStatsOfJumps(): StatsResp {
|
|
const resultat = new StatsResp();
|
|
resultat.statsByDz = this.http.get<StatsByDzResp>(
|
|
`${environment.urlApi}/api/Stats/ByDz`,
|
|
{ headers: this.headers }
|
|
);
|
|
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>(
|
|
`${environment.urlApi}/api/Stats/ByAircraft`,
|
|
{ headers: this.headers }
|
|
);
|
|
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>(
|
|
`${environment.urlApi}/api/Stats/ByJumpType`,
|
|
{ headers: this.headers }
|
|
);
|
|
resultat.statsByRig = this.http.get<StatsByRigResp>(
|
|
`${environment.urlApi}/api/Stats/ByRig`,
|
|
{ headers: this.headers }
|
|
);
|
|
resultat.statsByYear = this.http.get<StatsByYearResp>(
|
|
`${environment.urlApi}/api/Stats/ByYear`,
|
|
{ headers: this.headers }
|
|
);
|
|
|
|
return resultat;
|
|
}
|
|
}
|