commit luce

master^2
CATHERINA-LUCE 2024-08-23 13:49:36 +01:00
parent 2011e95585
commit d9635c16e7
14 changed files with 329 additions and 59 deletions

View File

@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {PlaceService} from "../../service/place.service.service"; import {PlaceService} from "../../service/place.service.service";
import {Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-place-edit', selector: 'app-place-edit',
@ -10,19 +10,49 @@ import {Router} from "@angular/router";
export class PlaceEditComponent implements OnInit{ export class PlaceEditComponent implements OnInit{
place : any = {}; place : any = {};
id:string = "0";
constructor(private router: Router,
constructor(private placeService: PlaceService, private placeService: PlaceService,
private router: Router) { } private activatedRoute : ActivatedRoute,) { }
ngOnInit(): void { 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() { save() {
if(this.id == "0"){
this.create(this.place);
}else {
this.update(this.place);
}
}
create(place: any): void{
this.placeService.create(this.place).subscribe( { this.placeService.create(this.place).subscribe( {
next: (res)=>{ next: (res)=>{
if(res.success){ 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();
}
}
})
}
} }

View File

@ -1,6 +1,19 @@
<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="Ajouter une place"></button> <button (click)="edit('0')" pButton type="button" label="Ajouter une place"></button>
</div> </div>
<p-table [value]="places" [tableStyle]="{'min-width': '50rem'}"> <p-table [value]="places" [tableStyle]="{'min-width': '50rem'}">
@ -9,26 +22,26 @@
<th>Etage</th> <th>Etage</th>
<th>Taille</th> <th>Taille</th>
<th>Disponibilité</th> <th>Disponibilité</th>
<th>Date sortie</th>
<th>Vehicule occupé</th> <th>Vehicule occupé</th>
<th>Date entrée</th> <th>Date entrée</th>
<th>Date sortie</th>
<th>Propriétaire</th> <th>Propriétaire</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-product> <ng-template pTemplate="body" let-item>
<tr> <tr>
<td>{{product.etage}}</td> <td>{{item.etage}}</td>
<td>{{product.taille}}</td> <td>{{item.taille}}</td>
<td>{{product.disponibilite}}</td> <td>{{item.disponibilite}}</td>
<td>{{product.vehiculeOccupe}}</td> <td>{{item.vehiculeOccupe}}</td>
<td>{{product.dateEntree}}</td> <td>{{item.dateEntree}}</td>
<td>{{product.dateSortie}}</td> <td>{{item.dateSortie}}</td>
<td>{{product.proprietaire}}</td> <td>{{item.proprietaire}}</td>
<td> <td>
<i class="pi pi-pencil" style="margin-right: 10px"></i> <i (click)="edit(item._id)" class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i> <i (click)="delete(item._id)" class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i> <i (click)="view(item._id)" class="pi pi-eye" style="margin-right: 10px"></i>
</td> </td>
</tr> </tr>
</ng-template> </ng-template>

View File

@ -10,8 +10,10 @@ import {PlaceService} from "../../service/place.service.service";
templateUrl: './place-liste.component.html', templateUrl: './place-liste.component.html',
styleUrl: './place-liste.component.scss' styleUrl: './place-liste.component.scss'
}) })
export class PlaceListeComponent implements OnInit{ export class PlaceListeComponent implements OnInit{
places: any[] = []; places: any[] = [];
searchTerm : string = "";
params : any = {};
constructor(private router: Router, constructor(private router: Router,
private placeService: PlaceService private placeService: PlaceService
@ -19,11 +21,15 @@ constructor(private router: Router,
} }
ngOnInit(): void { 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() { getPlaces() {
this.placeService.getAll().subscribe({ this.placeService.getAll(this.params).subscribe({
next: (res) => { next: (res) => {
if (res.success) { if (res.success) {
this.places = res.data; 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()
}
} }

View File

@ -1 +1,26 @@
<p>place-view works!</p> <div>
<div>
<label>etage</label><br>
<strong>{{place.etage }}</strong>
<br><br>
<label>taille</label><br>
{{place.taille}}
<br><br>
<label>disponibilite</label><br>
{{place.disponibilite}}
<br><br>
<label>Vehicule ocupée</label><br>
{{place.vehiculeOccupee}}
<br><br>
<label>date entrée</label><br>
{{place.dateEntree}}
<br><br>
<label>date sortie</label><br>
{{place.dateSortie}}
<label>proprietaire</label><br>
{{place.proprietaire}}
</div>
<br><br>
</div>

View File

@ -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({ @Component({
selector: 'app-place-view', selector: 'app-place-view',
@ -7,6 +10,40 @@ import { Component } from '@angular/core';
templateUrl: './place-view.component.html', templateUrl: './place-view.component.html',
styleUrl: './place-view.component.scss' 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)=>{
}
})
}
} }

View File

@ -15,11 +15,11 @@ const routes: Routes = [
component: PlaceListeComponent component: PlaceListeComponent
}, },
{ {
path: 'edit', path: 'edit/:id',
component: PlaceEditComponent component: PlaceEditComponent
}, },
{ {
path:'view', path:'view/:id',
component:PlaceViewComponent component:PlaceViewComponent
} }
] ]

View File

@ -12,8 +12,8 @@ export class PlaceService {
url: string = "place" url: string = "place"
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> {
@ -25,7 +25,7 @@ export class PlaceService {
} }
update(place: any):Observable<any>{ update(place: any):Observable<any>{
return this.http.put<any>(apiRoute+this.url+ "/"+place.id,place); return this.http.put<any>(apiRoute+this.url+ "/"+place._id,place);
} }
delete(id: string):Observable<any>{ delete(id: string):Observable<any>{

View File

@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {ServiceService} from "../../service/service.service"; import {ServiceService} from "../../service/service.service";
@Component({ @Component({
@ -9,28 +9,55 @@ import {ServiceService} from "../../service/service.service";
}) })
export class ServiceEditComponent implements OnInit{ export class ServiceEditComponent implements OnInit{
service: any = {}; service: any = {};
id: string = "0";
constructor(private router: Router, constructor(private router: Router,
private serviceService: ServiceService private serviceService: ServiceService,
private activatedRoute : ActivatedRoute,
) { ) {
} }
ngOnInit(): void { ngOnInit(): void {
this.id = this.activatedRoute.snapshot.params['id'];
if(this.id && this.id != "0"){
this.getById();
}
} }
getservice() { getById(): void{
this.serviceService.getAll().subscribe({ this.serviceService.getById(this.id).subscribe({
next: (res) => { next :(res)=>{
if (res.success) { 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() { update(service: any): void {
this.serviceService.create(this.service).subscribe( { this.serviceService.update(service).subscribe( {
next: (res)=>{ next: (res)=>{
if(res.success){ if(res.success){
this.router.navigateByUrl("/app/service").then(); this.router.navigateByUrl("/app/service").then();

View File

@ -1,12 +1,23 @@
<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="Ajouter un service"></button> <button (click)="edit('0')" pButton type="button" label="Ajouter un service"></button>
</div> </div>
<p-table [value]="services" [tableStyle]="{'min-width': '50rem'}"> <p-table [value]="services" [tableStyle]="{'min-width': '50rem'}">
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>vente<i class="pi pi-pencil" style="margin-right: 10px"></i></th> <th>vente</th>
<th>assurance</th> <th>assurance</th>
<th>programme</th> <th>programme</th>
<th>financement</th> <th>financement</th>
@ -24,9 +35,9 @@
<td>{{item.gestion}}</td> <td>{{item.gestion}}</td>
<td>{{item.location}}</td> <td>{{item.location}}</td>
<td> <td>
<i class="pi pi-pencil" style="margin-right: 10px"></i> <i (click)="edit(item._id)" class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i> <i (click)="delete(item._id)" class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i> <i (click)="view(item._id)" class="pi pi-eye" style="margin-right: 10px"></i>
</td> </td>
</tr> </tr>
</ng-template> </ng-template>

View File

@ -9,19 +9,26 @@ import {ServiceService} from "../../service/service.service";
styleUrl: './service-list.component.scss' styleUrl: './service-list.component.scss'
}) })
export class ServiceListComponent implements OnInit{ export class ServiceListComponent implements OnInit{
searchTerm : string = "";
params : any = {};
services: any[] = []; services: any[] = [];
constructor(private router: Router, constructor(private router: Router,
private serviceService: ServiceService private serviceService: ServiceService
) { ) {}
}
ngOnInit(): void { 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() { getServices() {
this.serviceService.getAll().subscribe({ this.serviceService.getAll(this.params).subscribe({
next: (res) => { next: (res) => {
if (res.success) { if (res.success) {
this.services = res.data; 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()
} }
} }

View File

@ -1 +1,23 @@
<p>service-view works!</p> <div>
<div>
<label>vente</label><br>
<strong>{{service.vente }}</strong>
<br><br>
<label>financement</label><br>
{{service.financement}}
<br><br>
<label>Assurance</label><br>
{{service.assurance}}
<br><br>
<label>Programme</label><br>
{{service.programme}}
<br><br>
<label>Gestion</label><br>
{{service.gestion}}
<br><br>
<label>Location</label><br>
{{service.location}}
</div>
<br><br>
</div>

View File

@ -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({ @Component({
selector: 'app-service-view', selector: 'app-service-view',
@ -7,6 +10,36 @@ import { Component } from '@angular/core';
templateUrl: './service-view.component.html', templateUrl: './service-view.component.html',
styleUrl: './service-view.component.scss' 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)=>{
}
})
}
} }

View File

@ -16,11 +16,11 @@ const routes: Routes = [
component: ServiceListComponent component: ServiceListComponent
}, },
{ {
path: 'edit', path: 'edit/:id',
component: ServiceEditComponent component: ServiceEditComponent
}, },
{ {
path:'view', path:'view/:id',
component:ServiceViewComponent component:ServiceViewComponent
} }
] ]

View File

@ -12,8 +12,8 @@ export class ServiceService {
url: string = "service" url: string = "service"
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> {
@ -25,7 +25,7 @@ export class ServiceService {
} }
update(service: any):Observable<any>{ update(service: any):Observable<any>{
return this.http.put<any>(apiRoute+this.url+ "/"+service.id,service); return this.http.put<any>(apiRoute+this.url+ "/"+service._id,service);
} }
delete(id: string):Observable<any>{ delete(id: string):Observable<any>{