-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
263 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/portail-admins/src/app/modules/shared/pipes/sort-array.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Pipe, PipeTransform } from "@angular/core"; | ||
import { compareAttributes } from "@domifa/common"; | ||
|
||
@Pipe({ | ||
name: "sortArray", | ||
standalone: true, | ||
}) | ||
export class SortArrayPipe implements PipeTransform { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
transform(array: any[], sortKey: string, sortValue: "asc" | "desc"): any[] { | ||
if (!array || array.length <= 1) { | ||
return array; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return array.sort((a: any, b: any) => { | ||
const valA = a[sortKey]; | ||
const valB = b[sortKey]; | ||
|
||
return compareAttributes(valA, valB, sortValue === "asc"); | ||
}); | ||
} | ||
} |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...-admins/src/app/modules/structure/components/structure-page/structure-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>structure-page works!</p> |
12 changes: 6 additions & 6 deletions
12
...nts/structure/structure.component.spec.ts → ...ure-page/structure-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...il-admins/src/app/modules/structure/components/structure-page/structure-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "app-structure-page", | ||
standalone: true, | ||
imports: [], | ||
templateUrl: "./structure-page.component.html", | ||
styleUrl: "./structure-page.component.css", | ||
}) | ||
export class StructurePageComponent {} |
Empty file.
2 changes: 1 addition & 1 deletion
2
...onents/structure/structure.component.html → ...onents/structure/structure.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...portail-admins/src/app/modules/structure/components/structure/structure.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
|
||
import { StructureComponent } from "./structure.component"; | ||
import { CommonModule } from "@angular/common"; | ||
import { TableHeadSortComponent } from "../../../shared/components/table-head-sort/table-head-sort.component"; | ||
import { SortArrayPipe } from "../../../shared/pipes/sort-array.pipe"; | ||
import { AdminStructuresApiClient } from "../../../shared/services"; | ||
import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
import { RouterModule } from "@angular/router"; | ||
|
||
describe("StructureComponent", () => { | ||
let component: StructureComponent; | ||
let fixture: ComponentFixture<StructureComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [StructureComponent], | ||
imports: [ | ||
CommonModule, | ||
TableHeadSortComponent, | ||
SortArrayPipe, | ||
HttpClientTestingModule, | ||
RouterModule.forRoot([]), | ||
], | ||
providers: [AdminStructuresApiClient], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(StructureComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should create", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
File renamed without changes.
Empty file.
89 changes: 89 additions & 0 deletions
89
packages/portail-admins/src/app/modules/structure/components/users/users.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<div class="content py-3"> | ||
<div class="container py-3"> | ||
<div class="page-content p-3"> | ||
<h2>Utilisateurs enregistrés: {{ users.length }} utilisateurs</h2> | ||
<div class="table-responsive"> | ||
<table class="table" [attr.aria-rowcount]="users.length"> | ||
<caption class="visually-hidden"> | ||
Liste des utilisateurs enregistrés | ||
</caption> | ||
<thead> | ||
<tr> | ||
<th scope="col"> | ||
<app-table-head-sort | ||
sortKey="nom" | ||
[(sortValue)]="sortValue" | ||
[(currentKey)]="currentKey" | ||
columnName="Nom prénom" | ||
> | ||
</app-table-head-sort> | ||
</th> | ||
<th scope="col"> | ||
<app-table-head-sort | ||
sortKey="email" | ||
[(sortValue)]="sortValue" | ||
[(currentKey)]="currentKey" | ||
columnName="Email" | ||
> | ||
</app-table-head-sort> | ||
</th> | ||
<th scope="col"> | ||
<app-table-head-sort | ||
sortKey="createdAt" | ||
[(sortValue)]="sortValue" | ||
[(currentKey)]="currentKey" | ||
columnName="Date d'inscription" | ||
> | ||
</app-table-head-sort> | ||
</th> | ||
<th scope="col"> | ||
<app-table-head-sort | ||
sortKey="lastLogin" | ||
[(sortValue)]="sortValue" | ||
[(currentKey)]="currentKey" | ||
columnName="Statut" | ||
> | ||
</app-table-head-sort> | ||
</th> | ||
<th scope="col"> | ||
<app-table-head-sort | ||
sortKey="role" | ||
[(sortValue)]="sortValue" | ||
[(currentKey)]="currentKey" | ||
columnName="Rôle" | ||
> | ||
</app-table-head-sort> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr | ||
*ngFor=" | ||
let user of users | sortArray : currentKey : sortValue; | ||
let i = index | ||
" | ||
[attr.aria-rowindex]="i + 1" | ||
> | ||
<td class="fw-bold">{{ user.nom }} {{ user.prenom }}</td> | ||
<td>{{ user.email }}</td> | ||
<td>{{ user.createdAt | date : "d MMMM y" }}</td> | ||
<td> | ||
<p *ngIf="user.verified">✅ Compte actif</p> | ||
<p *ngIf="!user.verified && user.lastLogin"> | ||
❌ Inactif depuis plus de 2 mois<br />Dernière connexion le | ||
{{ user.lastLogin | date : "d MMMM y" }} | ||
</p> | ||
<p class="fw-bold" *ngIf="!user.verified && !user.lastLogin"> | ||
❌ Compte jamais utilisé | ||
</p> | ||
</td> | ||
<td> | ||
{{ USER_ROLES_LABELS[user.role] }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
packages/portail-admins/src/app/modules/structure/components/users/users.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
|
||
import { UsersComponent } from "./users.component"; | ||
import { CommonModule } from "@angular/common"; | ||
import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
import { RouterModule } from "@angular/router"; | ||
import { TableHeadSortComponent } from "../../../shared/components/table-head-sort/table-head-sort.component"; | ||
import { SortArrayPipe } from "../../../shared/pipes/sort-array.pipe"; | ||
import { AdminStructuresApiClient } from "../../../shared/services"; | ||
|
||
describe("UsersComponent", () => { | ||
let component: UsersComponent; | ||
let fixture: ComponentFixture<UsersComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [UsersComponent], | ||
imports: [ | ||
CommonModule, | ||
TableHeadSortComponent, | ||
SortArrayPipe, | ||
HttpClientTestingModule, | ||
RouterModule.forRoot([]), | ||
], | ||
providers: [AdminStructuresApiClient], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UsersComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should create", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/portail-admins/src/app/modules/structure/components/users/users.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component } from "@angular/core"; | ||
import { SortValues, UserStructure, UserStructureRole } from "@domifa/common"; | ||
|
||
@Component({ | ||
selector: "app-users", | ||
templateUrl: "./users.component.html", | ||
styleUrl: "./users.component.css", | ||
}) | ||
export class UsersComponent { | ||
public users: UserStructure[] = []; | ||
public sortValue: SortValues = "asc"; | ||
public currentKey = "id"; | ||
|
||
public readonly USER_ROLES_LABELS: { [key in UserStructureRole]: string } = { | ||
admin: "Administrateur", | ||
responsable: "Gestionnaire", | ||
simple: "Instructeur", | ||
facteur: "Facteur", | ||
}; | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/portail-admins/src/app/modules/structure/structure-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { RouterModule, Routes } from "@angular/router"; | ||
import { StructureComponent } from "./components/structure/structure.component"; | ||
import { UsersComponent } from "./components/users/users.component"; | ||
|
||
const routes: Routes = [ | ||
{ path: ":structureId", component: StructureComponent }, | ||
{ path: ":structureId/users0", component: UsersComponent }, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class StructureRoutingModule {} |
24 changes: 24 additions & 0 deletions
24
packages/portail-admins/src/app/modules/structure/structure.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { StructureComponent } from "./components/structure/structure.component"; | ||
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome"; | ||
import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; | ||
import { TableHeadSortComponent } from "../shared/components/table-head-sort/table-head-sort.component"; | ||
import { SharedModule } from "../shared/shared.module"; | ||
import { StructureRoutingModule } from "./structure-routing.module"; | ||
import { UsersComponent } from "./components/users/users.component"; | ||
import { SortArrayPipe } from "../shared/pipes/sort-array.pipe"; | ||
|
||
@NgModule({ | ||
declarations: [StructureComponent, UsersComponent], | ||
imports: [ | ||
CommonModule, | ||
NgbModule, | ||
SharedModule, | ||
FontAwesomeModule, | ||
TableHeadSortComponent, | ||
StructureRoutingModule, | ||
SortArrayPipe, | ||
], | ||
}) | ||
export class StructureModule {} |