From 13b544c67df19cbe286641cd6c59e3081d062e4b Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 25 May 2025 19:14:04 +0100 Subject: [PATCH] Feature/refactor router links (#4752) * Refactor router links --- apps/client/src/app/app-routing.module.ts | 4 +- apps/client/src/app/app.component.html | 4 +- apps/client/src/app/app.component.ts | 2 + .../benchmark-comparator.component.html | 2 +- .../benchmark-comparator.component.ts | 5 +++ .../components/header/header.component.html | 42 ++++++++++--------- .../app/components/header/header.component.ts | 5 +++ .../home-holdings/home-holdings.component.ts | 5 +++ .../home-holdings/home-holdings.html | 2 +- .../home-overview/home-overview.component.ts | 7 ++++ .../home-overview/home-overview.html | 14 ++++--- apps/client/src/app/core/auth.guard.ts | 2 +- .../overview/about-overview-page.component.ts | 2 + .../about/overview/about-overview-page.html | 6 ++- .../app/pages/admin/admin-page.component.ts | 10 ++--- .../hallo-ghostfolio-page.component.ts | 1 + .../hallo-ghostfolio-page.html | 2 +- .../hello-ghostfolio-page.component.ts | 1 + .../hello-ghostfolio-page.html | 2 +- ...st-months-in-open-source-page.component.ts | 1 + .../first-months-in-open-source-page.html | 2 +- ...-meets-internet-identity-page.component.ts | 6 ++- ...ostfolio-meets-internet-identity-page.html | 2 +- ...get-my-finances-in-order-page.component.ts | 1 + ...ow-do-i-get-my-finances-in-order-page.html | 2 +- .../500-stars-on-github-page.component.ts | 1 + .../500-stars-on-github-page.html | 2 +- .../hacktoberfest-2022-page.component.ts | 6 ++- .../hacktoberfest-2022-page.html | 2 +- .../black-friday-2022-page.component.ts | 1 + .../black-friday-2022-page.html | 2 +- ...g-your-personal-finances-page.component.ts | 6 ++- ...-tracking-your-personal-finances-page.html | 2 +- ...auf-sackgeld-vorgestellt-page.component.ts | 6 ++- ...stfolio-auf-sackgeld-vorgestellt-page.html | 2 +- .../ghostfolio-meets-umbrel-page.component.ts | 6 ++- .../ghostfolio-meets-umbrel-page.html | 2 +- .../1000-stars-on-github-page.component.ts | 1 + .../1000-stars-on-github-page.html | 2 +- ...otential-with-ghostfolio-page.component.ts | 1 + ...ancial-potential-with-ghostfolio-page.html | 2 +- ...ploring-the-path-to-fire-page.component.ts | 1 + .../exploring-the-path-to-fire-page.html | 2 +- ...tfolio-joins-oss-friends-page.component.ts | 1 + .../ghostfolio-joins-oss-friends-page.html | 2 +- .../ghostfolio-2-page.component.ts | 1 + .../09/ghostfolio-2/ghostfolio-2-page.html | 2 +- .../hacktoberfest-2023-page.component.ts | 2 + .../hacktoberfest-2023-page.html | 12 +++--- .../black-week-2023-page.component.ts | 1 + .../black-week-2023/black-week-2023-page.html | 2 +- ...oberfest-2023-debriefing-page.component.ts | 1 + .../hacktoberfest-2023-debriefing-page.html | 2 +- .../hacktoberfest-2024-page.component.ts | 2 + .../hacktoberfest-2024-page.html | 12 +++--- .../black-weeks-2024-page.component.ts | 1 + .../black-weeks-2024-page.html | 2 +- .../app/pages/faq/saas/saas-page.component.ts | 2 + .../src/app/pages/faq/saas/saas-page.html | 4 +- .../pages/landing/landing-page.component.ts | 2 + .../src/app/pages/landing/landing-page.html | 12 +++--- libs/common/src/lib/paths.ts | 4 +- .../no-transactions-info.component.html | 2 +- .../no-transactions-info.component.ts | 7 ++++ 64 files changed, 172 insertions(+), 83 deletions(-) diff --git a/apps/client/src/app/app-routing.module.ts b/apps/client/src/app/app-routing.module.ts index 1d62f5f13..b3be70bb2 100644 --- a/apps/client/src/app/app-routing.module.ts +++ b/apps/client/src/app/app-routing.module.ts @@ -28,7 +28,7 @@ const routes: Routes = [ ) }, { - path: paths.admin, + path: paths.adminControl, loadChildren: () => import('./pages/admin/admin-page.module').then((m) => m.AdminPageModule) }, @@ -95,7 +95,7 @@ const routes: Routes = [ ) }, { - path: paths.open, + path: paths.openStartup, loadChildren: () => import('./pages/open/open-page.module').then((m) => m.OpenPageModule) }, diff --git a/apps/client/src/app/app.component.html b/apps/client/src/app/app.component.html index d5e56b517..a04e457ba 100644 --- a/apps/client/src/app/app.component.html +++ b/apps/client/src/app/app.component.html @@ -70,7 +70,7 @@
  • About
  • @if (hasPermissionForSubscription) {
  • - Blog + Blog
  • }
  • @@ -91,7 +91,7 @@ } @if (hasPermissionForStatistics) {
  • - Open Startup + Open Startup
  • } @if (hasPermissionForSubscription) { diff --git a/apps/client/src/app/app.component.ts b/apps/client/src/app/app.component.ts index 02db9fea0..5d198580e 100644 --- a/apps/client/src/app/app.component.ts +++ b/apps/client/src/app/app.component.ts @@ -74,9 +74,11 @@ export class AppComponent implements OnDestroy, OnInit { '/' + paths.about, paths.termsOfService ]; + public routerLinkBlog = ['/' + paths.blog]; public routerLinkFaq = ['/' + paths.faq]; public routerLinkFeatures = ['/' + paths.features]; public routerLinkMarkets = ['/' + paths.markets]; + public routerLinkOpenStartup = ['/' + paths.openStartup]; public routerLinkPricing = ['/' + paths.pricing]; public routerLinkRegister = ['/' + paths.register]; public routerLinkResources = ['/' + paths.resources]; diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html index eab89f53d..21d68984a 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html @@ -29,7 +29,7 @@ }} } @if (hasPermissionToAccessAdminControl) { - +
    Manage Benchmarks diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts index afcb561f6..c98f01fb7 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts @@ -12,6 +12,7 @@ import { parseDate } from '@ghostfolio/common/helper'; import { LineChartItem, User } from '@ghostfolio/common/interfaces'; +import { paths } from '@ghostfolio/common/paths'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { ColorScheme } from '@ghostfolio/common/types'; @@ -63,6 +64,10 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { public chart: Chart<'line'>; public hasPermissionToAccessAdminControl: boolean; + public routerLinkAdminControlMarketData = [ + '/' + paths.adminControl, + paths.marketData + ]; public constructor() { Chart.register( diff --git a/apps/client/src/app/components/header/header.component.html b/apps/client/src/app/components/header/header.component.html index b14d142f4..74737ca05 100644 --- a/apps/client/src/app/components/header/header.component.html +++ b/apps/client/src/app/components/header/header.component.html @@ -20,9 +20,9 @@ mat-flat-button [ngClass]="{ 'font-weight-bold': - currentRoute === 'home' || currentRoute === 'zen', + currentRoute === paths.home || currentRoute === paths.zen, 'text-decoration-underline': - currentRoute === 'home' || currentRoute === 'zen' + currentRoute === paths.home || currentRoute === paths.zen }" [routerLink]="['/']" >OverviewPortfolio @@ -47,10 +47,10 @@ i18n mat-flat-button [ngClass]="{ - 'font-weight-bold': currentRoute === 'accounts', - 'text-decoration-underline': currentRoute === 'accounts' + 'font-weight-bold': currentRoute === paths.accounts, + 'text-decoration-underline': currentRoute === paths.accounts }" - [routerLink]="['/accounts']" + [routerLink]="routerLinkAccounts" >Accounts @@ -61,10 +61,10 @@ i18n mat-flat-button [ngClass]="{ - 'font-weight-bold': currentRoute === 'admin', - 'text-decoration-underline': currentRoute === 'admin' + 'font-weight-bold': currentRoute === paths.adminControl, + 'text-decoration-underline': currentRoute === paths.adminControl }" - [routerLink]="['/admin']" + [routerLink]="routerLinkAdminControl" >Admin Control @@ -235,7 +235,7 @@ mat-menu-item [ngClass]="{ 'font-weight-bold': - currentRoute === 'home' || currentRoute === 'zen' + currentRoute === paths.home || currentRoute === paths.zen }" [routerLink]="['/']" >OverviewPortfolio Accounts My Ghostfolio @if (hasPermissionToAccessAdminControl) { @@ -270,8 +270,10 @@ class="d-flex d-sm-none" i18n mat-menu-item - [ngClass]="{ 'font-weight-bold': currentRoute === 'admin' }" - [routerLink]="['/admin']" + [ngClass]="{ + 'font-weight-bold': currentRoute === paths.adminControl + }" + [routerLink]="routerLinkAdminControl" >Admin Control } diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts index a0fbe8c84..52418bcb7 100644 --- a/apps/client/src/app/components/header/header.component.ts +++ b/apps/client/src/app/components/header/header.component.ts @@ -80,14 +80,19 @@ export class HeaderComponent implements OnChanges { public hasPermissionToCreateUser: boolean; public impersonationId: string; public isMenuOpen: boolean; + public paths = paths; public routeAbout = paths.about; public routeFeatures = paths.features; public routeMarkets = paths.markets; public routePricing = paths.pricing; public routeResources = paths.resources; public routerLinkAbout = ['/' + paths.about]; + public routerLinkAccount = ['/' + paths.account]; + public routerLinkAccounts = ['/' + paths.accounts]; + public routerLinkAdminControl = ['/' + paths.adminControl]; public routerLinkFeatures = ['/' + paths.features]; public routerLinkMarkets = ['/' + paths.markets]; + public routerLinkPortfolio = ['/' + paths.portfolio]; public routerLinkPricing = ['/' + paths.pricing]; public routerLinkRegister = ['/' + paths.register]; public routerLinkResources = ['/' + paths.resources]; diff --git a/apps/client/src/app/components/home-holdings/home-holdings.component.ts b/apps/client/src/app/components/home-holdings/home-holdings.component.ts index dd411f6cc..9f772a3e4 100644 --- a/apps/client/src/app/components/home-holdings/home-holdings.component.ts +++ b/apps/client/src/app/components/home-holdings/home-holdings.component.ts @@ -7,6 +7,7 @@ import { ToggleOption, User } from '@ghostfolio/common/interfaces'; +import { paths } from '@ghostfolio/common/paths'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { HoldingType, HoldingsViewMode } from '@ghostfolio/common/types'; @@ -36,6 +37,10 @@ export class HomeHoldingsComponent implements OnDestroy, OnInit { { label: $localize`Active`, value: 'ACTIVE' }, { label: $localize`Closed`, value: 'CLOSED' } ]; + public routerLinkPortfolioActivities = [ + '/' + paths.portfolio, + paths.activities + ]; public user: User; public viewModeFormControl = new FormControl( HomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE diff --git a/apps/client/src/app/components/home-holdings/home-holdings.html b/apps/client/src/app/components/home-holdings/home-holdings.html index f981e50a1..6040ffe2a 100644 --- a/apps/client/src/app/components/home-holdings/home-holdings.html +++ b/apps/client/src/app/components/home-holdings/home-holdings.html @@ -58,7 +58,7 @@ class="mt-3" i18n mat-stroked-button - [routerLink]="['/portfolio', 'activities']" + [routerLink]="routerLinkPortfolioActivities" >Manage Activities
    diff --git a/apps/client/src/app/components/home-overview/home-overview.component.ts b/apps/client/src/app/components/home-overview/home-overview.component.ts index b0e7be320..783b7d1b9 100644 --- a/apps/client/src/app/components/home-overview/home-overview.component.ts +++ b/apps/client/src/app/components/home-overview/home-overview.component.ts @@ -10,6 +10,7 @@ import { PortfolioPerformance, User } from '@ghostfolio/common/interfaces'; +import { paths } from '@ghostfolio/common/paths'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; @@ -36,6 +37,12 @@ export class HomeOverviewComponent implements OnDestroy, OnInit { public isLoadingPerformance = true; public performance: PortfolioPerformance; public precision = 2; + public routerLinkAccounts = ['/' + paths.accounts]; + public routerLinkPortfolio = ['/' + paths.portfolio]; + public routerLinkPortfolioActivities = [ + '/' + paths.portfolio, + paths.activities + ]; public showDetails = false; public unit: string; public user: User; diff --git a/apps/client/src/app/components/home-overview/home-overview.html b/apps/client/src/app/components/home-overview/home-overview.html index c13c8f043..04b47277f 100644 --- a/apps/client/src/app/components/home-overview/home-overview.html +++ b/apps/client/src/app/components/home-overview/home-overview.html @@ -11,7 +11,7 @@ class="mb-2" [ngClass]="{ 'text-muted': user?.accounts?.length > 1 }" > - Setup your accounts
    Get a comprehensive financial overview by adding your bank and @@ -20,7 +20,7 @@ >
  • - + Capture your activities
    Record your investment activities to keep your portfolio up to @@ -29,7 +29,7 @@ >
  • - + Monitor and analyze your portfolio
    Track your progress in real-time with comprehensive analysis @@ -40,14 +40,18 @@
    @if (user?.accounts?.length === 1) { - + Setup accounts } @else if (user?.accounts?.length > 1) { Add activity diff --git a/apps/client/src/app/core/auth.guard.ts b/apps/client/src/app/core/auth.guard.ts index 16851b4e0..87ef23d60 100644 --- a/apps/client/src/app/core/auth.guard.ts +++ b/apps/client/src/app/core/auth.guard.ts @@ -21,7 +21,7 @@ export class AuthGuard { `/${paths.faq}`, `/${paths.features}`, `/${paths.markets}`, - `/${paths.open}`, + `/${paths.openStartup}`, `/${paths.pricing}`, `/${paths.public}`, `/${paths.register}`, diff --git a/apps/client/src/app/pages/about/overview/about-overview-page.component.ts b/apps/client/src/app/pages/about/overview/about-overview-page.component.ts index 5ec30a32e..ec135e4d3 100644 --- a/apps/client/src/app/pages/about/overview/about-overview-page.component.ts +++ b/apps/client/src/app/pages/about/overview/about-overview-page.component.ts @@ -18,8 +18,10 @@ export class AboutOverviewPageComponent implements OnDestroy, OnInit { public hasPermissionForStatistics: boolean; public hasPermissionForSubscription: boolean; public isLoggedIn: boolean; + public routerLinkBlog = ['/' + paths.blog]; public routerLinkFaq = ['/' + paths.faq]; public routerLinkFeatures = ['/' + paths.features]; + public routerLinkOpenStartup = ['/' + paths.openStartup]; public user: User; private unsubscribeSubject = new Subject(); diff --git a/apps/client/src/app/pages/about/overview/about-overview-page.html b/apps/client/src/app/pages/about/overview/about-overview-page.html index 3891f929d..9a7dd142e 100644 --- a/apps/client/src/app/pages/about/overview/about-overview-page.html +++ b/apps/client/src/app/pages/about/overview/about-overview-page.html @@ -23,7 +23,9 @@ > @if (hasPermissionForStatistics) { and we share aggregated - key metrics + key metrics of the platform’s performance } . The project has been initiated by @@ -160,7 +162,7 @@ class="py-4 w-100" color="primary" mat-flat-button - [routerLink]="['/blog']" + [routerLink]="routerLinkBlog" >Blog
    diff --git a/apps/client/src/app/pages/admin/admin-page.component.ts b/apps/client/src/app/pages/admin/admin-page.component.ts index 8328b7aba..e787cb0fc 100644 --- a/apps/client/src/app/pages/admin/admin-page.component.ts +++ b/apps/client/src/app/pages/admin/admin-page.component.ts @@ -27,27 +27,27 @@ export class AdminPageComponent implements OnDestroy, OnInit { { iconName: 'reader-outline', label: $localize`Overview`, - path: ['/' + paths.admin] + path: ['/' + paths.adminControl] }, { iconName: 'settings-outline', label: $localize`Settings`, - path: ['/' + paths.admin, paths.settings] + path: ['/' + paths.adminControl, paths.settings] }, { iconName: 'server-outline', label: $localize`Market Data`, - path: ['/' + paths.admin, paths.marketData] + path: ['/' + paths.adminControl, paths.marketData] }, { iconName: 'flash-outline', label: $localize`Job Queue`, - path: ['/' + paths.admin, paths.jobs] + path: ['/' + paths.adminControl, paths.jobs] }, { iconName: 'people-outline', label: $localize`Users`, - path: ['/' + paths.admin, paths.users] + path: ['/' + paths.adminControl, paths.users] } ]; } diff --git a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.component.ts b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.component.ts index 5dcb6e359..222a79648 100644 --- a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.component.ts +++ b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.component.ts @@ -11,6 +11,7 @@ import { RouterModule } from '@angular/router'; templateUrl: './hallo-ghostfolio-page.html' }) export class HalloGhostfolioPageComponent { + public routerLinkBlog = ['/' + paths.blog]; public routerLinkPricing = ['/' + paths.pricing]; public routerLinkResources = ['/' + paths.resources]; } diff --git a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html index e0364f747..28e30d16b 100644 --- a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html +++ b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html @@ -201,7 +201,7 @@