Browse Source

Feature/reuse routes in app component (#4878)

* Reuse routes
pull/4869/head^2
Thomas Kaul 3 weeks ago
committed by GitHub
parent
commit
d77295f64c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 70
      apps/client/src/app/app.component.ts

70
apps/client/src/app/app.component.ts

@ -3,7 +3,11 @@ import { HoldingDetailDialogParams } from '@ghostfolio/client/components/holding
import { getCssVariable } from '@ghostfolio/common/helper'; import { getCssVariable } from '@ghostfolio/common/helper';
import { InfoItem, User } from '@ghostfolio/common/interfaces'; import { InfoItem, User } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { publicRoutes, routes } from '@ghostfolio/common/routes'; import {
internalRoutes,
publicRoutes,
routes
} from '@ghostfolio/common/routes';
import { ColorScheme } from '@ghostfolio/common/types'; import { ColorScheme } from '@ghostfolio/common/types';
import { DOCUMENT } from '@angular/common'; import { DOCUMENT } from '@angular/common';
@ -160,10 +164,13 @@ export class AppComponent implements OnDestroy, OnInit {
this.currentSubRoute = urlSegments[1]?.path; this.currentSubRoute = urlSegments[1]?.path;
if ( if (
((this.currentRoute === 'home' && !this.currentSubRoute) || ((this.currentRoute === internalRoutes.home.path &&
(this.currentRoute === 'home' && !this.currentSubRoute) ||
this.currentSubRoute === 'holdings') || (this.currentRoute === internalRoutes.home.path &&
(this.currentRoute === 'portfolio' && !this.currentSubRoute)) && this.currentSubRoute ===
internalRoutes.home.subRoutes.holdings.path) ||
(this.currentRoute === internalRoutes.portfolio.path &&
!this.currentSubRoute)) &&
this.user?.settings?.viewMode !== 'ZEN' this.user?.settings?.viewMode !== 'ZEN'
) { ) {
this.hasPermissionToChangeDateRange = true; this.hasPermissionToChangeDateRange = true;
@ -172,14 +179,19 @@ export class AppComponent implements OnDestroy, OnInit {
} }
if ( if (
(this.currentRoute === 'home' && (this.currentRoute === internalRoutes.home.path &&
this.currentSubRoute === 'holdings') || this.currentSubRoute ===
(this.currentRoute === 'portfolio' && !this.currentSubRoute) || internalRoutes.home.subRoutes.holdings.path) ||
(this.currentRoute === 'portfolio' && (this.currentRoute === internalRoutes.portfolio.path &&
this.currentSubRoute === 'activities') || !this.currentSubRoute) ||
(this.currentRoute === 'portfolio' && (this.currentRoute === internalRoutes.portfolio.path &&
this.currentSubRoute === 'allocations') || this.currentSubRoute ===
(this.currentRoute === 'zen' && this.currentSubRoute === 'holdings') internalRoutes.portfolio.subRoutes.activities.path) ||
(this.currentRoute === internalRoutes.portfolio.path &&
this.currentSubRoute === routes.allocations) ||
(this.currentRoute === internalRoutes.zen.path &&
this.currentSubRoute ===
internalRoutes.home.subRoutes.holdings.path)
) { ) {
this.hasPermissionToChangeFilters = true; this.hasPermissionToChangeFilters = true;
} else { } else {
@ -187,25 +199,25 @@ export class AppComponent implements OnDestroy, OnInit {
} }
this.hasTabs = this.hasTabs =
(this.currentRoute === this.routerLinkAbout[0].slice(1) || (this.currentRoute === routes.about ||
this.currentRoute === this.routerLinkFaq[0].slice(1) || this.currentRoute === routes.faq ||
this.currentRoute === this.routerLinkResources[0].slice(1) || this.currentRoute === routes.resources ||
this.currentRoute === 'account' || this.currentRoute === routes.account ||
this.currentRoute === 'admin' || this.currentRoute === routes.adminControl ||
this.currentRoute === 'home' || this.currentRoute === internalRoutes.home.path ||
this.currentRoute === 'portfolio' || this.currentRoute === internalRoutes.portfolio.path ||
this.currentRoute === 'zen') && this.currentRoute === internalRoutes.zen.path) &&
this.deviceType !== 'mobile'; this.deviceType !== 'mobile';
this.showFooter = this.showFooter =
(this.currentRoute === 'blog' || (this.currentRoute === routes.blog ||
this.currentRoute === this.routerLinkFeatures[0].slice(1) || this.currentRoute === routes.features ||
this.currentRoute === this.routerLinkMarkets[0].slice(1) || this.currentRoute === routes.markets ||
this.currentRoute === 'open' || this.currentRoute === publicRoutes.openStartup.path ||
this.currentRoute === 'p' || this.currentRoute === routes.public ||
this.currentRoute === this.routerLinkPricing[0].slice(1) || this.currentRoute === routes.pricing ||
this.currentRoute === this.routerLinkRegister[0].slice(1) || this.currentRoute === publicRoutes.register.path ||
this.currentRoute === 'start') && this.currentRoute === routes.start) &&
this.deviceType !== 'mobile'; this.deviceType !== 'mobile';
if (this.deviceType === 'mobile') { if (this.deviceType === 'mobile') {

Loading…
Cancel
Save