thirst commit

master^2
Richedman 2024-08-23 15:34:54 +02:00
parent 3d96e7d287
commit da745b3688
30 changed files with 581 additions and 0 deletions

View File

@ -0,0 +1,43 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {CarburantListComponent} from './page/carburant-list/carburant-list.component';
import {CarburantEditComponent} from './page/carburant-edit/carburant-edit.component';
import {CarburantViewComponent} from './page/carburant-view/carburant-view.component';
import {RouterModule, Routes} from "@angular/router";
import {TableModule} from "primeng/table";
import {ButtonModule} from "primeng/button";
import {InputTextModule} from "primeng/inputtext";
import {FormsModule} from "@angular/forms";
const routes: Routes = [
{
path: '',
component: CarburantListComponent
},
{
path: 'edit',
component: CarburantEditComponent
},
{
path:'view',
component:CarburantViewComponent
}
]
@NgModule({
declarations: [
CarburantListComponent,
CarburantEditComponent,
CarburantViewComponent
],
imports: [
CommonModule,
RouterModule.forChild(routes),
TableModule,
ButtonModule,
InputTextModule,
FormsModule
]
})
export class CarburantModule {
}

View File

@ -0,0 +1,11 @@
<div>
<div>
<label>Type</label>
<input [(ngModel)]="carburant.type" type="text" pInputText />
<br>
<label>Prix</label>
<input [(ngModel)]="carburant.prix" type="text" pInputText />
<button (click)="save()" pButton type="button" label="Enregistrer"></button>
</div>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CarburantEditComponent } from './carburant-edit.component';
describe('CarburantEditComponent', () => {
let component: CarburantEditComponent;
let fixture: ComponentFixture<CarburantEditComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CarburantEditComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(CarburantEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,30 @@
import { Component, OnInit } from '@angular/core';
import {CarburantService} from "../../service/carburant.service";
import {Router} from "@angular/router";
@Component({
selector: 'app-carburant-edit',
templateUrl: './carburant-edit.component.html',
styleUrls: ['./carburant-edit.component.scss']
})
export class CarburantEditComponent implements OnInit {
carburant : any = {};
constructor(private carburantService: CarburantService,
private router: Router) { }
ngOnInit(): void {
}
save() {
this.carburantService.create(this.carburant).subscribe( {
next: (res)=>{
if(res.success){
this.router.navigateByUrl("/app/carburant").then();
}
}
})
}
}

View File

@ -0,0 +1,25 @@
<div style="text-align: right; margin-bottom :10px">
<button (click)="edit()" pButton type="button" label="Commandez le carburant"></button>
</div>
<p-table [value]="carburants" [tableStyle]="{'min-width': '50rem'}">
<ng-template pTemplate="header">
<tr>
<th>Type</th>
<th>Prix</th>
<th></th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-product>
<tr>
<td>{{product.type}}</td>
<td>{{product.prix}}</td>
<td>
<i class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i>
</td>
</tr>
</ng-template>
</p-table>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CarburantListComponent } from './carburant-list.component';
describe('CarburantListComponent', () => {
let component: CarburantListComponent;
let fixture: ComponentFixture<CarburantListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CarburantListComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(CarburantListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,43 @@
import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {CarburantService} from "../../service/carburant.service";
@Component({
selector: 'app-carburant-list',
templateUrl: './carburant-list.component.html',
styleUrls: ['./carburant-list.component.scss']
})
export class CarburantListComponent implements OnInit {
carburants: any[] = [];
constructor(private router: Router,
private carburantService: CarburantService) {
}
ngOnInit(): void {
this.getServices();
}
getServices() {
this.carburantService.getAll().subscribe({
next: (res) => {
if (res.success) {
this.carburants = res.data;
}
}
})
}
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();
}
}

View File

@ -0,0 +1 @@
<p>carburant-view works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CarburantViewComponent } from './carburant-view.component';
describe('CarburantViewComponent', () => {
let component: CarburantViewComponent;
let fixture: ComponentFixture<CarburantViewComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CarburantViewComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(CarburantViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-carburant-view',
templateUrl: './carburant-view.component.html',
styleUrls: ['./carburant-view.component.scss']
})
export class CarburantViewComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { CarburantService } from './carburant.service';
describe('CarburantService', () => {
let service: CarburantService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CarburantService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import {Observable} from "rxjs";
import {HttpClient} from "@angular/common/http";
import {apiRoute} from "../../../core/routes/api.route";
@Injectable({
providedIn: 'root'
})
export class CarburantService {
url: string = "carburant"
constructor(private http: HttpClient) { }
getAll():Observable<any>{
return this.http.get<any>(apiRoute+this.url);
}
getById(id: string):Observable<any> {
return this.http.get<any>(apiRoute+this.url+"/"+id);
}
create(carburant: any):Observable<any>{
return this.http.post<any>(apiRoute+this.url,carburant);
}
update(carburant: any):Observable<any>{
return this.http.put<any>(apiRoute+this.url+ "/"+carburant.id,carburant);
}
delete(id: string):Observable<any>{
return this.http.delete<any>(apiRoute+this.url + "/"+id);
}
}

View File

@ -0,0 +1,18 @@
<div>
<div>
<label>Nom</label>
<input [(ngModel)]="utilisateur.nom" type="text" pInputText />
<br>
<label>Prenom</label>
<input [(ngModel)]="utilisateur.prenom" type="text" pInputText />
<br>
<label>pays</label>
<input [(ngModel)]="utilisateur.pays" 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>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UtilisateurEditComponent } from './utilisateur-edit.component';
describe('UtilisateurEditComponent', () => {
let component: UtilisateurEditComponent;
let fixture: ComponentFixture<UtilisateurEditComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UtilisateurEditComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(UtilisateurEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,30 @@
import { Component, OnInit } from '@angular/core';
import {UtilisateurService} from "../../service/utilisateur.service";
import {Router} from "@angular/router";
@Component({
selector: 'app-utilisateur-edit',
templateUrl: './utilisateur-edit.component.html',
styleUrls: ['./utilisateur-edit.component.scss']
})
export class UtilisateurEditComponent implements OnInit {
utilisateur : any = {};
constructor(private utilisateurService: UtilisateurService,
private router: Router) { }
ngOnInit(): void {
}
save() {
this.utilisateurService.create(this.utilisateur).subscribe( {
next: (res)=>{
if(res.success){
this.router.navigateByUrl("/app/utilisateur").then();
}
}
})
}
}

View File

@ -0,0 +1,29 @@
<div style="text-align: right; margin-bottom :10px">
<button (click)="edit()" pButton type="button" label="Veuillez insérer vos informations"></button>
</div>
<p-table [value]="utilisateurs" [tableStyle]="{'min-width': '50rem'}">
<ng-template pTemplate="header">
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Pays</th>
<th>Ville</th>
<th></th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-product>
<tr>
<td>{{product.nom}}</td>
<td>{{product.prenom}}</td>
<td>{{product.pays}}</td>
<td>{{product.ville}}</td>
<td>
<i class="pi pi-pencil" style="margin-right: 10px"></i>
<i class="pi pi-trash" style="margin-right: 10px"></i>
<i class="pi pi-eye" style="margin-right: 10px"></i>
</td>
</tr>
</ng-template>
</p-table>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UtilisateurListComponent } from './utilisateur-list.component';
describe('UtilisateurListComponent', () => {
let component: UtilisateurListComponent;
let fixture: ComponentFixture<UtilisateurListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UtilisateurListComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(UtilisateurListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,43 @@
import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {UtilisateurService} from "../../service/utilisateur.service";
@Component({
selector: 'app-utilisateur-list',
templateUrl: './utilisateur-list.component.html',
styleUrls: ['./utilisateur-list.component.scss']
})
export class UtilisateurListComponent implements OnInit {
utilisateurs: any[] = [];
constructor(private router: Router,
private utilisateurService: UtilisateurService) {
}
ngOnInit(): void {
this.getServices();
}
getServices() {
this.utilisateurService.getAll().subscribe({
next: (res) => {
if (res.success) {
this.utilisateurs = res.data;
}
}
})
}
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();
}
}

View File

@ -0,0 +1 @@
<p>utilisateur-view works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UtilisateurViewComponent } from './utilisateur-view.component';
describe('UtilisateurViewComponent', () => {
let component: UtilisateurViewComponent;
let fixture: ComponentFixture<UtilisateurViewComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UtilisateurViewComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(UtilisateurViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-utilisateur-view',
templateUrl: './utilisateur-view.component.html',
styleUrls: ['./utilisateur-view.component.scss']
})
export class UtilisateurViewComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { UtilisateurService } from './utilisateur.service';
describe('UtilisateurService', () => {
let service: UtilisateurService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(UtilisateurService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import {Observable} from "rxjs";
import {HttpClient} from "@angular/common/http";
import {apiRoute} from "../../../core/routes/api.route";
@Injectable({
providedIn: 'root'
})
export class UtilisateurService {
url: string = "utilisateur"
constructor(private http: HttpClient) { }
getAll():Observable<any>{
return this.http.get<any>(apiRoute+this.url);
}
getById(id: string):Observable<any> {
return this.http.get<any>(apiRoute+this.url+"/"+id);
}
create(utilisateur: any):Observable<any>{
return this.http.post<any>(apiRoute+this.url,utilisateur);
}
update(utilisateur: any):Observable<any>{
return this.http.put<any>(apiRoute+this.url+ "/"+utilisateur.id,utilisateur);
}
delete(id: string):Observable<any>{
return this.http.delete<any>(apiRoute+this.url + "/"+id);
}
}

View File

@ -0,0 +1,43 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {UtilisateurListComponent} from './page/utilisateur-list/utilisateur-list.component';
import {UtilisateurEditComponent} from './page/utilisateur-edit/utilisateur-edit.component';
import {UtilisateurViewComponent} from './page/utilisateur-view/utilisateur-view.component';
import {RouterModule, Routes} from "@angular/router";
import {TableModule} from "primeng/table";
import {ButtonModule} from "primeng/button";
import {InputTextModule} from "primeng/inputtext";
import {FormsModule} from "@angular/forms";
const routes: Routes = [
{
path: '',
component: UtilisateurListComponent
},
{
path: 'edit',
component: UtilisateurEditComponent
},
{
path:'view',
component:UtilisateurViewComponent
}
]
@NgModule({
declarations: [
UtilisateurListComponent,
UtilisateurEditComponent,
UtilisateurViewComponent
],
imports: [
CommonModule,
RouterModule.forChild(routes),
TableModule,
ButtonModule,
InputTextModule,
FormsModule
]
})
export class UtilisateurModule {
}