diff --git a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html index 61b6ea4..097e6c3 100644 --- a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html +++ b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html @@ -90,19 +90,6 @@ />

-

- - - -


@if (editMode) { diff --git a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts index 4ab72e0..bd03f1c 100644 --- a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts +++ b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts @@ -54,7 +54,6 @@ export class GearInfosComponent implements OnInit { this.gear.aad, this.gear.mainCanopy, this.gear.reserveCanopy, - this.gear.equipment, ) .subscribe(() => { this.serviceComm.refreshData(AddAction.Gear); 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 31ddc55..aaba7dd 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 @@ -28,7 +28,19 @@ type="text" > - +

+ + + +


@if (editMode) { 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 bf96de9..46d60fb 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 @@ -50,6 +50,7 @@ export class JumpInfosComponent implements OnInit { this.jump.isSpecial, this.jump.withCutaway, this.jump.notes, + this.jump.equipment, ) .subscribe(() => { this.serviceComm.refreshData(AddAction.Jump); diff --git a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html index 0bc63a9..f361f46 100644 --- a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html +++ b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html @@ -42,12 +42,6 @@

-

- - Equipment - - -

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 0e2e35a..abc8954 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 @@ -60,11 +60,6 @@ export class NewGearComponent implements OnInit { Validators.min(60), Validators.max(320), ]), - equipment: new FormControl("RAS", [ - Validators.required, - Validators.min(60), - Validators.max(320), - ]), }, { updateOn: "blur" }, ); @@ -90,7 +85,6 @@ export class NewGearComponent implements OnInit { formData.aad, formData.mainCanopy, formData.reserveCanopy, - formData.equipment, ) .subscribe(() => { this.serviceComm.refreshData(AddAction.Gear); 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 a11c20f..2c10206 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 @@ -137,8 +137,7 @@ > @for (gear of listOfGear; track gear) { - {{ gear.name }} ({{ gear.mainCanopy }} - - {{ gear.equipment }}) + {{ gear.name }} ({{ gear.mainCanopy }}) } @@ -153,6 +152,25 @@ } + + + @if (exitAltitude) { + + } + {{ "NewJump_Cutaway" | translate }} 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 3e91d6b..fe5dde8 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 @@ -96,6 +96,7 @@ export class NewJumpComponent implements OnInit { private pendingAddRequest: boolean; private listOfDropZone: Array; public maxDate: Date; + public equipment: string; constructor( private serviceComm: ServiceComm, @@ -142,10 +143,12 @@ export class NewJumpComponent implements OnInit { this.countOfJumps, this.comments, this.isSpecial === undefined ? false : this.isSpecial, + this.equipment, ) .subscribe(() => { this.statsService.resetStats(); this.comments = undefined; + this.equipment = undefined; this.withCutaway = false; this.isSpecial = false; @@ -233,6 +236,7 @@ export class NewJumpComponent implements OnInit { this.listOfFilteredDropZone = this.listOfDropZone; this.comments = undefined; + this.equipment = undefined; this.withCutaway = false; this.isSpecial = false; diff --git a/Front/skydivelogs-app/src/app/summary/summary.component.ts b/Front/skydivelogs-app/src/app/summary/summary.component.ts index 8e93329..0128c8f 100644 --- a/Front/skydivelogs-app/src/app/summary/summary.component.ts +++ b/Front/skydivelogs-app/src/app/summary/summary.component.ts @@ -99,6 +99,7 @@ export class SummaryComponent implements OnInit { } public refreshStats() { + this.serviceApi.resetStats(); this.serviceApi.deleteAllCache(); this.tabGroup.selectedIndex = 0; } diff --git a/Front/skydivelogs-app/src/assets/i18n/en.json b/Front/skydivelogs-app/src/assets/i18n/en.json index 4934e9e..dff883a 100644 --- a/Front/skydivelogs-app/src/assets/i18n/en.json +++ b/Front/skydivelogs-app/src/assets/i18n/en.json @@ -69,7 +69,6 @@ "ListGears_Header_Aad": "AAD system", "ListGears_Header_Main": "Main canopy", "ListGears_Header_Reserve": "Reserve canopy", - "ListGears_Header_Equipment": "Equipment", "ListJumpType_Add": "Add a jump type", "ListJumpType_Header_Id": "ID", @@ -121,6 +120,7 @@ "NewJump_Count": "Count of jumps", "NewJump_Comments": "Comments", "NewJump_Submit": "Submit", + "NewJump_Equipment": "Equipment", "NewTunnelFlight_ChooseTunnel": "Choose the tunnel", "NewTunnelFlight_Minutes": "Minutes of the flight", diff --git a/Front/skydivelogs-app/src/assets/i18n/fr.json b/Front/skydivelogs-app/src/assets/i18n/fr.json index 694fe1e..4591941 100644 --- a/Front/skydivelogs-app/src/assets/i18n/fr.json +++ b/Front/skydivelogs-app/src/assets/i18n/fr.json @@ -69,7 +69,6 @@ "ListGears_Header_Aad": "Système de sécurité", "ListGears_Header_Main": "Principale", "ListGears_Header_Reserve": "Réserve", - "ListGears_Header_Equipment": "Équipment", "ListJumpType_Add": "Ajouter un type de saut", "ListJumpType_Header_Id": "ID", @@ -121,6 +120,7 @@ "NewJump_Count": "Nombre de sauts", "NewJump_Comments": "Commentaires", "NewJump_Submit": "Ajouter", + "NewJump_Equipment": "Équipment", "NewTunnelFlight_ChooseTunnel": "Choisir le tunnel", "NewTunnelFlight_Minutes": "Temps de vol(minutes)", diff --git a/Front/skydivelogs-app/src/models/gear.ts b/Front/skydivelogs-app/src/models/gear.ts index bc2c46f..762adf4 100644 --- a/Front/skydivelogs-app/src/models/gear.ts +++ b/Front/skydivelogs-app/src/models/gear.ts @@ -11,7 +11,6 @@ export class GearReq { public aad: string; public mainCanopy: string; public reserveCanopy: string; - public equipment: string; } export class GearResp { @@ -27,5 +26,4 @@ export class GearResp { public aad: string; public mainCanopy: string; public reserveCanopy: string; - public equipment: string; } diff --git a/Front/skydivelogs-app/src/models/jump.ts b/Front/skydivelogs-app/src/models/jump.ts index 940cbc9..0137690 100644 --- a/Front/skydivelogs-app/src/models/jump.ts +++ b/Front/skydivelogs-app/src/models/jump.ts @@ -1,66 +1,69 @@ -import { GearResp } from './gear'; -import { DropZoneResp } from './dropzone'; -import { AircraftResp } from './aircraft'; -import { JumpTypeResp } from './jumpType'; +import { GearResp } from "./gear"; +import { DropZoneResp } from "./dropzone"; +import { AircraftResp } from "./aircraft"; +import { JumpTypeResp } from "./jumpType"; export class JumpReq { - constructor(data: any) { - Object.assign(this, data); - } + constructor(data: any) { + Object.assign(this, data); + } - public id: number; - public jumpTypeId: number; - public aircraftId: number; - public dropZoneId: number; - public gearId: number; - public exitAltitude: number; - public deployAltitude: number; - public withCutaway: boolean; - public notes: string; - public jumpDate: string; - public isSpecial: boolean; + public id: number; + public jumpTypeId: number; + public aircraftId: number; + public dropZoneId: number; + public gearId: number; + public exitAltitude: number; + public deployAltitude: number; + public withCutaway: boolean; + public notes: string; + public jumpDate: string; + public isSpecial: boolean; + public equipment: string; } export class JumpResp { - constructor(data: any) { - Object.assign(this, data); - this.jumpDate = new Date(data.jumpDate); - } + constructor(data: any) { + Object.assign(this, data); + this.jumpDate = new Date(data.jumpDate); + } - public id: number; - public jumpType: JumpTypeResp; - public aircraft: AircraftResp; - public dropZone: DropZoneResp; - public gear: GearResp; + public id: number; + public jumpType: JumpTypeResp; + public aircraft: AircraftResp; + public dropZone: DropZoneResp; + public gear: GearResp; - public jumpTypeId: number; - public aircraftId: number; - public dropZoneId: number; - public gearId: number; + public jumpTypeId: number; + public aircraftId: number; + public dropZoneId: number; + public gearId: number; - public exitAltitude: number; - public deployAltitude: number; - public withCutaway: boolean; - public notes: string; - public jumpDate: Date; - public isSpecial: boolean; + public exitAltitude: number; + public deployAltitude: number; + public withCutaway: boolean; + public notes: string; + public jumpDate: Date; + public isSpecial: boolean; + public equipment: string; } export class Jump { - constructor(data: any) { - Object.assign(this, data); - this.jumpDate = new Date(data.jumpDate); - } + constructor(data: any) { + Object.assign(this, data); + this.jumpDate = new Date(data.jumpDate); + } - public id: number; - public jumpType: JumpTypeResp; - public aircraft: AircraftResp; - public dropZone: DropZoneResp; - public gear: GearResp; - public exitAltitude: number; - public deployAltitude: number; - public withCutaway: boolean; - public notes: string; - public jumpDate: Date; - public isSpecial: boolean; -} \ No newline at end of file + public id: number; + public jumpType: JumpTypeResp; + public aircraft: AircraftResp; + public dropZone: DropZoneResp; + public gear: GearResp; + public exitAltitude: number; + public deployAltitude: number; + public withCutaway: boolean; + public notes: string; + public jumpDate: Date; + public isSpecial: boolean; + public equipment: string; +} diff --git a/Front/skydivelogs-app/src/services/gear.service.ts b/Front/skydivelogs-app/src/services/gear.service.ts index f9b5513..69a3174 100644 --- a/Front/skydivelogs-app/src/services/gear.service.ts +++ b/Front/skydivelogs-app/src/services/gear.service.ts @@ -32,7 +32,6 @@ export class GearService extends BaseService { aad: string, mainCanopy: string, reserveCanopy: string, - equipment: string, ) { const bodyNewGear: GearReq = { id: 0, @@ -43,7 +42,6 @@ export class GearService extends BaseService { aad: aad, mainCanopy: mainCanopy, reserveCanopy: reserveCanopy, - equipment: equipment, }; this.serviceCacheApi.delete(CacheApiKey.Gear); @@ -75,7 +73,6 @@ export class GearService extends BaseService { aad: string, mainCanopy: string, reserveCanopy: string, - equipment: string, ) { const gearData = { id: id, @@ -86,10 +83,10 @@ export class GearService extends BaseService { aad: aad, mainCanopy: mainCanopy, reserveCanopy: reserveCanopy, - equipment: equipment, }; const bodyUpdatedGear = new GearReq(gearData); + this.serviceCacheApi.delete(CacheApiKey.Gear); return this.http.put(`${this.apiUrl}/Gear/${id}`, bodyUpdatedGear, { headers: this.headers, }); diff --git a/Front/skydivelogs-app/src/services/jump.service.ts b/Front/skydivelogs-app/src/services/jump.service.ts index a3874af..f56b78b 100644 --- a/Front/skydivelogs-app/src/services/jump.service.ts +++ b/Front/skydivelogs-app/src/services/jump.service.ts @@ -1,6 +1,6 @@ import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; -import { DatePipe } from '@angular/common'; +import { DatePipe } from "@angular/common"; import { forkJoin, Observable } from "rxjs"; import { map } from "rxjs/operators"; @@ -20,158 +20,204 @@ import { GearService } from "./gear.service"; @Injectable() export class JumpService extends BaseService { - private callsToAdd: Array>; + private callsToAdd: Array>; - constructor(private http: HttpClient, - private dateService: DateService, - private datePipe: DatePipe, - private dropzoneService: DropzoneService, - private aircraftService: AircraftService, - private jumpTypeService: JumpTypeService, - private gearService: GearService) { - super(); - } + constructor( + private http: HttpClient, + private dateService: DateService, + private datePipe: DatePipe, + private dropzoneService: DropzoneService, + private aircraftService: AircraftService, + private jumpTypeService: JumpTypeService, + private gearService: GearService, + ) { + super(); + } - public getListOfJumps(): Observable> { - return this.http.get>(`${this.apiUrl}/Jump`, { headers: this.headers }) - .pipe(map((response) => { - return this.mapWithDataInCache(response); - })); - } + public getListOfJumps(): Observable> { + return this.http + .get< + Array + >(`${this.apiUrl}/Jump`, { headers: this.headers }) + .pipe( + map((response) => { + return this.mapWithDataInCache(response); + }), + ); + } - public getJumps(beginIndex: number, endIndex: number): Observable { - return this.http.get(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, { headers: this.headers }) - .pipe(map(response => { - let result: JumpList = { + public getJumps( + beginIndex: number, + endIndex: number, + ): Observable { + return this.http + .get( + `${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, + { headers: this.headers }, + ) + .pipe( + map((response) => { + let result: JumpList = { rows: this.mapWithDataInCache(response.rows), - count: response.count - }; + count: response.count, + }; - return new JumpList(result); - })); - } - - public addListOfJump(selectedJumpType: number, - selectedAircraft: number, - selectedDz: number, - selectedRig: number, - withCutaway: boolean, - beginDate: Date, - endDate: Date, - defaultExitAltitude: number, - defaultDeployAltitude: number, - countOfJumps: number, - notes: string, - isSpecial: boolean): Observable { - this.callsToAdd = new Array>(); - const diffInDays = this.dateService.diffBetweenDates(beginDate, endDate) + 1; - const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays); - - for (let i = 1; beginDate.getTime() < endDate.getTime(); i++) { - this.addJumps(selectedJumpType, - selectedAircraft, - selectedDz, - selectedRig, - withCutaway, - beginDate, - defaultExitAltitude, - defaultDeployAltitude, - countOfJumpsPerDay, - notes, - isSpecial); - - beginDate = this.dateService.addDays(beginDate, 1); + return new JumpList(result); + }), + ); } - const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1); + public addListOfJump( + selectedJumpType: number, + selectedAircraft: number, + selectedDz: number, + selectedGear: number, + withCutaway: boolean, + beginDate: Date, + endDate: Date, + defaultExitAltitude: number, + defaultDeployAltitude: number, + countOfJumps: number, + notes: string, + isSpecial: boolean, + equipment: string, + ): Observable { + this.callsToAdd = new Array>(); + const diffInDays = + this.dateService.diffBetweenDates(beginDate, endDate) + 1; + const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays); - this.addJumps(selectedJumpType, - selectedAircraft, - selectedDz, - selectedRig, - withCutaway, - beginDate, - defaultExitAltitude, - defaultDeployAltitude, - restfJumps, - notes, - isSpecial); + for (let i = 1; beginDate.getTime() < endDate.getTime(); i++) { + this.addJumps( + selectedJumpType, + selectedAircraft, + selectedDz, + selectedGear, + withCutaway, + beginDate, + defaultExitAltitude, + defaultDeployAltitude, + countOfJumpsPerDay, + notes, + isSpecial, + equipment, + ); - return forkJoin(this.callsToAdd); - } + beginDate = this.dateService.addDays(beginDate, 1); + } - public deleteJump(item: Jump) { - this.http.delete(`${this.apiUrl}/Jump/${item.id}`, { headers: this.headers }).subscribe(); - } + const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1); - 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); + this.addJumps( + selectedJumpType, + selectedAircraft, + selectedDz, + selectedGear, + withCutaway, + beginDate, + defaultExitAltitude, + defaultDeployAltitude, + restfJumps, + notes, + isSpecial, + equipment, + ); - return this.http.put(`${this.apiUrl}/Jump/${id}`, - bodyUpdatedJump, - { headers: this.headers, }); - } - - private addJumps(selectedJumpType: number, - selectedAircraft: number, - selectedDz: number, - selectedRig: number, - withCutaway: boolean, - jumpDate: Date, - defaultExitAltitude: number, - defaultDeployAltitude: number, - countOfJumps: number, - notes: string, - isSpecial: boolean) { - for (let i = 0; i < countOfJumps; i++) { - const bodyNewjump: JumpReq = { - jumpTypeId: selectedJumpType, - aircraftId: selectedAircraft, - dropZoneId: selectedDz, - withCutaway: withCutaway, - exitAltitude: defaultExitAltitude, - deployAltitude: defaultDeployAltitude, - gearId: selectedRig, - notes: notes, - id: 0, - jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd"), - isSpecial: isSpecial - }; - - let call = this.http.post(`${this.apiUrl}/Jump`, bodyNewjump, { headers: this.headers }); - - this.callsToAdd.push(call); + return forkJoin(this.callsToAdd); } - } - private mapWithDataInCache(apiResp: Array): Array { - let allDropzones: Array; - this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; }); - let allAircrafts: Array; - this.aircraftService.getFromCache().subscribe(data => { allAircrafts = data; }); - let allJumpType: Array; - this.jumpTypeService.getFromCache().subscribe(data => { allJumpType = data; }); - let allGears: Array; - this.gearService.getFromCache().subscribe(data => { allGears = data; }); + public deleteJump(item: Jump) { + this.http + .delete(`${this.apiUrl}/Jump/${item.id}`, { headers: this.headers }) + .subscribe(); + } - return apiResp.map((data) => { - let tmp = new Jump(data); + public updateJump( + id: number, + isSpecial: boolean, + withCutaway: boolean, + notes: string, + equipment: string, + ) { + const jumpData = { + id: id, + isSpecial: isSpecial, + withCutaway: withCutaway, + notes: notes, + equipment: equipment, + }; + const bodyUpdatedJump = new JumpReq(jumpData); - tmp.dropZone = allDropzones.find(d => d.id == data.dropZoneId); - tmp.aircraft = allAircrafts.find(d => d.id == data.aircraftId); - tmp.jumpType = allJumpType.find(d => d.id == data.jumpTypeId); - tmp.gear = allGears.find(d => d.id == data.gearId); + return this.http.put(`${this.apiUrl}/Jump/${id}`, bodyUpdatedJump, { + headers: this.headers, + }); + } - return tmp; - }); - } + private addJumps( + selectedJumpType: number, + selectedAircraft: number, + selectedDz: number, + selectedGear: number, + withCutaway: boolean, + jumpDate: Date, + defaultExitAltitude: number, + defaultDeployAltitude: number, + countOfJumps: number, + notes: string, + isSpecial: boolean, + equipment: string, + ) { + for (let i = 0; i < countOfJumps; i++) { + const bodyNewjump: JumpReq = { + jumpTypeId: selectedJumpType, + aircraftId: selectedAircraft, + dropZoneId: selectedDz, + withCutaway: withCutaway, + exitAltitude: defaultExitAltitude, + deployAltitude: defaultDeployAltitude, + gearId: selectedGear, + notes: notes, + id: 0, + jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd"), + isSpecial: isSpecial, + equipment: equipment, + }; + + let call = this.http.post(`${this.apiUrl}/Jump`, bodyNewjump, { + headers: this.headers, + }); + + this.callsToAdd.push(call); + } + } + + private mapWithDataInCache(apiResp: Array): Array { + let allDropzones: Array; + this.dropzoneService.getFromCache().subscribe((data) => { + allDropzones = data; + }); + let allAircrafts: Array; + this.aircraftService.getFromCache().subscribe((data) => { + allAircrafts = data; + }); + let allJumpType: Array; + this.jumpTypeService.getFromCache().subscribe((data) => { + allJumpType = data; + }); + let allGears: Array; + this.gearService.getFromCache().subscribe((data) => { + allGears = data; + }); + + return apiResp.map((data) => { + let tmp = new Jump(data); + + tmp.dropZone = allDropzones.find((d) => d.id == data.dropZoneId); + tmp.aircraft = allAircrafts.find((d) => d.id == data.aircraftId); + tmp.jumpType = allJumpType.find((d) => d.id == data.jumpTypeId); + tmp.gear = allGears.find((d) => d.id == data.gearId); + + return tmp; + }); + } }