Bug fix +

Meilleur chargement du cache après login
This commit is contained in:
Sébastien André
2021-05-03 16:13:55 +02:00
parent f9930a10e6
commit 784bdea786
9 changed files with 107 additions and 81 deletions
@@ -4,7 +4,7 @@ import { DatePipe } from '@angular/common';
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { JumpResp, JumpReq } from "../models/jump";
import { JumpResp, JumpReq, Jump } from "../models/jump";
import { DateService } from "./date.service";
import { BaseService } from "./base.service";
@@ -21,27 +21,25 @@ export class JumpService extends BaseService {
private dropzoneService: DropzoneService,
private aircraftService: AircraftService,
private jumpTypeService: JumpTypeService,
private gearService: GearService,) {
private gearService: GearService) {
super();
}
public GetListOfJumps(): Observable<Array<JumpResp>> {
public GetListOfJumps(): Observable<Array<Jump>> {
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
{ headers: this.headers })
.pipe(
map((response) => {
.pipe(map((response) => {
let details = response.map((data) =>
{
let t = new JumpResp(data);
this.dropzoneService.getById(t.dropZoneId).subscribe((d)=> t.dropZone = d );
this.aircraftService.getById(t.aircraftId).subscribe((d)=> t.aircraft = d );
this.jumpTypeService.getById(t.jumpTypeId).subscribe((d)=> t.jumpType = d );
this.gearService.getById(t.gearId).subscribe((d)=> t.gear = d );
return t;
});
{
let tmp = new Jump(data);
this.dropzoneService.getById(data.dropZoneId).subscribe((d)=> tmp.dropZone = d );
this.aircraftService.getById(data.aircraftId).subscribe((d)=> tmp.aircraft = d );
this.jumpTypeService.getById(data.jumpTypeId).subscribe((d)=> tmp.jumpType = d );
this.gearService.getById(data.gearId).subscribe((d)=> tmp.gear = d );
return tmp;
});
return details;
})
);
}));
}
public AddListOfJump(selectedJumpType: number,
@@ -91,10 +89,10 @@ export class JumpService extends BaseService {
isSpecial);
}
public DeleteJump(item: JumpResp) {
public DeleteJump(item: Jump) {
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
{ headers: this.headers, })
.subscribe((data) => console.log(data));
.subscribe();
}
public UpdateJump(id: number,
@@ -144,7 +142,7 @@ export class JumpService extends BaseService {
this.http.post(`${this.apiUrl}/Jump`,
bodyNewjump,
{ headers: this.headers, })
.subscribe((data) => console.log(data));
.subscribe();
}
}
}