diff --git a/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.html b/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.html index 4def8d6..2f1f54d 100644 --- a/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.html +++ b/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.html @@ -1,3 +1,11 @@ -

Gear : {{data.gear.name}} ({{data.gear.mainCanopy}})

-

Cutaway :

-

Notes : {{data.notes}}

\ No newline at end of file +
+

Gear : {{jump.gear.name}} ({{jump.gear.mainCanopy}})

+

Special jump

+

Cutaway

+ + + + +
+ +
\ No newline at end of file diff --git a/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.ts b/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.ts index b9f76be..eaf516d 100644 --- a/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.ts +++ b/Front/skydivelogs-app/src/app/jump-infos/jump-infos.component.ts @@ -1,7 +1,10 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { AddAction } from '../../models/add-action.enum'; import { JumpResp } from '../../models/jump'; +import { JumpService } from '../../services/jump.service'; +import { ServiceComm } from '../../services/service-comm.service'; @Component({ selector: 'app-jump-infos', @@ -9,10 +12,25 @@ import { JumpResp } from '../../models/jump'; styleUrls: ['./jump-infos.component.css'] }) export class JumpInfosComponent implements OnInit { + public editMode: boolean; + public jump: JumpResp - constructor(@Inject(MAT_DIALOG_DATA) public data: JumpResp) {} - - ngOnInit(): void { + constructor(@Inject(MAT_DIALOG_DATA) public data: any, + private serviceJump: JumpService, + private serviceComm: ServiceComm) { + this.jump = new JumpResp(data.jump); + this.editMode = data.editMode; } + ngOnInit(): void {} + + public updateJump() { + this.serviceJump.UpdateJump(this.jump.id, + this.jump.isSpecial, + this.jump.withCutaway, + this.jump.notes) + .subscribe(() => { + this.serviceComm.RefreshData(AddAction.Jump); + }); + } } diff --git a/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.ts b/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.ts index 8f576cc..1040a1c 100644 --- a/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.ts +++ b/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.ts @@ -28,11 +28,9 @@ export class ListOfGearsComponent implements OnInit { public resultsLength = 0; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; - constructor( - private serviceApi: GearService, - private serviceComm: ServiceComm, - public dialog: MatDialog - ) {} + constructor(private serviceApi: GearService, + private serviceComm: ServiceComm, + public dialog: MatDialog) {} ngOnInit() { this.serviceComm.refreshRequest.subscribe(action => { diff --git a/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.html b/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.html index 1800f83..e0aee03 100644 --- a/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.html +++ b/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.html @@ -7,8 +7,9 @@ - info + celebration + info @@ -55,6 +56,8 @@ delete + edit diff --git a/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.ts b/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.ts index 9b9c1bb..395ae81 100644 --- a/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.ts +++ b/Front/skydivelogs-app/src/app/list-of-jumps/list-of-jumps.component.ts @@ -8,6 +8,7 @@ import { JumpResp } from '../../models/jump'; import { JumpService } from '../../services/jump.service'; import { ServiceComm } from '../../services/service-comm.service'; import { JumpInfosComponent } from "../jump-infos/jump-infos.component"; +import { AddAction } from '../../models/add-action.enum'; @Component({ selector: 'app-list-of-jumps', @@ -34,12 +35,18 @@ export class ListOfJumpsComponent implements OnInit { public dialog: MatDialog) { } ngOnInit() { + this.serviceComm.refreshRequest.subscribe(action => { + if (action === AddAction.Jump) { + this.dialog.closeAll(); + this.getListOfJumps(); + } + }); this.serviceComm.UpdatedComponentTitle('List of jumps'); this.getListOfJumps(); } getListOfJumps() { - this.listOfJumps = this.serviceApi.getListOfJumps(); + this.listOfJumps = this.serviceApi.GetListOfJumps(); this.listOfJumps.subscribe(data => { setTimeout(() => { data.sort((a, b) => b.jumpDate.getTime() - a.jumpDate.getTime()); @@ -50,10 +57,16 @@ export class ListOfJumpsComponent implements OnInit { }); } - openDialog(item: JumpResp) { - this.dialog.open(JumpInfosComponent, { - data: item - }); + openDialog(item: JumpResp, editMode: boolean) { + this.dialog.open(JumpInfosComponent, + { data: { "jump": item, "editMode": editMode}, + maxHeight: "400px", + minWidth: "350px" + }); + } + + toShow(item: JumpResp) { + return item.withCutaway === true || item.notes != undefined; } delete(item: JumpResp) { diff --git a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts index 6ccbe1e..452fcc3 100644 --- a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts +++ b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts @@ -13,10 +13,9 @@ import { AddAction } from "../../models/add-action.enum"; export class NewGearComponent implements OnInit { public addForm: FormGroup; - constructor( - private serviceComm: ServiceComm, - private serviceApi: GearService - ) { + constructor(private serviceComm: ServiceComm, + private serviceApi: GearService) + { this.addForm = new FormGroup( { name: new FormControl("", Validators.required), diff --git a/Front/skydivelogs-app/src/app/new-jump/new-jump.component.html b/Front/skydivelogs-app/src/app/new-jump/new-jump.component.html index 7f90c61..432b922 100644 --- a/Front/skydivelogs-app/src/app/new-jump/new-jump.component.html +++ b/Front/skydivelogs-app/src/app/new-jump/new-jump.component.html @@ -2,7 +2,7 @@
-

Reset form after adding :

+

Reset form after adding

@@ -66,6 +66,7 @@ With a cutaway ? + Is a special jump ? diff --git a/Front/skydivelogs-app/src/app/new-jump/new-jump.component.ts b/Front/skydivelogs-app/src/app/new-jump/new-jump.component.ts index aada49e..8dc8d37 100644 --- a/Front/skydivelogs-app/src/app/new-jump/new-jump.component.ts +++ b/Front/skydivelogs-app/src/app/new-jump/new-jump.component.ts @@ -27,6 +27,7 @@ export class NewJumpComponent implements OnInit { public selectedAircraft: AircraftResp; public selectedJumpType: JumpTypeResp; public withCutaway: boolean; + public isSpecial: boolean; public listOfJumpType: Array; public listOfAircraft: Array; public listOfFilteredDropZone: Array; @@ -67,7 +68,8 @@ export class NewJumpComponent implements OnInit { this.exitAltitude, this.deployAltitude, this.countOfJumps, - this.comments); + this.comments, + this.isSpecial === undefined ? false : this.isSpecial); setTimeout(() => { if (this.resetForm === true) { @@ -143,6 +145,9 @@ export class NewJumpComponent implements OnInit { this.listOfFilteredDropZone = this.listOfDropZone; this.comments = undefined; + + this.withCutaway = false; + this.isSpecial = false; } public displayFn(data?: JumpTypeResp): string | undefined { diff --git a/Front/skydivelogs-app/src/models/jump.ts b/Front/skydivelogs-app/src/models/jump.ts index e3079f3..b5fbfe0 100644 --- a/Front/skydivelogs-app/src/models/jump.ts +++ b/Front/skydivelogs-app/src/models/jump.ts @@ -17,7 +17,8 @@ export class JumpReq { public deployAltitude: number; public withCutaway: boolean; public notes: string; - public jumpDate: string; //Date; + public jumpDate: string; + public isSpecial: boolean; } export class JumpResp { @@ -36,4 +37,5 @@ export class JumpResp { public withCutaway: boolean; public notes: string; public jumpDate: Date; + public isSpecial: boolean; } diff --git a/Front/skydivelogs-app/src/services/gear.service.ts b/Front/skydivelogs-app/src/services/gear.service.ts index c78848b..d4db769 100644 --- a/Front/skydivelogs-app/src/services/gear.service.ts +++ b/Front/skydivelogs-app/src/services/gear.service.ts @@ -24,7 +24,8 @@ export class GearService extends BaseService { maxSize: number, aad: string, mainCanopy: string, - reserveCanopy: string) { + reserveCanopy: string) + { const bodyNewGear: GearReq = { id: 0, name: name, diff --git a/Front/skydivelogs-app/src/services/jump.service.ts b/Front/skydivelogs-app/src/services/jump.service.ts index 2ec562f..c2ae918 100644 --- a/Front/skydivelogs-app/src/services/jump.service.ts +++ b/Front/skydivelogs-app/src/services/jump.service.ts @@ -17,17 +17,15 @@ export class JumpService extends BaseService { super(); } - public getListOfJumps(): Observable> { - return this.http - .get>(`${this.apiUrl}/Jump`, { - headers: this.headers, - }) - .pipe( - map((response) => { - const details = response.map((data) => new JumpResp(data)); - return details; - }) - ); + public GetListOfJumps(): Observable> { + return this.http.get>(`${this.apiUrl}/Jump`, + { headers: this.headers }) + .pipe( + map((response) => { + const details = response.map((data) => new JumpResp(data)); + return details; + }) + ); } public AddListOfJump(selectedJumpType: number, @@ -40,7 +38,8 @@ export class JumpService extends BaseService { defaultExitAltitude: number, defaultDeployAltitude: number, countOfJumps: number, - notes: string) + notes: string, + isSpecial: boolean) { const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1; const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays); @@ -55,7 +54,8 @@ export class JumpService extends BaseService { defaultExitAltitude, defaultDeployAltitude, countOfJumpsPerDay, - notes); + notes, + isSpecial); beginDate = this.dateService.AddDays(beginDate, 1); } @@ -71,7 +71,8 @@ export class JumpService extends BaseService { defaultExitAltitude, defaultDeployAltitude, restfJumps, - notes); + notes, + isSpecial); } public DeleteJump(item: JumpResp) { @@ -80,6 +81,23 @@ export class JumpService extends BaseService { .subscribe((data) => console.log(data)); } + public UpdateJump(id: number, + isSpecial: boolean, + withCutaway: boolean, + notes: string) { + const jumpData = { + id: id, + isSpecial: isSpecial, + withCutaway: withCutaway, + notes: notes + }; + const bodyUpdatedJump = new JumpReq(jumpData); + + return this.http.put(`${this.apiUrl}/Jump/${id}`, + bodyUpdatedJump, + { headers: this.headers, }); + } + private AddJumps(selectedJumpType: number, selectedAircraft: number, selectedDz: number, @@ -89,7 +107,8 @@ export class JumpService extends BaseService { defaultExitAltitude: number, defaultDeployAltitude: number, countOfJumps: number, - notes: string) + notes: string, + isSpecial: boolean) { for (let i = 0; i < countOfJumps; i++) { const bodyNewjump: JumpReq = { @@ -102,7 +121,8 @@ export class JumpService extends BaseService { gearId: selectedRig, notes: notes, id: 0, - jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd") + jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd"), + isSpecial: isSpecial }; this.http.post(`${this.apiUrl}/Jump`,