Ajout de la mise en favoris des DZs
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
<div *ngIf="dataSourceTable != null else loading">
|
||||
<table mat-table [dataSource]="dataSourceTable">
|
||||
<ng-container matColumnDef="isfavorite">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let element" style="text-align: center;">
|
||||
<img src="../../assets/img/favorite.png" alt="favorite DZ" *ngIf="element.isfavorite"
|
||||
(click)="removeToFavorite(element)">
|
||||
<img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="!element.isfavorite"
|
||||
(click)="setToFavorite(element)">
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef>ID</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.id}}</td>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { MatTableDataSource } from '@angular/material/table';
|
||||
|
||||
import { DropZoneResp } from '../../models/dropzone';
|
||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
||||
import { ServiceApiPut } from '../../services/service-api-put.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
|
||||
@Component({
|
||||
@@ -13,6 +14,7 @@ import { ServiceComm } from '../../services/service-comm.service';
|
||||
})
|
||||
export class ListOfDzsComponent implements OnInit {
|
||||
public displayedColumns: Array<string> = [
|
||||
'isfavorite',
|
||||
'id',
|
||||
'name',
|
||||
'latitude',
|
||||
@@ -26,7 +28,8 @@ export class ListOfDzsComponent implements OnInit {
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
constructor(
|
||||
private serviceApi: ServiceApiGet,
|
||||
private serviceApiGet: ServiceApiGet,
|
||||
private serviceApiPut: ServiceApiPut,
|
||||
private serviceComm: ServiceComm
|
||||
) { }
|
||||
|
||||
@@ -35,11 +38,19 @@ export class ListOfDzsComponent implements OnInit {
|
||||
this.getListOfDropZones();
|
||||
}
|
||||
|
||||
getListOfDropZones() {
|
||||
this.serviceApi.getListOfDropZones().subscribe(data => {
|
||||
private getListOfDropZones() {
|
||||
this.serviceApiGet.getListOfDropZones().subscribe(data => {
|
||||
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
||||
this.dataSourceTable.paginator = this.paginator;
|
||||
this.resultsLength = data.length;
|
||||
});
|
||||
}
|
||||
|
||||
public setToFavorite(dropzone: DropZoneResp) {
|
||||
dropzone.isfavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
|
||||
}
|
||||
|
||||
public removeToFavorite(dropzone: DropZoneResp) {
|
||||
dropzone.isfavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user