diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md index 8a8e3247ae81e2a65c01d2ffc0cc5d4768f35abd..5ca9e96a5937aab281788f0287fa6fa22f133412 100644 --- a/.gitlab/merge_request_templates/default.md +++ b/.gitlab/merge_request_templates/default.md @@ -1,3 +1,5 @@ +# Related to #000 + ## What does this MR do and why? _Describe in detail what your merge request does and why._ diff --git a/src/app/admin/admin-routing.module.ts b/src/app/admin/admin-routing.module.ts index 9a945719de25b6a9f248bf6030eea363255e824a..eb4d6760c9aa67dd68ba273111fa7405b7306c4e 100644 --- a/src/app/admin/admin-routing.module.ts +++ b/src/app/admin/admin-routing.module.ts @@ -1,11 +1,58 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { PanelComponent } from './components/panel/panel.component'; +import { RouterModule, Routes } from '@angular/router'; +import { ClaimStructureComponent } from './components/claim-structure/claim-structure.component'; +import { DeletedStructuresComponent } from './components/deleted-structures/deleted-structures.component'; +import { ManageLockdownInfoComponent } from './components/lockdown-info/manage-lockdown-info.component'; +import { ManageEmployersComponent } from './components/manage-employers/manage-employers.component'; +import { ManageJobsComponent } from './components/manage-jobs/manage-jobs.component'; +import { ManageUsersComponent } from './components/manage-users/manage-users.component'; +import { AdminStructuresListComponent } from './components/structures-list/admin-structures-list.component'; + +export const AdminRoutes = { + deletedStructures: { + link: 'admin/deleted-structures', + path: 'deleted-structures', + }, + employersList: { + link: 'admin/employers-list', + path: 'employers-list', + }, + jobsList: { + link: 'admin/jobs-list', + path: 'jobs-list', + }, + lockdownInfo: { + link: 'admin/lockdown-info', + path: 'lockdown-info', + }, + manageUsers: { + link: 'admin/manage-users', + path: 'manage-users', + }, + pendingStructures: { + link: 'admin/pending-structure', + path: 'pending-structure', + }, + structuresList: { + link: 'admin/structure-list', + path: 'structure-list', + }, +}; const routes: Routes = [ { path: '', - component: PanelComponent, + component: ClaimStructureComponent, + }, + { path: AdminRoutes.deletedStructures.path, component: DeletedStructuresComponent }, + { path: AdminRoutes.employersList.path, component: ManageEmployersComponent }, + { path: AdminRoutes.jobsList.path, component: ManageJobsComponent }, + { path: AdminRoutes.lockdownInfo.path, component: ManageLockdownInfoComponent }, + { path: AdminRoutes.manageUsers.path, component: ManageUsersComponent }, + { path: AdminRoutes.pendingStructures.path, component: ClaimStructureComponent }, + { + path: AdminRoutes.structuresList.path, + component: AdminStructuresListComponent, }, ]; @NgModule({ diff --git a/src/app/admin/admin.module.ts b/src/app/admin/admin.module.ts index 22525977de6ed7adc8599cd0e641bfbc386d3aef..31320291cc272d00ac9557dd4bf6ed9bf9d5f473 100644 --- a/src/app/admin/admin.module.ts +++ b/src/app/admin/admin.module.ts @@ -4,6 +4,7 @@ import { AgGridModule } from 'ag-grid-angular'; import { SharedModule } from '../shared/shared.module'; import { AdminRoutingModule } from './admin-routing.module'; import { ClaimStructureComponent } from './components/claim-structure/claim-structure.component'; +import { DeletedStructuresComponent } from './components/deleted-structures/deleted-structures.component'; import { ManageLockdownInfoComponent } from './components/lockdown-info/manage-lockdown-info.component'; import { DeleteEmployerComponent } from './components/manage-employers/delete-employer/delete-employer.component'; import { ManageEmployersComponent } from './components/manage-employers/manage-employers.component'; @@ -18,13 +19,11 @@ import { DeleteUserComponent } from './components/manage-users/delete-user/delet import { EmployerRendererComponent } from './components/manage-users/employer-renderer/employer-renderer.component'; import { JobRendererComponent } from './components/manage-users/job-renderer/job-renderer.component'; import { ManageUsersComponent } from './components/manage-users/manage-users.component'; -import { PanelComponent } from './components/panel/panel.component'; +import { NavBarComponent } from './components/nav-bar/nav-bar.component'; import { AdminStructuresListComponent } from './components/structures-list/admin-structures-list.component'; -import { DeletedStructuresComponent } from './components/deleted-structures/deleted-structures.component'; @NgModule({ declarations: [ - PanelComponent, ClaimStructureComponent, AdminStructuresListComponent, ManageLockdownInfoComponent, @@ -42,6 +41,7 @@ import { DeletedStructuresComponent } from './components/deleted-structures/dele ManageJobsComponent, ManageEmployersComponent, DeletedStructuresComponent, + NavBarComponent, ], imports: [CommonModule, AdminRoutingModule, SharedModule, AgGridModule], }) diff --git a/src/app/admin/admin-pannel.scss b/src/app/admin/admin.scss similarity index 65% rename from src/app/admin/admin-pannel.scss rename to src/app/admin/admin.scss index 1de269d3ae0a9a5ebcb9c070c989c82c7659a613..fa2f89dbb8afea9a5b7a6387e885c7bbbcf01840 100644 --- a/src/app/admin/admin-pannel.scss +++ b/src/app/admin/admin.scss @@ -1,19 +1,11 @@ @import '../../assets/scss/color'; -.selector { - margin-bottom: 20px; - .option { - margin-right: 30px; - } -} - -.results-tab { - margin-bottom: 20px; -} - -.results-column { - width: 100%; - max-width: 600px; +.adminLayout { + display: flex; + flex-direction: column; + align-items: center; + margin: auto; + width: 80%; } .incomplete { @@ -24,8 +16,11 @@ color: $red; } -.structure-updated-at { - text-align: right; +::ng-deep .red { + color: $red; + a { + color: $red; + } } .error { @@ -33,7 +28,7 @@ font-weight: bold; } -.singleCheckbox { +.lockdownCheckbox { background: $white; border-radius: 4px; padding: 0 16px; diff --git a/src/app/admin/components/claim-structure/claim-structure.component.html b/src/app/admin/components/claim-structure/claim-structure.component.html index 8b2d42ada18049e8ee0b257ddd9fe3e68bf41592..0e63cd7fefb8a296ee154c196c6db0b6872d56c2 100644 --- a/src/app/admin/components/claim-structure/claim-structure.component.html +++ b/src/app/admin/components/claim-structure/claim-structure.component.html @@ -1,25 +1,13 @@ -<div fxLayout="column" fxLayoutAlign="center center"> +<app-admin-nav-bar /> +<div class="adminLayout"> <h2>Revendication structure</h2> - <table *ngIf="isClaimedStructure" aria-describedby="demands attachment results" class="results-tab"> - <thead> - <th scope="col">Utilisateur</th> - <th scope="col">Structure</th> - <th scope="col">Date de demande</th> - <th scope="col">Options</th> - </thead> - <tbody> - <tr *ngFor="let structure of demandsAttachment"> - <td>{{ structure.userEmail }}</td> - <td>{{ structure.structureName }}</td> - <td>{{ structure.createdAt | date: 'mediumDate' }}</td> - <td> - <button type="button" (click)="acceptDemand(structure)">Valider</button> - <button type="button" (click)="refuseDemand(structure)">Refuser</button> - </td> - </tr> - <tr *ngIf="!demandsAttachment?.length"> - <td colspan="3">Aucune demande en attente</td> - </tr> - </tbody> - </table> + <ag-grid-angular + *ngIf="demandsAttachment?.length" + class="ag-theme-alpine" + domLayout="autoHeight" + style="width: 100%" + [rowData]="demandsAttachment" + [columnDefs]="columnsDefs" + /> + <div *ngIf="!demandsAttachment?.length">Aucune demande en attente</div> </div> diff --git a/src/app/admin/components/claim-structure/claim-structure.component.ts b/src/app/admin/components/claim-structure/claim-structure.component.ts index 56938c59b832b44ca43d636af93f8fc00fe7acf8..3dd2a7f23d31d599b08ee153112922350f63ef37 100644 --- a/src/app/admin/components/claim-structure/claim-structure.component.ts +++ b/src/app/admin/components/claim-structure/claim-structure.component.ts @@ -1,4 +1,6 @@ +import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; +import { ColDef } from 'ag-grid-community'; import { NotificationService } from '../../../services/notification.service'; import { StructureAdminInfo } from '../../models/demandAttachment.model'; import { AdminService } from '../../services/admin.service'; @@ -6,14 +8,19 @@ import { AdminService } from '../../services/admin.service'; @Component({ selector: 'app-admin-claim-structure', templateUrl: './claim-structure.component.html', - styleUrls: ['../../admin-pannel.scss'], + styleUrls: ['../../admin.scss'], }) export class ClaimStructureComponent implements OnInit { public demandsAttachment: StructureAdminInfo[]; public structuresUnclaimed: StructureAdminInfo[]; public isClaimedStructure: boolean = true; public isUnclaimedStructure: boolean = false; - constructor(private adminService: AdminService, private notificationService: NotificationService) {} + + constructor( + private adminService: AdminService, + private notificationService: NotificationService, + private datePipe: DatePipe + ) {} ngOnInit(): void { this.adminService.getPendingStructure().subscribe((demands) => { @@ -27,7 +34,7 @@ export class ClaimStructureComponent implements OnInit { this.demandsAttachment = data; this.notificationService.showSuccess('Demande acceptée avec succès'); }, - error: (e) => { + error: () => { this.notificationService.showError('Une erreur est survenue'); }, }); @@ -39,13 +46,42 @@ export class ClaimStructureComponent implements OnInit { this.demandsAttachment = data; this.notificationService.showSuccess('Demande refusée avec succès'); }, - error: (e) => { + error: () => { this.notificationService.showError('Une erreur est survenue'); }, }); } - public claimedStructure(_event: boolean): void { - this.isClaimedStructure = !this.isClaimedStructure; - } + public columnsDefs: ColDef<StructureAdminInfo>[] = [ + { + headerName: 'Utilisateur', + field: 'userEmail', + }, + { + headerName: 'Structure', + field: 'structureName', + flex: 1, + }, + { + headerName: 'Date de demande', + field: 'createdAt', + valueFormatter: (params) => this.datePipe.transform(params.value, 'mediumDate'), + }, + { + headerName: 'Valider', + width: 100, + cellRenderer: () => '<button type="button">Valider</button>', + onCellClicked: (params) => { + this.acceptDemand(params.data); + }, + }, + { + headerName: 'Refuser', + width: 100, + cellRenderer: () => '<button type="button">Refuser</button>', + onCellClicked: (params) => { + this.refuseDemand(params.data); + }, + }, + ]; } diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.html b/src/app/admin/components/deleted-structures/deleted-structures.component.html index e4b520515ab118c23bd93cfbac8f2b287ae9539f..636ee8bbf5169a426744180e4d323c9144aa347a 100644 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.html +++ b/src/app/admin/components/deleted-structures/deleted-structures.component.html @@ -1,7 +1,8 @@ +<app-admin-nav-bar /> <div *ngIf="isLoading" class="loader"> <img class="loader-gif" src="/assets/gif/loader_circle_grey.gif" alt /> </div> -<div *ngIf="!isLoading" class="deletedStructures"> +<div *ngIf="!isLoading" class="adminLayout"> <h2>Liste des structures supprimées</h2> <ag-grid-angular *ngIf="deletedStructures" diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.scss b/src/app/admin/components/deleted-structures/deleted-structures.component.scss deleted file mode 100644 index 74e60b461980be7d6a84c4cb6c6baedc26163c30..0000000000000000000000000000000000000000 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.deletedStructures { - display: flex; - flex-direction: column; - align-items: center; - margin: auto; - width: 80%; -} diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.ts b/src/app/admin/components/deleted-structures/deleted-structures.component.ts index 2c3e281cf83bc0efd57b6ebb920953bf0581fbf2..d6f56b36c0e54c44d29ec84aad0f942caa77828e 100644 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.ts +++ b/src/app/admin/components/deleted-structures/deleted-structures.component.ts @@ -8,7 +8,7 @@ import { AdminService } from '../../services/admin.service'; @Component({ selector: 'app-deleted-structures', templateUrl: './deleted-structures.component.html', - styleUrls: ['./deleted-structures.component.scss'], + styleUrls: ['../../admin.scss'], }) export class DeletedStructuresComponent implements OnInit { public deletedStructures: Structure[]; @@ -45,7 +45,7 @@ export class DeletedStructuresComponent implements OnInit { { headerName: 'Structure', field: 'structureName', - minWidth: 450, + flex: 1, sortable: true, cellRenderer: (params) => this.renderLink(params.data), }, diff --git a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.html b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.html index e4e78daa9153511d690c5a32268a5de88ca58e80..8b0f729ac8a9bc9a75885de2d7fca6b5ee63db7a 100644 --- a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.html +++ b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.html @@ -1,3 +1,4 @@ +<app-admin-nav-bar /> <div *ngIf="isLoading" class="loader"> <img class="loader-gif" src="/assets/gif/loader_circle_grey.gif" alt /> </div> @@ -5,7 +6,7 @@ <h2>Gestion de l'affichage des infos Covid</h2> <div *ngIf="lockdownInfoDisplay">Les infos covid sont actuellement affichées dans les fiches structure.</div> <div *ngIf="!lockdownInfoDisplay">Les infos covid ne sont actuellement pas affichées dans les fiches structure.</div> - <div *ngIf="!error" class="singleCheckbox" [ngClass]="{ checked: lockdownInfoDisplay }"> + <div *ngIf="!error" class="lockdownCheckbox" [ngClass]="{ checked: lockdownInfoDisplay }"> <input type="checkbox" name="lockdownInfo" diff --git a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts index 187fb3541a963c6fb72174751a12938e19cb09ad..11a2e9a99e5d85a367b478665eec6694e48a8243 100644 --- a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts +++ b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts @@ -4,7 +4,7 @@ import { ParametersService } from '../../services/parameters.service'; @Component({ selector: 'app-admin-manage-lockdown-info', templateUrl: './manage-lockdown-info.component.html', - styleUrls: ['../../admin-pannel.scss'], + styleUrls: ['../../admin.scss'], }) export class ManageLockdownInfoComponent implements OnInit { public isLoading: boolean = true; diff --git a/src/app/admin/components/manage-employers/manage-employers.component.html b/src/app/admin/components/manage-employers/manage-employers.component.html index 5abe1c66aa30033ff4c6873243e8e57dfa9be20f..acdcc7b103f0a619dae2dba9d7d529f5546ae753 100644 --- a/src/app/admin/components/manage-employers/manage-employers.component.html +++ b/src/app/admin/components/manage-employers/manage-employers.component.html @@ -1,3 +1,4 @@ +<app-admin-nav-bar /> <div fxLayout="column" fxLayoutGap="5px" fxLayoutAlign="center center" class="userBlock"> <h2> Gestion des employeurs @@ -7,44 +8,42 @@ </h2> </div> -<div class="tables-list"> - <div> - <h3 *ngIf="unvalidatedEmployers" class="title">Employeurs non validées ({{ unvalidatedEmployers.length }})</h3> - <ag-grid-angular - *ngIf="unvalidatedEmployers" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="unvalidatedEmployers" - [columnDefs]="unvalidEmployersColumnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="unvalidColDef" - [frameworkComponents]="frameworkComponents" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="validatedEmployers" class="title">Employeurs validées ({{ validatedEmployers.length }})</h3> - <ag-grid-angular - *ngIf="validatedEmployers" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="validatedEmployers" - [columnDefs]="columnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="defaultColDef" - [frameworkComponents]="frameworkComponents" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="validatedEmployers" class="title">Créer un nouvel employeur</h3> - <form [formGroup]="newEmployerForm" (ngSubmit)="onSubmit()"> - <input type="text" maxlength="100" formControlName="employer" class="form-input" /> - <button type="submit" [ngClass]="{ invalid: !newEmployerForm.valid }">Créer</button> - </form> - </div> +<div class="adminLayout"> + <h3 *ngIf="unvalidatedEmployers" class="title">Employeurs non validées ({{ unvalidatedEmployers.length }})</h3> + <ag-grid-angular + *ngIf="unvalidatedEmployers" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="unvalidatedEmployers" + [columnDefs]="unvalidEmployersColumnDefs" + [getRowHeight]="getRowHeight" + [defaultColDef]="unvalidColDef" + [frameworkComponents]="frameworkComponents" + > + </ag-grid-angular> + + <h3 *ngIf="validatedEmployers" class="title">Employeurs validées ({{ validatedEmployers.length }})</h3> + <ag-grid-angular + *ngIf="validatedEmployers" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="validatedEmployers" + [columnDefs]="columnDefs" + [getRowHeight]="getRowHeight" + [defaultColDef]="defaultColDef" + [frameworkComponents]="frameworkComponents" + > + </ag-grid-angular> + + <h3 *ngIf="validatedEmployers" class="title">Créer un nouvel employeur</h3> + <form [formGroup]="newEmployerForm" (ngSubmit)="onSubmit()"> + <input type="text" maxlength="100" formControlName="employer" class="form-input" /> + <button type="submit" [ngClass]="{ invalid: !newEmployerForm.valid }">Créer</button> + </form> </div> <app-modal-confirmation *ngIf="employerToDelete" diff --git a/src/app/admin/components/manage-employers/manage-employers.component.scss b/src/app/admin/components/manage-employers/manage-employers.component.scss deleted file mode 100644 index 27ad71aba310d2d37158fcf0c4021718959b8323..0000000000000000000000000000000000000000 --- a/src/app/admin/components/manage-employers/manage-employers.component.scss +++ /dev/null @@ -1,20 +0,0 @@ -@import '../../../../assets/scss/color'; - -.user-table { - width: 100%; - height: 100%; - text-overflow: clip; -} - -.tables-list { - height: 100%; - width: 80%; - display: flex; - flex-direction: column; - margin-left: 10%; - margin-bottom: 2%; -} - -app-delete-user { - text-align: center; -} diff --git a/src/app/admin/components/manage-employers/manage-employers.component.ts b/src/app/admin/components/manage-employers/manage-employers.component.ts index 9474074386a85b7c65b46137e2a0c5b37fd61c64..dbd7450b5fe1eb43ffe5fb847d010e57c073febc 100644 --- a/src/app/admin/components/manage-employers/manage-employers.component.ts +++ b/src/app/admin/components/manage-employers/manage-employers.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; +import { ColDef } from 'ag-grid-community'; import { Employer } from '../../../models/employer.model'; import { NotificationService } from '../../../services/notification.service'; import { AdminService } from '../../services/admin.service'; @@ -11,7 +12,7 @@ import { ValidateEmployerComponent } from './validate-employer/validate-employer @Component({ selector: 'app-admin-manage-employers', templateUrl: './manage-employers.component.html', - styleUrls: ['./manage-employers.component.scss'], + styleUrls: ['../../admin.scss'], }) export class ManageEmployersComponent implements OnInit { public newEmployerForm: UntypedFormGroup; @@ -30,10 +31,8 @@ export class ManageEmployersComponent implements OnInit { }; public contextRow: any; - public columnDefs; - public unvalidEmployersColumnDefs; public frameworkComponents; - public defaultColDef = { + public defaultColDef: ColDef = { editable: true, sortable: true, flex: 1, @@ -41,12 +40,75 @@ export class ManageEmployersComponent implements OnInit { filter: true, resizable: true, }; - public unvalidColDef = { + public unvalidColDef: ColDef = { ...this.defaultColDef, cellStyle: { color: '#da6c2e', }, }; + public columnDefs: ColDef<Employer>[] = [ + { + headerName: 'Employeur', + field: 'name', + editable: true, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Acteurs rattachés', + cellRenderer: 'attachedUsersComponent', + cellRendererParams: { + users: 'users', + }, + minWidth: 500, + }, + { + headerName: 'Suppression', + editable: false, + minWidth: 100, + cellRenderer: 'deleteEmployerComponent', + cellRendererParams: { + onClick: this.onDeleteButtonClick.bind(this), + label: 'Supprimer', + }, + }, + ]; + public unvalidEmployersColumnDefs: ColDef<Employer>[] = [ + { + headerName: 'Employeur', + field: 'name', + editable: true, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Acteurs rattachés', + cellRenderer: 'attachedUsersComponent', + cellRendererParams: { + users: 'users', + }, + minWidth: 500, + }, + { + headerName: 'Fusionner', + field: '_id', + cellRenderer: 'employerRenderer', + singleClickEdit: true, + cellEditor: 'agSelectCellEditor', + cellEditorParams: { + values: this.validatedEmployersName, + }, + onCellValueChanged: this.onMerge.bind(this), + }, + { + headerName: 'Valider', + editable: false, + minWidth: 100, + cellRenderer: 'validateEmployerComponent', + cellRendererParams: { + onClick: this.onValidateButtonClick.bind(this), + label: 'Valider', + }, + }, + ]; constructor( private adminService: AdminService, @@ -55,69 +117,6 @@ export class ManageEmployersComponent implements OnInit { ) { this.findValidatedEmployers(); this.findUnvalidatedEmployers(); - this.unvalidEmployersColumnDefs = [ - { - headerName: 'Employeur', - field: 'name', - editable: true, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Acteurs rattachés', - cellRenderer: 'attachedUsersComponent', - cellRendererParams: { - users: 'users', - }, - minWidth: 500, - }, - { - headerName: 'Fusionner', - field: '_id', - cellRenderer: 'employerRenderer', - singleClickEdit: true, - cellEditor: 'agSelectCellEditor', - cellEditorParams: { - values: this.validatedEmployersName, - }, - onCellValueChanged: this.onMerge.bind(this), - }, - { - headerName: 'Valider', - editable: false, - minWidth: 100, - cellRenderer: 'validateEmployerComponent', - cellRendererParams: { - onClick: this.onValidateButtonClick.bind(this), - label: 'Valider', - }, - }, - ]; - this.columnDefs = [ - { - headerName: 'Employeur', - field: 'name', - editable: true, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Acteurs rattachés', - cellRenderer: 'attachedUsersComponent', - cellRendererParams: { - users: 'users', - }, - minWidth: 500, - }, - { - headerName: 'Suppression', - editable: false, - minWidth: 100, - cellRenderer: 'deleteEmployerComponent', - cellRendererParams: { - onClick: this.onDeleteButtonClick.bind(this), - label: 'Supprimer', - }, - }, - ]; this.frameworkComponents = { employerRenderer: EmployerRendererComponent, deleteEmployerComponent: DeleteEmployerComponent, diff --git a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.html b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.html index 0d678274ecdff0456a27bc02d4156777810dc58c..79877cac0ab7c1eb696546681aa1d23945ca5ed9 100644 --- a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.html +++ b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.html @@ -1,7 +1,7 @@ <div *ngIf="users.data.users && users.data.users.length !== 0"> <p *ngFor="let user of users.data.users"> - <span tabindex="0" (click)="goToManageUsers()" (keyup.enter)="goToManageUsers()" - >{{ user.name }} {{ user.surname }} - {{ user.email }}</span - > + <span tabindex="0" (click)="goToManageUsers()" (keyup.enter)="goToManageUsers()"> + {{ user.name }} {{ user.surname }} - {{ user.email }} + </span> </p> </div> diff --git a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts index 89c1cd56edab16ce3c4de7d49d06ee5f59091a71..0796f51b51f9f9b50282e0b1f7858250cb1309ee 100644 --- a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts +++ b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; -import { AdminPanelEnum } from '../../../../shared/enum/adminPanel.enum'; -import { PanelRouteService } from '../../../services/panel-route.service'; +import { Router } from '@angular/router'; +import { AdminRoutes } from '../../../admin-routing.module'; @Component({ selector: 'app-attached-users', @@ -11,10 +11,10 @@ export class AttachedUsersComponent { @Input() redirect = ''; public users: any; - constructor(private panelRouteService: PanelRouteService) {} + constructor(private router: Router) {} public goToManageUsers() { - this.panelRouteService.redirectTo(AdminPanelEnum.manageUsers); + this.router.navigateByUrl(AdminRoutes.manageUsers.link); } public agInit(params: any): void { diff --git a/src/app/admin/components/manage-jobs/manage-jobs.component.html b/src/app/admin/components/manage-jobs/manage-jobs.component.html index 8575f3b79e910ca1571b4fd156dda110aacb022d..efb928223a00416654f8dc3f7c7bd1f4093c266d 100644 --- a/src/app/admin/components/manage-jobs/manage-jobs.component.html +++ b/src/app/admin/components/manage-jobs/manage-jobs.component.html @@ -1,3 +1,4 @@ +<app-admin-nav-bar /> <div fxLayout="column" fxLayoutGap="5px" fxLayoutAlign="center center" class="userBlock"> <h2> Gestion des fonctions @@ -5,44 +6,42 @@ </h2> </div> -<div class="tables-list"> - <div> - <h3 *ngIf="unvalidatedJobs" class="title">Fonctions non validées ({{ unvalidatedJobs.length }})</h3> - <ag-grid-angular - *ngIf="unvalidatedJobs" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="unvalidatedJobs" - [columnDefs]="unvalidJobsColumnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="unvalidColDef" - [frameworkComponents]="frameworkComponents" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="validatedJobs" class="title">Fonctions validées ({{ validatedJobs.length }})</h3> - <ag-grid-angular - *ngIf="validatedJobs" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="validatedJobs" - [columnDefs]="columnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="defaultColDef" - [frameworkComponents]="frameworkComponents" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="validatedJobs" class="title">Créer une nouvelle fonction</h3> - <form [formGroup]="newJobForm" (ngSubmit)="onSubmit()"> - <input type="text" maxlength="100" formControlName="job" class="form-input" /> - <button type="submit" [ngClass]="{ invalid: !newJobForm.valid }">Créer</button> - </form> - </div> +<div class="adminLayout"> + <h3 *ngIf="unvalidatedJobs" class="title">Fonctions non validées ({{ unvalidatedJobs.length }})</h3> + <ag-grid-angular + *ngIf="unvalidatedJobs" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="unvalidatedJobs" + [columnDefs]="unvalidJobsColumnDefs" + [getRowHeight]="getRowHeight" + [defaultColDef]="unvalidColDef" + [frameworkComponents]="frameworkComponents" + > + </ag-grid-angular> + + <h3 *ngIf="validatedJobs" class="title">Fonctions validées ({{ validatedJobs.length }})</h3> + <ag-grid-angular + *ngIf="validatedJobs" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="validatedJobs" + [columnDefs]="columnDefs" + [getRowHeight]="getRowHeight" + [defaultColDef]="defaultColDef" + [frameworkComponents]="frameworkComponents" + > + </ag-grid-angular> + + <h3 *ngIf="validatedJobs" class="title">Créer une nouvelle fonction</h3> + <form [formGroup]="newJobForm" (ngSubmit)="onSubmit()"> + <input type="text" maxlength="100" formControlName="job" class="form-input" /> + <button type="submit" [ngClass]="{ invalid: !newJobForm.valid }">Créer</button> + </form> </div> <app-modal-confirmation *ngIf="jobToDelete" diff --git a/src/app/admin/components/manage-jobs/manage-jobs.component.scss b/src/app/admin/components/manage-jobs/manage-jobs.component.scss index 27ad71aba310d2d37158fcf0c4021718959b8323..31e29570cfb6aba866cab121c6f51c05b28d8eb1 100644 --- a/src/app/admin/components/manage-jobs/manage-jobs.component.scss +++ b/src/app/admin/components/manage-jobs/manage-jobs.component.scss @@ -7,7 +7,6 @@ } .tables-list { - height: 100%; width: 80%; display: flex; flex-direction: column; diff --git a/src/app/admin/components/manage-jobs/manage-jobs.component.ts b/src/app/admin/components/manage-jobs/manage-jobs.component.ts index 627b77bb997efc0ea6e4bf828bb3a1259af41727..fa7a05715c16aff7b6dfa5afa18d53ddab7c79ad 100644 --- a/src/app/admin/components/manage-jobs/manage-jobs.component.ts +++ b/src/app/admin/components/manage-jobs/manage-jobs.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { ValueGetterParams } from 'ag-grid-community'; +import { ColDef, ValueGetterParams } from 'ag-grid-community'; import { Job } from '../../../models/job.model'; import { NotificationService } from '../../../services/notification.service'; import { AdminService } from '../../services/admin.service'; @@ -13,7 +13,7 @@ import { ValidateJobComponent } from './validate-job/validate-job.component'; @Component({ selector: 'app-admin-manage-jobs', templateUrl: './manage-jobs.component.html', - styleUrls: ['./manage-jobs.component.scss'], + styleUrls: ['../../admin.scss'], }) export class ManageJobsComponent implements OnInit { public newJobForm: UntypedFormGroup; @@ -33,10 +33,8 @@ export class ManageJobsComponent implements OnInit { }; public contextRow: any; - public columnDefs; - public unvalidJobsColumnDefs; public frameworkComponents; - public defaultColDef = { + public defaultColDef: ColDef = { editable: true, sortable: true, flex: 1, @@ -44,12 +42,100 @@ export class ManageJobsComponent implements OnInit { filter: true, resizable: true, }; - public unvalidColDef = { + public unvalidColDef: ColDef = { ...this.defaultColDef, cellStyle: { color: '#da6c2e', }, }; + public columnDefs: ColDef<Job>[] = [ + { + headerName: 'Fonction', + field: 'name', + editable: true, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Offre de service', + field: 'hasPersonalOffer', + cellRenderer: 'jobPersonalOffer', + cellEditor: 'agSelectCellEditor', + valueGetter: this.translateBoolean, + singleClickEdit: true, + cellEditorParams: { + values: [true, false], + }, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Acteurs rattachés', + cellRenderer: 'attachedUsersComponent', + cellRendererParams: { + users: 'users', + }, + minWidth: 500, + }, + { + headerName: 'Suppression', + editable: false, + minWidth: 100, + cellRenderer: 'deleteJobComponent', + cellRendererParams: { + onClick: this.onDeleteButtonClick.bind(this), + label: 'Supprimer', + }, + }, + ]; + public unvalidJobsColumnDefs: ColDef<Job>[] = [ + { + headerName: 'Fonction', + field: 'name', + editable: true, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Offre de service', + field: 'hasPersonalOffer', + cellRenderer: 'jobPersonalOffer', + cellEditor: 'agSelectCellEditor', + valueGetter: this.translateBoolean, + singleClickEdit: true, + cellEditorParams: { + values: [true, false], + cellEditorPopup: true, + }, + onCellValueChanged: this.onChange.bind(this), + }, + { + headerName: 'Acteurs rattachés', + cellRenderer: 'attachedUsersComponent', + cellRendererParams: { + users: 'users', + }, + minWidth: 500, + }, + { + headerName: 'Fusionner', + field: '_id', + cellRenderer: 'jobRenderer', + cellEditor: 'agSelectCellEditor', + singleClickEdit: true, + cellEditorParams: { + values: this.validatedJobsName, + }, + onCellValueChanged: this.onMerge.bind(this), + }, + { + headerName: 'Valider', + editable: false, + minWidth: 100, + cellRenderer: 'validateJobComponent', + cellRendererParams: { + onClick: this.onValidateButtonClick.bind(this), + label: 'Valider', + }, + }, + ]; constructor( private adminService: AdminService, @@ -58,94 +144,7 @@ export class ManageJobsComponent implements OnInit { ) { this.findValidatedJobs(); this.findUnvalidatedJobs(); - this.unvalidJobsColumnDefs = [ - { - headerName: 'Fonction', - field: 'name', - editable: true, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Offre de service', - field: 'hasPersonalOffer', - cellRenderer: 'jobPersonalOffer', - cellEditor: 'agSelectCellEditor', - valueGetter: this.translateBoolean, - singleClickEdit: true, - cellEditorParams: { - values: [true, false], - cellEditorPopup: true, - }, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Acteurs rattachés', - cellRenderer: 'attachedUsersComponent', - cellRendererParams: { - users: 'users', - }, - minWidth: 500, - }, - { - headerName: 'Fusionner', - field: '_id', - cellRenderer: 'jobRenderer', - cellEditor: 'agSelectCellEditor', - singleClickEdit: true, - cellEditorParams: { - values: this.validatedJobsName, - }, - onCellValueChanged: this.onMerge.bind(this), - }, - { - headerName: 'Valider', - editable: false, - minWidth: 100, - cellRenderer: 'validateJobComponent', - cellRendererParams: { - onClick: this.onValidateButtonClick.bind(this), - label: 'Valider', - }, - }, - ]; - this.columnDefs = [ - { - headerName: 'Fonction', - field: 'name', - editable: true, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Offre de service', - field: 'hasPersonalOffer', - cellRenderer: 'jobPersonalOffer', - cellEditor: 'agSelectCellEditor', - valueGetter: this.translateBoolean, - singleClickEdit: true, - cellEditorParams: { - values: [true, false], - }, - onCellValueChanged: this.onChange.bind(this), - }, - { - headerName: 'Acteurs rattachés', - cellRenderer: 'attachedUsersComponent', - cellRendererParams: { - users: 'users', - }, - minWidth: 500, - }, - { - headerName: 'Suppression', - editable: false, - minWidth: 100, - cellRenderer: 'deleteJobComponent', - cellRendererParams: { - onClick: this.onDeleteButtonClick.bind(this), - label: 'Supprimer', - }, - }, - ]; + this.frameworkComponents = { jobRenderer: JobRendererComponent, jobPersonalOffer: JobPersonalOfferComponent, diff --git a/src/app/admin/components/manage-users/manage-users.component.html b/src/app/admin/components/manage-users/manage-users.component.html index 6ef12e939fa3ab7b3ac25cb42e026c58dbcea24f..b3068c14799f66a03f72bf86887791d8109c6b4e 100644 --- a/src/app/admin/components/manage-users/manage-users.component.html +++ b/src/app/admin/components/manage-users/manage-users.component.html @@ -1,3 +1,4 @@ +<app-admin-nav-bar /> <div fxLayout="column" fxLayoutGap="5px" fxLayoutAlign="center center" class="userBlock"> <h2> Gestion des utilisateurs @@ -7,64 +8,59 @@ </h2> </div> -<div class="tables-list"> - <div> - <h3 *ngIf="unVerifiedUsers" class="title">Utilisateurs non vérifiés ({{ unVerifiedUsers.length }})</h3> - <ag-grid-angular - *ngIf="validatedJobs && validatedEmployers" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="unVerifiedUsers" - [columnDefs]="columnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="unAttachedColDef" - [frameworkComponents]="frameworkComponents" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="unAttachedUsers" class="title"> - Utilisateurs non rattachés ({{ unAttachedUsers.length }}) - <app-button - [text]="'Exporter'" - [style]="buttonTypeEnum.Tertiary" - (click)="exportUsers('unattached')" - /> - </h3> - <ag-grid-angular - *ngIf="validatedJobs && validatedEmployers" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="unAttachedUsers" - [columnDefs]="columnDefsUnattached" - [getRowHeight]="getRowHeight" - [defaultColDef]="unAttachedColDef" - [frameworkComponents]="frameworkComponents" - (gridReady)="onGridReady($event, 'unattached')" - > - </ag-grid-angular> - </div> - <div> - <h3 *ngIf="attachedUsers" class="title"> - Utilisateurs rattachés ({{ attachedUsers.length }}) - <app-button [text]="'Exporter'" [style]="buttonTypeEnum.Tertiary" (click)="exportUsers('attached')"/> - </h3> - <ag-grid-angular - *ngIf="validatedJobs && validatedEmployers" - class="ag-theme-alpine user-table" - rowSelection="multiple" - domLayout="autoHeight" - [rowData]="attachedUsers" - [columnDefs]="columnDefs" - [getRowHeight]="getRowHeight" - [defaultColDef]="defaultColDef" - [frameworkComponents]="frameworkComponents" - (gridReady)="onGridReady($event, 'attached')" - > - </ag-grid-angular> - </div> +<div class="adminLayout"> + <h3 *ngIf="unVerifiedUsers" class="title">Utilisateurs non vérifiés ({{ unVerifiedUsers.length }})</h3> + <ag-grid-angular + *ngIf="validatedJobs && validatedEmployers" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="unVerifiedUsers" + [columnDefs]="columnDefs" + [defaultColDef]="unAttachedColDef" + [getRowHeight]="getRowHeight" + [frameworkComponents]="frameworkComponents" + > + </ag-grid-angular> + + <h3 *ngIf="unAttachedUsers" class="title"> + Utilisateurs non rattachés ({{ unAttachedUsers.length }}) + <app-button [text]="'Exporter'" [style]="buttonTypeEnum.Tertiary" (click)="exportUsers('unattached')" /> + </h3> + <ag-grid-angular + *ngIf="validatedJobs && validatedEmployers" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="unAttachedUsers" + [columnDefs]="columnDefsUnattached" + [getRowHeight]="getRowHeight" + [defaultColDef]="unAttachedColDef" + [frameworkComponents]="frameworkComponents" + (gridReady)="onGridReady($event, 'unattached')" + > + </ag-grid-angular> + + <h3 *ngIf="attachedUsers" class="title"> + Utilisateurs rattachés ({{ attachedUsers.length }}) + <app-button [text]="'Exporter'" [style]="buttonTypeEnum.Tertiary" (click)="exportUsers('attached')" /> + </h3> + <ag-grid-angular + *ngIf="validatedJobs && validatedEmployers" + class="ag-theme-alpine user-table" + rowSelection="multiple" + domLayout="autoHeight" + style="width: 100%" + [rowData]="attachedUsers" + [columnDefs]="columnDefs" + [getRowHeight]="getRowHeight" + [defaultColDef]="defaultColDef" + [frameworkComponents]="frameworkComponents" + (gridReady)="onGridReady($event, 'attached')" + > + </ag-grid-angular> </div> <app-modal-confirmation *ngIf="userToDelete" diff --git a/src/app/admin/components/manage-users/manage-users.component.scss b/src/app/admin/components/manage-users/manage-users.component.scss index 94d4220051c789c7c4b9351f7f66f3b269d52260..b599dea1dca7072568f635ec1f3a70d57ab1fb30 100644 --- a/src/app/admin/components/manage-users/manage-users.component.scss +++ b/src/app/admin/components/manage-users/manage-users.component.scss @@ -7,7 +7,6 @@ } .tables-list { - height: 100%; width: 80%; display: flex; flex-direction: column; diff --git a/src/app/admin/components/manage-users/manage-users.component.ts b/src/app/admin/components/manage-users/manage-users.component.ts index 009c7c3443230726c67f9e7760d5a7a529372484..e3f20df86c0b4f7c16906bdfb7281c74e1c78558 100644 --- a/src/app/admin/components/manage-users/manage-users.component.ts +++ b/src/app/admin/components/manage-users/manage-users.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { CsvExportParams, GridApi, GridReadyEvent } from 'ag-grid-community'; +import { ColDef, CsvExportParams, GridApi, GridReadyEvent } from 'ag-grid-community'; import { Employer } from '../../../models/employer.model'; import { Job } from '../../../models/job.model'; import { User } from '../../../models/user.model'; @@ -16,7 +16,7 @@ type UsersStatus = 'attached' | 'unattached'; @Component({ selector: 'app-admin-manage-users', templateUrl: './manage-users.component.html', - styleUrls: ['./manage-users.component.scss'], + styleUrls: ['../../admin.scss'], }) export class ManageUsersComponent { public attachedUsers: User[] = []; @@ -41,11 +41,9 @@ export class ManageUsersComponent { { name: null, validated: false }, ]; public contextRow: any; - - public columnDefs; - public columnDefsUnattached; + public buttonTypeEnum = ButtonType; public frameworkComponents; - public defaultColDef = { + public defaultColDef: ColDef = { editable: true, sortable: true, flex: 1, @@ -53,83 +51,84 @@ export class ManageUsersComponent { filter: true, resizable: true, }; - public unAttachedColDef = { + public unAttachedColDef: ColDef = { ...this.defaultColDef, cellStyle: { color: '#da6c2e', }, }; - public buttonTypeEnum = ButtonType; - constructor(private adminService: AdminService, private notificationService: NotificationService) { - this.findValidatedJobs(); - this.findValidatedEmployers(); - this.columnDefs = [ - { - headerName: 'Nom', - field: 'surname', - }, - { - headerName: 'Prénom', - field: 'name', - }, - { - minWidth: 150, - headerName: 'Mail', - field: 'email', - }, - { - minWidth: 100, - headerName: 'Téléphone', - field: 'phone', - }, - { - headerName: 'Structures administrées', - cellRenderer: 'administredStructuresComponent', - cellRendererParams: { - structures: 'structures', - }, - minWidth: 350, - }, - { - headerName: 'Fonction', - field: 'job', - cellRenderer: 'jobRenderer', - cellEditor: 'agSelectCellEditor', - // Ag select cell editor doesn't accept an object a parameter. - // Only giving name to display in the select, then recompose the full object when filter on change. - cellEditorParams: { - values: this.validatedJobsName, - }, - onCellValueChanged: this.onJobChange.bind(this), + public columnDefsUnattached: ColDef<User>[]; + public columnDefs: ColDef<User>[] = [ + { + headerName: 'Nom', + field: 'surname', + }, + { + headerName: 'Prénom', + field: 'name', + }, + { + minWidth: 150, + headerName: 'Mail', + field: 'email', + }, + { + minWidth: 100, + headerName: 'Téléphone', + field: 'phone', + }, + { + headerName: 'Structures administrées', + cellRenderer: 'administredStructuresComponent', + cellRendererParams: { + structures: 'structures', }, - { - headerName: 'Employeur', - field: 'employer', - cellRenderer: 'employerRenderer', - cellEditor: 'agSelectCellEditor', - cellEditorParams: { - values: this.validatedEmployersName, - }, - onCellValueChanged: this.onEmployerChange.bind(this), + minWidth: 350, + }, + { + headerName: 'Fonction', + field: 'job', + cellRenderer: 'jobRenderer', + cellEditor: 'agSelectCellEditor', + // Ag select cell editor doesn't accept an object a parameter. + // Only giving name to display in the select, then recompose the full object when filter on change. + cellEditorParams: { + values: this.validatedJobsName, }, - { - headerName: 'Date de création', - field: 'createdAt', - minWidth: 150, + onCellValueChanged: this.onJobChange.bind(this), + }, + { + headerName: 'Employeur', + field: 'employer', + cellRenderer: 'employerRenderer', + cellEditor: 'agSelectCellEditor', + cellEditorParams: { + values: this.validatedEmployersName, }, - { - headerName: 'Actions', - editable: false, - minWidth: 150, - cellRenderer: 'deleteUserComponent', - cellRendererParams: { - onClick: this.onDeleteButtonClick.bind(this), - label: 'Supprimer', - }, - cellStyle: { 'text-align': 'center' }, + onCellValueChanged: this.onEmployerChange.bind(this), + }, + { + headerName: 'Date de création', + field: 'createdAt', + minWidth: 150, + }, + { + headerName: 'Actions', + editable: false, + minWidth: 150, + cellRenderer: 'deleteUserComponent', + cellRendererParams: { + onClick: this.onDeleteButtonClick.bind(this), + label: 'Supprimer', }, - ]; + cellStyle: { 'text-align': 'center' }, + }, + ]; + + constructor(private adminService: AdminService, private notificationService: NotificationService) { + this.findValidatedJobs(); + this.findValidatedEmployers(); this.columnDefsUnattached = [...this.columnDefs]; this.columnDefsUnattached = this.columnDefsUnattached.filter((item) => String(item.headerName).toLowerCase().indexOf('structure') diff --git a/src/app/admin/components/nav-bar/nav-bar.component.html b/src/app/admin/components/nav-bar/nav-bar.component.html new file mode 100644 index 0000000000000000000000000000000000000000..dcc0fe9dfac180726e0f7fe3cbfe800c756574af --- /dev/null +++ b/src/app/admin/components/nav-bar/nav-bar.component.html @@ -0,0 +1,41 @@ +<div fxLayout="column" fxLayoutGap="20px" class="content-container"> + <div fxLayout="row" fxLayoutAlign="center center"><h1>Administration</h1></div> + <div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center center"> + <app-button + [text]="'Revendication structure'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.pendingStructures.link)" + /> + <app-button + [text]="'Liste structures'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.structuresList.link)" + /> + <app-button + [text]="'Structures supprimées'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.deletedStructures.link)" + /> + <app-button + [text]="'Gestion des utilisateurs'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.manageUsers.link)" + /> + <app-button + [text]="'Fonctions'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.jobsList.link)" + /> + <app-button + [text]="'Employeurs'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.employersList.link)" + /> + <app-button + [text]="'Infos covid'" + [style]="buttonTypeEnum.Secondary" + (click)="router.navigateByUrl(routes.lockdownInfo.link)" + /> + <a target="_blank" class="custom-link" rel="noopener noreferrer" [href]="ghostLink">Ghost</a> + </div> +</div> diff --git a/src/app/admin/components/nav-bar/nav-bar.component.ts b/src/app/admin/components/nav-bar/nav-bar.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1b0fc6622fcbbf2b297bd301e08443c48af6e6c --- /dev/null +++ b/src/app/admin/components/nav-bar/nav-bar.component.ts @@ -0,0 +1,17 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { RuntimeConfigLoaderService } from 'runtime-config-loader'; +import { ButtonType } from '../../../shared/components/button/buttonType.enum'; +import { AdminRoutes } from '../../admin-routing.module'; + +@Component({ + selector: 'app-admin-nav-bar', + templateUrl: './nav-bar.component.html', +}) +export class NavBarComponent { + public ghostLink = this.runtimeConfigLoaderService.getConfigObjectKey('ghostAdmin'); + public buttonTypeEnum = ButtonType; + public routes = AdminRoutes; + + constructor(private runtimeConfigLoaderService: RuntimeConfigLoaderService, public router: Router) {} +} diff --git a/src/app/admin/components/panel/panel.component.html b/src/app/admin/components/panel/panel.component.html deleted file mode 100644 index 4afbd9a950ec45bcdfe7e394c39ac119980bd567..0000000000000000000000000000000000000000 --- a/src/app/admin/components/panel/panel.component.html +++ /dev/null @@ -1,45 +0,0 @@ -<div fxLayout="column" fxLayoutGap="20px" class="content-container full-screen"> - <div fxLayout="row" fxLayoutAlign="center center"><h1>Administration</h1></div> - <div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center center"> - <app-button - [text]="'Revendication structure'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.pendingStructures)" - /> - <app-button - [text]="'Liste structures'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.structuresList)" - /> - <app-button - [text]="'Structures supprimées'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.deletedStructures)" - /> - <app-button - [text]="'Gestion des utilisateurs'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.manageUsers)" - /> - <app-button - [text]="'Infos covid'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.lockdownInfo)" - /> - <app-button [text]="'Fonctions'" [style]="buttonTypeEnum.Secondary" (click)="changeActiveFeature(tab.jobsList)" /> - <app-button - [text]="'Employeurs'" - [style]="buttonTypeEnum.Secondary" - (click)="changeActiveFeature(tab.employersList)" - /> - <a target="_blank" class="custom-link" rel="noopener noreferrer" [href]="ghostLink">Ghost</a> - </div> - - <app-deleted-structures *ngIf="selectedTab === tab.deletedStructures" /> - <app-admin-structures-list *ngIf="selectedTab === tab.structuresList" /> - <app-admin-manage-users *ngIf="selectedTab === tab.manageUsers" /> - <app-admin-claim-structure *ngIf="selectedTab === tab.pendingStructures" /> - <app-admin-manage-lockdown-info *ngIf="selectedTab === tab.lockdownInfo" /> - <app-admin-manage-jobs *ngIf="selectedTab === tab.jobsList" /> - <app-admin-manage-employers *ngIf="selectedTab === tab.employersList" /> -</div> diff --git a/src/app/admin/components/panel/panel.component.spec.ts b/src/app/admin/components/panel/panel.component.spec.ts deleted file mode 100644 index b0f6a9d73a99cd74c146b1761b3a5cb6c21a993e..0000000000000000000000000000000000000000 --- a/src/app/admin/components/panel/panel.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PanelComponent } from './panel.component'; - -describe('PanelComponent', () => { - let component: PanelComponent; - let fixture: ComponentFixture<PanelComponent>; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ PanelComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PanelComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/admin/components/panel/panel.component.ts b/src/app/admin/components/panel/panel.component.ts deleted file mode 100644 index 94b1bde1c9919ba9d793b03ba424bd984d82c580..0000000000000000000000000000000000000000 --- a/src/app/admin/components/panel/panel.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component } from '@angular/core'; -import { RuntimeConfigLoaderService } from 'runtime-config-loader'; -import { ButtonType } from '../../../shared/components/button/buttonType.enum'; -import { AdminPanelEnum } from '../../../shared/enum/adminPanel.enum'; -import { PanelRouteService } from '../../services/panel-route.service'; - -@Component({ - selector: 'app-admin-panel', - templateUrl: './panel.component.html', - providers: [PanelRouteService], -}) -export class PanelComponent { - public ghostLink = this.runtimeConfigLoaderService.getConfigObjectKey('ghostAdmin'); - public selectedTab = AdminPanelEnum.pendingStructures; - public tab = AdminPanelEnum; - public buttonTypeEnum = ButtonType; - - constructor( - private panelRouteService: PanelRouteService, - private runtimeConfigLoaderService: RuntimeConfigLoaderService - ) { - this.panelRouteService.destinationChanged$.subscribe((selected: AdminPanelEnum) => { - this.selectedTab = selected; - }); - } - - public changeActiveFeature(newFeature: AdminPanelEnum): void { - this.selectedTab = newFeature; - } -} diff --git a/src/app/admin/components/structures-list/admin-structures-list.component.html b/src/app/admin/components/structures-list/admin-structures-list.component.html index cf8bb2038be86d535b815d1556c56d3adba22f45..ea5d3a133bca46d5603fa46d588f4825ab182e70 100644 --- a/src/app/admin/components/structures-list/admin-structures-list.component.html +++ b/src/app/admin/components/structures-list/admin-structures-list.component.html @@ -1,82 +1,55 @@ +<app-admin-nav-bar /> <div *ngIf="isLoading" class="loader"> <img class="loader-gif" src="/assets/gif/loader_circle_grey.gif" alt /> </div> -<div *ngIf="!isLoading" fxLayout="column" fxLayoutAlign="center center"> +<div *ngIf="!isLoading" class="adminLayout" fxLayout="column" fxLayoutAlign="center center"> <h2>Liste structures</h2> - <table aria-describedby="demands attachment results" class="results-tab results-column"> - <thead> - <th colspan="2" scope="colgroup"> - Structures avec des données manquantes ({{ structuresIncomplete ? structuresIncomplete.length : 0 }}) - </th> - </thead> - <tbody> - <tr *ngFor="let structure of structuresIncomplete"> - <td> - <a class="incomplete" target="_blank" href="/acteurs?id={{ structure.structureId }}"> - {{ structure.structureName }} - </a> - </td> - <td class="structure-updated-at"> - <span [ngClass]="{ isOutdated: structure.isOutdated }">{{ structure.updatedAt | date: 'mediumDate' }}</span> - </td> - </tr> - <tr *ngIf="!structuresIncomplete?.length"> - <td colspan="3">Aucune structure</td> - </tr> - </tbody> - </table> - <table aria-describedby="demands attachment results" class="results-tab results-column"> - <thead> - <th colspan="2" scope="colgroup">Structures en cours de revendication ({{ structuresInClaim.length }})</th> - </thead> - <tbody> - <tr *ngFor="let structure of structuresInClaim"> - <td> - <a target="_blank" href="/acteurs?id={{ structure.structureId }}">{{ structure.structureName }}</a> - </td> - <td class="structure-updated-at"> - <span [ngClass]="{ isOutdated: structure.isOutdated }">{{ structure.updatedAt | date: 'mediumDate' }}</span> - </td> - </tr> - <tr *ngIf="!structuresInClaim?.length"> - <td colspan="3">Aucune structure</td> - </tr> - </tbody> - </table> - <table aria-describedby="demands attachment results" class="results-tab results-column"> - <thead> - <th colspan="2" scope="colgroup">Structures à revendiquer ({{ structuresToClaim.length }})</th> - </thead> - <tbody> - <tr *ngFor="let structure of structuresToClaim"> - <td> - <a target="_blank" href="/acteurs?id={{ structure.structureId }}">{{ structure.structureName }}</a> - </td> - <td class="structure-updated-at"> - <span [ngClass]="{ isOutdated: structure.isOutdated }">{{ structure.updatedAt | date: 'mediumDate' }}</span> - </td> - </tr> - <tr *ngIf="!structuresToClaim?.length"> - <td colspan="3">Aucune structure</td> - </tr> - </tbody> - </table> - <table aria-describedby="demands attachment results" class="results-tab results-column"> - <thead> - <th colspan="2" scope="colgroup">Structures revendiquées ({{ structuresClaimed.length }})</th> - </thead> - <tbody> - <tr *ngFor="let structure of structuresClaimed"> - <td> - <a target="_blank" href="/acteurs?id={{ structure.structureId }}">{{ structure.structureName }}</a> - </td> - <td class="structure-updated-at"> - <span [ngClass]="{ isOutdated: structure.isOutdated }">{{ structure.updatedAt | date: 'mediumDate' }}</span> - </td> - </tr> - <tr *ngIf="!structuresClaimed?.length"> - <td colspan="3">Aucune structure</td> - </tr> - </tbody> - </table> + <h3>Structures avec des données manquantes ({{ structuresIncomplete ? structuresIncomplete.length : 0 }})</h3> + <ag-grid-angular + *ngIf="structuresIncomplete.length" + class="ag-theme-alpine" + domLayout="autoHeight" + style="width: 100%" + [rowData]="structuresIncomplete" + [columnDefs]="columnDefs" + [rowHeight]="rowHeight" + [ngClass]="'red'" + /> + <div *ngIf="!structuresIncomplete?.length">Aucune structure</div> + + <h3>Structures en cours de revendication ({{ structuresInClaim.length }})</h3> + <ag-grid-angular + *ngIf="structuresInClaim.length" + class="ag-theme-alpine" + domLayout="autoHeight" + style="width: 100%" + [rowData]="structuresInClaim" + [columnDefs]="columnDefs" + [rowHeight]="rowHeight" + /> + <div *ngIf="!structuresInClaim?.length">Aucune structure</div> + + <h3>Structures à revendiquer ({{ structuresToClaim.length }})</h3> + <ag-grid-angular + *ngIf="structuresToClaim.length" + class="ag-theme-alpine" + domLayout="autoHeight" + style="width: 100%" + [rowData]="structuresToClaim" + [columnDefs]="columnDefs" + [rowHeight]="rowHeight" + /> + <div *ngIf="!structuresToClaim?.length">Aucune structure</div> + + <h3>Structures revendiquées ({{ structuresClaimed.length }})</h3> + <ag-grid-angular + *ngIf="structuresClaimed.length" + class="ag-theme-alpine" + domLayout="autoHeight" + style="width: 100%" + [rowData]="structuresClaimed" + [columnDefs]="columnDefs" + [rowHeight]="rowHeight" + /> + <div *ngIf="!structuresClaimed?.length">Aucune structure</div> </div> diff --git a/src/app/admin/components/structures-list/admin-structures-list.component.ts b/src/app/admin/components/structures-list/admin-structures-list.component.ts index 3127ba460b261a2e09ddf701e363473454230b6f..15a8dc0fcd3e2be63564bc02a6dbaee3ae4754a7 100644 --- a/src/app/admin/components/structures-list/admin-structures-list.component.ts +++ b/src/app/admin/components/structures-list/admin-structures-list.component.ts @@ -1,4 +1,7 @@ +import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { ColDef } from 'ag-grid-community'; import { finalize } from 'rxjs/operators'; import { AdminStructure } from '../../models/adminStructureList.interface'; import { AdminService } from '../../services/admin.service'; @@ -6,7 +9,7 @@ import { AdminService } from '../../services/admin.service'; @Component({ selector: 'app-admin-structures-list', templateUrl: './admin-structures-list.component.html', - styleUrls: ['../../admin-pannel.scss'], + styleUrls: ['../../admin.scss'], }) export class AdminStructuresListComponent implements OnInit { public structuresClaimed: AdminStructure[]; @@ -15,7 +18,8 @@ export class AdminStructuresListComponent implements OnInit { public structuresIncomplete: AdminStructure[]; public isAll: boolean = false; public isLoading: boolean = true; - constructor(private adminService: AdminService) {} + public rowHeight = 25; + constructor(private adminService: AdminService, private datePipe: DatePipe, private router: Router) {} ngOnInit(): void { this.adminService @@ -28,4 +32,30 @@ export class AdminStructuresListComponent implements OnInit { this.structuresIncomplete = response.incomplete; }); } + + private renderLink(structureId: string, structureName: string) { + return `<a href="/acteurs?id=${structureId}" target="_blank">${structureName}</a>`; + } + + public columnDefs: ColDef<AdminStructure>[] = [ + { + headerName: 'Structure', + cellRenderer: (params) => this.renderLink(params.data.structureId, params.data.structureName), + comparator(_, __, nodeA, nodeB) { + return nodeA.data.structureName.toLowerCase() > nodeB.data.structureName.toLocaleLowerCase() ? -1 : 1; + }, + sortable: true, + flex: 3, + }, + { + headerName: 'Date de mise à jour', + field: 'updatedAt', + valueFormatter: ({ value }) => this.datePipe.transform(value, 'mediumDate'), + cellClass: (params) => { + return params.data.isOutdated ? 'red' : ''; + }, + flex: 1, + sortable: true, + }, + ]; } diff --git a/src/app/admin/services/panel-route.service.ts b/src/app/admin/services/panel-route.service.ts deleted file mode 100644 index 111a50102938f038b3af8bf6a97a4517923d34f7..0000000000000000000000000000000000000000 --- a/src/app/admin/services/panel-route.service.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Subject } from 'rxjs'; -import { AdminPanelEnum } from '../../shared/enum/adminPanel.enum'; - -@Injectable() -export class PanelRouteService { - private destination = new Subject<AdminPanelEnum>(); - - destinationChanged$ = this.destination.asObservable(); - - redirectTo(dest: AdminPanelEnum) { - this.destination.next(dest); - } -} diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index da9643c6ce63cc8d4581e5d7b11590f5deff0064..d5c43742aa6d9883ec61097371de2e4385a8457b 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -21,7 +21,15 @@ /> </div> <div class="containerIconMenu"> - <app-svg-icon [type]="'ico'" [icon]="'profile'" [iconClass]="'icon-32'" /> + <app-svg-icon + class="clickable" + tabindex="0" + [type]="'ico'" + [icon]="'profile'" + [iconClass]="'icon-32'" + (click)="isLoggedIn ? openProfileMenu() : goToLoginPage()" + (keyup.enter)="isLoggedIn ? openProfileMenu() : goToLoginPage()" + /> </div> <div fxLayout="row" class="right-header" fxLayoutAlign="center center" fxLayoutGap="3vw"> <a routerLink="/news" [routerLinkActive]="'active'" i18n>Actualités</a> diff --git a/src/app/shared/enum/adminPanel.enum.ts b/src/app/shared/enum/adminPanel.enum.ts deleted file mode 100644 index 8432a8294fa625a36903cbf8771c9b0b484e75c2..0000000000000000000000000000000000000000 --- a/src/app/shared/enum/adminPanel.enum.ts +++ /dev/null @@ -1,9 +0,0 @@ -export enum AdminPanelEnum { - deletedStructures, - employersList, - jobsList, - lockdownInfo, - manageUsers, - pendingStructures, - structuresList, -} diff --git a/src/app/structure-list/models/category.model.ts b/src/app/structure-list/models/category.model.ts index 42c2d77e3f4d6394b6a509e9cdcf9b725f8b4c77..1bef26f7746ac0c0a1fced7dfcd9828d2baf74c9 100644 --- a/src/app/structure-list/models/category.model.ts +++ b/src/app/structure-list/models/category.model.ts @@ -10,7 +10,7 @@ export class Category { Object.assign(this, obj, { modules: obj && obj.modules - ? obj.modules.map((module: Module) => new Module(module.id, module.name, module.displayText, module.apticIds)) + ? obj.modules.map((module: Module) => new Module(module.id, module.name, module.displayText)) : null, }); } diff --git a/src/app/structure-list/models/module.model.ts b/src/app/structure-list/models/module.model.ts index ec92c00a16a91e1d81faceb62c03eb94318d2c6f..870ffaee22c2210f2a487cdef0124d2c8e14d124 100644 --- a/src/app/structure-list/models/module.model.ts +++ b/src/app/structure-list/models/module.model.ts @@ -2,12 +2,10 @@ export class Module { id: string; name: string; displayText?: string; - apticIds?: string[]; - constructor(id: string, name: string, displayText?: string, apticIds?: string[]) { + constructor(id: string, name: string, displayText?: string) { this.id = id; this.name = name; this.displayText = displayText || name; - this.apticIds = apticIds; } }