Ajout de la mise en favoris des DZs
This commit is contained in:
@@ -38,6 +38,11 @@ namespace skydiveLogs_api.Business
|
||||
public bool UpdateDz(int id, DropZone dropZone)
|
||||
{
|
||||
dropZone.Id = id;
|
||||
|
||||
//dropZone.Address = dropZone.Address ?? string.Empty;
|
||||
//dropZone.Website = dropZone.Address ?? string.Empty;
|
||||
//dropZone.Email = dropZone.Address ?? string.Empty;
|
||||
|
||||
return _dropZoneRepository.Update(dropZone);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -14,6 +14,7 @@ import { ListOfJumpTypesComponent } from './list-of-jump-types/list-of-jump-type
|
||||
import { ListOfGearsComponent } from './list-of-gears/list-of-gears.component';
|
||||
|
||||
import { DateService } from '../services/date.service';
|
||||
import { ServiceApiPut } from '../services/service-api-put.service';
|
||||
import { ServiceApiGet } from '../services/service-api-get.service';
|
||||
import { ServiceApiPost } from '../services/service-api-post.service';
|
||||
import { ServiceComm } from '../services/service-comm.service';
|
||||
@@ -80,6 +81,7 @@ const appRoutes: Routes = [
|
||||
],
|
||||
exports: [HttpClientModule],
|
||||
providers: [
|
||||
ServiceApiPut,
|
||||
ServiceApiPost,
|
||||
ServiceApiGet,
|
||||
ServiceComm,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Front/skydivelogs-app/src/assets/img/favorite.png
Normal file
BIN
Front/skydivelogs-app/src/assets/img/favorite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
BIN
Front/skydivelogs-app/src/assets/img/not-favorite.png
Normal file
BIN
Front/skydivelogs-app/src/assets/img/not-favorite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 796 B |
@@ -11,6 +11,7 @@ export class DropZoneResp {
|
||||
public website: string;
|
||||
public email: string;
|
||||
public type: Array<string>;
|
||||
public isfavorite: boolean;
|
||||
}
|
||||
|
||||
export class DropZoneReq {
|
||||
@@ -26,4 +27,5 @@ export class DropZoneReq {
|
||||
public website: string;
|
||||
public email: string;
|
||||
public type: Array<string>;
|
||||
public isfavorite: boolean;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
import { environment } from "../environments/environment";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
import { DropZoneResp } from "../models/dropzone";
|
||||
import { JumpResp } from "../models/jump";
|
||||
import { AircraftResp } from "../models/aircraft";
|
||||
import { JumpTypeResp } from "../models/jumpType";
|
||||
import { GearResp } from "../models/gear";
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
import { JumpResp } from '../models/jump';
|
||||
import { AircraftResp } from '../models/aircraft';
|
||||
import { JumpTypeResp } from '../models/jumpType';
|
||||
import { GearResp } from '../models/gear';
|
||||
|
||||
import {
|
||||
StatsResp,
|
||||
@@ -17,14 +17,14 @@ import {
|
||||
StatsByJumpTypeResp,
|
||||
StatsByRigResp,
|
||||
StatsByYearResp
|
||||
} from "../models/stats";
|
||||
} from '../models/stats';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiGet {
|
||||
private readonly headers = new HttpHeaders({
|
||||
"Access-Control-Allow-Origin": environment.urlApi
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) {}
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
return this.http
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { JumpReq } from "../models/jump";
|
||||
import { environment } from "../environments/environment";
|
||||
import { DateService } from "./date.service";
|
||||
import { JumpReq } from '../models/jump';
|
||||
import { environment } from '../environments/environment';
|
||||
import { DateService } from './date.service';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiPost {
|
||||
private readonly headers = new HttpHeaders({
|
||||
"Access-Control-Allow-Origin": environment.urlApi
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
|
||||
constructor(private http: HttpClient, private dateService: DateService) {}
|
||||
constructor(private http: HttpClient, private dateService: DateService) { }
|
||||
|
||||
public AddListOfJump(
|
||||
selectedJumpType: number,
|
||||
@@ -79,7 +79,7 @@ export class ServiceApiPost {
|
||||
exitAltitude: defaultExitAltitude,
|
||||
deployAltitude: defaultDeployAltitude,
|
||||
gearId: selectedRig,
|
||||
notes: "",
|
||||
notes: '',
|
||||
id: 0,
|
||||
jumpDate: jumpDate
|
||||
};
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { environment } from '../environments/environment';
|
||||
import { DateService } from './date.service';
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiPut {
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
|
||||
constructor(private http: HttpClient, private dateService: DateService) { }
|
||||
|
||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
selectedDz.isfavorite = true;
|
||||
this.http
|
||||
.put(`${environment.urlApi}/api/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
selectedDz.isfavorite = false;
|
||||
this.http
|
||||
.put(`${environment.urlApi}/api/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user