first commit riche

master^2
Richedman 2024-08-23 16:39:09 +02:00
parent da745b3688
commit 6a74efb462
19 changed files with 342 additions and 89 deletions

View File

@ -35,6 +35,14 @@ const routes: Routes = [
path:'service', path:'service',
loadChildren: () => import('./features/service/service.module').then(m => m.ServiceModule) loadChildren: () => import('./features/service/service.module').then(m => m.ServiceModule)
}, },
{
path:'carburant',
loadChildren: () => import('./features/carburant/carburant.module').then(m => m.CarburantModule)
},
{
path:'utilisateur',
loadChildren: () => import('./features/utilisateur/utilisateur.module').then(m => m.UtilisateurModule)
},
{ {
path:'place', path:'place',
loadChildren: () => import('./features/place/place.module').then(m => m.PlaceModule) loadChildren: () => import('./features/place/place.module').then(m => m.PlaceModule)

View File

@ -5,6 +5,9 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import {LayoutModule} from "./layout/layout.module"; import {LayoutModule} from "./layout/layout.module";
import {HttpClientModule} from "@angular/common/http"; import {HttpClientModule} from "@angular/common/http";
import {CarburantService} from "./features/carburant/service/carburant.service";
import {CarburantModule} from "./features/carburant/carburant.module";
import {UtilisateurService} from "./features/utilisateur/service/utilisateur.service";
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -16,7 +19,10 @@ import {HttpClientModule} from "@angular/common/http";
LayoutModule, LayoutModule,
HttpClientModule HttpClientModule
], ],
providers: [], providers: [
CarburantService,
UtilisateurService
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

View File

@ -15,11 +15,11 @@ const routes: Routes = [
component: CarburantListComponent component: CarburantListComponent
}, },
{ {
path: 'edit', path: 'edit/:id',
component: CarburantEditComponent component: CarburantEditComponent
}, },
{ {
path:'view', path:'view/:id',
component:CarburantViewComponent component:CarburantViewComponent
} }
] ]

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {CarburantService} from "../../service/carburant.service"; import {CarburantService} from "../../service/carburant.service";
import {Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {VehicleService} from "../../../vehicle/service/vehicle.service";
@Component({ @Component({
selector: 'app-carburant-edit', selector: 'app-carburant-edit',
@ -10,16 +11,55 @@ import {Router} from "@angular/router";
export class CarburantEditComponent implements OnInit { export class CarburantEditComponent implements OnInit {
carburant : any = {}; carburant : any = {};
id: string = "0";
constructor(private carburantService: CarburantService, constructor(private carburantService: CarburantService,
private activatedRoute : ActivatedRoute,
private router: Router) { } private router: Router) { }
ngOnInit(): void { ngOnInit(): void {
this.id = this.activatedRoute.snapshot.params['id'];
if(this.id && this.id != "0"){
this.getById();
}
} }
save() { getById(): void{
this.carburantService.create(this.carburant).subscribe( { this.carburantService.getById(this.id).subscribe({
next :(res)=>{
if(res.success){
this.carburant = res.data;
}
},
error:(err)=>{
}
})
}
save(): void {
if(this.id == "0"){
this.create(this.carburant);
}else {
this.update(this.carburant);
}
}
create(carburant: any): void{
this.carburantService.create(carburant).subscribe( {
next: (res)=>{
if(res.success){
this.router.navigateByUrl("/app/carburant").then();
}
}
})
}
update(carburant: any): void {
this.carburantService.update(carburant).subscribe( {
next: (res)=>{ next: (res)=>{
if(res.success){ if(res.success){
this.router.navigateByUrl("/app/carburant").then(); this.router.navigateByUrl("/app/carburant").then();

View File

@ -1,6 +1,16 @@
<div>
<div style="display: inline-flex">
<div style="">
Recherche <br>
<input type="text" pInputText [(ngModel)]="searchTerm" (ngModelChange)="search()" />
</div>
<div style="margin-left: 10px">Filtre pard ta</div>
</div>
<div style="text-align: right; margin-bottom :10px"> <div style="text-align: right; margin-bottom :10px">
<button (click)="edit()" pButton type="button" label="Commandez le carburant"></button> <button (click)="edit('0')" pButton type="button" label="Commandez le carburant"></button>
</div> </div>
<p-table [value]="carburants" [tableStyle]="{'min-width': '50rem'}"> <p-table [value]="carburants" [tableStyle]="{'min-width': '50rem'}">
@ -11,15 +21,16 @@
<th></th> <th></th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-product> <ng-template pTemplate="body" let-carburant>
<tr> <tr>
<td>{{product.type}}</td> <td>{{carburant.type}}</td>
<td>{{product.prix}}</td> <td>{{carburant.prix}}</td>
<td> <td>
<i class="pi pi-pencil" style="margin-right: 10px"></i> <i (click)="edit(carburant._id)" class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i> <i (click)="delete(carburant._id)" class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i> <i (click)="view(carburant._id)" class="pi pi-eye" style="margin-right: 10px"></i>
</td> </td>
</tr> </tr>
</ng-template> </ng-template>
</p-table> </p-table>
</div>

View File

@ -9,17 +9,28 @@ import {CarburantService} from "../../service/carburant.service";
}) })
export class CarburantListComponent implements OnInit { export class CarburantListComponent implements OnInit {
carburants: any[] = []; carburants: any[] = [];
//1. filter
searchTerm : string = "";
params : any = {};
//2. table
constructor(private router: Router, constructor(private router: Router,
private carburantService: CarburantService) { private carburantService: CarburantService) {
} }
ngOnInit(): void { ngOnInit(): void {
this.getServices(); this.params.search = "";
this.params.fields = ["type", "prix"];
this.params.page = 1;
this.params.limit = 5;
this.getCarburants();
} }
getServices() { getCarburants() {
this.carburantService.getAll().subscribe({
this.carburantService.getAll(this.params).subscribe({
next: (res) => { next: (res) => {
if (res.success) { if (res.success) {
this.carburants = res.data; this.carburants = res.data;
@ -28,16 +39,27 @@ export class CarburantListComponent implements OnInit {
}) })
} }
edit(): void { edit(_id: string): void {
/* this.router.navigateByUrl('/app/carburant/edit/'+_id).then();
let vehicle : any = {}; }
vehicle.model = "RangeRoger"; view(_id: string): void {
vehicle.mark = "Sport"; this.router.navigateByUrl('/app/carburant/view/'+_id).then();
vehicle.matricule = "535353";
this.vehicles.push(vehicle);
*/
this.router.navigateByUrl('/app/carburant/edit').then();
} }
protected readonly visualViewport = visualViewport;
delete(_id: string): void {
this.carburantService.delete(_id).subscribe({
next: (res)=>{
if(res.success){
this.getCarburants();
}
}
})
}
search() {
this.params.search = this.searchTerm;
this.getCarburants()
}
} }

View File

@ -1 +1,14 @@
<p>carburant-view works!</p>
<div>
<div>
<label>Type</label><br>
<strong>{{carburant.type }}</strong>
<br><br>
<label>Prix</label><br>
{{carburant.prix}}
<br><br>
</div>
<br><br>
</div>

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core'; import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {CarburantService} from "../../../carburant/service/carburant.service";
import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-carburant-view', selector: 'app-carburant-view',
@ -6,10 +8,39 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./carburant-view.component.scss'] styleUrls: ['./carburant-view.component.scss']
}) })
export class CarburantViewComponent implements OnInit { export class CarburantViewComponent implements OnInit {
carburant : any = {};
id: string = "0";
constructor() { } constructor(private carburantService: CarburantService,
private activatedRoute : ActivatedRoute,
private cdr: ChangeDetectorRef,
private router: Router) { }
ngOnInit(): void { ngOnInit(): void {
this.id = this.activatedRoute.snapshot.params['id'];
if(this.id && this.id != "0"){
this.getById();
}
} }
getById(): void{
this.carburantService.getById(this.id).subscribe({
next :(res)=>{
if(res.success){
this.carburant = res.data;
this.cdr.detectChanges();
}
},
error:(err)=>{
}
})
}
} }

View File

@ -10,8 +10,8 @@ export class CarburantService {
url: string = "carburant" url: string = "carburant"
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
getAll():Observable<any>{ getAll(params:any):Observable<any>{
return this.http.get<any>(apiRoute+this.url); return this.http.get<any>(apiRoute+this.url, {params});
} }
getById(id: string):Observable<any> { getById(id: string):Observable<any> {

View File

@ -1,18 +1,16 @@
<div> <div>
<div> <div>
<label>Nom</label> <label>Nom</label><br>
<input [(ngModel)]="utilisateur.nom" type="text" pInputText /> <input [(ngModel)]="utilisateur.name" type="text" pInputText />
<br> <br><br>
<label>Prenom</label> <label>Prenom</label><br>
<input [(ngModel)]="utilisateur.prenom" type="text" pInputText /> <input [(ngModel)]="utilisateur.firstname" type="text" pInputText />
<br> <br><br>
<label>pays</label> <label>Pays</label><br>
<input [(ngModel)]="utilisateur.pays" type="text" pInputText /> <input [(ngModel)]="utilisateur.country" type="text" pInputText />
<br>
<label>ville</label>
<input [(ngModel)]="utilisateur.ville" type="text" pInputText />
<br>
<button (click)="save()" pButton type="button" label="Enregistrer"></button>
</div> </div>
<label>Ville</label><br>
<input [(ngModel)]="utilisateur.city" type="text" pInputText />
</div> </div>
<br><br>
<button (click)="save()" pButton type="button" label="Enregistrer"></button>

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {UtilisateurService} from "../../service/utilisateur.service"; import {UtilisateurService} from "../../service/utilisateur.service";
import {Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-utilisateur-edit', selector: 'app-utilisateur-edit',
@ -9,22 +9,63 @@ import {Router} from "@angular/router";
}) })
export class UtilisateurEditComponent implements OnInit { export class UtilisateurEditComponent implements OnInit {
utilisateur : any = {}; utilisateur: any = {};
id: string = "0";
constructor(private utilisateurService: UtilisateurService, constructor(private utilisateurService: UtilisateurService,
private router: Router) { } private activatedRoute: ActivatedRoute,
private router: Router) {
}
ngOnInit(): void { ngOnInit(): void {
this.id = this.activatedRoute.snapshot.params['id'];
if (this.id && this.id != "0") {
this.getById();
}
} }
save() { getById(): void {
this.utilisateurService.create(this.utilisateur).subscribe( { this.utilisateurService.getById(this.id).subscribe({
next: (res)=>{ next: (res) => {
if(res.success){ if (res.success) {
this.utilisateur = res.data;
}
},
error: (err) => {
}
})
}
save(): void {
if (this.id == "0") {
this.create(this.utilisateur);
} else {
this.update(this.utilisateur);
}
}
create(utilisateur: any): void {
this.utilisateurService.create(utilisateur).subscribe({
next: (res) => {
if (res.success) {
this.router.navigateByUrl("/app/utilisateur").then(); this.router.navigateByUrl("/app/utilisateur").then();
} }
} }
}) })
} }
update(utilisateur: any): void {
this.utilisateurService.update(utilisateur).subscribe({
next: (res) => {
if (res.success) {
this.router.navigateByUrl("/app/utilisateur").then();
}
}
})
}
} }

View File

@ -1,28 +1,39 @@
<div>
<div style="display: inline-flex">
<div style="">
Recherche <br>
<input type="text" pInputText [(ngModel)]="searchTerm" (ngModelChange)="search()" />
</div>
<div style="margin-left: 10px">Filtre pard ta</div>
</div>
</div>
<div style="text-align: right; margin-bottom :10px"> <div style="text-align: right; margin-bottom :10px">
<button (click)="edit()" pButton type="button" label="Veuillez insérer vos informations"></button> <button (click)="edit('0')" pButton type="button" label="Insérez vos informations"></button>
</div> </div>
<p-table [value]="utilisateurs" [tableStyle]="{'min-width': '50rem'}"> <p-table [value]="utilisateurs" [tableStyle]="{'min-width': '50rem'}">
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>Nom</th> <th>Nom</th>
<th>Prénom</th> <th>Prenom</th>
<th>Pays</th> <th>Pays</th>
<th>Ville</th> <th>Ville</th>
<th></th> <th></th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-product> <ng-template pTemplate="body" let-utilisateur>
<tr> <tr>
<td>{{product.nom}}</td> <td>{{utilisateur.name}}</td>
<td>{{product.prenom}}</td> <td>{{utilisateur.fistname}}</td>
<td>{{product.pays}}</td> <td>{{utilisateur.country}}</td>
<td>{{product.ville}}</td> <td>{{utilisateur.city}}</td>
<td> <td>
<i class="pi pi-pencil" style="margin-right: 10px"></i> <i (click)="edit(utilisateur._id)" class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i> <i (click)="delete(utilisateur._id)" class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i> <i (click)="view(utilisateur._id)" class="pi pi-eye" style="margin-right: 10px"></i>
</td> </td>
</tr> </tr>
</ng-template> </ng-template>

View File

@ -8,18 +8,30 @@ import {UtilisateurService} from "../../service/utilisateur.service";
styleUrls: ['./utilisateur-list.component.scss'] styleUrls: ['./utilisateur-list.component.scss']
}) })
export class UtilisateurListComponent implements OnInit { export class UtilisateurListComponent implements OnInit {
utilisateurs: any[] = [];
//1. filter
searchTerm : string = "";
params : any = {};
//2. table
utilisateurs: any[] = [];
constructor(private router: Router, constructor(private router: Router,
private utilisateurService: UtilisateurService) { private utilisateurService: UtilisateurService) {
} }
ngOnInit(): void { ngOnInit(): void {
this.getServices(); this.params.search = "";
this.params.fields = ["name", "firstname", "country", "city"];
this.params.page = 1;
this.params.limit = 5;
this.getUtilisateurs();
} }
getServices() { getUtilisateurs() {
this.utilisateurService.getAll().subscribe({
this.utilisateurService.getAll(this.params).subscribe({
next: (res) => { next: (res) => {
if (res.success) { if (res.success) {
this.utilisateurs = res.data; this.utilisateurs = res.data;
@ -28,16 +40,27 @@ export class UtilisateurListComponent implements OnInit {
}) })
} }
edit(): void { edit(_id: string): void {
/* this.router.navigateByUrl('/app/utilisateur/edit/'+_id).then();
let vehicle : any = {}; }
vehicle.model = "RangeRoger"; view(_id: string): void {
vehicle.mark = "Sport"; this.router.navigateByUrl('/app/utilisateur/view/'+_id).then();
vehicle.matricule = "535353";
this.vehicles.push(vehicle);
*/
this.router.navigateByUrl('/app/utilisateur/edit').then();
} }
protected readonly visualViewport = visualViewport;
delete(_id: string): void {
this.utilisateurService.delete(_id).subscribe({
next: (res)=>{
if(res.success){
this.getUtilisateurs();
}
}
})
}
search() {
this.params.search = this.searchTerm;
this.getUtilisateurs()
}
} }

View File

@ -1 +1,18 @@
<p>utilisateur-view works!</p> <div>
<div>
<label>Nom</label><br>
<strong>{{utilisateur.name }}</strong>
<br><br>
<label>Prenom</label><br>
{{utilisateur.firstname}}
<label>Pays</label><br>
{{utilisateur.country}}
<label>Ville</label><br>
{{utilisateur.city}}
<br><br>
</div>
<br><br>
</div>

View File

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core'; import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {UtilisateurService} from "../../../utilisateur/service/utilisateur.service";
import {ActivatedRoute, Router} from "@angular/router";
import {VehicleService} from "../../../vehicle/service/vehicle.service";
@Component({ @Component({
selector: 'app-utilisateur-view', selector: 'app-utilisateur-view',
@ -6,10 +9,39 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./utilisateur-view.component.scss'] styleUrls: ['./utilisateur-view.component.scss']
}) })
export class UtilisateurViewComponent implements OnInit { export class UtilisateurViewComponent implements OnInit {
utilisateur : any = {};
id: string = "0";
constructor() { } constructor(private utilisateurService: UtilisateurService,
private activatedRoute : ActivatedRoute,
private cdr: ChangeDetectorRef,
private router: Router) { }
ngOnInit(): void { ngOnInit(): void {
this.id = this.activatedRoute.snapshot.params['id'];
if(this.id && this.id != "0"){
this.getById();
}
} }
getById(): void{
this.utilisateurService.getById(this.id).subscribe({
next :(res)=>{
if(res.success){
this.utilisateur = res.data;
this.cdr.detectChanges();
}
},
error:(err)=>{
}
})
}
} }

View File

@ -10,8 +10,8 @@ export class UtilisateurService {
url: string = "utilisateur" url: string = "utilisateur"
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
getAll():Observable<any>{ getAll(params:any):Observable<any>{
return this.http.get<any>(apiRoute+this.url); return this.http.get<any>(apiRoute+this.url, {params});
} }
getById(id: string):Observable<any> { getById(id: string):Observable<any> {
@ -23,7 +23,7 @@ export class UtilisateurService {
} }
update(utilisateur: any):Observable<any>{ update(utilisateur: any):Observable<any>{
return this.http.put<any>(apiRoute+this.url+ "/"+utilisateur.id,utilisateur); return this.http.put<any>(apiRoute+this.url+ "/"+utilisateur._id,utilisateur);
} }
delete(id: string):Observable<any>{ delete(id: string):Observable<any>{

View File

@ -15,11 +15,11 @@ const routes: Routes = [
component: UtilisateurListComponent component: UtilisateurListComponent
}, },
{ {
path: 'edit', path: 'edit/:id',
component: UtilisateurEditComponent component: UtilisateurEditComponent
}, },
{ {
path:'view', path:'view/:id',
component:UtilisateurViewComponent component:UtilisateurViewComponent
} }
] ]

View File

@ -6,8 +6,7 @@
<input type="text" pInputText [(ngModel)]="searchTerm" (ngModelChange)="search()" /> <input type="text" pInputText [(ngModel)]="searchTerm" (ngModelChange)="search()" />
</div> </div>
<div style="margin-left: 10px">Filtre pard ta</div>
<div style="margin-left: 10px">Filtre par date</div>
</div> </div>
</div> </div>

View File

@ -15,8 +15,8 @@
<!-- service --> <!-- service -->
<a routerLink="/app/service"><span><i class="pi-compass"></i>Service</span></a> <a routerLink="/app/service"><span><i class="pi-compass"></i>Service</span></a>
<div class="spacer"></div> <div class="spacer"></div>
<!-- carburant-->
<span>Carburant</span> <a routerLink="/app/carburant"><span>Carburant</span></a>
<div class="spacer"></div> <div class="spacer"></div>
<span><a routerLink="/app/problem">Problème</a></span> <span><a routerLink="/app/problem">Problème</a></span>
<div class="spacer"></div> <div class="spacer"></div>
@ -28,7 +28,8 @@
<div class="spacer"></div> <div class="spacer"></div>
<span><a routerLink="/app/contact">Contact</a></span> <span><a routerLink="/app/contact">Contact</a></span>
<div class="spacer"></div> <div class="spacer"></div>
<span>Utilisateur</span> <!-- utilisateur-->
<a routerLink="/app/utilisateur"><span>Utilisateur</span></a>
<div class="spacer"></div> <div class="spacer"></div>
</div> </div>