Correction sur l'ajout de sauts sur 1 jour.

This commit is contained in:
Sébastien André
2021-06-29 18:10:47 +02:00
parent 28de998183
commit ba7a4fbdfb
5 changed files with 41 additions and 22 deletions

View File

@@ -11,10 +11,11 @@ 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());
currentDate.setTime(currentTime + totalMilliSeconds);
tmpDate.setTime(currentTime + totalMilliSeconds);
return currentDate;
return tmpDate;
}
public DiffBetweenDates(beginDate: Date, endDate: Date): number {

View File

@@ -1,7 +1,7 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { DatePipe } from '@angular/common';
import { Observable } from "rxjs";
import { forkJoin, Observable, of } from "rxjs";
import { map } from "rxjs/operators";
import { JumpResp, JumpReq, Jump } from "../models/jump";
@@ -19,6 +19,8 @@ import { GearService } from "./gear.service";
@Injectable()
export class JumpService extends BaseService {
private callsToAdd : Array<Observable<any>>;
constructor(private http: HttpClient,
private dateService: DateService,
private datePipe: DatePipe,
@@ -48,8 +50,9 @@ export class JumpService extends BaseService {
defaultDeployAltitude: number,
countOfJumps: number,
notes: string,
isSpecial: boolean)
isSpecial: boolean): Observable<any[]>
{
this.callsToAdd = new Array<Observable<any>>();
const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1;
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
@@ -82,6 +85,8 @@ export class JumpService extends BaseService {
restfJumps,
notes,
isSpecial);
return forkJoin(this.callsToAdd);
}
public DeleteJump(item: Jump) {
@@ -134,10 +139,14 @@ export class JumpService extends BaseService {
isSpecial: isSpecial
};
this.http.post(`${this.apiUrl}/Jump`,
bodyNewjump,
{ headers: this.headers, })
.subscribe();
// let call = this.http.post(`${this.apiUrl}/Jump`,
// bodyNewjump,
// { headers: this.headers });
let call = of("2");
console.warn("Jump : " + i);
this.callsToAdd.push(call);
}
}