La page des stats avance, on a maintenant
des infos
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
import {
|
||||
StatsResp,
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByRigResp,
|
||||
StatsByGearResp,
|
||||
StatsByYearResp
|
||||
} from '../models/stats';
|
||||
|
||||
@@ -20,28 +22,79 @@ export class StatsService {
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultat = new StatsResp();
|
||||
resultat.statsByDz = this.http.get<StatsByDzResp>(
|
||||
const resultats = new StatsResp();
|
||||
|
||||
resultats.statsByDz = this.getStatsByDz();
|
||||
resultats.statsByAircraft = this.getStatsByAircraft();
|
||||
resultats.statsByJumpType = this.getStatsByJumpType();
|
||||
resultats.statsByGear = this.getStatsByGear();
|
||||
resultats.statsByYear = this.getStatsByYear();
|
||||
|
||||
return resultats;
|
||||
}
|
||||
|
||||
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||
return this.http.get<Array<StatsByDzResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByDz`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>(
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByDzResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
||||
return this.http.get<Array<StatsByAircraftResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByAircraft`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>(
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByAircraftResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
||||
return this.http.get<Array<StatsByJumpTypeResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByJumpType`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByRig = this.http.get<StatsByRigResp>(
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
||||
return this.http.get<Array<StatsByGearResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByGear`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByYear = this.http.get<StatsByYearResp>(
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByGearResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
||||
return this.http.get<Array<StatsByYearResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByYear`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
|
||||
return resultat;
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByYearResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user