From 18f94a1ba15f37151d8de340e66dcc944e7b5bcd Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 16 Jun 2025 08:02:11 +0200 Subject: [PATCH] Feature/refactor various routes (part 2) (#4949) * Refactor various routes --- apps/client/src/app/app-routing.module.ts | 2 +- apps/client/src/app/app.component.ts | 8 ++------ .../components/access-table/access-table.component.ts | 4 ++-- apps/client/src/app/core/auth.guard.ts | 8 ++------ .../src/app/pages/home/home-page-routing.module.ts | 9 +++------ apps/client/src/app/pages/home/home-page.component.ts | 6 +++--- libs/common/src/lib/routes/routes.ts | 11 +++++++++-- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/apps/client/src/app/app-routing.module.ts b/apps/client/src/app/app-routing.module.ts index 63eef7250..a7e587ea8 100644 --- a/apps/client/src/app/app-routing.module.ts +++ b/apps/client/src/app/app-routing.module.ts @@ -119,7 +119,7 @@ const routes: Routes = [ ) }, { - path: ghostfolioRoutes.public, + path: publicRoutes.public.path, loadChildren: () => import('./pages/public/public-page.module').then( (m) => m.PublicPageModule diff --git a/apps/client/src/app/app.component.ts b/apps/client/src/app/app.component.ts index 72e8b84d8..fb39028fc 100644 --- a/apps/client/src/app/app.component.ts +++ b/apps/client/src/app/app.component.ts @@ -3,11 +3,7 @@ import { HoldingDetailDialogParams } from '@ghostfolio/client/components/holding import { getCssVariable } from '@ghostfolio/common/helper'; import { InfoItem, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; -import { - internalRoutes, - publicRoutes, - routes -} from '@ghostfolio/common/routes/routes'; +import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes'; import { ColorScheme } from '@ghostfolio/common/types'; import { DOCUMENT } from '@angular/common'; @@ -213,7 +209,7 @@ export class AppComponent implements OnDestroy, OnInit { this.currentRoute === publicRoutes.features.path || this.currentRoute === publicRoutes.markets.path || this.currentRoute === publicRoutes.openStartup.path || - this.currentRoute === routes.public || + this.currentRoute === publicRoutes.public.path || this.currentRoute === publicRoutes.pricing.path || this.currentRoute === publicRoutes.register.path || this.currentRoute === publicRoutes.start.path) && diff --git a/apps/client/src/app/components/access-table/access-table.component.ts b/apps/client/src/app/components/access-table/access-table.component.ts index 50d823def..641156f5b 100644 --- a/apps/client/src/app/components/access-table/access-table.component.ts +++ b/apps/client/src/app/components/access-table/access-table.component.ts @@ -1,7 +1,7 @@ import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type'; import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { Access, User } from '@ghostfolio/common/interfaces'; -import { routes } from '@ghostfolio/common/routes/routes'; +import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { Clipboard } from '@angular/cdk/clipboard'; import { @@ -55,7 +55,7 @@ export class AccessTableComponent implements OnChanges { public getPublicUrl(aId: string): string { const languageCode = this.user.settings.language; - return `${this.baseUrl}/${languageCode}/${routes.public}/${aId}`; + return `${this.baseUrl}/${languageCode}/${publicRoutes.public.path}/${aId}`; } public onCopyUrlToClipboard(aId: string): void { diff --git a/apps/client/src/app/core/auth.guard.ts b/apps/client/src/app/core/auth.guard.ts index ef6a8f4a7..69280af6a 100644 --- a/apps/client/src/app/core/auth.guard.ts +++ b/apps/client/src/app/core/auth.guard.ts @@ -1,11 +1,7 @@ import { DataService } from '@ghostfolio/client/services/data.service'; import { SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; -import { - internalRoutes, - publicRoutes, - routes -} from '@ghostfolio/common/routes/routes'; +import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes'; import { Injectable } from '@angular/core'; import { @@ -27,7 +23,7 @@ export class AuthGuard { `/${publicRoutes.markets.path}`, `/${publicRoutes.openStartup.path}`, `/${publicRoutes.pricing.path}`, - `/${routes.public}`, + `/${publicRoutes.public.path}`, `/${publicRoutes.register.path}`, `/${publicRoutes.resources.path}` ]; diff --git a/apps/client/src/app/pages/home/home-page-routing.module.ts b/apps/client/src/app/pages/home/home-page-routing.module.ts index 68432c17d..6fa7f1c27 100644 --- a/apps/client/src/app/pages/home/home-page-routing.module.ts +++ b/apps/client/src/app/pages/home/home-page-routing.module.ts @@ -4,10 +4,7 @@ import { HomeOverviewComponent } from '@ghostfolio/client/components/home-overvi import { HomeSummaryComponent } from '@ghostfolio/client/components/home-summary/home-summary.component'; import { HomeWatchlistComponent } from '@ghostfolio/client/components/home-watchlist/home-watchlist.component'; import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; -import { - routes as ghostfolioRoutes, - internalRoutes -} from '@ghostfolio/common/routes/routes'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; @@ -33,9 +30,9 @@ const routes: Routes = [ title: internalRoutes.home.subRoutes.summary.title }, { - path: ghostfolioRoutes.market, + path: internalRoutes.home.subRoutes.markets.path, component: HomeMarketComponent, - title: $localize`Markets` + title: internalRoutes.home.subRoutes.markets.title }, { path: internalRoutes.home.subRoutes.watchlist.path, diff --git a/apps/client/src/app/pages/home/home-page.component.ts b/apps/client/src/app/pages/home/home-page.component.ts index 68d93520a..ad9a65a4c 100644 --- a/apps/client/src/app/pages/home/home-page.component.ts +++ b/apps/client/src/app/pages/home/home-page.component.ts @@ -1,7 +1,7 @@ import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { TabConfiguration, User } from '@ghostfolio/common/interfaces'; -import { internalRoutes, routes } from '@ghostfolio/common/routes/routes'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { DeviceDetectorService } from 'ngx-device-detector'; @@ -56,8 +56,8 @@ export class HomePageComponent implements OnDestroy, OnInit { }, { iconName: 'newspaper-outline', - label: $localize`Markets`, - routerLink: ['/' + internalRoutes.home.path, routes.market] + label: internalRoutes.home.subRoutes.markets.title, + routerLink: internalRoutes.home.subRoutes.markets.routerLink } ]; diff --git a/libs/common/src/lib/routes/routes.ts b/libs/common/src/lib/routes/routes.ts index 6f6017623..adf2b5704 100644 --- a/libs/common/src/lib/routes/routes.ts +++ b/libs/common/src/lib/routes/routes.ts @@ -5,9 +5,7 @@ import { IRoute } from './interfaces/interfaces'; export const routes = { api: 'api', i18n: 'i18n', - market: 'market', personalFinanceTools: 'personal-finance-tools', - public: 'p', // Publicly accessible pages openSourceAlternativeTo: $localize`:kebab-case:open-source-alternative-to` @@ -79,6 +77,11 @@ export const internalRoutes: Record = { routerLink: ['/home', 'holdings'], title: $localize`Holdings` }, + markets: { + path: 'markets', + routerLink: ['/home', 'markets'], + title: $localize`Markets` + }, summary: { path: 'summary', routerLink: ['/home', 'summary'], @@ -240,6 +243,10 @@ export const publicRoutes = { routerLink: ['/' + $localize`:kebab-case:pricing`], title: $localize`Pricing` }, + public: { + path: 'p', + routerLink: ['/p'] + }, register: { path: $localize`:kebab-case:register`, routerLink: ['/' + $localize`:kebab-case:register`],