diff --git a/src/app/features/place/page/place-edit/place-edit.component.ts b/src/app/features/place/page/place-edit/place-edit.component.ts
index f05ae82..14fbb16 100644
--- a/src/app/features/place/page/place-edit/place-edit.component.ts
+++ b/src/app/features/place/page/place-edit/place-edit.component.ts
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {PlaceService} from "../../service/place.service.service";
-import {Router} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-place-edit',
@@ -10,19 +10,49 @@ import {Router} from "@angular/router";
export class PlaceEditComponent implements OnInit{
place : any = {};
+id:string = "0";
-
- constructor(private placeService: PlaceService,
- private router: Router) { }
+ constructor(private router: Router,
+ private placeService: PlaceService,
+ private activatedRoute : ActivatedRoute,) { }
ngOnInit(): void {
+ this.id = this.activatedRoute.snapshot.params['id'];
+
+ if(this.id && this.id != "0"){
+ this.getById();
}
+
+ }
+
+ getById(): void{
+ this.placeService.getById(this.id).subscribe({
+ next :(res)=>{
+ if(res.success){
+ this.place = res.data;
+ }
+ },
+ error:(err)=>{
+
+ }
+ })
+ }
+
+
+
save() {
+ if(this.id == "0"){
+ this.create(this.place);
+ }else {
+ this.update(this.place);
+ }
+ }
+ create(place: any): void{
this.placeService.create(this.place).subscribe( {
next: (res)=>{
if(res.success){
@@ -31,5 +61,24 @@ export class PlaceEditComponent implements OnInit{
}
})
}
+
+
+ update(service: any): void {
+ this.placeService.update(service).subscribe( {
+ next: (res)=>{
+ if(res.success){
+ this.router.navigateByUrl("/app/place").then();
+ }
+ }
+ })
+ }
+
+
+
}
+
+
+
+
+
diff --git a/src/app/features/place/page/place-liste/place-liste.component.html b/src/app/features/place/page/place-liste/place-liste.component.html
index 961b5d3..1f5f09e 100644
--- a/src/app/features/place/page/place-liste/place-liste.component.html
+++ b/src/app/features/place/page/place-liste/place-liste.component.html
@@ -1,6 +1,19 @@
+
+
+
+ Recherche
+
+
+
+
+
Filtre pard ta
+
+
+
+
-
+
@@ -9,26 +22,26 @@
Etage |
Taille |
Disponibilité |
+ Date sortie |
Vehicule occupé |
Date entrée |
- Date sortie |
Propriétaire |
Action |
-
+
- {{product.etage}} |
- {{product.taille}} |
- {{product.disponibilite}} |
- {{product.vehiculeOccupe}} |
- {{product.dateEntree}} |
- {{product.dateSortie}} |
- {{product.proprietaire}} |
+ {{item.etage}} |
+ {{item.taille}} |
+ {{item.disponibilite}} |
+ {{item.vehiculeOccupe}} |
+ {{item.dateEntree}} |
+ {{item.dateSortie}} |
+ {{item.proprietaire}} |
-
-
-
+
+
+
|
diff --git a/src/app/features/place/page/place-liste/place-liste.component.ts b/src/app/features/place/page/place-liste/place-liste.component.ts
index 0d6f591..2933725 100644
--- a/src/app/features/place/page/place-liste/place-liste.component.ts
+++ b/src/app/features/place/page/place-liste/place-liste.component.ts
@@ -10,8 +10,10 @@ import {PlaceService} from "../../service/place.service.service";
templateUrl: './place-liste.component.html',
styleUrl: './place-liste.component.scss'
})
-export class PlaceListeComponent implements OnInit{
+export class PlaceListeComponent implements OnInit{
places: any[] = [];
+ searchTerm : string = "";
+ params : any = {};
constructor(private router: Router,
private placeService: PlaceService
@@ -19,11 +21,15 @@ constructor(private router: Router,
}
ngOnInit(): void {
- this.getplaces();
+ this.params.search = "";
+ this.params.fields = ["etage", "taille", "disponibilite", "vehicule occupe", "date entrée", "date sortie", "proprietaire"];
+ this.params.page = 1;
+ this.params.limit = 5;
+ this.getPlaces();
}
-getplaces() {
- this.placeService.getAll().subscribe({
+getPlaces() {
+ this.placeService.getAll(this.params).subscribe({
next: (res) => {
if (res.success) {
this.places = res.data;
@@ -33,9 +39,28 @@ getplaces() {
})
}
-edit(): void {
+ view(_id: string): void {
+ this.router.navigateByUrl('/app/place/view/'+_id).then();
+ }
- this.router.navigateByUrl('/app/place/edit').then();
+ delete(_id: string): void {
+ this.placeService.delete(_id).subscribe({
+ next: (res)=>{
+ if(res.success){
+ this.getPlaces();
+ }
+ }
+ })
+ }
+
+edit(_id: string): void {
+ this.router.navigateByUrl('/app/place/edit/'+_id).then();
}
+
+ search() {
+ this.params.search = this.searchTerm;
+ this.getPlaces()
+ }
+
}
diff --git a/src/app/features/place/page/place-view/place-view.component.html b/src/app/features/place/page/place-view/place-view.component.html
index b881cb8..542b0f4 100644
--- a/src/app/features/place/page/place-view/place-view.component.html
+++ b/src/app/features/place/page/place-view/place-view.component.html
@@ -1 +1,26 @@
-place-view works!
+
+
+
+ {{place.etage }}
+
+
+ {{place.taille}}
+
+
+ {{place.disponibilite}}
+
+
+ {{place.vehiculeOccupee}}
+
+
+ {{place.dateEntree}}
+
+
+ {{place.dateSortie}}
+
+ {{place.proprietaire}}
+
+
+
+
+
diff --git a/src/app/features/place/page/place-view/place-view.component.ts b/src/app/features/place/page/place-view/place-view.component.ts
index 03146cc..c5de71d 100644
--- a/src/app/features/place/page/place-view/place-view.component.ts
+++ b/src/app/features/place/page/place-view/place-view.component.ts
@@ -1,4 +1,7 @@
-import { Component } from '@angular/core';
+import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
+import {ServiceService} from "../../../service/service/service.service";
+import {ActivatedRoute, Router} from "@angular/router";
+import {PlaceService} from "../../service/place.service.service";
@Component({
selector: 'app-place-view',
@@ -7,6 +10,40 @@ import { Component } from '@angular/core';
templateUrl: './place-view.component.html',
styleUrl: './place-view.component.scss'
})
-export class PlaceViewComponent {
+export class PlaceViewComponent implements OnInit{
+ place : any = {};
+ id: string = "0";
+
+ constructor(private PlaceService: PlaceService,
+ 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.PlaceService.getById(this.id).subscribe({
+ next :(res)=>{
+ if(res.success){
+ this.place = res.data;
+ this.cdr.detectChanges();
+ }
+ },
+ error:(err)=>{
+
+ }
+ })
+ }
}
+
+
+
diff --git a/src/app/features/place/place.module.ts b/src/app/features/place/place.module.ts
index d82cff1..9a6a7c4 100644
--- a/src/app/features/place/place.module.ts
+++ b/src/app/features/place/place.module.ts
@@ -15,11 +15,11 @@ const routes: Routes = [
component: PlaceListeComponent
},
{
- path: 'edit',
+ path: 'edit/:id',
component: PlaceEditComponent
},
{
- path:'view',
+ path:'view/:id',
component:PlaceViewComponent
}
]
diff --git a/src/app/features/place/service/place.service.service.ts b/src/app/features/place/service/place.service.service.ts
index 89af4d9..d2eb072 100644
--- a/src/app/features/place/service/place.service.service.ts
+++ b/src/app/features/place/service/place.service.service.ts
@@ -12,8 +12,8 @@ export class PlaceService {
url: string = "place"
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 {
@@ -25,7 +25,7 @@ export class PlaceService {
}
update(place: any):Observable{
- return this.http.put(apiRoute+this.url+ "/"+place.id,place);
+ return this.http.put(apiRoute+this.url+ "/"+place._id,place);
}
delete(id: string):Observable{
diff --git a/src/app/features/service/page/service-edit/service-edit.component.ts b/src/app/features/service/page/service-edit/service-edit.component.ts
index e8f8f87..35243c1 100644
--- a/src/app/features/service/page/service-edit/service-edit.component.ts
+++ b/src/app/features/service/page/service-edit/service-edit.component.ts
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
-import {Router} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
import {ServiceService} from "../../service/service.service";
@Component({
@@ -9,28 +9,55 @@ import {ServiceService} from "../../service/service.service";
})
export class ServiceEditComponent implements OnInit{
service: any = {};
+ id: string = "0";
constructor(private router: Router,
- private serviceService: ServiceService
+ private serviceService: ServiceService,
+ private activatedRoute : ActivatedRoute,
) {
}
ngOnInit(): void {
+ this.id = this.activatedRoute.snapshot.params['id'];
+ if(this.id && this.id != "0"){
+ this.getById();
+ }
}
- getservice() {
- this.serviceService.getAll().subscribe({
- next: (res) => {
- if (res.success) {
+ getById(): void{
+ this.serviceService.getById(this.id).subscribe({
+ next :(res)=>{
+ if(res.success){
+ this.service = res.data;
+ }
+ },
+ error:(err)=>{
+ }
+ })
+ }
+
+ save():void {
+ if(this.id == "0"){
+ this.create(this.service);
+ }else {
+ this.update(this.service);
+ }
+ }
+
+ create(service: any): void{
+ this.serviceService.create(service).subscribe( {
+ next: (res)=>{
+ if(res.success){
+ this.router.navigateByUrl("/app/service").then();
}
}
})
}
- save() {
- this.serviceService.create(this.service).subscribe( {
+ update(service: any): void {
+ this.serviceService.update(service).subscribe( {
next: (res)=>{
if(res.success){
this.router.navigateByUrl("/app/service").then();
diff --git a/src/app/features/service/page/service-list/service-list.component.html b/src/app/features/service/page/service-list/service-list.component.html
index d3c7a54..c67e937 100644
--- a/src/app/features/service/page/service-list/service-list.component.html
+++ b/src/app/features/service/page/service-list/service-list.component.html
@@ -1,12 +1,23 @@
+
+
+
+ Recherche
+
+
+
+
+
Filtre pard ta
+
+
-
+
- vente |
+ vente |
assurance |
programme |
financement |
@@ -24,9 +35,9 @@
{{item.gestion}} |
{{item.location}} |
-
-
-
+
+
+
|
diff --git a/src/app/features/service/page/service-list/service-list.component.ts b/src/app/features/service/page/service-list/service-list.component.ts
index 6995ed4..9a785e3 100644
--- a/src/app/features/service/page/service-list/service-list.component.ts
+++ b/src/app/features/service/page/service-list/service-list.component.ts
@@ -9,19 +9,26 @@ import {ServiceService} from "../../service/service.service";
styleUrl: './service-list.component.scss'
})
export class ServiceListComponent implements OnInit{
+
+ searchTerm : string = "";
+ params : any = {};
+
services: any[] = [];
constructor(private router: Router,
private serviceService: ServiceService
- ) {
- }
+ ) {}
ngOnInit(): void {
- this.getplace();
+ this.params.search = "";
+ this.params.fields = ["vente", "assurance", "programme", "financement", "gestion", "location"];
+ this.params.page = 1;
+ this.params.limit = 5;
+ this.getServices();
}
- getplace() {
- this.serviceService.getAll().subscribe({
+ getServices() {
+ this.serviceService.getAll(this.params).subscribe({
next: (res) => {
if (res.success) {
this.services = res.data;
@@ -31,9 +38,30 @@ export class ServiceListComponent implements OnInit{
})
}
- edit(): void {
+ edit(_id: string): void {
+ this.router.navigateByUrl('/app/service/edit/'+_id).then();
+ }
- this.router.navigateByUrl('/app/service/edit').then();
+ view(_id: string): void {
+ this.router.navigateByUrl('/app/service/view/'+_id).then();
+ }
+
+ delete(_id: string): void {
+ this.serviceService.delete(_id).subscribe({
+ next: (res)=>{
+ if(res.success){
+ this.getServices();
+ }
+ }
+ })
+ }
+
+ search() {
+ this.params.search = this.searchTerm;
+ this.getServices()
}
}
+
+
+
diff --git a/src/app/features/service/page/service-view/service-view.component.html b/src/app/features/service/page/service-view/service-view.component.html
index 162ed53..ffed1ec 100644
--- a/src/app/features/service/page/service-view/service-view.component.html
+++ b/src/app/features/service/page/service-view/service-view.component.html
@@ -1 +1,23 @@
-service-view works!
+
+
+
+ {{service.vente }}
+
+
+ {{service.financement}}
+
+
+ {{service.assurance}}
+
+
+ {{service.programme}}
+
+
+ {{service.gestion}}
+
+
+ {{service.location}}
+
+
+
+
diff --git a/src/app/features/service/page/service-view/service-view.component.ts b/src/app/features/service/page/service-view/service-view.component.ts
index 56a10f7..2cd8846 100644
--- a/src/app/features/service/page/service-view/service-view.component.ts
+++ b/src/app/features/service/page/service-view/service-view.component.ts
@@ -1,4 +1,7 @@
-import { Component } from '@angular/core';
+import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
+import {VehicleService} from "../../../vehicle/service/vehicle.service";
+import {ActivatedRoute, Router} from "@angular/router";
+import {ServiceService} from "../../service/service.service";
@Component({
selector: 'app-service-view',
@@ -7,6 +10,36 @@ import { Component } from '@angular/core';
templateUrl: './service-view.component.html',
styleUrl: './service-view.component.scss'
})
-export class ServiceViewComponent {
+export class ServiceViewComponent implements OnInit{
+ service : any = {};
+ id: string = "0";
+
+ constructor(private serviceService: ServiceService,
+ 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.serviceService.getById(this.id).subscribe({
+ next :(res)=>{
+ if(res.success){
+ this.service = res.data;
+ this.cdr.detectChanges();
+ }
+ },
+ error:(err)=>{
+
+ }
+ })
+ }
}
diff --git a/src/app/features/service/service.module.ts b/src/app/features/service/service.module.ts
index 709a416..6b4dd3a 100644
--- a/src/app/features/service/service.module.ts
+++ b/src/app/features/service/service.module.ts
@@ -16,11 +16,11 @@ const routes: Routes = [
component: ServiceListComponent
},
{
- path: 'edit',
+ path: 'edit/:id',
component: ServiceEditComponent
},
{
- path:'view',
+ path:'view/:id',
component:ServiceViewComponent
}
]
diff --git a/src/app/features/service/service/service.service.ts b/src/app/features/service/service/service.service.ts
index bc0fef8..92f7835 100644
--- a/src/app/features/service/service/service.service.ts
+++ b/src/app/features/service/service/service.service.ts
@@ -12,8 +12,8 @@ export class ServiceService {
url: string = "service"
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 {
@@ -25,7 +25,7 @@ export class ServiceService {
}
update(service: any):Observable{
- return this.http.put(apiRoute+this.url+ "/"+service.id,service);
+ return this.http.put(apiRoute+this.url+ "/"+service._id,service);
}
delete(id: string):Observable{