Get the jump type only for the tunnel

This commit is contained in:
Sébastien ANDRE
2023-08-22 18:26:49 +02:00
parent 5199f746c3
commit bf05e1c668
4 changed files with 37 additions and 27 deletions

View File

@@ -133,40 +133,44 @@ export class NewJumpComponent implements OnInit {
} }
private getListOfJumpTypes() { private getListOfJumpTypes() {
this.serviceJumpType.getListOfJumpTypes().subscribe((data) => { this.serviceJumpType.getListOfJumpTypes()
data.sort((a, b) => a.name.localeCompare(b.name)); .subscribe((data) => {
this.listOfJumpType = data; data.sort((a, b) => a.name.localeCompare(b.name));
this.countDatasLoaded = 1; this.listOfJumpType = data;
this.countDatasLoaded = 1;
this.getListOfAircrafts(); this.getListOfAircrafts();
this.getListOfDropZones(); this.getListOfDropZones();
this.getListOfGears(); this.getListOfGears();
}); });
} }
private getListOfAircrafts() { private getListOfAircrafts() {
this.serviceAircraft.getListOfAircrafts(true).subscribe((data) => { this.serviceAircraft.getListOfAircrafts(true)
data.sort((a, b) => a.name.localeCompare(b.name)); .subscribe((data) => {
this.listOfAircraft = data; data.sort((a, b) => a.name.localeCompare(b.name));
this.countDatasLoaded++; this.listOfAircraft = data;
}); this.countDatasLoaded++;
});
} }
private getListOfDropZones() { private getListOfDropZones() {
this.serviceDropzone.getListOfDropZones(true).subscribe((data) => { this.serviceDropzone.getListOfDropZones(true)
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0) || a.name.localeCompare(b.name)); .subscribe((data) => {
this.listOfDropZone = data; data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0) || a.name.localeCompare(b.name));
this.listOfFilteredDropZone = data; this.listOfDropZone = data;
this.countDatasLoaded++; this.listOfFilteredDropZone = data;
}); this.countDatasLoaded++;
});
} }
private getListOfGears() { private getListOfGears() {
this.serviceGear.getListOfGears().subscribe((data) => { this.serviceGear.getListOfGears()
data.sort((a, b) => b.id - a.id); .subscribe((data) => {
this.listOfGear = data; data.sort((a, b) => b.id - a.id);
this.countDatasLoaded++; this.listOfGear = data;
}); this.countDatasLoaded++;
});
} }
private initForm() { private initForm() {

View File

@@ -106,7 +106,7 @@ export class NewTunnelFlightComponent implements OnInit {
} }
private getListOfJumpTypes() { private getListOfJumpTypes() {
this.serviceJumpType.getListOfJumpTypes() this.serviceJumpType.getListOfJumpTypesForTunnel()
.subscribe((data) => { .subscribe((data) => {
data.sort((a, b) => a.name.localeCompare(b.name)); data.sort((a, b) => a.name.localeCompare(b.name));
this.listOfJumpType = data; this.listOfJumpType = data;

View File

@@ -1,5 +1,6 @@
export enum CacheApiKey { export enum CacheApiKey {
JumpType, JumpType,
TunnelJumpType,
Aircraft, Aircraft,
Gear, Gear,
Dropzone, Dropzone,

View File

@@ -14,11 +14,16 @@ export class JumpTypeService extends BaseService {
super(); super();
} }
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> { public getListOfJumpTypes(onlyTunnel: boolean = false): Observable<Array<JumpTypeResp>> {
let callToApi = this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType`, { headers: this.headers }); let callToApi = this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType${onlyTunnel ? "/tunnel" : ""}`, { headers: this.headers });
return this.serviceCacheApi.get<Array<JumpTypeResp>>(CacheApiKey.JumpType, callToApi); return this.serviceCacheApi.get<Array<JumpTypeResp>>(CacheApiKey.JumpType, callToApi);
} }
public getListOfJumpTypesForTunnel(): Observable<Array<JumpTypeResp>> {
let callToApi = this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType/tunnel`, { headers: this.headers });
return this.serviceCacheApi.get<Array<JumpTypeResp>>(CacheApiKey.TunnelJumpType, callToApi);
}
public addJumpType(jumptypetName: string) { public addJumpType(jumptypetName: string) {
const bodyJumpType: JumpTypeReq = { const bodyJumpType: JumpTypeReq = {
id: 0, id: 0,