Evol de la page Summary avec
les stats pour la saison en cours
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
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 { 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,
|
||||
@@ -12,16 +12,15 @@ import {
|
||||
StatsByYearResp,
|
||||
StatsForLastMonthResp,
|
||||
StatsForLastYearResp
|
||||
} from '../models/stats';
|
||||
} from "../models/stats";
|
||||
|
||||
@Injectable()
|
||||
export class StatsService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
"Access-Control-Allow-Origin": environment.urlApi
|
||||
});
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultats = new StatsResp();
|
||||
@@ -39,10 +38,10 @@ export class StatsService {
|
||||
}
|
||||
|
||||
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||
return this.http.get<Array<StatsByDzResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByDz`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<Array<StatsByDzResp>>(`${environment.urlApi}/api/Stats/ByDz`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByDzResp(data));
|
||||
@@ -52,10 +51,11 @@ export class StatsService {
|
||||
}
|
||||
|
||||
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
||||
return this.http.get<Array<StatsByAircraftResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByAircraft`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<Array<StatsByAircraftResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByAircraft`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByAircraftResp(data));
|
||||
@@ -65,10 +65,11 @@ export class StatsService {
|
||||
}
|
||||
|
||||
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
||||
return this.http.get<Array<StatsByJumpTypeResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByJumpType`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<Array<StatsByJumpTypeResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByJumpType`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
||||
@@ -78,10 +79,10 @@ export class StatsService {
|
||||
}
|
||||
|
||||
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
||||
return this.http.get<Array<StatsByGearResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByGear`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<Array<StatsByGearResp>>(`${environment.urlApi}/api/Stats/ByGear`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByGearResp(data));
|
||||
@@ -91,10 +92,10 @@ export class StatsService {
|
||||
}
|
||||
|
||||
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
||||
return this.http.get<Array<StatsByYearResp>>(
|
||||
`${environment.urlApi}/api/Stats/ByYear`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<Array<StatsByYearResp>>(`${environment.urlApi}/api/Stats/ByYear`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByYearResp(data));
|
||||
@@ -103,31 +104,39 @@ export class StatsService {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private getStatsOfLastYear(): Observable<StatsForLastYearResp> {
|
||||
return this.http.get<StatsForLastYearResp>(
|
||||
`${environment.urlApi}/api/Stats/ForLastYear`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<StatsForLastYearResp>(
|
||||
`${environment.urlApi}/api/Stats/ForLastYear`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByDzResp(data));
|
||||
return stats;
|
||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||
const statsByJumpType = response.byJumpType.map(
|
||||
data => new StatsByDzResp(data)
|
||||
);
|
||||
|
||||
return new StatsForLastYearResp(statsByDz, statsByJumpType);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
|
||||
return this.http.get<StatsForLastYearResp>(
|
||||
`${environment.urlApi}/api/Stats/ForLastMonth`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
return this.http
|
||||
.get<StatsForLastYearResp>(
|
||||
`${environment.urlApi}/api/Stats/ForLastMonth`,
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByDzResp(data));
|
||||
return stats;
|
||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||
const statsByJumpType = response.byJumpType.map(
|
||||
data => new StatsByDzResp(data)
|
||||
);
|
||||
|
||||
return new StatsForLastMonthResp(statsByDz, statsByJumpType);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user