Add the "delete flight" in the table

This commit is contained in:
Sébastien ANDRE
2023-12-04 14:35:44 +01:00
parent ff2fc96575
commit be6f9af954
6 changed files with 30 additions and 7 deletions

View File

@@ -1,17 +1,22 @@
<div class="content">
<p>
<a class="nostyle" routerLink="/summary" routerLinkActive="active" skipLocationChange>
<mat-icon aria-hidden="false" aria-label="Summary" style="width: 256px; height:256px; font-size: 256px;">timeline</mat-icon>
<mat-icon aria-hidden="false" aria-label="Summary" style="width: 128px; height:128px; font-size: 128px;">timeline</mat-icon>
</a>
</p>
<p>
<a class="nostyle" routerLink="/newjump" routerLinkActive="active" skipLocationChange>
<mat-icon aria-hidden="false" aria-label="Add jumps" style="width: 256px; height:256px; font-size: 256px;">add_circle</mat-icon>
<mat-icon aria-hidden="false" aria-label="Add jumps" style="width: 128px; height:128px; font-size: 128px;">add_circle</mat-icon>
</a>
</p>
<p>
<a class="nostyle" routerLink="/jumps" routerLinkActive="active" skipLocationChange>
<mat-icon aria-hidden="false" aria-label="List of jumps" style="width: 256px; height:256px; font-size: 256px;">list_alt</mat-icon>
<mat-icon aria-hidden="false" aria-label="List of jumps" style="width: 128px; height:128px; font-size: 128px;">list_alt</mat-icon>
</a>
</p>
<p>
<a class="nostyle" routerLink="/tunnelFlights" routerLinkActive="active" skipLocationChange>
<img src="assets/img/tunnel.jpg" alt="Tunnel flights" style="width: 128px; height:128px; font-size: 128px;" />
</a>
</p>
</div>

View File

@@ -64,7 +64,7 @@
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef style="min-width: 70px;"></th>
<th mat-header-cell *matHeaderCellDef style="min-width: 80px;"></th>
<td mat-cell *matCellDef="let element" style="text-align: left;">
<mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;"
(click)='delete(element)'>delete</mat-icon>

View File

@@ -68,6 +68,14 @@
</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef style="min-width: 80px;"></th>
<td mat-cell *matCellDef="let element" style="text-align: left;">
<mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;"
(click)='delete(element)'>delete</mat-icon>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>

View File

@@ -203,4 +203,12 @@ export class ListOfTunnelFlightsComponent implements OnInit {
return beginDate;
}
public delete(item: TunnelFlight) {
let data: Array<TunnelFlight> = this.dataSourceTable.data;
data = data.filter((d) => d.id !== item.id);
this.dataSourceTable.data = data;
this.serviceTunnelFlight.deleteTunnelFlight(item);
}
}

View File

@@ -101,9 +101,7 @@ export class JumpService extends BaseService {
}
public deleteJump(item: Jump) {
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
{ headers: this.headers, })
.subscribe();
this.http.delete(`${this.apiUrl}/Jump/${item.id}`, { headers: this.headers }).subscribe();
}
public updateJump(id: number,

View File

@@ -50,6 +50,10 @@ export class TunnelFlightService extends BaseService {
);
}
public deleteTunnelFlight(item: TunnelFlight) {
this.http.delete(`${this.apiUrl}/TunnelFlight/${item.id}`, { headers: this.headers }).subscribe();
}
public getTunnelFlightsByMonth(begin: Date, end: Date): Observable<Array<TunnelFlightByMonth>> {
let beginDate = this.datePipe.transform(begin, "yyyy-MM-dd");
let endDate = this.datePipe.transform(end, "yyyy-MM-dd");