Découpage en 1 service par composant
This commit is contained in:
47
Front/skydivelogs-app/src/services/stats.service.ts
Normal file
47
Front/skydivelogs-app/src/services/stats.service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user