From bf05e1c668bc61cbf8262a28a0928f692cbf2db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20ANDRE?= Date: Tue, 22 Aug 2023 18:26:49 +0200 Subject: [PATCH] Get the jump type only for the tunnel --- .../src/app/new-jump/new-jump.component.ts | 52 ++++++++++--------- .../new-tunnel-flight.component.ts | 2 +- .../src/models/cache-api-key.enum.ts | 1 + .../src/services/jump-type.service.ts | 9 +++- 4 files changed, 37 insertions(+), 27 deletions(-) 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 ece7456..13879ab 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 @@ -133,40 +133,44 @@ export class NewJumpComponent implements OnInit { } private getListOfJumpTypes() { - this.serviceJumpType.getListOfJumpTypes().subscribe((data) => { - data.sort((a, b) => a.name.localeCompare(b.name)); - this.listOfJumpType = data; - this.countDatasLoaded = 1; + this.serviceJumpType.getListOfJumpTypes() + .subscribe((data) => { + data.sort((a, b) => a.name.localeCompare(b.name)); + this.listOfJumpType = data; + this.countDatasLoaded = 1; - this.getListOfAircrafts(); - this.getListOfDropZones(); - this.getListOfGears(); - }); + this.getListOfAircrafts(); + this.getListOfDropZones(); + this.getListOfGears(); + }); } private getListOfAircrafts() { - this.serviceAircraft.getListOfAircrafts(true).subscribe((data) => { - data.sort((a, b) => a.name.localeCompare(b.name)); - this.listOfAircraft = data; - this.countDatasLoaded++; - }); + this.serviceAircraft.getListOfAircrafts(true) + .subscribe((data) => { + data.sort((a, b) => a.name.localeCompare(b.name)); + this.listOfAircraft = data; + this.countDatasLoaded++; + }); } private getListOfDropZones() { - this.serviceDropzone.getListOfDropZones(true).subscribe((data) => { - data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0) || a.name.localeCompare(b.name)); - this.listOfDropZone = data; - this.listOfFilteredDropZone = data; - this.countDatasLoaded++; - }); + this.serviceDropzone.getListOfDropZones(true) + .subscribe((data) => { + data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0) || a.name.localeCompare(b.name)); + this.listOfDropZone = data; + this.listOfFilteredDropZone = data; + this.countDatasLoaded++; + }); } private getListOfGears() { - this.serviceGear.getListOfGears().subscribe((data) => { - data.sort((a, b) => b.id - a.id); - this.listOfGear = data; - this.countDatasLoaded++; - }); + this.serviceGear.getListOfGears() + .subscribe((data) => { + data.sort((a, b) => b.id - a.id); + this.listOfGear = data; + this.countDatasLoaded++; + }); } private initForm() { diff --git a/Front/skydivelogs-app/src/app/new-tunnel-flight/new-tunnel-flight.component.ts b/Front/skydivelogs-app/src/app/new-tunnel-flight/new-tunnel-flight.component.ts index 8779e52..231a3a9 100644 --- a/Front/skydivelogs-app/src/app/new-tunnel-flight/new-tunnel-flight.component.ts +++ b/Front/skydivelogs-app/src/app/new-tunnel-flight/new-tunnel-flight.component.ts @@ -106,7 +106,7 @@ export class NewTunnelFlightComponent implements OnInit { } private getListOfJumpTypes() { - this.serviceJumpType.getListOfJumpTypes() + this.serviceJumpType.getListOfJumpTypesForTunnel() .subscribe((data) => { data.sort((a, b) => a.name.localeCompare(b.name)); this.listOfJumpType = data; diff --git a/Front/skydivelogs-app/src/models/cache-api-key.enum.ts b/Front/skydivelogs-app/src/models/cache-api-key.enum.ts index 6eaf525..1664ddd 100644 --- a/Front/skydivelogs-app/src/models/cache-api-key.enum.ts +++ b/Front/skydivelogs-app/src/models/cache-api-key.enum.ts @@ -1,5 +1,6 @@ export enum CacheApiKey { JumpType, + TunnelJumpType, Aircraft, Gear, Dropzone, diff --git a/Front/skydivelogs-app/src/services/jump-type.service.ts b/Front/skydivelogs-app/src/services/jump-type.service.ts index b8b0c91..66ca539 100644 --- a/Front/skydivelogs-app/src/services/jump-type.service.ts +++ b/Front/skydivelogs-app/src/services/jump-type.service.ts @@ -14,11 +14,16 @@ export class JumpTypeService extends BaseService { super(); } - public getListOfJumpTypes(): Observable> { - let callToApi = this.http.get>(`${this.apiUrl}/JumpType`, { headers: this.headers }); + public getListOfJumpTypes(onlyTunnel: boolean = false): Observable> { + let callToApi = this.http.get>(`${this.apiUrl}/JumpType${onlyTunnel ? "/tunnel" : ""}`, { headers: this.headers }); return this.serviceCacheApi.get>(CacheApiKey.JumpType, callToApi); } + public getListOfJumpTypesForTunnel(): Observable> { + let callToApi = this.http.get>(`${this.apiUrl}/JumpType/tunnel`, { headers: this.headers }); + return this.serviceCacheApi.get>(CacheApiKey.TunnelJumpType, callToApi); + } + public addJumpType(jumptypetName: string) { const bodyJumpType: JumpTypeReq = { id: 0,