Update on the tunnel flight

This commit is contained in:
Sébastien ANDRE
2023-08-16 17:39:24 +02:00
parent dc06f256b4
commit fe7ffa9016
6 changed files with 108 additions and 45 deletions

View File

@@ -4,7 +4,7 @@ import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { TunnelFlightReq, TunnelFlightResp, TunnelFlight } from "../models/tunnel-flight";
import { TunnelFlightReq, TunnelFlightResp, TunnelFlight, TunnelFlightByMonthResp, TunnelFlightByMonth } from "../models/tunnel-flight";
import { DropZoneResp } from '../models/dropzone';
import { BaseService } from "./base.service";
@@ -45,6 +45,19 @@ export class TunnelFlightService extends BaseService {
);
}
public getTunnelFlightsByMonth(begin: Date, end: Date): Observable<Array<TunnelFlightByMonth>> {
let beginDate = this.datePipe.transform(begin, "yyyy-MM-dd");
let endDate = this.datePipe.transform(end, "yyyy-MM-dd");
return this.http.get<Array<TunnelFlightByMonthResp>>(`${this.apiUrl}/TunnelFlight/month/${beginDate}/${endDate}`, { headers: this.headers })
.pipe(
map(response => {
const stats = response.map(data => new TunnelFlightByMonth(data));
return stats;
})
);
}
private mapWithDataInCache(apiResp: Array<TunnelFlightResp>): Array<TunnelFlight> {
let allDropzones: Array<DropZoneResp>;
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });