Skip to content

Commit bb69d18

Browse files
committed
feat(admin): intégration header
1 parent f615fcb commit bb69d18

File tree

4 files changed

+64
-78
lines changed

4 files changed

+64
-78
lines changed

packages/portail-admins/src/app/app.component.html

Lines changed: 10 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -39,80 +39,16 @@
3939
</li>
4040
</ul>
4141
</nav>
42-
43-
<header id="page-header" role="banner">
44-
<nav
45-
class="navbar bg-white"
46-
role="navigation"
47-
aria-label="Navigation principale"
48-
style="position: sticky; top: 0; z-index: 1000"
49-
>
50-
<a class="navbar-brand" routerLink="/">
51-
<img
52-
src="../assets/images/logo-mini.svg"
53-
width="30"
54-
height="30"
55-
class="d-inline-block align-top"
56-
alt=""
57-
/>
58-
<span class="nav-brand">Administration de DomiFa</span>
59-
</a>
60-
<div>
61-
<div
62-
*ngIf="adminProfile?.role === 'super-admin-domifa'"
63-
ngbDropdown
64-
class="d-inline-block me-2"
65-
>
66-
<button
67-
type="button"
68-
class="btn btn-outline-primary"
69-
id="dropdownBasic1"
70-
ngbDropdownToggle
71-
>
72-
Menu
73-
</button>
74-
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
75-
<a
76-
ngbDropdownItem
77-
class="btn btn-outline-primary"
78-
routerLink="/stats"
79-
>
80-
<fa-icon [icon]="faChartBar" aria-hidden="true"></fa-icon>
81-
Statistiques de la domiciliation
82-
</a>
83-
<a
84-
ngbDropdownItem
85-
class="btn btn-outline-primary"
86-
routerLink="/structures"
87-
>
88-
<fa-icon [icon]="faList" aria-hidden="true"></fa-icon>
89-
Liste des structures
90-
</a>
91-
<a
92-
ngbDropdownItem
93-
class="btn btn-outline-primary"
94-
routerLink="/manage-users"
95-
>
96-
<fa-icon [icon]="faUsers" aria-hidden="true"></fa-icon>
97-
98-
Utilisateurs de l'administration
99-
</a>
100-
</div>
101-
</div>
102-
103-
<button
104-
type="button"
105-
class="btn btn-outline-primary"
106-
*ngIf="adminProfile"
107-
(click)="logout()"
108-
>
109-
<fa-icon aria-hidden="true" [icon]="['fas', 'sign-out-alt']"> </fa-icon>
110-
Déconnexion
111-
</button>
112-
</div>
113-
</nav>
114-
</header>
115-
42+
<dsfr-header
43+
[logoLabel]="'République<br/>Française'"
44+
[operatorImageAlt]="'Espace d\'administration de DomiFa'"
45+
[operatorImagePath]="'../assets/images/logo-dsfr.svg'"
46+
[ariaLabel]="'Menu principal'"
47+
[logoLink]="{ routerLink: '/' }"
48+
[headerToolsLinks]="headerToolsLinks"
49+
(linkSelect)="logout($event)"
50+
[menu]="menuHeaderItems"
51+
></dsfr-header>
11652
<main role="main" id="page">
11753
<router-outlet></router-outlet>
11854
</main>

packages/portail-admins/src/app/app.component.ts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { LIENS_PARTENAIRES } from "./modules/general/components/static-pages/pla
88
import { PortailAdminUser } from "@domifa/common";
99
import { faChartBar } from "@fortawesome/free-regular-svg-icons";
1010
import { faList, faUsers } from "@fortawesome/free-solid-svg-icons";
11+
import { DsfrHeaderMenuItem, DsfrLink } from "@edugouvfr/ngx-dsfr";
1112

1213
@Component({
1314
selector: "app-root",
@@ -21,7 +22,8 @@ export class AppComponent implements OnInit {
2122
public faUsers = faUsers;
2223
public faList = faList;
2324
public currentUrl = "";
24-
25+
public headerToolsLinks: DsfrLink[] = [];
26+
public menuHeaderItems: DsfrHeaderMenuItem[] = [];
2527
constructor(
2628
private readonly router: Router,
2729
private readonly titleService: Title,
@@ -38,6 +40,36 @@ export class AppComponent implements OnInit {
3840
this.adminAuthService.currentAdminSubject.subscribe(
3941
(admin: PortailAdminUser | null) => {
4042
this.adminProfile = admin;
43+
if (admin && admin.role === "super-admin-domifa") {
44+
// left logout button
45+
this.headerToolsLinks = [
46+
{
47+
ariaControls: "logoutModal",
48+
linkId: "logout",
49+
mode: "button",
50+
label: "Se déconnecter",
51+
icon: "fr-icon-logout-box-r-line",
52+
},
53+
];
54+
// subheader menun
55+
this.menuHeaderItems = [
56+
{
57+
linkId: "stats",
58+
label: "Statistiques de la domiciliation",
59+
routerLink: "/stats",
60+
},
61+
{
62+
linkId: "structures",
63+
label: "Liste des structures",
64+
routerLink: "/structures",
65+
},
66+
{
67+
linkId: "manage-users",
68+
label: "Utilisateurs de l'administration",
69+
routerLink: "/manage-users",
70+
},
71+
];
72+
}
4173
}
4274
);
4375

@@ -72,7 +104,11 @@ export class AppComponent implements OnInit {
72104
});
73105
}
74106

75-
public logout(): void {
76-
this.adminAuthService.logoutAndRedirect();
107+
public logout(event: DsfrLink): void {
108+
if (event.linkId === "logout") {
109+
this.headerToolsLinks = [];
110+
this.menuHeaderItems = [];
111+
this.adminAuthService.logoutAndRedirect();
112+
}
77113
}
78114
}

packages/portail-admins/src/app/modules/shared/shared.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { FonctionSelectionComponent } from "./components/fonction-selection/fonction-selection.component";
1818
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
1919
import { FonctionFormatPipe } from "./pipes/fonction-format.pipe";
20-
import { DsfrAlertModule } from "@edugouvfr/ngx-dsfr";
20+
import { DsfrAlertModule, DsfrHeaderModule } from "@edugouvfr/ngx-dsfr";
2121

2222
@NgModule({
2323
declarations: [
@@ -37,6 +37,7 @@ import { DsfrAlertModule } from "@edugouvfr/ngx-dsfr";
3737
CustomToastrComponent,
3838
FonctionSelectionComponent,
3939
FonctionFormatPipe,
40+
DsfrHeaderModule,
4041
],
4142
imports: [
4243
CommonModule,
@@ -45,6 +46,7 @@ import { DsfrAlertModule } from "@edugouvfr/ngx-dsfr";
4546
ReactiveFormsModule,
4647
FonctionFormatPipe,
4748
DsfrAlertModule,
49+
DsfrHeaderModule,
4850
],
4951
providers: [AdminStructuresApiClient],
5052
})
Lines changed: 12 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)