Affichage des DZs favorites +
tri des DZs en fonction de cela
This commit is contained in:
BIN
Back/skydiveLogs-api/Data/JumpsDb-log.db
Normal file
BIN
Back/skydiveLogs-api/Data/JumpsDb-log.db
Normal file
Binary file not shown.
Binary file not shown.
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user