Little test with AI + Add the equipment #8
@@ -71,6 +71,14 @@
|
||||
{{ element.reserveCanopy }}
|
||||
</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="equipment">
|
||||
<th mat-header-cell *matHeaderCellDef>
|
||||
{{ "ListGears_Header_Equipment" | translate }}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
{{ element.equipment }}
|
||||
</td>
|
||||
</ng-container>
|
||||
<tr
|
||||
mat-header-row
|
||||
*matHeaderRowDef="displayedColumns; sticky: true"
|
||||
|
||||
@@ -33,6 +33,7 @@ export class ListOfGearsComponent implements OnInit {
|
||||
"aad",
|
||||
"mainCanopy",
|
||||
"reserveCanopy",
|
||||
"equipment",
|
||||
];
|
||||
public dataSourceTable: MatTableDataSource<GearResp>;
|
||||
public resultsLength = 0;
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
<input matInput type="text" formControlName="reserveCanopy" />
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<p>
|
||||
<mat-form-field>
|
||||
<mat-label>Equipment</mat-label>
|
||||
<input matInput type="text" formControlName="equipment" />
|
||||
</mat-form-field>
|
||||
</p>
|
||||
|
||||
<button mat-raised-button color="accent" type="submit">Add</button>
|
||||
</form>
|
||||
|
||||
@@ -60,6 +60,11 @@ 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" },
|
||||
);
|
||||
@@ -85,6 +90,7 @@ export class NewGearComponent implements OnInit {
|
||||
formData.aad,
|
||||
formData.mainCanopy,
|
||||
formData.reserveCanopy,
|
||||
formData.equipment,
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.serviceComm.refreshData(AddAction.Gear);
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
"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",
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
"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",
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
export class GearReq {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
|
||||
public id: number;
|
||||
public name: string;
|
||||
public manufacturer: string;
|
||||
public minSize: number;
|
||||
public maxSize: number;
|
||||
public aad: string;
|
||||
public mainCanopy: string;
|
||||
public reserveCanopy: string;
|
||||
public id: number;
|
||||
public name: string;
|
||||
public manufacturer: string;
|
||||
public minSize: number;
|
||||
public maxSize: number;
|
||||
public aad: string;
|
||||
public mainCanopy: string;
|
||||
public reserveCanopy: string;
|
||||
public equipment: string;
|
||||
}
|
||||
|
||||
export class GearResp {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
|
||||
public id: number;
|
||||
public name: string;
|
||||
public manufacturer: string;
|
||||
public minSize: number;
|
||||
public maxSize: number;
|
||||
public aad: string;
|
||||
public mainCanopy: string;
|
||||
public reserveCanopy: string;
|
||||
public id: number;
|
||||
public name: string;
|
||||
public manufacturer: string;
|
||||
public minSize: number;
|
||||
public maxSize: number;
|
||||
public aad: string;
|
||||
public mainCanopy: string;
|
||||
public reserveCanopy: string;
|
||||
public equipment: string;
|
||||
}
|
||||
|
||||
@@ -10,46 +10,59 @@ import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
|
||||
@Injectable()
|
||||
export class GearService extends BaseService {
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
}
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getListOfGears(): Observable<Array<GearResp>> {
|
||||
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers });
|
||||
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi);
|
||||
}
|
||||
public getListOfGears(): Observable<Array<GearResp>> {
|
||||
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, {
|
||||
headers: this.headers,
|
||||
});
|
||||
return this.serviceCacheApi.get<Array<GearResp>>(
|
||||
CacheApiKey.Gear,
|
||||
callToApi,
|
||||
);
|
||||
}
|
||||
|
||||
public addGear(name: string,
|
||||
manufacturer: string,
|
||||
minSize: number,
|
||||
maxSize: number,
|
||||
aad: string,
|
||||
mainCanopy: string,
|
||||
reserveCanopy: string)
|
||||
{
|
||||
const bodyNewGear: GearReq = {
|
||||
id: 0,
|
||||
name: name,
|
||||
manufacturer: manufacturer,
|
||||
minSize: minSize,
|
||||
maxSize: maxSize,
|
||||
aad: aad,
|
||||
mainCanopy: mainCanopy,
|
||||
reserveCanopy: reserveCanopy
|
||||
};
|
||||
public addGear(
|
||||
name: string,
|
||||
manufacturer: string,
|
||||
minSize: number,
|
||||
maxSize: number,
|
||||
aad: string,
|
||||
mainCanopy: string,
|
||||
reserveCanopy: string,
|
||||
equipment: string,
|
||||
) {
|
||||
const bodyNewGear: GearReq = {
|
||||
id: 0,
|
||||
name: name,
|
||||
manufacturer: manufacturer,
|
||||
minSize: minSize,
|
||||
maxSize: maxSize,
|
||||
aad: aad,
|
||||
mainCanopy: mainCanopy,
|
||||
reserveCanopy: reserveCanopy,
|
||||
equipment: equipment,
|
||||
};
|
||||
|
||||
this.serviceCacheApi.delete(CacheApiKey.Gear);
|
||||
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
|
||||
}
|
||||
this.serviceCacheApi.delete(CacheApiKey.Gear);
|
||||
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, {
|
||||
headers: this.headers,
|
||||
});
|
||||
}
|
||||
|
||||
public getById(id: number) : Observable<GearResp> {
|
||||
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear)
|
||||
.pipe(map(data => {
|
||||
return data.find(f => f.id === id);
|
||||
}));
|
||||
}
|
||||
public getById(id: number): Observable<GearResp> {
|
||||
return this.serviceCacheApi
|
||||
.getByKey<Array<GearResp>>(CacheApiKey.Gear)
|
||||
.pipe(
|
||||
map((data) => {
|
||||
return data.find((f) => f.id === id);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public getFromCache(): Observable<Array<GearResp>> {
|
||||
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear);
|
||||
}
|
||||
public getFromCache(): Observable<Array<GearResp>> {
|
||||
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user