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)
|
public bool UpdateDz(int id, DropZone dropZone)
|
||||||
{
|
{
|
||||||
dropZone.Id = id;
|
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);
|
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 { ListOfGearsComponent } from './list-of-gears/list-of-gears.component';
|
||||||
|
|
||||||
import { DateService } from '../services/date.service';
|
import { DateService } from '../services/date.service';
|
||||||
|
import { ServiceApiPut } from '../services/service-api-put.service';
|
||||||
import { ServiceApiGet } from '../services/service-api-get.service';
|
import { ServiceApiGet } from '../services/service-api-get.service';
|
||||||
import { ServiceApiPost } from '../services/service-api-post.service';
|
import { ServiceApiPost } from '../services/service-api-post.service';
|
||||||
import { ServiceComm } from '../services/service-comm.service';
|
import { ServiceComm } from '../services/service-comm.service';
|
||||||
@@ -80,6 +81,7 @@ const appRoutes: Routes = [
|
|||||||
],
|
],
|
||||||
exports: [HttpClientModule],
|
exports: [HttpClientModule],
|
||||||
providers: [
|
providers: [
|
||||||
|
ServiceApiPut,
|
||||||
ServiceApiPost,
|
ServiceApiPost,
|
||||||
ServiceApiGet,
|
ServiceApiGet,
|
||||||
ServiceComm,
|
ServiceComm,
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
<div *ngIf="dataSourceTable != null else loading">
|
<div *ngIf="dataSourceTable != null else loading">
|
||||||
<table mat-table [dataSource]="dataSourceTable">
|
<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">
|
<ng-container matColumnDef="id">
|
||||||
<th mat-header-cell *matHeaderCellDef>ID</th>
|
<th mat-header-cell *matHeaderCellDef>ID</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.id}}</td>
|
<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 { DropZoneResp } from '../../models/dropzone';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { ServiceApiGet } from '../../services/service-api-get.service';
|
||||||
|
import { ServiceApiPut } from '../../services/service-api-put.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -13,6 +14,7 @@ import { ServiceComm } from '../../services/service-comm.service';
|
|||||||
})
|
})
|
||||||
export class ListOfDzsComponent implements OnInit {
|
export class ListOfDzsComponent implements OnInit {
|
||||||
public displayedColumns: Array<string> = [
|
public displayedColumns: Array<string> = [
|
||||||
|
'isfavorite',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'latitude',
|
'latitude',
|
||||||
@@ -26,7 +28,8 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApiGet: ServiceApiGet,
|
||||||
|
private serviceApiPut: ServiceApiPut,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@@ -35,11 +38,19 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
this.getListOfDropZones();
|
this.getListOfDropZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
getListOfDropZones() {
|
private getListOfDropZones() {
|
||||||
this.serviceApi.getListOfDropZones().subscribe(data => {
|
this.serviceApiGet.getListOfDropZones().subscribe(data => {
|
||||||
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
||||||
this.dataSourceTable.paginator = this.paginator;
|
this.dataSourceTable.paginator = this.paginator;
|
||||||
this.resultsLength = data.length;
|
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 website: string;
|
||||||
public email: string;
|
public email: string;
|
||||||
public type: Array<string>;
|
public type: Array<string>;
|
||||||
|
public isfavorite: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DropZoneReq {
|
export class DropZoneReq {
|
||||||
@@ -26,4 +27,5 @@ export class DropZoneReq {
|
|||||||
public website: string;
|
public website: string;
|
||||||
public email: string;
|
public email: string;
|
||||||
public type: Array<string>;
|
public type: Array<string>;
|
||||||
|
public isfavorite: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import { map } from "rxjs/operators";
|
import { map } from 'rxjs/operators';
|
||||||
import { environment } from "../environments/environment";
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
import { DropZoneResp } from "../models/dropzone";
|
import { DropZoneResp } from '../models/dropzone';
|
||||||
import { JumpResp } from "../models/jump";
|
import { JumpResp } from '../models/jump';
|
||||||
import { AircraftResp } from "../models/aircraft";
|
import { AircraftResp } from '../models/aircraft';
|
||||||
import { JumpTypeResp } from "../models/jumpType";
|
import { JumpTypeResp } from '../models/jumpType';
|
||||||
import { GearResp } from "../models/gear";
|
import { GearResp } from '../models/gear';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
StatsResp,
|
StatsResp,
|
||||||
@@ -17,12 +17,12 @@ import {
|
|||||||
StatsByJumpTypeResp,
|
StatsByJumpTypeResp,
|
||||||
StatsByRigResp,
|
StatsByRigResp,
|
||||||
StatsByYearResp
|
StatsByYearResp
|
||||||
} from "../models/stats";
|
} from '../models/stats';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceApiGet {
|
export class ServiceApiGet {
|
||||||
private readonly headers = new HttpHeaders({
|
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) { }
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
import { JumpReq } from "../models/jump";
|
import { JumpReq } from '../models/jump';
|
||||||
import { environment } from "../environments/environment";
|
import { environment } from '../environments/environment';
|
||||||
import { DateService } from "./date.service";
|
import { DateService } from './date.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceApiPost {
|
export class ServiceApiPost {
|
||||||
private readonly headers = new HttpHeaders({
|
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) { }
|
||||||
@@ -79,7 +79,7 @@ export class ServiceApiPost {
|
|||||||
exitAltitude: defaultExitAltitude,
|
exitAltitude: defaultExitAltitude,
|
||||||
deployAltitude: defaultDeployAltitude,
|
deployAltitude: defaultDeployAltitude,
|
||||||
gearId: selectedRig,
|
gearId: selectedRig,
|
||||||
notes: "",
|
notes: '',
|
||||||
id: 0,
|
id: 0,
|
||||||
jumpDate: jumpDate
|
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