first commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<div class="row" [ngClass]="isActionInProgress ? 'hidden-for-loading': 'visible-for-loading'">
|
||||
<div class="col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h4 class="card-title" style="font-size: 18px!important;font-weight: 900;">BLOCS</h4>
|
||||
<p class="card-description">
|
||||
Liste des différents blocs (découpage des zones) assignés
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Code
|
||||
</th>
|
||||
<th>
|
||||
Nom
|
||||
</th>
|
||||
<th>
|
||||
Secteur
|
||||
</th>
|
||||
<th>
|
||||
Découpage
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let todo of blocsList; let i=index" class="border-bottom-light">
|
||||
<td style="padding: 15px !important;">
|
||||
{{ todo.cote }}
|
||||
</td>
|
||||
<td>
|
||||
{{ todo.nom }}
|
||||
</td>
|
||||
<td>
|
||||
{{ todo.secteur.nom }}
|
||||
</td>
|
||||
<td>
|
||||
{{ todo.arrondissement && todo.arrondissement.commune ? todo.arrondissement.commune.nom : '-' }} / {{ todo.arrondissement ? todo.arrondissement.nom : '-' }} {{ todo.quartier ? ' / '+ todo.quartier.nom : '' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
import { Component, ChangeDetectionStrategy, OnInit, ViewChild } from '@angular/core';
|
||||
import { DataTableDirective } from 'angular-datatables';
|
||||
import { Subject } from 'rxjs';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { CrudService } from 'src/app/crud.service';
|
||||
import { GlobalService } from 'src/app/global.service';
|
||||
import { TokenStorage } from 'src/app/utilitaire/token-storage';
|
||||
import { JwtHelperService } from '@auth0/angular-jwt';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bloc-by-structure',
|
||||
templateUrl: './bloc-by-structure.component.html',
|
||||
styleUrls: ['./bloc-by-structure.component.css']
|
||||
})
|
||||
export class BlocByStructureComponent implements OnInit {
|
||||
|
||||
@ViewChild(DataTableDirective, { static: false })
|
||||
dtElement?: DataTableDirective;
|
||||
dtOptions: DataTables.Settings = {};
|
||||
dtTrigger: Subject<any> = new Subject<any>();
|
||||
|
||||
blocsList: any[] = [];
|
||||
|
||||
isActionInProgress: boolean = false;
|
||||
|
||||
user: any = null;
|
||||
|
||||
constructor(
|
||||
private crudService: CrudService,
|
||||
private globalService: GlobalService,
|
||||
private tokenStorage: TokenStorage,
|
||||
) {
|
||||
this.globalService.getLodingSuccess().subscribe({
|
||||
next: (data: boolean) => {
|
||||
this.isActionInProgress = data;
|
||||
},
|
||||
error: () => {
|
||||
this.isActionInProgress = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const token = this.tokenStorage.getToken() != null ? this.tokenStorage.getToken() : '';
|
||||
const helper = new JwtHelperService();
|
||||
const decodeToken = helper.decodeToken(token ? token : '');
|
||||
this.user = decodeToken?.user;
|
||||
console.log(this.user);
|
||||
this.globalService.setLodingSuccess(false);
|
||||
this.dtOptions = {
|
||||
pagingType: 'full_numbers',
|
||||
pageLength: 10,
|
||||
processing: true,
|
||||
language: {
|
||||
search: "Rechercher :",
|
||||
emptyTable: "Aucune donnée disponible",
|
||||
lengthMenu: "Afficher _MENU_ éléments",
|
||||
info: "Affichage de l'élement _START_ à _END_ sur _TOTAL_ éléments",
|
||||
infoEmpty: "Affichage de l'élement 0 à 0 sur 0 éléments",
|
||||
infoFiltered: "(filtré de _MAX_ éléments au total)",
|
||||
paginate: {
|
||||
first: "<i class='menu-icon mdi mdi-chevron-double-left'></i>",
|
||||
previous: "<i class='menu-icon mdi mdi-chevron-left'></i>",
|
||||
next: "<i class='menu-icon mdi mdi-chevron-right'></i>",
|
||||
last: "<i class='menu-icon mdi mdi-chevron-double-right'></i>"
|
||||
},
|
||||
}
|
||||
};
|
||||
this.list();
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.dtTrigger.next(this.dtOptions);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.dtTrigger.unsubscribe();
|
||||
}
|
||||
|
||||
list(): void {
|
||||
this.globalService.setLodingSuccess(true);
|
||||
this.blocsList = [];
|
||||
this.refreshDataTable();
|
||||
if(this.user && this.user.structure) {
|
||||
this.crudService.getAll('bloc/list-by-structure?idStructure='+this.user.structure?.id).subscribe(
|
||||
(data: any) => {
|
||||
this.blocsList = data != null ? data.object : [];
|
||||
this.blocsList = [...this.blocsList];
|
||||
this.refreshDataTable();
|
||||
this.globalService.setLodingSuccess(false);
|
||||
},
|
||||
(error: HttpErrorResponse) => {
|
||||
console.log('OK');
|
||||
this.globalService.setLodingSuccess(false);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
refreshDataTable(): void {
|
||||
this.dtElement?.dtInstance.then((dtInstance: DataTables.Api) => {
|
||||
// Destroy the table first
|
||||
dtInstance.destroy();
|
||||
// Call the dtTrigger to rerender again
|
||||
this.dtTrigger.next(null);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user