diff --git a/frontend/src/app/components/nav-home/nav-home.component.ts b/frontend/src/app/components/nav-home/nav-home.component.ts index 89c34666e5..35edad38d0 100644 --- a/frontend/src/app/components/nav-home/nav-home.component.ts +++ b/frontend/src/app/components/nav-home/nav-home.component.ts @@ -44,6 +44,7 @@ export class NavHomeComponent implements OnInit, OnDestroy { // Set the current module name in the navbar this.onModuleChange(); + // Init the sidenav instance in sidebar service this.sideNavService.setSideNav(this.sidenav); @@ -80,6 +81,7 @@ export class NavHomeComponent implements OnInit, OnDestroy { private onModuleChange() { this._moduleService.currentModule$.subscribe((module) => { if (!module) { + // If in Home Page module = this.sideNavService.getHomeItem(); module.module_doc_url = this._moduleService.geoNatureModule.module_doc_url; } diff --git a/frontend/src/app/components/sidenav-items/sidenav-service.ts b/frontend/src/app/components/sidenav-items/sidenav-service.ts index 14c1213dea..4fc37d81be 100644 --- a/frontend/src/app/components/sidenav-items/sidenav-service.ts +++ b/frontend/src/app/components/sidenav-items/sidenav-service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { MatSidenav } from '@angular/material/sidenav'; +import { Module } from '@geonature/models/module.model'; import { Subject } from 'rxjs'; @Injectable() @@ -30,8 +31,12 @@ export class SideNavService { return this.currentModule; } - getHomeItem() { - return { module_url: '/', module_label: 'Accueil', module_picto: 'fa-home', id: '1' }; + getHomeItem() : Module { + let abs_path = '/'; + if (window.location.pathname) { // for GeoNature URL like https://demo.geonature.fr/geonature/ + abs_path = window.location.pathname; + } + return { module_url: abs_path, module_label: 'Accueil', module_picto: 'fa-home', id_module: 1, module_path: "/geonature"}; } toggleSideNav() { diff --git a/frontend/src/app/models/module.model.ts b/frontend/src/app/models/module.model.ts new file mode 100644 index 0000000000..793da23355 --- /dev/null +++ b/frontend/src/app/models/module.model.ts @@ -0,0 +1,8 @@ +export interface Module{ + id_module: number; + module_label: string; + module_picto?: string; + module_path:string; + module_doc_url?: string; + module_url?: string; +} \ No newline at end of file