Merge branch 'main' into feature/ajouter

This commit is contained in:
HarmandI 2022-03-21 18:59:04 +01:00
commit 4d93763aa5
4 changed files with 6068 additions and 6123 deletions

12177
db.json

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
<!-- <td>{{products.Catégorie.}}</td> --> <!-- <td>{{products.Catégorie.}}</td> -->
<td>{{products.rating}}</td> <td>{{products.rating}}</td>
<td><a class="bi-pencil-square" routerLink="../modifier"></a></td> <td><a class="bi-pencil-square" routerLink="../modifier"></a></td>
<td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(5)"></td> <td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(products.id)"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -28,8 +28,11 @@ export class PageTableauComponent implements OnInit {
// }) // })
} }
onClickDelete(id: number){ onClickDelete(id: any){
console.log(id); console.log(id);
this.adminService.onClickDelete(id).subscribe((resp) => {
console.log("Suppression successful : ", resp);
});
} }

View File

@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { map, Observable, Subject } from 'rxjs'; import { map, Observable, Subject, tap } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { Plant } from '../models/plant'; import { Plant } from '../models/plant';
@ -40,6 +40,11 @@ export class AdminService {
addPlant(plant: Plant): Observable<any> | void { addPlant(plant: Plant): Observable<any> | void {
return this.httpClient.post(`${this.apiUrl}`, plant); return this.httpClient.post(`${this.apiUrl}`, plant);
} }
onClickDelete(id: number): Observable<any> {
return this.httpClient.delete<any>(`${this.apiUrl}/list_products/${id}`).pipe(
tap(() => this.refreshCollection())
);
}
// getData(): Observable<any[]> { // getData(): Observable<any[]> {
// return this.httpClient.get<any[]>(`${this.apiUrl}/list_products`); // return this.httpClient.get<any[]>(`${this.apiUrl}/list_products`);
// } // }