Affichage des DZs favorites +

tri des DZs en fonction de cela
This commit is contained in:
Sébastien André
2019-11-28 10:42:39 +01:00
parent 2a2ea38a14
commit 5522a534b2
6 changed files with 9 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -3,9 +3,9 @@
<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"
<img src="../../assets/img/favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === true"
(click)="removeToFavorite(element)">
<img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="!element.isfavorite"
<img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === false"
(click)="setToFavorite(element)">
</td>
</ng-container>

View File

@@ -40,6 +40,7 @@ export class ListOfDzsComponent implements OnInit {
private getListOfDropZones() {
this.serviceApiGet.getListOfDropZones().subscribe(data => {
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length;
@@ -47,10 +48,10 @@ export class ListOfDzsComponent implements OnInit {
}
public setToFavorite(dropzone: DropZoneResp) {
dropzone.isfavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
dropzone.isFavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
}
public removeToFavorite(dropzone: DropZoneResp) {
dropzone.isfavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
dropzone.isFavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
}
}

View File

@@ -11,7 +11,7 @@ export class DropZoneResp {
public website: string;
public email: string;
public type: Array<string>;
public isfavorite: boolean;
public isFavorite: boolean;
}
export class DropZoneReq {
@@ -27,5 +27,5 @@ export class DropZoneReq {
public website: string;
public email: string;
public type: Array<string>;
public isfavorite: boolean;
public isFavorite: boolean;
}

View File

@@ -14,7 +14,7 @@ export class ServiceApiPut {
constructor(private http: HttpClient, private dateService: DateService) { }
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
selectedDz.isfavorite = true;
selectedDz.isFavorite = true;
this.http
.put(`${environment.urlApi}/api/DropZone/${selectedDz.id}`, selectedDz, {
headers: this.headers
@@ -25,7 +25,7 @@ export class ServiceApiPut {
}
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
selectedDz.isfavorite = false;
selectedDz.isFavorite = false;
this.http
.put(`${environment.urlApi}/api/DropZone/${selectedDz.id}`, selectedDz, {
headers: this.headers