Added conditions to check role after connexion and changed guards
This commit is contained in:
@@ -43,9 +43,11 @@
|
||||
<div style="justify-content: center; display: flex">
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(deliverer)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliverer.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
@if (admin()){
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliverer.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {DelivererForm} from "../deliverer-form/deliverer-form";
|
||||
import {DeliverersService, GetDelivererDto, GetSupplierDto} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-deliverer-table',
|
||||
@@ -28,14 +29,17 @@ import {firstValueFrom} from "rxjs";
|
||||
export class DelivererTable implements OnInit {
|
||||
private deliverersService = inject(DeliverersService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private authService = inject(AuthService);
|
||||
|
||||
deliverers = signal<GetDelivererDto[]>([]);
|
||||
deliverersLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchDeliverers();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchDeliverers() {
|
||||
|
||||
@@ -38,9 +38,11 @@
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(deliveryNote)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)"
|
||||
class="cursor-pointer text-red-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
@if (admin()){
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)"
|
||||
class="cursor-pointer text-red-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
}
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)"
|
||||
class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {format} from "date-fns";
|
||||
import {FileService} from "../../services/file.service";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-deliverery-note-table',
|
||||
@@ -28,9 +29,11 @@ export class DelivereryNoteTable implements OnInit {
|
||||
private deliveryNotesService = inject(DeliverynotesService);
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||
deliveryNotesLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
|
||||
@@ -38,6 +41,7 @@ export class DelivereryNoteTable implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchDeliveryNotes();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchDeliveryNotes() {
|
||||
|
||||
@@ -59,14 +59,14 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||
@if (authService.hasRole(['ADMIN'])) {
|
||||
@if (admin()) {
|
||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||
<a routerLink="/user">
|
||||
<nz-icon nzType="user"></nz-icon>
|
||||
<span>Utilisateur</span>
|
||||
</a>
|
||||
}
|
||||
</li>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<!-- ICONES À DROITE -->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzContentComponent, NzHeaderComponent, NzLayoutComponent} from "ng-zorro-antd/layout";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
@@ -28,10 +28,16 @@ import {AuthService} from "../../services/auth.service";
|
||||
templateUrl: './layout.html',
|
||||
styleUrl: './layout.css',
|
||||
})
|
||||
export class Layout {
|
||||
protected authService = inject(AuthService);
|
||||
export class Layout implements OnInit {
|
||||
private authService = inject(AuthService);
|
||||
private router = inject(Router);
|
||||
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
ngOnInit() {
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
this.authService.logout();
|
||||
await this.router.navigate(['/login']);
|
||||
|
||||
@@ -60,9 +60,11 @@
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(purchaseOrder)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(purchaseOrder.id)"
|
||||
class="cursor-pointer text-red-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
@if (admin()) {
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(purchaseOrder.id)"
|
||||
class="cursor-pointer text-red-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
}
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(purchaseOrder.id)"
|
||||
class="cursor-pointer text-green-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
import {QuantityForm} from "../quantity-form/quantity-form";
|
||||
import {DelivererChoice} from "../deliverer-choice/deliverer-choice";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-purchase-order-table',
|
||||
@@ -38,9 +39,11 @@ export class PurchaseOrderTable implements OnInit {
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
private deliveryNoteService = inject(DeliverynotesService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
|
||||
purchaseOrdersLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
||||
@@ -48,6 +51,7 @@ export class PurchaseOrderTable implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchPurchaseOrder();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchPurchaseOrder() {
|
||||
|
||||
@@ -60,9 +60,11 @@
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(quotation)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"
|
||||
(click)="delete(quotation.id)"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
@if (admin()) {
|
||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"
|
||||
(click)="delete(quotation.id)"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
}
|
||||
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline"
|
||||
class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
import {QuantityForm} from "../quantity-form/quantity-form";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotation-table',
|
||||
@@ -34,15 +35,18 @@ export class QuotationTable implements OnInit {
|
||||
private quotationsService = inject(QuotationsService);
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
quotations = signal<GetQuotationDto[]>([]);
|
||||
quotationsLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchQuotations();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchQuotations() {
|
||||
|
||||
@@ -10,15 +10,23 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="9">Logo</nz-form-label>
|
||||
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||
<input #fileInputLogo nz-input type="file" placeholder="Déposer"
|
||||
(change)="onFileChange('logo', fileInputLogo.files)">
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
@if (admin()){
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="9">Logo</nz-form-label>
|
||||
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||
<input #fileInputLogo nz-input type="file" placeholder="Déposer"
|
||||
(change)="onFileChange('logo', fileInputLogo.files)">
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<p class="text-red-600">Vous ne pouvez pas modifier le logo</p>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Signature -->
|
||||
@@ -31,14 +39,22 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="9">Signature</nz-form-label>
|
||||
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||
<input #fileInputSignature nz-input type="file" placeholder="Déposer"
|
||||
(change)="onFileChange('electronicSignature', fileInputSignature.files)">
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
@if (admin()) {
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="9">Signature</nz-form-label>
|
||||
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||
<input #fileInputSignature nz-input type="file" placeholder="Déposer"
|
||||
(change)="onFileChange('electronicSignature', fileInputSignature.files)">
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="row-right">
|
||||
<nz-form-item>
|
||||
<p class="text-red-600">Vous ne pouvez pas modifier la signature</p>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {firstValueFrom} from "rxjs";
|
||||
import {GetSettingDto, SettingsService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import imageCompression from "browser-image-compression";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-setting-form',
|
||||
@@ -27,8 +28,10 @@ import imageCompression from "browser-image-compression";
|
||||
export class SettingForm implements OnInit {
|
||||
private settingsService = inject(SettingsService);
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
settings = signal<GetSettingDto>({});
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
setting: SettingInfo = {
|
||||
logo: 'https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png',
|
||||
@@ -42,6 +45,7 @@ export class SettingForm implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchSettings();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchSettings() {
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
<div style="justify-content: center; display: flex">
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(product)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(product.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
@if (admin()) {
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(product.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {GetProductDto, ProductsService, WarehouseproductsService} from "../../se
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {first, firstValueFrom} from "rxjs";
|
||||
import {NzCheckboxComponent} from "ng-zorro-antd/checkbox";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
interface ProductWithQuantity extends GetProductDto {
|
||||
totalQuantity?: number;
|
||||
@@ -34,9 +35,11 @@ export class StockTable implements OnInit {
|
||||
private productsService = inject(ProductsService);
|
||||
private wareHousseProductsService = inject(WarehouseproductsService)
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private authService = inject(AuthService);
|
||||
|
||||
products = signal<ProductWithQuantity[]>([]);
|
||||
productsLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
|
||||
@@ -50,6 +53,7 @@ export class StockTable implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchProducts();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchProducts() {
|
||||
|
||||
@@ -46,10 +46,12 @@
|
||||
<nz-icon nzType="edit" nzTheme="outline"
|
||||
class="cursor-pointer text-gray-600 hover:text-gray-900"
|
||||
(click)="openEditProductModal(product, supplier.id)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline"
|
||||
class="cursor-pointer text-red-600 hover:text-red-800"
|
||||
(click)="deleteProduct(product.productId, supplier.id)"></nz-icon>
|
||||
@if (admin()) {
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline"
|
||||
class="cursor-pointer text-red-600 hover:text-red-800"
|
||||
(click)="deleteProduct(product.productId, supplier.id)"></nz-icon>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -62,9 +64,11 @@
|
||||
<div style="display: flex; align-items: center;">
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||
(click)="openEditModal(supplier)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(supplier.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
@if (admin()) {
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(supplier.id)"
|
||||
class="text-red-600 cursor-pointer"></nz-icon>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {GetPriceDto, GetSupplierDto, PricesService, SuppliersService} from "../.
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {PriceForm} from "../price-form/price-form";
|
||||
import {AuthService} from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-supplier-table',
|
||||
@@ -29,9 +30,11 @@ export class SupplierTable implements OnInit {
|
||||
private suppliersService = inject(SuppliersService);
|
||||
private pricesService = inject(PricesService);
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
suppliers = signal<GetSupplierDto[]>([]);
|
||||
suppliersLoading = signal<boolean>(false);
|
||||
admin = signal<boolean>(false);
|
||||
|
||||
supplierModal = viewChild.required<ModalNav>('supplierModal');
|
||||
productModal = viewChild.required<ModalNav>('productModal');
|
||||
@@ -42,6 +45,7 @@ export class SupplierTable implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchSuppliers();
|
||||
this.admin.set(this.authService.isAdmin());
|
||||
}
|
||||
|
||||
async fetchSuppliers() {
|
||||
|
||||
Reference in New Issue
Block a user