Retrieve the tunnel flights
Show the list of tunnel flights
This commit is contained in:
@@ -9,11 +9,21 @@ export class DateService {
|
||||
}
|
||||
|
||||
public addDays(currentDate: Date, nbDays: number): Date {
|
||||
const totalMilliSeconds = nbDays * this.milliSeconInDay;
|
||||
const currentTime = currentDate.getTime();
|
||||
const tmpDate = new Date(currentDate.getTime());
|
||||
tmpDate.setDate(tmpDate.getDate() + nbDays);
|
||||
|
||||
tmpDate.setTime(currentTime + totalMilliSeconds);
|
||||
// const totalMilliSeconds = nbDays * this.milliSeconInDay;
|
||||
// const currentTime = currentDate.getTime();
|
||||
// const tmpDate = new Date(currentDate.getTime());
|
||||
|
||||
// tmpDate.setTime(currentTime + totalMilliSeconds);
|
||||
|
||||
return tmpDate;
|
||||
}
|
||||
|
||||
public addMonths(currentDate: Date, nbMonths: number): Date {
|
||||
const tmpDate = new Date(currentDate.getTime());
|
||||
tmpDate.setMonth(tmpDate.getMonth() + nbMonths);
|
||||
|
||||
return tmpDate;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ export class JumpService extends BaseService {
|
||||
private callsToAdd: Array<Observable<any>>;
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private dateService: DateService,
|
||||
private datePipe: DatePipe,
|
||||
private dropzoneService: DropzoneService,
|
||||
private aircraftService: AircraftService,
|
||||
private jumpTypeService: JumpTypeService,
|
||||
private gearService: GearService) {
|
||||
private dateService: DateService,
|
||||
private datePipe: DatePipe,
|
||||
private dropzoneService: DropzoneService,
|
||||
private aircraftService: AircraftService,
|
||||
private jumpTypeService: JumpTypeService,
|
||||
private gearService: GearService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class JumpService extends BaseService {
|
||||
|
||||
public getJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
|
||||
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, { headers: this.headers })
|
||||
.pipe(map((response) => {
|
||||
.pipe(map(response => {
|
||||
let result: JumpList = {
|
||||
rows: this.mapWithDataInCache(response.rows),
|
||||
count: response.count
|
||||
|
||||
@@ -5,12 +5,16 @@ import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { TunnelFlightReq, TunnelFlightResp, TunnelFlight } from "../models/tunnel-flight";
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
|
||||
import { BaseService } from "./base.service";
|
||||
import { DropzoneService } from "./dropzone.service";
|
||||
|
||||
@Injectable()
|
||||
export class TunnelFlightService extends BaseService {
|
||||
constructor(private http: HttpClient, private datePipe: DatePipe) {
|
||||
constructor(private http: HttpClient,
|
||||
private datePipe: DatePipe,
|
||||
private dropzoneService: DropzoneService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -31,15 +35,25 @@ export class TunnelFlightService extends BaseService {
|
||||
}
|
||||
|
||||
public getTunnelFlights(begin: Date, end: Date): Observable<Array<TunnelFlight>> {
|
||||
let beginDate = this.datePipe.transform(begin, "yyyyMMdd");
|
||||
let endDate = this.datePipe.transform(end, "yyyyMMdd");
|
||||
let beginDate = this.datePipe.transform(begin, "yyyy-MM-dd");
|
||||
let endDate = this.datePipe.transform(end, "yyyy-MM-dd");
|
||||
|
||||
return this.http.get<Array<TunnelFlightResp>>(`${this.apiUrl}/TunnelFlight/${beginDate}/${endDate}`, { headers: this.headers })
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new TunnelFlightResp(data));
|
||||
return stats;
|
||||
.pipe(map(response => {
|
||||
return this.mapWithDataInCache(response);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private mapWithDataInCache(apiResp: Array<TunnelFlightResp>): Array<TunnelFlight> {
|
||||
let allDropzones: Array<DropZoneResp>;
|
||||
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
|
||||
|
||||
return apiResp.map((data) => {
|
||||
let tmp = new TunnelFlight(data);
|
||||
tmp.tunnel = allDropzones.find(d => d.id == data.tunnelId);
|
||||
|
||||
return tmp;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user