Compare commits

...

13 Commits

Author SHA1 Message Date
Sana EL HIRI
adfd1db2ff correction jeremy 2022-03-22 14:54:07 +01:00
HarmandI
d09b147af2
Merge pull request #8 from HarmandI/feature/supprimer
Feature/supprimer
2022-03-22 12:55:35 +01:00
HarmandI
4aced57191 der des der? 2022-03-22 12:54:31 +01:00
Vincent Ramiere
a2ddf52c88 lien Page administrateur dans navbar 2022-03-22 12:52:32 +01:00
Vincent Ramiere
200221dc5c lien admin dans navbar 2022-03-22 12:49:35 +01:00
Sana
4f5e6cd180
Merge pull request #7 from HarmandI/css
css
2022-03-22 12:38:08 +01:00
Sana EL HIRI
33c431921d css 2022-03-22 12:36:25 +01:00
Vincent Ramiere
bd4468a9d6 Merge branch 'main' of https://github.com/HarmandI/Admin-La-Belle-Plante
pull
2022-03-22 12:14:04 +01:00
Vincent Ramiere
983533e4e1 Merge branch 'main' into feature/supprimer 2022-03-22 12:11:34 +01:00
HarmandI
a2cf4f55ed
Merge pull request #6 from HarmandI/feature/ajouter
Feature/ajouter
2022-03-22 12:09:42 +01:00
HarmandI
49edb1782d derniere? 2022-03-22 12:08:27 +01:00
HarmandI
be9e510a94 erreur 2022-03-22 11:47:05 +01:00
HarmandI
a99dbc57ab
Merge pull request #5 from HarmandI/feature/modifier-plante
Feature/modifier plante
2022-03-22 11:45:31 +01:00
12 changed files with 128 additions and 72 deletions

25
db.json
View File

@ -5983,6 +5983,31 @@
"product_image_source": "https://images.truffaut.com/media/catalog/product/cdn:///Articles/jpg/0832000/832900_001.jpg", "product_image_source": "https://images.truffaut.com/media/catalog/product/cdn:///Articles/jpg/0832000/832900_001.jpg",
"product_seller": "Truffaut", "product_seller": "Truffaut",
"product_web_only": "oui" "product_web_only": "oui"
},
{
"id": "JbdahUA",
"product_name": "bibi",
"product_price": "8",
"product_qty": 5,
"product_rating": 5,
"product_breadcrumb_label": "plantes fleuries",
"product_instock": [
[
"non disponible"
]
],
"product_url_picture": "https//picsum.photos/id/18/200/300",
"product_discount_code": "",
"product_color": "",
"product_unitprice_ati": "",
"product_unitprice_tf": "",
"product_discount_tf": "",
"product_discount_ati": "",
"product_url_page": "",
"product_shipping_method": null,
"product_image_source": "",
"product_seller": "market place",
"product_web_only": "non"
} }
], ],
"users": [ "users": [

View File

@ -1,12 +1,12 @@
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light shadow "> <nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light shadow ">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">🪴 La Belle Plante</a> <a class="navbar-brand" href="#">🪴 La Belle Plante</a>
<button class="navbar-toggler" <button class="navbar-toggler"
type="button" type="button"
data-bs-toggle="collapse" data-bs-toggle="collapse"
data-bs-target="#navbarNavAltMarkup" data-bs-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-controls="navbarNavAltMarkup"
aria-expanded="false" aria-expanded="false"
aria-label="Toggle navigation"> aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -21,6 +21,7 @@
<a class="nav-link disabled" *ngIf="likeCounter == 0"> Pas de plante likée</a> <a class="nav-link disabled" *ngIf="likeCounter == 0"> Pas de plante likée</a>
<a class="nav-link disabled" *ngIf="likeCounter == 1">Plante likée : {{ likeCounter }}</a> <a class="nav-link disabled" *ngIf="likeCounter == 1">Plante likée : {{ likeCounter }}</a>
<a class="nav-link disabled" *ngIf="likeCounter > 1">Plantes likées : {{ likeCounter }}</a> <a class="nav-link disabled" *ngIf="likeCounter > 1">Plantes likées : {{ likeCounter }}</a>
<a routerLink="admin" routerLinkActive="active-custom" class="nav-link">Page administrateur</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,8 +13,8 @@
margin-right: auto; margin-right: auto;
border: solid 1px; border: solid 1px;
border-radius: 10px; border-radius: 10px;
background-color: #64c982; background-color: #306340;
border-color: #64c982; border-color: #306340;
} }
.form-plant .checkbox { .form-plant .checkbox {
@ -70,6 +70,6 @@
.btn-outline-success { .btn-outline-success {
margin-top: 10px; margin-top: 10px;
background-color: #ffff; background-color: #ffff;
color: #64c982 !important; color: #306340 !important;
border-color: #64c982 !important; border-color: #306340 !important;
} }

View File

@ -1,5 +1,3 @@
import { Category } from "./category";
export class Plant { export class Plant {
constructor( constructor(
public name: string='', public name: string='',
@ -9,6 +7,6 @@ export class Plant {
public category:string[]=['plantes fleuries','orchides','cactus et plantes grasses','bonsas','plantes vertes','palmier dintrieur'], public category:string[]=['plantes fleuries','orchides','cactus et plantes grasses','bonsas','plantes vertes','palmier dintrieur'],
public urlPicture: string = "https//picsum.photos/id/18/200/300", public urlPicture: string = "https//picsum.photos/id/18/200/300",
public rating: number = 0, public rating: number = 0,
public id?: string public id: string = ''
){} ){}
} }

View File

@ -1,2 +1,2 @@
<h1>Ajouter une plante</h1> <h1>Ajouter une plante</h1>
<app-formulaire [buttonLabel]="'Ajouter une plante'"></app-formulaire> <app-formulaire [plantInfos]="newplant" (submitted)="addPlant($event)" [buttonLabel]="'Ajouter une plante'"></app-formulaire>

View File

@ -1,4 +1,6 @@
h1{ h1{
display: flex;
justify-content: center;
color: rgba(0, 0, 0, 0.658); color: rgba(0, 0, 0, 0.658);
font-size: 28px; font-size: 28px;
margin-top: 20px; margin-top: 20px;

View File

@ -19,43 +19,49 @@ import { AdminService } from '../../services/admin.service';
styleUrls: ['./page-ajouter.component.scss'], styleUrls: ['./page-ajouter.component.scss'],
}) })
export class PageAjouterComponent implements OnInit { export class PageAjouterComponent implements OnInit {
public plantForm: FormGroup; public newplant = new Plant();
public isAdd: boolean = false;
constructor(private fb: FormBuilder, private router: Router, private adminService: AdminService) { constructor(private fb: FormBuilder, private router: Router, private adminService: AdminService) {
this.plantForm = new FormGroup({});
this.isAdd = false;
} }
ngOnInit(): void { ngOnInit(): void {
} }
public onSubmit(): void { public addPlant(plant: any): void {
const nameValue = this.plantForm.value['nameFC']; const nameValue = plant.nameFc;
const priceValue = this.plantForm.value['priceFc']; const priceValue = plant.priceFc;
const quantityValue = this.plantForm.value['quantityFc']; const ratingValue = plant.ratingFc;
const inStockValue = this.plantForm.value['inStockFC']; const quantityValue = plant.quantityFc;
const categoryValue = this.plantForm.value['categotyFC']; const categoryValue = plant.categoryFc;
const urlPicture: string = 'https//picsum.photos/id/18/200/300'; const inStockValue = plant.inStockFc;
const ratingValue = this.plantForm.value['ratingFc'];
const idValue = this.plantForm.value[''];
const plant : Plant = { const plante: any = {
name: nameValue, product_name: nameValue,
price: priceValue, product_price: priceValue,
quantity: quantityValue, product_qty: quantityValue,
inStock: [inStockValue], product_rating: ratingValue,
category: [categoryValue], product_breadcrumb_label: categoryValue,
urlPicture: 'https//picsum.photos/id/18/200/300', product_instock: [inStockValue],
rating: ratingValue, product_url_picture : "https//picsum.photos/id/18/200/300",
id: idValue, product_discount_code : "",
product_color: "",
product_unitprice_ati: "",
product_unitprice_tf: "",
product_discount_tf: "",
product_discount_ati: "",
product_url_page: "",
product_shipping_method: null,
product_image_source: "",
product_seller: "market place",
product_web_only: "non"
}; };
console.log("coco",plant);
this.adminService.addPlant(plant)?.subscribe((resp)=>{ this.adminService.addPlant(plante)?.subscribe((resp)=>{
this.router.navigate(['admin']);
}) })
this.router.navigate(['admin']);
} }
} }

View File

@ -1,4 +1,6 @@
h1{ h1{
display: flex;
justify-content: center;
color: rgba(0, 0, 0, 0.658); color: rgba(0, 0, 0, 0.658);
font-size: 28px; font-size: 28px;
margin-top: 20px; margin-top: 20px;

View File

@ -1,30 +1,35 @@
<table class="table" *ngIf="subCollection$ | async as collection"> <div id="container">
<thead class="thead-dark"> <div id="button">
<tr> <button class="w-100 btn btn-lg btn-outline-success" routerLink="../ajouter">Ajouter une plante </button>
<th scope="col">Id</th> </div>
<th scope="col">Nom</th> <table class="table" *ngIf="subCollection$ | async as collection">
<th scope="col">Prix</th> <thead class="thead-dark" style="background-color: #306340 ; color:#f3f7f4 ;">
<th scope="col">Quantité</th> <tr>
<th scope="col">En stock</th> <th scope="col">Id</th>
<th scope="col">Catégorie</th> <th scope="col">Nom</th>
<th scope="col">Note</th> <th scope="col">Prix</th>
<th scope="col">Modifier</th> <th scope="col">Quantité</th>
<th scope="col">Supprimer</th> <th scope="col">En stock</th>
<th scope="col">Catégorie</th>
<th scope="col">Note</th>
<th scope="col">Modifier</th>
<th scope="col">Supprimer</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let products of collection">
<td>{{products.id}}</td>
<td>{{products.name}}</td>
<td>{{products.price}}</td>
<td>{{products.quantity}}</td>
<td>{{products.inStock}}</td>
<td>{{products.category}}</td>
<td>{{products.rating}}</td>
<td><a class="bi-pencil-square" style="color: #5472b1;" routerLink="../modifier/{{products.id}}"></a></td>
<td class="bi-trash-fill" style="color: rgb(231, 73, 73); cursor: pointer;" (click)="onClickDelete(products.id)"></td>
</tr>
</tbody>
</table>
</div>
</tr>
</thead>
<tbody>
<tr *ngFor="let products of collection">
<th scope="row">{{products.id}}</th>
<td>{{products.name}}</td>
<td>{{products.price}}</td>
<td>{{products.quantity}}</td>
<td>{{products.inStock}}</td>
<td>{{products.category}}</td>
<td>{{products.rating}}</td>
<td><a class="bi-pencil-square" routerLink="../modifier/{{products.id}}"></a></td>
<td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(products.id)"></td>
</tr>
</tbody>
</table>
<button routerLink="../ajouter">Ajouter une plante </button>

View File

@ -0,0 +1,19 @@
#container{
display: flex;
justify-content: center;
margin-top: 5rem;
}
table{
width: 75%;
margin-left: 2rem;
}
button{
background-color: #306340;
color: #f3f7f4 !important;
border-color: #306340 !important;
}
#button{
width: 10%;
}

View File

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

View File

@ -31,16 +31,15 @@ export class AdminService {
public refreshCollection(): void { public refreshCollection(): void {
// On se sert de notre flux de donnée type observable froid // On se sert de notre flux de donnée type observable froid
this.collection$.subscribe((listPlant: Plant[]) => { this.collection$.subscribe((listPlant: Plant[]) => {
this.plantCollection = [...listPlant];
// Utiliser un observable chaud (subject) pour nexter nos données recues de notre observable froid // Utiliser un observable chaud (subject) pour nexter nos données recues de notre observable froid
this.subCollection$.next(listPlant); this.subCollection$.next(listPlant);
}) })
} }
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}/list_products`, plant);
} }
onClickDelete(id: number): Observable<any> { onClickDelete(id: string): Observable<any> {
return this.httpClient.delete<any>(`${this.apiUrl}/list_products/${id}`).pipe( return this.httpClient.delete<any>(`${this.apiUrl}/list_products/${id}`).pipe(
tap(() => this.refreshCollection()) tap(() => this.refreshCollection())
); );