This commit is contained in:
Sébastien André
2020-08-25 16:25:24 +02:00
parent 4ee2dc98ae
commit 25cfc62005
2 changed files with 36 additions and 23 deletions

View File

@@ -12,8 +12,6 @@ import { JumpTypeService } from "../../services/jump-type.service";
import { GearService } from "../../services/gear.service";
import { isNumber } from "util";
import { FormControl } from "@angular/forms";
@Component({
selector: "app-new-jump",
templateUrl: "./new-jump.component.html",
@@ -54,7 +52,7 @@ export class NewJumpComponent implements OnInit {
this.beginDate = this.dateService.AddDays(new Date(), -1);
this.exitAltitude = 4000;
this.deployAltitude = 1500;
this.deployAltitude = 1000;
this.countOfJumps = 1;
this.getListOfJumpTypes();
@@ -73,6 +71,8 @@ export class NewJumpComponent implements OnInit {
this.deployAltitude,
this.countOfJumps
);
this.initForm();
}
public isValidatedForm(): boolean {
@@ -128,6 +128,20 @@ export class NewJumpComponent implements OnInit {
});
}
private initForm() {
this.endDate = new Date();
this.beginDate = this.dateService.AddDays(new Date(), -1);
this.exitAltitude = 4000;
this.deployAltitude = 1000;
this.countOfJumps = 1;
this.selectedDz = undefined;
this.selectedGear = undefined;
this.selectedAircraft = undefined;
this.selectedJumpType = undefined;
}
public displayFn(data?: JumpTypeResp): string | undefined {
return data ? data.name : undefined;
}

View File

@@ -1,13 +1,12 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { JumpResp, JumpReq } from '../models/jump';
import { DateService } from './date.service';
import { BaseService } from './base.service';
import { JumpResp, JumpReq } from "../models/jump";
import { DateService } from "./date.service";
import { BaseService } from "./base.service";
@Injectable()
export class JumpService extends BaseService {
@@ -16,12 +15,13 @@ export class JumpService extends BaseService {
}
public getListOfJumps(): Observable<Array<JumpResp>> {
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, {
headers: this.headers
})
return this.http
.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, {
headers: this.headers,
})
.pipe(
map(response => {
const details = response.map(data => new JumpResp(data));
map((response) => {
const details = response.map((data) => new JumpResp(data));
return details;
})
);
@@ -60,6 +60,7 @@ export class JumpService extends BaseService {
}
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
this.AddJumps(
selectedJumpType,
selectedAircraft,
@@ -93,16 +94,14 @@ export class JumpService extends BaseService {
exitAltitude: defaultExitAltitude,
deployAltitude: defaultDeployAltitude,
gearId: selectedRig,
notes: '',
notes: "",
id: 0,
jumpDate: jumpDate
jumpDate: jumpDate,
};
this.http
.post(`${this.apiUrl}/Jump`, bodyNewjump, {
headers: this.headers
})
.subscribe(data => console.log(data));
this.http.post(`${this.apiUrl}/Jump`, bodyNewjump, {
headers: this.headers,
});
}
}
}