|
19 | 19 | * SPDX-License-Identifier: Apache-2.0 |
20 | 20 | ********************************************************************************/ |
21 | 21 |
|
22 | | -import { Component, Input } from '@angular/core'; |
| 22 | +import { Component } from '@angular/core'; |
23 | 23 | import { NavigationEnd, Router } from '@angular/router'; |
24 | | -import { getAboutRoute } from '@page/about/about-route'; |
25 | | -import { getAdminRoute } from '@page/admin/admin-route'; |
26 | | -import { getDashboardRoute } from '@page/dashboard/dashboard-route'; |
27 | | -import { getInvestigationInboxRoute } from '@page/investigations/investigations-external-route'; |
28 | | -import { getOtherPartsRoute } from '@page/other-parts/other-parts-route'; |
29 | | -import { getPartsRoute } from '@page/parts/parts-route'; |
30 | | -import { PageRoute } from '@shared/model/page-route.model'; |
| 24 | +import { KnownUrl, NavigableUrls } from '@core/known-route'; |
31 | 25 | import { filter } from 'rxjs/operators'; |
32 | 26 |
|
33 | 27 | @Component({ |
34 | | - selector: 'app-sidebar', |
35 | | - templateUrl: './sidebar.component.html', |
36 | | - styleUrls: ['./sidebar.component.scss'], |
| 28 | + selector: 'app-header', |
| 29 | + templateUrl: './header.component.html', |
| 30 | + styleUrls: ['./header.component.scss'], |
37 | 31 | }) |
38 | | -export class SidebarComponent { |
39 | | - @Input() expanded: boolean; |
| 32 | +export class HeaderComponent { |
40 | 33 | public activeMenu = ''; |
41 | 34 |
|
42 | | - private readonly menu: Record<string, PageRoute> = { |
43 | | - dashboard: getDashboardRoute(), |
44 | | - about: getAboutRoute(), |
45 | | - parts: getPartsRoute(), |
46 | | - otherParts: getOtherPartsRoute(), |
47 | | - investigations: getInvestigationInboxRoute(), |
48 | | - admin: getAdminRoute(), |
| 35 | + public readonly iconMapping: Record<KnownUrl, string> = { |
| 36 | + dashboard: 'dashboard', |
| 37 | + about: 'info', |
| 38 | + parts: 'build', |
| 39 | + otherParts: 'commute', |
| 40 | + investigations: 'inbox', |
| 41 | + admin: 'apps', |
49 | 42 | }; |
50 | 43 |
|
51 | 44 | constructor(private readonly router: Router) { |
52 | 45 | this.router.events |
53 | 46 | .pipe(filter(event => event instanceof NavigationEnd)) |
54 | 47 | .subscribe(({ urlAfterRedirects, url }: NavigationEnd) => { |
55 | 48 | const currentUrl = urlAfterRedirects ?? url; |
56 | | - this.activeMenu = Object.keys(this.menu).find(menuKey => currentUrl.includes(menuKey)); |
| 49 | + this.activeMenu = NavigableUrls.find(menuKey => currentUrl.includes(menuKey)); |
57 | 50 | }); |
58 | 51 | } |
59 | 52 |
|
60 | | - public navigate(item: string): void { |
61 | | - this.router.navigate([this.menu[item].link]).then(); |
62 | | - this.activeMenu = item; |
| 53 | + public openDocumentation(): void { |
| 54 | + window.open('https://eclipse-tractusx.github.io/traceability-foss-backend/docs/', '_blank', 'noopener'); |
63 | 55 | } |
64 | 56 | } |
0 commit comments