diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 07ab528..e5e1dc8 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -35,6 +35,14 @@ const routes: Routes = [
path:'service',
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',
loadChildren: () => import('./features/place/place.module').then(m => m.PlaceModule)
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index fba7493..555beef 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -5,6 +5,9 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {LayoutModule} from "./layout/layout.module";
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({
declarations: [
@@ -16,7 +19,10 @@ import {HttpClientModule} from "@angular/common/http";
LayoutModule,
HttpClientModule
],
- providers: [],
+ providers: [
+ CarburantService,
+ UtilisateurService
+ ],
bootstrap: [AppComponent]
})
export class AppModule { }
diff --git a/src/app/features/carburant/carburant.module.ts b/src/app/features/carburant/carburant.module.ts
index c4695de..121d524 100644
--- a/src/app/features/carburant/carburant.module.ts
+++ b/src/app/features/carburant/carburant.module.ts
@@ -15,11 +15,11 @@ const routes: Routes = [
component: CarburantListComponent
},
{
- path: 'edit',
+ path: 'edit/:id',
component: CarburantEditComponent
},
{
- path:'view',
+ path:'view/:id',
component:CarburantViewComponent
}
]
diff --git a/src/app/features/carburant/page/carburant-edit/carburant-edit.component.ts b/src/app/features/carburant/page/carburant-edit/carburant-edit.component.ts
index 3b3fbc2..5264d03 100644
--- a/src/app/features/carburant/page/carburant-edit/carburant-edit.component.ts
+++ b/src/app/features/carburant/page/carburant-edit/carburant-edit.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
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({
selector: 'app-carburant-edit',
@@ -10,16 +11,55 @@ import {Router} from "@angular/router";
export class CarburantEditComponent implements OnInit {
carburant : any = {};
+ id: string = "0";
constructor(private carburantService: CarburantService,
+ private activatedRoute : ActivatedRoute,
private router: Router) { }
ngOnInit(): void {
+ this.id = this.activatedRoute.snapshot.params['id'];
+
+ if(this.id && this.id != "0"){
+ this.getById();
+ }
}
- save() {
- this.carburantService.create(this.carburant).subscribe( {
+ getById(): void{
+ 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)=>{
if(res.success){
this.router.navigateByUrl("/app/carburant").then();
diff --git a/src/app/features/carburant/page/carburant-list/carburant-list.component.html b/src/app/features/carburant/page/carburant-list/carburant-list.component.html
index 3b1823c..916ebab 100644
--- a/src/app/features/carburant/page/carburant-list/carburant-list.component.html
+++ b/src/app/features/carburant/page/carburant-list/carburant-list.component.html
@@ -1,6 +1,16 @@
+
+
+
+ Recherche
+
+
+
+
Filtre pard ta
+
+
-
+
@@ -11,15 +21,16 @@
|
-
+
- {{product.type}} |
- {{product.prix}} |
+ {{carburant.type}} |
+ {{carburant.prix}} |
-
-
-
+
+
+
|
+
diff --git a/src/app/features/carburant/page/carburant-list/carburant-list.component.ts b/src/app/features/carburant/page/carburant-list/carburant-list.component.ts
index c9ba0da..a638230 100644
--- a/src/app/features/carburant/page/carburant-list/carburant-list.component.ts
+++ b/src/app/features/carburant/page/carburant-list/carburant-list.component.ts
@@ -9,17 +9,28 @@ import {CarburantService} from "../../service/carburant.service";
})
export class CarburantListComponent implements OnInit {
carburants: any[] = [];
+ //1. filter
+ searchTerm : string = "";
+ params : any = {};
+
+ //2. table
+
constructor(private router: Router,
private carburantService: CarburantService) {
}
ngOnInit(): void {
- this.getServices();
+ this.params.search = "";
+ this.params.fields = ["type", "prix"];
+ this.params.page = 1;
+ this.params.limit = 5;
+ this.getCarburants();
}
- getServices() {
- this.carburantService.getAll().subscribe({
+ getCarburants() {
+
+ this.carburantService.getAll(this.params).subscribe({
next: (res) => {
if (res.success) {
this.carburants = res.data;
@@ -28,16 +39,27 @@ export class CarburantListComponent implements OnInit {
})
}
- edit(): void {
- /*
- let vehicle : any = {};
- vehicle.model = "RangeRoger";
- vehicle.mark = "Sport";
- vehicle.matricule = "535353";
-
- this.vehicles.push(vehicle);
- */
- this.router.navigateByUrl('/app/carburant/edit').then();
+ edit(_id: string): void {
+ this.router.navigateByUrl('/app/carburant/edit/'+_id).then();
+ }
+ view(_id: string): void {
+ this.router.navigateByUrl('/app/carburant/view/'+_id).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()
+ }
}
diff --git a/src/app/features/carburant/page/carburant-view/carburant-view.component.html b/src/app/features/carburant/page/carburant-view/carburant-view.component.html
index 8f0cd28..eb204dd 100644
--- a/src/app/features/carburant/page/carburant-view/carburant-view.component.html
+++ b/src/app/features/carburant/page/carburant-view/carburant-view.component.html
@@ -1 +1,14 @@
-carburant-view works!
+
+
+
+
+ {{carburant.type }}
+
+
+ {{carburant.prix}}
+
+
+
+
+
+
diff --git a/src/app/features/carburant/page/carburant-view/carburant-view.component.ts b/src/app/features/carburant/page/carburant-view/carburant-view.component.ts
index 5ffa176..c878108 100644
--- a/src/app/features/carburant/page/carburant-view/carburant-view.component.ts
+++ b/src/app/features/carburant/page/carburant-view/carburant-view.component.ts
@@ -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({
selector: 'app-carburant-view',
@@ -6,10 +8,39 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./carburant-view.component.scss']
})
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 {
+ 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)=>{
+
+ }
+ })
+ }
+
+
+
+
+
}
diff --git a/src/app/features/carburant/service/carburant.service.ts b/src/app/features/carburant/service/carburant.service.ts
index f833e07..34e45ff 100644
--- a/src/app/features/carburant/service/carburant.service.ts
+++ b/src/app/features/carburant/service/carburant.service.ts
@@ -10,8 +10,8 @@ export class CarburantService {
url: string = "carburant"
constructor(private http: HttpClient) { }
- getAll():Observable{
- return this.http.get(apiRoute+this.url);
+ getAll(params:any):Observable{
+ return this.http.get(apiRoute+this.url, {params});
}
getById(id: string):Observable {
diff --git a/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.html b/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.html
index 3bbbb1d..e90abaa 100644
--- a/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.html
+++ b/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.html
@@ -1,18 +1,16 @@
+
+
diff --git a/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.ts b/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.ts
index 81d80ec..9ed666b 100644
--- a/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.ts
+++ b/src/app/features/utilisateur/page/utilisateur-edit/utilisateur-edit.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import {UtilisateurService} from "../../service/utilisateur.service";
-import {Router} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-utilisateur-edit',
@@ -9,22 +9,63 @@ import {Router} from "@angular/router";
})
export class UtilisateurEditComponent implements OnInit {
- utilisateur : any = {};
+ utilisateur: any = {};
+ id: string = "0";
constructor(private utilisateurService: UtilisateurService,
- private router: Router) { }
+ private activatedRoute: ActivatedRoute,
+ private router: Router) {
+ }
ngOnInit(): void {
+ this.id = this.activatedRoute.snapshot.params['id'];
+
+ if (this.id && this.id != "0") {
+ this.getById();
+ }
}
- save() {
- this.utilisateurService.create(this.utilisateur).subscribe( {
- next: (res)=>{
- if(res.success){
+ getById(): void {
+ this.utilisateurService.getById(this.id).subscribe({
+ next: (res) => {
+ 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();
}
}
})
}
+
+ update(utilisateur: any): void {
+ this.utilisateurService.update(utilisateur).subscribe({
+ next: (res) => {
+ if (res.success) {
+ this.router.navigateByUrl("/app/utilisateur").then();
+ }
+ }
+ })
+ }
+
}
diff --git a/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.html b/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.html
index e13649a..1cdbc01 100644
--- a/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.html
+++ b/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.html
@@ -1,28 +1,39 @@
+
+
+
+ Recherche
+
+
+
+
Filtre pard ta
+
+
+
-
+
Nom |
- Prénom |
+ Prenom |
Pays |
Ville |
|
-
+
- {{product.nom}} |
- {{product.prenom}} |
- {{product.pays}} |
- {{product.ville}} |
+ {{utilisateur.name}} |
+ {{utilisateur.fistname}} |
+ {{utilisateur.country}} |
+ {{utilisateur.city}} |
-
-
-
+
+
+
|
diff --git a/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.ts b/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.ts
index 730574f..13be586 100644
--- a/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.ts
+++ b/src/app/features/utilisateur/page/utilisateur-list/utilisateur-list.component.ts
@@ -8,18 +8,30 @@ import {UtilisateurService} from "../../service/utilisateur.service";
styleUrls: ['./utilisateur-list.component.scss']
})
export class UtilisateurListComponent implements OnInit {
- utilisateurs: any[] = [];
+
+ //1. filter
+ searchTerm : string = "";
+ params : any = {};
+
+ //2. table
+
+ utilisateurs: any[] = [];
constructor(private router: Router,
private utilisateurService: UtilisateurService) {
}
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() {
- this.utilisateurService.getAll().subscribe({
+ getUtilisateurs() {
+
+ this.utilisateurService.getAll(this.params).subscribe({
next: (res) => {
if (res.success) {
this.utilisateurs = res.data;
@@ -28,16 +40,27 @@ export class UtilisateurListComponent implements OnInit {
})
}
- edit(): void {
- /*
- let vehicle : any = {};
- vehicle.model = "RangeRoger";
- vehicle.mark = "Sport";
- vehicle.matricule = "535353";
-
- this.vehicles.push(vehicle);
- */
- this.router.navigateByUrl('/app/utilisateur/edit').then();
+ edit(_id: string): void {
+ this.router.navigateByUrl('/app/utilisateur/edit/'+_id).then();
+ }
+ view(_id: string): void {
+ this.router.navigateByUrl('/app/utilisateur/view/'+_id).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()
+ }
}
diff --git a/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.html b/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.html
index b1a8fdb..110f8ad 100644
--- a/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.html
+++ b/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.html
@@ -1 +1,18 @@
-utilisateur-view works!
+
+
+
+ {{utilisateur.name }}
+
+
+ {{utilisateur.firstname}}
+
+ {{utilisateur.country}}
+
+ {{utilisateur.city}}
+
+
+
+
+
+
+
diff --git a/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.ts b/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.ts
index ed85bdb..44c87ff 100644
--- a/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.ts
+++ b/src/app/features/utilisateur/page/utilisateur-view/utilisateur-view.component.ts
@@ -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({
selector: 'app-utilisateur-view',
@@ -6,10 +9,39 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./utilisateur-view.component.scss']
})
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 {
+ 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)=>{
+
+ }
+ })
+ }
+
+
+
+
+
}
diff --git a/src/app/features/utilisateur/service/utilisateur.service.ts b/src/app/features/utilisateur/service/utilisateur.service.ts
index c27a09f..d5d2540 100644
--- a/src/app/features/utilisateur/service/utilisateur.service.ts
+++ b/src/app/features/utilisateur/service/utilisateur.service.ts
@@ -10,8 +10,8 @@ export class UtilisateurService {
url: string = "utilisateur"
constructor(private http: HttpClient) { }
- getAll():Observable{
- return this.http.get(apiRoute+this.url);
+ getAll(params:any):Observable{
+ return this.http.get(apiRoute+this.url, {params});
}
getById(id: string):Observable {
@@ -23,7 +23,7 @@ export class UtilisateurService {
}
update(utilisateur: any):Observable{
- return this.http.put(apiRoute+this.url+ "/"+utilisateur.id,utilisateur);
+ return this.http.put(apiRoute+this.url+ "/"+utilisateur._id,utilisateur);
}
delete(id: string):Observable{
diff --git a/src/app/features/utilisateur/utilisateur.module.ts b/src/app/features/utilisateur/utilisateur.module.ts
index 0d2ba4f..d328e75 100644
--- a/src/app/features/utilisateur/utilisateur.module.ts
+++ b/src/app/features/utilisateur/utilisateur.module.ts
@@ -15,11 +15,11 @@ const routes: Routes = [
component: UtilisateurListComponent
},
{
- path: 'edit',
+ path: 'edit/:id',
component: UtilisateurEditComponent
},
{
- path:'view',
+ path:'view/:id',
component:UtilisateurViewComponent
}
]
diff --git a/src/app/features/vehicle/page/vehicle-list/vehicle-list.component.html b/src/app/features/vehicle/page/vehicle-list/vehicle-list.component.html
index f1f96b4..a721ea7 100644
--- a/src/app/features/vehicle/page/vehicle-list/vehicle-list.component.html
+++ b/src/app/features/vehicle/page/vehicle-list/vehicle-list.component.html
@@ -6,8 +6,7 @@
-
- Filtre par date
+ Filtre pard ta
diff --git a/src/app/layout/layout.component.html b/src/app/layout/layout.component.html
index a5eac7b..44a016b 100644
--- a/src/app/layout/layout.component.html
+++ b/src/app/layout/layout.component.html
@@ -15,8 +15,8 @@
Service
-
- Carburant
+
+ Carburant
Problème
@@ -28,7 +28,8 @@
Contact
- Utilisateur
+
+ Utilisateur