diff --git a/.agents/skills/angular-developer/SKILL.md b/.agents/skills/angular-developer/SKILL.md index f332e3e087..b0bf568944 100644 --- a/.agents/skills/angular-developer/SKILL.md +++ b/.agents/skills/angular-developer/SKILL.md @@ -1,6 +1,6 @@ --- name: angular-developer -description: Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling. +description: Generates Angular code and provides architectural guidance. Trigger when creating projects, components, services, or HTTP communication, or for best practices on reactivity (signals, linkedSignal, resource, httpResource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, naming conventions, or CLI tooling. license: MIT metadata: author: Copyright 2026 Google LLC @@ -17,10 +17,10 @@ metadata: ## Creating New Projects -If no guidelines are provided by the user, here are same default rules to follow when creating a new Angular project: +If no guidelines are provided by the user, here are some default rules to follow when creating a new Angular project: 1. Use the latest stable version of Angular unless the user specifies otherwise. -2. Use Signals Forms for form management in new projects (available in Angular v21 and newer) [Find out more](references/signal-forms.md). +2. Use Signal Forms for form management in new projects (stable in Angular v22 and newer) [Find out more](references/signal-forms.md). **Execution Rules for `ng new`:** When asked to create a new Angular project, you must determine the correct execution command by following these strict steps: @@ -45,10 +45,11 @@ When asked to create a new Angular project, you must determine the correct execu When working with Angular components, consult the following references based on the task: -- **Fundamentals**: Anatomy, metadata, core concepts, and template control flow (@if, @for, @switch). Read [components.md](references/components.md) +- **Fundamentals**: Anatomy, metadata, core concepts, self-closing tags, and template control flow (@if, @for, @switch). Read [components.md](references/components.md) - **Inputs**: Signal-based inputs, transforms, and model inputs. Read [inputs.md](references/inputs.md) - **Outputs**: Signal-based outputs and custom event best practices. Read [outputs.md](references/outputs.md) - **Host Elements**: Host bindings and attribute injection. Read [host-elements.md](references/host-elements.md) +- **Naming Conventions**: Modern Angular v20+ naming style ("Intent over Role") for files, components, services, directives, pipes, and models. Read [naming-conventions.md](references/naming-conventions.md) If you require deeper documentation not found in the references above, read the documentation at `https://angular.dev/guide/components`. @@ -61,12 +62,18 @@ When managing state and data reactivity, use Angular Signals and consult the fol - **Async Reactivity (`resource`)**: Fetching asynchronous data directly into signal state. Read [resource.md](references/resource.md) - **Side Effects (`effect`)**: Logging, third-party DOM manipulation (`afterRenderEffect`), and when NOT to use effects. Read [effects.md](references/effects.md) +## HTTP Communication + +When communicating with backend services, use Angular HTTP APIs and consult the following reference: + +- **HTTP Client and Resources**: `provideHttpClient`, `HttpClient`, interceptors, and `httpResource`. Read [http-client.md](references/http-client.md) + ## Forms In most cases for new apps, **prefer signal forms**. When making a forms decision, analyze the project and consider the following guidelines: -- if the application is using v21 or newer and this is a new form, **prefer signal forms**. - -For older applications or when working with existing forms, use the appropriate form type that matches the applications current form strategy. +- If the application is using v22 or newer and this is a new form, **prefer Signal Forms**. +- For older applications or when working with existing forms, use the appropriate form type that matches the applications current form strategy. - **Signal Forms**: Use signals for form state management. Read [signal-forms.md](references/signal-forms.md) - **Template-driven forms**: Use for simple forms. Read [template-driven-forms.md](references/template-driven-forms.md) @@ -82,6 +89,12 @@ When implementing dependency injection in Angular, follow these guidelines: - **Injection Context**: Where `inject()` is allowed, `runInInjectionContext`, and `assertInInjectionContext`. Read [injection-context.md](references/injection-context.md) - **Hierarchical Injectors**: The `EnvironmentInjector` vs `ElementInjector`, resolution rules, modifiers (`optional`, `skipSelf`), and `providers` vs `viewProviders`. Read [hierarchical-injectors.md](references/hierarchical-injectors.md) +## Pipes + +When formatting values in templates, creating custom pipes, or reusing pipe-like logic in TypeScript, consult the following reference. Prefer pipes in templates; outside templates, avoid injecting pipe classes just to call `transform()`. + +- **Pipes**: Built-in pipe imports, custom pipe naming and implementation, pure vs impure pipes, and TypeScript reuse patterns using standalone formatting functions or extracted plain functions. Read [pipes.md](references/pipes.md) + ## Angular Aria When building accessible custom components for any of the following patterns: Accordion, Listbox, Combobox, Menu, Tabs, Toolbar, Tree, Grid, consult the following reference: @@ -119,7 +132,7 @@ When writing or updating tests, consult the following references based on the ta - **Fundamentals**: Best practices for unit testing (Vitest), async patterns, and `TestBed`. Read [testing-fundamentals.md](references/testing-fundamentals.md) - **Component Harnesses**: Standard patterns for robust component interaction. Read [component-harnesses.md](references/component-harnesses.md) - **Router Testing**: Using `RouterTestingHarness` for reliable navigation tests. Read [router-testing.md](references/router-testing.md) -- **End-to-End (E2E) Testing**: Best practices for E2E tests with Cypress. Read [e2e-testing.md](references/e2e-testing.md) +- **End-to-End (E2E) Testing**: Setting up and running E2E tests. Read [e2e-testing.md](references/e2e-testing.md) ## Tooling @@ -128,3 +141,4 @@ When working with Angular tooling, consult the following references: - **Angular CLI**: Creating applications, generating code (components, routes, services), serving, and building. Read [cli.md](references/cli.md) - **Code Modernization**: Automatically refactoring to modern standards using migrations. Read [migrations.md](references/migrations.md) - **Angular MCP Server**: Available tools, configuration, and experimental features. Read [mcp.md](references/mcp.md) +- **Environment Configuration**: Strategies for build-time and runtime configuration. Read [environment-configuration.md](references/environment-configuration.md) diff --git a/.agents/skills/angular-developer/references/angular-animations.md b/.agents/skills/angular-developer/references/angular-animations.md index c96c4d9c6e..4abc961a61 100644 --- a/.agents/skills/angular-developer/references/angular-animations.md +++ b/.agents/skills/angular-developer/references/angular-animations.md @@ -155,6 +155,6 @@ import {trigger, state, style, animate, transition} from '@angular/animations'; template: `
...
`, }) export class OpenClose { - isOpen = signal(true); + protected readonly isOpen = signal(true); } ``` diff --git a/.agents/skills/angular-developer/references/angular-aria.md b/.agents/skills/angular-developer/references/angular-aria.md index 2dd0cf451f..6c618a8b33 100644 --- a/.agents/skills/angular-developer/references/angular-aria.md +++ b/.agents/skills/angular-developer/references/angular-aria.md @@ -17,7 +17,7 @@ Common ARIA attributes to target in CSS: --- -**CRITICAL**: Before using this package, it must be installed via the package manager. Confirm that it has been installed in the project. Use `npm install @angular/aria` to install if necessary. +**CRITICAL**: Before using this package, confirm that `@angular/aria` is installed. If necessary, install it using the package manager configured for the project. ## 1. Accordion @@ -44,11 +44,11 @@ export class App { ```html
- -
+

Lazy loaded content here.

@@ -98,7 +98,7 @@ export class App { ```html -
    +
    • Apple
    • Banana
    @@ -126,37 +126,69 @@ Target `[aria-selected="true"]` for selected state and `:focus-visible` or `[dat ## 3. Combobox, Select, and Multiselect -These patterns combine `ngCombobox` with a popup containing an `ngListbox`. +These patterns combine the `ngCombobox` directive (applied directly to the trigger/combobox element) with a popup containing an `ngListbox` widget. -- **Combobox**: Text input + popup (used for Autocomplete). -- **Select**: Readonly Combobox + single-select Listbox. -- **Multiselect**: Readonly Combobox + multi-select Listbox. - -**Usage:** The Combobox is a low-level primitive directive that synchronizes a text input with a popup, serving as the foundational logic for autocomplete, select, and multiselect patterns. Use it specifically for building custom filtering, unique selection requirements, or specialized input-to-popup coordination that deviates from standard, documented components. +- **Combobox (Autocomplete)**: Applied to an `` element. Ideal when typing filters the list. +- **Select**: Applied to a focusable wrapper like a `
    ` or ` - - -
    + +@if (isLoading()) { + +} 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 122b4f88b8..9b666b3b62 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,9 +1,15 @@ import { ConfirmationDialogType } from '@ghostfolio/common/enums'; +import { getDateFormatString } from '@ghostfolio/common/helper'; import { Access, User } from '@ghostfolio/common/interfaces'; -import { publicRoutes } from '@ghostfolio/common/routes/routes'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes'; +import { getAccessLevel } from '@ghostfolio/common/scopes'; +import { GfAccessLevelIconComponent } from '@ghostfolio/ui/access-level-icon'; import { NotificationService } from '@ghostfolio/ui/notifications'; +import { DataService } from '@ghostfolio/ui/services'; import { Clipboard, ClipboardModule } from '@angular/cdk/clipboard'; +import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -25,21 +31,23 @@ import { copyOutline, createOutline, ellipsisHorizontal, - linkOutline, - lockClosedOutline, - lockOpenOutline, - removeCircleOutline + removeCircleOutline, + trashOutline } from 'ionicons/icons'; import ms from 'ms'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, imports: [ ClipboardModule, + CommonModule, + GfAccessLevelIconComponent, IonIcon, MatButtonModule, MatMenuModule, MatTableModule, + NgxSkeletonLoaderModule, RouterModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -49,17 +57,29 @@ import ms from 'ms'; }) export class GfAccessTableComponent { public readonly accesses = input.required(); + public readonly isReceivedAccess = input(false); public readonly showActions = input(false); public readonly user = input.required(); public readonly accessDeleted = output(); - public readonly accessToUpdate = output(); + + protected readonly accessDialogRouterLinks = computed(() => { + const { update } = internalRoutes.account.subRoutes.access.subRoutes; + + const routerLinks = new Map(); + + for (const { id } of this.accesses() ?? []) { + routerLinks.set(id, update.routerLink(id)); + } + + return routerLinks; + }); protected readonly baseUrl = window.location.origin; protected readonly dataSource = new MatTableDataSource(); protected readonly displayedColumns = computed(() => { - const columns = ['alias', 'grantee', 'type', 'details']; + const columns = ['alias', 'grantee', 'type', 'lastUsedAt', 'expiresAt']; if (this.showActions()) { columns.push('actions'); @@ -68,7 +88,20 @@ export class GfAccessTableComponent { return columns; }); + protected readonly defaultDateFormat = computed(() => { + return getDateFormatString(this.user()?.settings?.locale); + }); + + protected readonly getAccessLevel = getAccessLevel; + + protected hasPermissionToEnableMcp = false; + + protected readonly isLoading = computed(() => { + return !this.accesses(); + }); + private readonly clipboard = inject(Clipboard); + private readonly dataService = inject(DataService); private readonly notificationService = inject(NotificationService); private readonly snackBar = inject(MatSnackBar); @@ -77,12 +110,15 @@ export class GfAccessTableComponent { copyOutline, createOutline, ellipsisHorizontal, - linkOutline, - lockClosedOutline, - lockOpenOutline, - removeCircleOutline + removeCircleOutline, + trashOutline }); + this.hasPermissionToEnableMcp = hasPermission( + this.dataService.fetchInfo().globalPermissions, + permissions.enableMcp + ); + effect(() => { this.dataSource.data = this.accesses() ?? []; }); @@ -112,11 +148,9 @@ export class GfAccessTableComponent { this.accessDeleted.emit(aId); }, confirmType: ConfirmationDialogType.Warn, - title: $localize`Do you really want to revoke this granted access?` + title: this.isReceivedAccess() + ? $localize`Do you really want to remove this received access?` + : $localize`Do you really want to revoke this granted access?` }); } - - protected onUpdateAccess(aId: string) { - this.accessToUpdate.emit(aId); - } } diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 7cdf3e6718..539e43a67a 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -1,27 +1,31 @@ -import { GfInvestmentChartComponent } from '@ghostfolio/client/components/investment-chart/investment-chart.component'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { DEFAULT_DATE_RANGE, DEFAULT_PAGE_SIZE, - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_3_FIGURES, + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES } from '@ghostfolio/common/config'; import { CreateAccountBalanceDto } from '@ghostfolio/common/dtos'; import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper'; import { AccountBalancesResponse, Activity, - HistoricalDataItem, + LineChartItem, PortfolioPosition, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; -import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { hasScope, scopes } from '@ghostfolio/common/scopes'; +import type { Tag } from '@ghostfolio/prisma/browser'; import { GfAccountBalancesComponent } from '@ghostfolio/ui/account-balances'; import { GfActivitiesTableComponent } from '@ghostfolio/ui/activities-table'; import { GfDialogFooterComponent } from '@ghostfolio/ui/dialog-footer'; import { GfDialogHeaderComponent } from '@ghostfolio/ui/dialog-header'; import { GfHoldingsTableComponent } from '@ghostfolio/ui/holdings-table'; +import { translate } from '@ghostfolio/ui/i18n'; +import { GfInvestmentChartComponent } from '@ghostfolio/ui/investment-chart'; import { DataService } from '@ghostfolio/ui/services'; +import { GfTagsSelectorComponent } from '@ghostfolio/ui/tags-selector'; import { GfValueComponent } from '@ghostfolio/ui/value'; import { @@ -30,9 +34,9 @@ import { Component, DestroyRef, inject, - OnInit + OnInit, + signal } from '@angular/core'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @@ -41,7 +45,7 @@ import { PageEvent } from '@angular/material/paginator'; import { Sort, SortDirection } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { MatTabsModule } from '@angular/material/tabs'; -import { Router } from '@angular/router'; +import { NavigationStart, Router } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; import { Big } from 'big.js'; import { format, parseISO } from 'date-fns'; @@ -49,13 +53,17 @@ import { addIcons } from 'ionicons'; import { albumsOutline, cashOutline, + readerOutline, swapVerticalOutline } from 'ionicons/icons'; -import { isNumber } from 'lodash'; +import { isNumber } from 'lodash-es'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { forkJoin } from 'rxjs'; +import { filter, finalize, forkJoin } from 'rxjs'; -import { AccountDetailDialogParams } from './interfaces/interfaces'; +import { + AccountDetailDialogParams, + AccountDetailDialogResult +} from './interfaces/interfaces'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -67,6 +75,7 @@ import { AccountDetailDialogParams } from './interfaces/interfaces'; GfDialogHeaderComponent, GfHoldingsTableComponent, GfInvestmentChartComponent, + GfTagsSelectorComponent, GfValueComponent, IonIcon, MatButtonModule, @@ -74,7 +83,6 @@ import { AccountDetailDialogParams } from './interfaces/interfaces'; MatTabsModule, NgxSkeletonLoaderModule ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-account-detail-dialog', styleUrls: ['./account-detail-dialog.component.scss'], templateUrl: 'account-detail-dialog.html' @@ -91,18 +99,24 @@ export class GfAccountDetailDialogComponent implements OnInit { protected equity: number | null; protected equityPrecision = 2; protected hasPermissionToDeleteAccountBalance: boolean; - protected historicalDataItems: HistoricalDataItem[]; + protected historicalDataItems: LineChartItem[]; protected holdings: PortfolioPosition[]; protected interestInBaseCurrency: number; protected interestInBaseCurrencyPrecision = 2; - protected isLoadingActivities: boolean; + protected isLoading = true; protected isLoadingChart: boolean; + protected readonly isSubmitting = signal(false); protected name: string | null; + protected netPerformancePercentageWithCurrencyEffect: number; + protected netPerformancePercentageWithCurrencyEffectPrecision = 2; + protected netPerformanceWithCurrencyEffect: number; + protected netPerformanceWithCurrencyEffectPrecision = 2; protected pageIndex = 0; protected pageSize = DEFAULT_PAGE_SIZE; protected platformName: string; protected sortColumn = 'date'; protected sortDirection: SortDirection = 'desc'; + protected tags: Tag[]; protected totalItems: number; protected user: User; protected valueInBaseCurrency: number; @@ -113,11 +127,24 @@ export class GfAccountDetailDialogComponent implements OnInit { private readonly dataService = inject(DataService); private readonly destroyRef = inject(DestroyRef); private readonly dialogRef = - inject>(MatDialogRef); + inject< + MatDialogRef + >(MatDialogRef); private readonly router = inject(Router); private readonly userService = inject(UserService); public constructor() { + this.router.events + .pipe( + filter((event) => { + return event instanceof NavigationStart; + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(() => { + this.dialogRef.close({ isNavigating: true }); + }); + this.userService.stateChanged .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((state) => { @@ -133,7 +160,12 @@ export class GfAccountDetailDialogComponent implements OnInit { } }); - addIcons({ albumsOutline, cashOutline, swapVerticalOutline }); + addIcons({ + albumsOutline, + cashOutline, + readerOutline, + swapVerticalOutline + }); } public ngOnInit() { @@ -141,11 +173,23 @@ export class GfAccountDetailDialogComponent implements OnInit { } protected onAddAccountBalance(accountBalance: CreateAccountBalanceDto) { + this.isSubmitting.set(true); + this.dataService - .postAccountBalance(accountBalance) - .pipe(takeUntilDestroyed(this.destroyRef)) + .postAccountBalance({ + accountBalance, + accountId: this.data.accountId + }) + .pipe( + finalize(() => { + this.isSubmitting.set(false); + }), + takeUntilDestroyed(this.destroyRef) + ) .subscribe(() => { this.initialize(); + + this.refreshUser(); }); } @@ -155,27 +199,18 @@ export class GfAccountDetailDialogComponent implements OnInit { this.fetchActivities(); } - protected onCloneActivity(aActivity: Activity) { - this.router.navigate( - internalRoutes.portfolio.subRoutes.activities.routerLink, - { - queryParams: { activityId: aActivity.id, createDialog: true } - } - ); - - this.dialogRef.close(); - } - protected onClose() { this.dialogRef.close(); } protected onDeleteAccountBalance(aId: string) { this.dataService - .deleteAccountBalance(aId) + .deleteAccountBalance({ accountId: this.data.accountId, id: aId }) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { this.initialize(); + + this.refreshUser(); }); } @@ -208,20 +243,10 @@ export class GfAccountDetailDialogComponent implements OnInit { this.fetchActivities(); } - protected onUpdateActivity(aActivity: Activity) { - this.router.navigate( - internalRoutes.portfolio.subRoutes.activities.routerLink, - { - queryParams: { activityId: aActivity.id, editDialog: true } - } - ); - - this.dialogRef.close(); - } - protected showValuesInPercentage() { return ( - this.data.hasImpersonationId || this.user?.settings?.isRestrictedView + !hasScope(this.user?.scopes, scopes.portfolioReadValues) || + this.user?.settings?.isRestrictedView ); } @@ -238,6 +263,7 @@ export class GfAccountDetailDialogComponent implements OnInit { interestInBaseCurrency, name, platform, + tags, value, valueInBaseCurrency }) => { @@ -245,7 +271,7 @@ export class GfAccountDetailDialogComponent implements OnInit { this.balance = balance; if ( - this.balance >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES && + this.balance >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES && this.data.deviceType === 'mobile' ) { this.balancePrecision = 0; @@ -257,7 +283,7 @@ export class GfAccountDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && this.dividendInBaseCurrency >= - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.dividendInBaseCurrencyPrecision = 0; } @@ -267,7 +293,7 @@ export class GfAccountDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && - this.equity >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + this.equity >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.equityPrecision = 0; } @@ -280,23 +306,32 @@ export class GfAccountDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && this.interestInBaseCurrency >= - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.interestInBaseCurrencyPrecision = 0; } this.name = name; this.platformName = platform?.name ?? '-'; + + this.tags = + tags?.map((tag) => { + return { + ...tag, + name: translate(tag.name) + }; + }) ?? []; + this.valueInBaseCurrency = valueInBaseCurrency; + this.isLoading = false; + this.changeDetectorRef.markForCheck(); } ); } private fetchActivities() { - this.isLoadingActivities = true; - this.dataService .fetchActivities({ filters: [{ id: this.data.accountId, type: 'ACCOUNT' }], @@ -310,8 +345,6 @@ export class GfAccountDetailDialogComponent implements OnInit { this.dataSource = new MatTableDataSource(activities); this.totalItems = count; - this.isLoadingActivities = false; - this.changeDetectorRef.markForCheck(); }); } @@ -332,27 +365,59 @@ export class GfAccountDetailDialogComponent implements OnInit { } ], range: DEFAULT_DATE_RANGE, - withExcludedAccounts: true, - withItems: true + withExcludedAccounts: true }) .pipe(takeUntilDestroyed(this.destroyRef)) }).subscribe({ error: () => { this.isLoadingChart = false; + + this.changeDetectorRef.markForCheck(); }, next: ({ accountBalances, portfolioPerformance }) => { this.accountBalances = accountBalances.balances; + const { + netPerformancePercentageWithCurrencyEffect, + netPerformanceWithCurrencyEffect + } = portfolioPerformance.performance; + + this.netPerformancePercentageWithCurrencyEffect = + netPerformancePercentageWithCurrencyEffect; + + if ( + this.data.deviceType === 'mobile' && + this.netPerformancePercentageWithCurrencyEffect >= + NUMERICAL_PRECISION_THRESHOLD_3_FIGURES + ) { + this.netPerformancePercentageWithCurrencyEffectPrecision = 0; + } + + this.netPerformanceWithCurrencyEffect = + netPerformanceWithCurrencyEffect; + + if ( + this.data.deviceType === 'mobile' && + this.netPerformanceWithCurrencyEffect >= + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES + ) { + this.netPerformanceWithCurrencyEffectPrecision = 0; + } + if ( portfolioPerformance.chart && portfolioPerformance.chart.length > 0 ) { - this.historicalDataItems = portfolioPerformance.chart.map( - ({ date, netWorth, netWorthInPercentage }) => ({ - date, - value: isNumber(netWorth) ? netWorth : netWorthInPercentage + this.historicalDataItems = portfolioPerformance.chart + .map(({ date, netWorth, netWorthInPercentage }) => { + return { + date, + value: isNumber(netWorth) ? netWorth : netWorthInPercentage + }; }) - ); + .filter((item): item is LineChartItem => { + return isNumber(item.value); + }); } else { this.historicalDataItems = this.accountBalances.map( ({ date, valueInBaseCurrency }) => { @@ -376,8 +441,12 @@ export class GfAccountDetailDialogComponent implements OnInit { .fetchPortfolioHoldings({ filters: [ { - type: 'ACCOUNT', - id: this.data.accountId + id: this.data.accountId, + type: 'ACCOUNT' + }, + { + id: 'ACTIVE', + type: 'HOLDING_TYPE' } ] }) @@ -395,4 +464,11 @@ export class GfAccountDetailDialogComponent implements OnInit { this.fetchChart(); this.fetchPortfolioHoldings(); } + + private refreshUser() { + this.userService + .get(true) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(); + } } diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html index 4b652db96c..2d3007f5bb 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html @@ -12,6 +12,7 @@
-
-
- Cash Balance -
-
- Equity -
-
- Interest -
-
- Dividend -
-
- Activities -
-
- Platform -
-
- + + + +
Overview
+
+
+
+
+ Cash Balance +
+
+ Equity +
+ @if (user?.settings?.isExperimentalFeatures) { +
+ Change +
+
+ Performance +
+ } +
+ Interest +
+
+ Dividend +
+
+ + @if (activitiesCount === 1) { + Activity + } @else { + Activities + } + +
+
+ Platform +
+ @if (user?.settings?.isExperimentalFeatures) { +
+ +
+ } +
+
+
-
Holdings
+
Holdings
-
Activities
+
Activities
-
Cash Balances
+
Cash Balances
Job ID - + {{ element.id }} @@ -113,13 +113,13 @@ Attempts - + {{ element.attemptsMade }} @@ -179,7 +179,7 @@ - + - + @@ -332,5 +385,12 @@
- +
+ + diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts index 77e2151efb..f86ba08a71 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts @@ -3,35 +3,45 @@ import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { AdminService } from '@ghostfolio/ui/services'; -import { Injectable } from '@angular/core'; -import { EMPTY, catchError, finalize, forkJoin } from 'rxjs'; +import { inject, Service } from '@angular/core'; +import { EMPTY, Subject, catchError, finalize, forkJoin } from 'rxjs'; -@Injectable() +@Service({ autoProvided: false }) export class AdminMarketDataService { - public constructor( - private adminService: AdminService, - private notificationService: NotificationService - ) {} + private readonly refreshSubject = new Subject(); + + private readonly adminService = inject(AdminService); + private readonly notificationService = inject(NotificationService); + + public get refresh$() { + return this.refreshSubject.asObservable(); + } public deleteAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) { + const assetProfileDeleted = new Subject(); + this.notificationService.confirm({ confirmFn: () => { this.adminService .deleteProfileData({ dataSource, symbol }) .subscribe(() => { - setTimeout(() => { - window.location.reload(); - }, 300); + assetProfileDeleted.next(); + assetProfileDeleted.complete(); }); }, confirmType: ConfirmationDialogType.Warn, title: $localize`Do you really want to delete this asset profile?` }); + + return assetProfileDeleted.asObservable(); } public deleteAssetProfiles( aAssetProfileIdentifiers: AssetProfileIdentifier[] ) { + const assetProfileCount = aAssetProfileIdentifiers.length; + const assetProfilesDeleted = new Subject(); + this.notificationService.confirm({ confirmFn: () => { const deleteRequests = aAssetProfileIdentifiers.map( @@ -44,19 +54,32 @@ export class AdminMarketDataService { .pipe( catchError(() => { this.notificationService.alert({ - title: $localize`Oops! Could not delete profiles.` + title: + assetProfileCount === 1 + ? $localize`Oops! Could not delete the asset profile.` + : $localize`Oops! Could not delete the asset profiles.` }); return EMPTY; }), finalize(() => { - window.location.reload(); + assetProfilesDeleted.next(); + assetProfilesDeleted.complete(); }) ) .subscribe(); }, confirmType: ConfirmationDialogType.Warn, - title: $localize`Do you really want to delete these profiles?` + title: + assetProfileCount === 1 + ? $localize`Do you really want to delete this asset profile?` + : $localize`Do you really want to delete these ${assetProfileCount}:count: asset profiles?` }); + + return assetProfilesDeleted.asObservable(); + } + + public triggerRefresh() { + this.refreshSubject.next(); } } diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/asset-profile-dialog-host.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/asset-profile-dialog-host.component.ts new file mode 100644 index 0000000000..26af45e20b --- /dev/null +++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/asset-profile-dialog-host.component.ts @@ -0,0 +1,214 @@ +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { DEFAULT_LOCALE } from '@ghostfolio/common/config'; +import { AssetProfileIdentifier, User } from '@ghostfolio/common/interfaces'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { DataSource } from '@ghostfolio/prisma/enums'; +import { AdminService } from '@ghostfolio/ui/services'; + +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + inject, + OnDestroy, + OnInit +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DeviceDetectorService } from 'ngx-device-detector'; +import { Subject } from 'rxjs'; +import { distinctUntilChanged, map, takeUntil, tap } from 'rxjs/operators'; + +import { AdminMarketDataService } from '../admin-market-data.service'; +import { GfAssetProfileDialogComponent } from '../asset-profile-dialog/asset-profile-dialog.component'; +import { AssetProfileDialogParams } from '../asset-profile-dialog/interfaces/interfaces'; +import { GfCreateAssetProfileDialogComponent } from '../create-asset-profile-dialog/create-asset-profile-dialog.component'; +import { CreateAssetProfileDialogParams } from '../create-asset-profile-dialog/interfaces/interfaces'; +import { AssetProfileDialogMode } from './types/asset-profile-dialog-mode.type'; + +@Component({ + changeDetection: ChangeDetectionStrategy.OnPush, + selector: 'gf-asset-profile-dialog-host', + template: '' +}) +export class GfAssetProfileDialogHostComponent implements OnDestroy, OnInit { + private dialogRef: MatDialogRef< + GfAssetProfileDialogComponent | GfCreateAssetProfileDialogComponent + >; + + private readonly deviceType = computed(() => { + return this.deviceDetectorService.deviceInfo().deviceType; + }); + + private readonly dialogClosed = new Subject(); + + private readonly adminMarketDataService = inject(AdminMarketDataService); + private readonly adminService = inject(AdminService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly dialog = inject(MatDialog); + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public ngOnInit() { + const mode = this.route.snapshot.data.mode as AssetProfileDialogMode; + + // The router reuses this component when only the asset profile identifier + // changes, so the parameters are observed instead of read from the + // snapshot once + this.route.paramMap + .pipe( + map((paramMap) => { + return { + dataSource: paramMap.get('dataSource'), + symbol: paramMap.get('symbol') + }; + }), + distinctUntilChanged((previous, current) => { + return ( + previous.dataSource === current.dataSource && + previous.symbol === current.symbol + ); + }), + tap(() => { + this.closeDialog(); + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(({ dataSource, symbol }) => { + this.userService + .get() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((user) => { + if (mode === 'create') { + this.openCreateAssetProfileDialog({ user }); + } else if (dataSource && symbol) { + this.openAssetProfileDialog({ + symbol, + user, + dataSource: dataSource as DataSource + }); + } else { + this.navigateBack(); + } + }); + }); + } + + public ngOnDestroy() { + // The dialog lives in an overlay outside of this component, so it needs to + // be closed explicitly when leaving the route (for example via the browser + // navigation) + this.dialogRef?.close(); + + this.dialogClosed.complete(); + } + + private closeDialog() { + // Tear down the subscription of the dialog which is about to be replaced, + // so that its result is not mistaken for the user closing it + this.dialogClosed.next(); + + this.dialogRef?.close(); + } + + private navigateBack() { + void this.router.navigate( + internalRoutes.adminControl.subRoutes.marketData.routerLink + ); + } + + private navigateToAssetProfileDialog({ + dataSource, + symbol + }: AssetProfileIdentifier) { + void this.router.navigate( + internalRoutes.adminControl.subRoutes.marketData.subRoutes.update.routerLink( + dataSource, + symbol + ) + ); + } + + private openAssetProfileDialog({ + dataSource, + symbol, + user + }: AssetProfileIdentifier & { user: User }) { + const dialogRef = this.dialog.open< + GfAssetProfileDialogComponent, + AssetProfileDialogParams, + AssetProfileIdentifier + >(GfAssetProfileDialogComponent, { + autoFocus: false, + data: { + dataSource, + symbol, + colorScheme: user?.settings?.colorScheme, + deviceType: this.deviceType(), + locale: user?.settings?.locale ?? DEFAULT_LOCALE + } satisfies AssetProfileDialogParams, + height: this.deviceType() === 'mobile' ? '98vh' : '80vh', + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((newAssetProfileIdentifier) => { + this.adminMarketDataService.triggerRefresh(); + + if (newAssetProfileIdentifier) { + this.navigateToAssetProfileDialog(newAssetProfileIdentifier); + } else { + this.navigateBack(); + } + }); + } + + private openCreateAssetProfileDialog({ user }: { user: User }) { + const dialogRef = this.dialog.open< + GfCreateAssetProfileDialogComponent, + CreateAssetProfileDialogParams, + AssetProfileIdentifier & { addAssetProfile: boolean } + >(GfCreateAssetProfileDialogComponent, { + autoFocus: false, + data: { + deviceType: this.deviceType(), + locale: user?.settings?.locale ?? DEFAULT_LOCALE + } satisfies CreateAssetProfileDialogParams, + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((result) => { + if (!result) { + this.navigateBack(); + + return; + } + + const { addAssetProfile, dataSource, symbol } = result; + + if (addAssetProfile && dataSource && symbol) { + this.adminService + .addAssetProfile({ dataSource, symbol }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + this.navigateToAssetProfileDialog({ dataSource, symbol }); + }); + } else { + this.navigateToAssetProfileDialog({ dataSource, symbol }); + } + }); + } +} diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/types/asset-profile-dialog-mode.type.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/types/asset-profile-dialog-mode.type.ts new file mode 100644 index 0000000000..13460a9aef --- /dev/null +++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog-host/types/asset-profile-dialog-mode.type.ts @@ -0,0 +1 @@ +export type AssetProfileDialogMode = 'create' | 'update'; diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.scss b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.scss index db23cf0a7d..fbc938c9c7 100644 --- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.scss +++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.scss @@ -16,6 +16,8 @@ } .mat-mdc-dialog-title { - padding-right: 0.5rem !important; + button[mat-icon-button] { + --mat-icon-button-icon-size: 1rem; + } } } diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts index ce997cf274..ba119b565f 100644 --- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts +++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts @@ -2,15 +2,22 @@ import { AdminMarketDataService } from '@ghostfolio/client/components/admin-mark import { UserService } from '@ghostfolio/client/services/user/user.service'; import { ASSET_CLASS_MAPPING, + COMMENT_MAXIMUM_LENGTH, PROPERTY_IS_DATA_GATHERING_ENABLED } from '@ghostfolio/common/config'; import { UpdateAssetProfileDto } from '@ghostfolio/common/dtos'; +import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { canDeleteAssetProfile, + canMergeAssetProfile, DATE_FORMAT, getCountryName, getCurrencyFromSymbol, - isCurrency + getDateFormatString, + getStringOrNull, + getStringOrUndefined, + isCurrency, + isSplitRatio } from '@ghostfolio/common/helper'; import { AdminMarketDataDetails, @@ -22,6 +29,18 @@ import { } from '@ghostfolio/common/interfaces'; import { DateRange } from '@ghostfolio/common/types'; import { jsonValidator, validateObjectForForm } from '@ghostfolio/common/utils'; +import type { + AssetProfileSplit, + MarketData, + Prisma, + SymbolProfile +} from '@ghostfolio/prisma/browser'; +import { + AssetClass, + AssetSubClass, + DataGatheringFrequency, + DataSource +} from '@ghostfolio/prisma/enums'; import { GfCurrencySelectorComponent } from '@ghostfolio/ui/currency-selector'; import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo'; import { GfHistoricalMarketDataEditorComponent } from '@ghostfolio/ui/historical-market-data-editor'; @@ -34,6 +53,7 @@ import { GfSymbolAutocompleteComponent } from '@ghostfolio/ui/symbol-autocomplet import { GfValueComponent } from '@ghostfolio/ui/value'; import { TextFieldModule } from '@angular/cdk/text-field'; +import { CommonModule } from '@angular/common'; import { HttpErrorResponse } from '@angular/common/http'; import { ChangeDetectionStrategy, @@ -60,6 +80,7 @@ import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox'; +import { MatDatepickerModule } from '@angular/material/datepicker'; import { MAT_DIALOG_DATA, MatDialogModule, @@ -71,25 +92,21 @@ import { MatSelectModule } from '@angular/material/select'; import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTabsModule } from '@angular/material/tabs'; import { IonIcon } from '@ionic/angular/standalone'; -import { - AssetClass, - AssetSubClass, - MarketData, - Prisma, - SymbolProfile -} from '@prisma/client'; import { isUUID } from 'class-validator'; import { format } from 'date-fns'; import { StatusCodes } from 'http-status-codes'; import { addIcons } from 'ionicons'; import { + calendarClearOutline, codeSlashOutline, createOutline, ellipsisVertical, + gitCompareOutline, readerOutline, - serverOutline + serverOutline, + trashOutline } from 'ionicons/icons'; -import { isBoolean } from 'lodash'; +import { isBoolean } from 'lodash-es'; import ms from 'ms'; import { EMPTY } from 'rxjs'; import { catchError } from 'rxjs/operators'; @@ -100,6 +117,7 @@ import { AssetProfileDialogParams } from './interfaces/interfaces'; changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'd-flex flex-column h-100' }, imports: [ + CommonModule, FormsModule, GfCurrencySelectorComponent, GfEntityLogoComponent, @@ -111,6 +129,7 @@ import { AssetProfileDialogParams } from './interfaces/interfaces'; IonIcon, MatButtonModule, MatCheckboxModule, + MatDatepickerModule, MatDialogModule, MatInputModule, MatMenuModule, @@ -155,6 +174,7 @@ export class GfAssetProfileDialogComponent implements OnInit { comment: '', countries: ['', jsonValidator()], currency: '', + dataGatheringFrequency: new FormControl('DAILY'), historicalData: this.formBuilder.group({ csvString: '' }), @@ -190,8 +210,29 @@ export class GfAssetProfileDialogComponent implements OnInit { } ); + protected readonly assetProfileSplitForm = this.formBuilder.group( + { + date: new FormControl(null, Validators.required), + denominator: new FormControl(null, Validators.required), + numerator: new FormControl(null, Validators.required) + }, + { + validators: (control: AbstractControl): ValidationErrors | null => { + const { denominator, numerator } = control.value as { + denominator: number; + numerator: number; + }; + + return isSplitRatio({ denominator, numerator }) + ? null + : { invalidSplitRatio: true }; + } + } + ); + protected readonly canDeleteAssetProfile = canDeleteAssetProfile; protected canEditAssetProfile = true; + protected readonly COMMENT_MAXIMUM_LENGTH = COMMENT_MAXIMUM_LENGTH; protected countries: { [code: string]: { name: string; value: number }; @@ -199,6 +240,22 @@ export class GfAssetProfileDialogComponent implements OnInit { protected currencies: string[] = []; + protected readonly dataGatheringFrequencyValues: { + value: DataGatheringFrequency; + viewValue: string; + }[] = [ + { + value: 'DAILY', + viewValue: $localize`Daily` + }, + { + value: 'HOURLY', + viewValue: $localize`Hourly` + } + ]; + + protected readonly DataSource = DataSource; + protected readonly dateRangeOptions = [ { label: $localize`Current week` + ' (' + $localize`WTD` + ')', @@ -225,11 +282,13 @@ export class GfAssetProfileDialogComponent implements OnInit { value: 'max' } ]; + protected defaultDateFormat: string; protected readonly getCountryName = getCountryName; protected historicalDataItems: LineChartItem[]; protected isBenchmark = false; protected isDataGatheringEnabled: boolean; protected isEditAssetProfileIdentifierMode = false; + protected isLoading = true; protected readonly isUUID = isUUID; protected marketDataItems: MarketData[] = []; @@ -248,6 +307,8 @@ export class GfAssetProfileDialogComponent implements OnInit { [name: string]: { name: string; value: number }; }; + protected splits: AssetProfileSplit[] = []; + protected readonly translate = translate; protected user: User; @@ -261,18 +322,24 @@ export class GfAssetProfileDialogComponent implements OnInit { @Inject(MAT_DIALOG_DATA) protected data: AssetProfileDialogParams, private dataService: DataService, private destroyRef: DestroyRef, - private dialogRef: MatDialogRef, + private dialogRef: MatDialogRef< + GfAssetProfileDialogComponent, + AssetProfileIdentifier + >, private formBuilder: FormBuilder, private notificationService: NotificationService, private snackBar: MatSnackBar, private userService: UserService ) { addIcons({ + calendarClearOutline, codeSlashOutline, createOutline, ellipsisVertical, + gitCompareOutline, readerOutline, - serverOutline + serverOutline, + trashOutline }); } @@ -285,6 +352,7 @@ export class GfAssetProfileDialogComponent implements OnInit { this.benchmarks = benchmarks; this.currencies = currencies; + this.defaultDateFormat = getDateFormatString(this.data.locale); this.initialize(); } @@ -339,8 +407,9 @@ export class GfAssetProfileDialogComponent implements OnInit { symbol: this.data.symbol }) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ assetProfile, marketData }) => { + .subscribe(({ assetProfile, marketData, splits }) => { this.assetProfile = assetProfile; + this.splits = splits ?? []; this.assetClassLabel = translate(this.assetProfile?.assetClass ?? ''); this.assetSubClassLabel = translate( @@ -373,7 +442,7 @@ export class GfAssetProfileDialogComponent implements OnInit { ) { for (const { code, weight } of this.assetProfile.countries) { this.countries[code] = { - name: getCountryName({ code, locale: this.data.locale }), + name: getCountryName({ code }), value: weight }; } @@ -401,6 +470,8 @@ export class GfAssetProfileDialogComponent implements OnInit { }) ?? [] ), currency: this.assetProfile?.currency ?? null, + dataGatheringFrequency: + this.assetProfile?.dataGatheringFrequency ?? 'DAILY', historicalData: { csvString: GfAssetProfileDialogComponent.HISTORICAL_DATA_TEMPLATE }, @@ -431,6 +502,8 @@ export class GfAssetProfileDialogComponent implements OnInit { this.assetProfileForm.markAsPristine(); + this.isLoading = false; + this.changeDetectorRef.markForCheck(); }); } @@ -449,13 +522,29 @@ export class GfAssetProfileDialogComponent implements OnInit { this.dialogRef.close(); } + protected onConvertToManualDataSource() { + this.patchAssetProfileIdentifier({ + getErrorMessage: () => { + return ( + '😞 ' + + $localize`An error occurred while converting the data source to ${DataSource.MANUAL}.` + ); + }, + title: $localize`Do you really want to convert the data source to ${DataSource.MANUAL}?`, + updateAssetProfileDto: { dataSource: DataSource.MANUAL } + }); + } + protected onDeleteProfileData({ dataSource, symbol }: AssetProfileIdentifier) { - this.adminMarketDataService.deleteAssetProfile({ dataSource, symbol }); - - this.dialogRef.close(); + this.adminMarketDataService + .deleteAssetProfile({ dataSource, symbol }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + this.dialogRef.close(); + }); } protected onGatherProfileDataBySymbol({ @@ -481,6 +570,45 @@ export class GfAssetProfileDialogComponent implements OnInit { .subscribe(); } + protected onAddSplit() { + const { date, denominator, numerator } = + this.assetProfileSplitForm.getRawValue(); + + if (!date || !denominator || !numerator) { + return; + } + + this.adminService + .postAssetProfileSplit({ + dataSource: this.data.dataSource, + split: { + denominator, + numerator, + date: format(date, DATE_FORMAT) + }, + symbol: this.data.symbol + }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + this.assetProfileSplitForm.reset(); + + this.initialize(); + }); + } + + protected onDeleteSplit(aId: string) { + this.adminService + .deleteAssetProfileSplit({ + dataSource: this.data.dataSource, + id: aId, + symbol: this.data.symbol + }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + this.initialize(); + }); + } + protected onMarketDataChanged(withRefresh: boolean = false) { if (withRefresh) { this.initialize(); @@ -530,9 +658,10 @@ export class GfAssetProfileDialogComponent implements OnInit { this.assetProfileForm.controls.scraperConfiguration.controls.headers .value ?? '{}' ) as Record, - locale: + locale: getStringOrUndefined( this.assetProfileForm.controls.scraperConfiguration.controls.locale - ?.value ?? undefined, + ?.value + ), mode: this.assetProfileForm.controls.scraperConfiguration.controls.mode ?.value ?? undefined, @@ -581,13 +710,16 @@ export class GfAssetProfileDialogComponent implements OnInit { assetClass: this.assetProfileForm.controls.assetClass.value ?? undefined, assetSubClass: this.assetProfileForm.controls.assetSubClass.value ?? undefined, - comment: this.assetProfileForm.controls.comment.value || undefined, + comment: getStringOrNull(this.assetProfileForm.controls.comment.value), currency: this.assetProfileForm.controls.currency.value ?? undefined, + dataGatheringFrequency: + this.assetProfileForm.controls.dataGatheringFrequency.value ?? + undefined, isActive: isBoolean(this.assetProfileForm.controls.isActive.value) ? this.assetProfileForm.controls.isActive.value : undefined, - name: this.assetProfileForm.controls.name.value || undefined, - url: this.assetProfileForm.controls.url.value || undefined + name: this.assetProfileForm.controls.name.value ?? undefined, + url: getStringOrNull(this.assetProfileForm.controls.url.value) }; try { @@ -645,13 +777,16 @@ export class GfAssetProfileDialogComponent implements OnInit { } protected async onSubmitAssetProfileIdentifierForm() { + const newAssetProfileIdentifier = + this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value; + + if (!newAssetProfileIdentifier?.dataSource) { + return; + } + const assetProfileIdentifier: UpdateAssetProfileDto = { - dataSource: - this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value - ?.dataSource ?? undefined, - symbol: - this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value - ?.symbol ?? undefined + dataSource: newAssetProfileIdentifier.dataSource, + symbol: newAssetProfileIdentifier.symbol }; try { @@ -666,46 +801,18 @@ export class GfAssetProfileDialogComponent implements OnInit { return; } - this.adminService - .patchAssetProfile( - { - dataSource: this.data.dataSource, - symbol: this.data.symbol - }, - assetProfileIdentifier - ) - .pipe( - catchError((error: HttpErrorResponse) => { - if (error.status === StatusCodes.CONFLICT) { - this.snackBar.open( - $localize`${assetProfileIdentifier.symbol} (${assetProfileIdentifier.dataSource}) is already in use.`, - undefined, - { - duration: ms('3 seconds') - } - ); - } else { - this.snackBar.open( - $localize`An error occurred while updating to ${assetProfileIdentifier.symbol} (${assetProfileIdentifier.dataSource}).`, - undefined, - { - duration: ms('3 seconds') - } - ); + this.patchAssetProfileIdentifier({ + conflictFn: this.user?.settings?.isExperimentalFeatures + ? () => { + this.mergeAssetProfile(newAssetProfileIdentifier); } - - return EMPTY; - }), - takeUntilDestroyed(this.destroyRef) - ) - .subscribe(() => { - const newAssetProfileIdentifier = { - dataSource: assetProfileIdentifier.dataSource, - symbol: assetProfileIdentifier.symbol - }; - - this.dialogRef.close(newAssetProfileIdentifier); - }); + : undefined, + getErrorMessage: () => { + return $localize`An error occurred while updating to ${assetProfileIdentifier.symbol} (${assetProfileIdentifier.dataSource}).`; + }, + title: $localize`Do you really want to convert this asset profile to ${newAssetProfileIdentifier.symbol} (${newAssetProfileIdentifier.dataSource})?`, + updateAssetProfileDto: assetProfileIdentifier + }); } protected onTestMarketData() { @@ -720,9 +827,10 @@ export class GfAssetProfileDialogComponent implements OnInit { this.assetProfileForm.controls.scraperConfiguration.controls.headers .value ?? '{}' ) as Record, - locale: + locale: getStringOrUndefined( this.assetProfileForm.controls.scraperConfiguration.controls.locale - ?.value || undefined, + ?.value + ), mode: this.assetProfileForm.controls.scraperConfiguration.controls .mode?.value, selector: @@ -744,13 +852,12 @@ export class GfAssetProfileDialogComponent implements OnInit { takeUntilDestroyed(this.destroyRef) ) .subscribe(({ price }) => { + const currency = this.assetProfileForm.controls.currency.value; + this.notificationService.alert({ - title: - $localize`The current market price is` + - ' ' + - price + - ' ' + - this.assetProfileForm.controls.currency.value + title: `${$localize`The current market price is`} ${price}${ + currency ? ` ${currency}` : '' + }` }); }); } @@ -803,4 +910,107 @@ export class GfAssetProfileDialogComponent implements OnInit { return null; } + + private mergeAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) { + if ( + !canMergeAssetProfile({ + isBenchmark: this.isBenchmark, + splitsCount: this.splits.length, + symbol: this.data.symbol + }) || + !canMergeAssetProfile({ symbol }) + ) { + this.notificationService.alert({ + message: $localize`This asset profile cannot be merged into ${symbol} (${dataSource}).`, + title: $localize`Error` + }); + + return; + } + + this.notificationService.confirm({ + confirmFn: () => { + this.adminService + .mergeAssetProfile( + { + dataSource: this.data.dataSource, + symbol: this.data.symbol + }, + { dataSource, symbol } + ) + .pipe( + catchError(({ error }: HttpErrorResponse) => { + this.notificationService.alert({ + message: + error?.message ?? + $localize`An error occurred while merging this asset profile into ${symbol} (${dataSource}).`, + title: $localize`Error` + }); + + return EMPTY; + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe((mergedAssetProfile) => { + this.dialogRef.close({ + dataSource: mergedAssetProfile.dataSource, + symbol: mergedAssetProfile.symbol + }); + }); + }, + confirmType: ConfirmationDialogType.Warn, + message: + $localize`The data of this asset profile is moved to ${symbol} (${dataSource}) and this asset profile is deleted.` + + ' ' + + $localize`This action cannot be undone.`, + title: + $localize`${symbol} (${dataSource}) is already in use.` + + ' ' + + $localize`Do you really want to merge this asset profile into it?` + }); + } + + private patchAssetProfileIdentifier({ + conflictFn, + getErrorMessage, + title, + updateAssetProfileDto + }: { + conflictFn?: () => void; + getErrorMessage: (error: HttpErrorResponse) => string; + title: string; + updateAssetProfileDto: UpdateAssetProfileDto; + }) { + this.notificationService.confirm({ + title, + confirmFn: () => { + this.adminService + .patchAssetProfile( + { + dataSource: this.data.dataSource, + symbol: this.data.symbol + }, + updateAssetProfileDto + ) + .pipe( + catchError((error: HttpErrorResponse) => { + if (error.status === StatusCodes.CONFLICT && conflictFn) { + conflictFn(); + } else { + this.snackBar.open(getErrorMessage(error), undefined, { + duration: ms('3 seconds') + }); + } + + return EMPTY; + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(({ dataSource, symbol }) => { + this.dialogRef.close({ dataSource, symbol }); + }); + }, + confirmType: ConfirmationDialogType.Primary + }); + } } diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html index d9a5354e56..bc7edcbe81 100644 --- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html +++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html @@ -4,13 +4,15 @@ assetProfile?.name ?? data.symbol }} -
Overview
+
Overview
-
-
+
+
@if (isEditAssetProfileIdentifierMode) {
+ @if (data.dataSource !== DataSource.MANUAL) { +

or

+ + }
} @else {
- Symbol
-
+
- Currency
ISINFirst ActivityActivities
@if ( - assetProfile?.countries?.length > 0 || - assetProfile?.sectors?.length > 0 + (assetProfile?.countries?.length ?? 0) > 0 || + (assetProfile?.sectors?.length ?? 0) > 0 ) { @if ( assetProfile?.countries?.length === 1 && @@ -271,8 +300,7 @@ [locale]="data.locale" [value]=" getCountryName({ - code: assetProfile?.countries[0].code, - locale: data.locale + code: assetProfile?.countries[0].code }) " >Country
+
+ + Data Gathering Frequency + + @for ( + dataGatheringFrequencyValue of dataGatheringFrequencyValues; + track dataGatheringFrequencyValue.value + ) { + {{ + dataGatheringFrequencyValue.viewValue + }} + } + + +
-
Historical Market Data
+
Historical Market Data
-
+
+ @if (user?.settings?.isExperimentalFeatures) { + + + +
Splits
+
+
+
+
+ @if (splits.length > 0) { + + + + + + + + + + @for (split of splits; track split.id) { + + + + + + } + +
Date + Split Ratio +
+ {{ split.date | date: defaultDateFormat }} + + {{ split.numerator }}:{{ split.denominator }} + + +
+ } +
+ + Date + + + + + + +
+ + Shares After + + +
:
+ + Shares Before + + +
+
+ +
+
+
+
+
+
+ } @if (assetProfile?.dataSource === 'MANUAL') { -
Scraper Configuration
+
Scraper Configuration
@@ -503,7 +659,6 @@ formControlName="headers" matInput type="text" - [matAutocomplete]="auto" >
@@ -558,7 +713,7 @@
-
+
@@ -63,7 +63,9 @@ color="primary" mat-flat-button type="submit" - [disabled]="createAssetProfileForm.hasError('atLeastOneValid')" + [disabled]=" + createAssetProfileForm.hasError('atLeastOneValid') || isSubmitting() + " > Save diff --git a/apps/client/src/app/components/admin-overview/admin-overview.component.ts b/apps/client/src/app/components/admin-overview/admin-overview.component.ts index 3b8fdc38cb..5824bda366 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.component.ts +++ b/apps/client/src/app/components/admin-overview/admin-overview.component.ts @@ -27,11 +27,13 @@ import { GfValueComponent } from '@ghostfolio/ui/value'; import { Clipboard, ClipboardModule } from '@angular/cdk/clipboard'; import { CommonModule } from '@angular/common'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, - OnInit + OnInit, + signal } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -47,12 +49,7 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { - addMilliseconds, - differenceInSeconds, - formatDistanceToNowStrict, - parseISO -} from 'date-fns'; +import { addMilliseconds, formatDistanceToNowStrict } from 'date-fns'; import { addIcons } from 'ionicons'; import { closeCircleOutline, @@ -62,8 +59,11 @@ import { trashOutline } from 'ionicons/icons'; import ms, { StringValue } from 'ms'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; +import { catchError, finalize, of, switchMap } from 'rxjs'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [ ClipboardModule, CommonModule, @@ -77,6 +77,7 @@ import ms, { StringValue } from 'ms'; MatSnackBarModule, MatSlideToggleModule, MatTableModule, + NgxSkeletonLoaderModule, ReactiveFormsModule, RouterModule ], @@ -88,13 +89,22 @@ export class GfAdminOverviewComponent implements OnInit { protected activitiesCount: number; protected couponDuration: StringValue = '14 days'; protected readonly couponsDataSource = new MatTableDataSource(); - protected readonly couponsDisplayedColumns = ['code', 'duration', 'actions']; + protected readonly couponsDisplayedColumns = [ + 'code', + 'duration', + 'createdAt', + 'actions' + ]; protected hasPermissionForSubscription: boolean; protected hasPermissionForSystemMessage: boolean; protected hasPermissionToSyncDemoUserAccount: boolean; protected hasPermissionToToggleReadOnlyMode: boolean; protected readonly info: InfoItem; protected isDataGatheringEnabled: boolean; + protected isLoading = false; + protected isReadOnlyMode: boolean; + protected readonly isSavingCoupons = signal(false); + protected isUserSignupEnabled: boolean; protected readonly permissions = permissions; protected systemMessage: SystemMessage; protected userCount: number; @@ -140,6 +150,8 @@ export class GfAdminOverviewComponent implements OnInit { permissions.toggleReadOnlyMode ); } + + this.changeDetectorRef.markForCheck(); }); addIcons({ @@ -160,29 +172,17 @@ export class GfAdminOverviewComponent implements OnInit { this.activitiesCount / this.userCount ).toLocaleString(this.user?.settings?.locale, { maximumFractionDigits: 2, - minimumFractionDigits: 2 + minimumFractionDigits: 2, + useGrouping: true }); return `(${formattedActivitiesCountPerUser} ${$localize`per User`})`; } public ngOnInit() { - this.fetchAdminData(); - } - - protected formatDistanceToNow(aDateString: string) { - if (aDateString) { - const distanceString = formatDistanceToNowStrict(parseISO(aDateString), { - addSuffix: true - }); + this.isLoading = true; - return Math.abs(differenceInSeconds(parseISO(aDateString), new Date())) < - 60 - ? 'just now' - : distanceString; - } - - return ''; + this.fetchAdminData(); } protected formatStringValue(aStringValue: StringValue) { @@ -197,12 +197,20 @@ export class GfAdminOverviewComponent implements OnInit { protected onAddCoupon() { const newCoupon: Coupon = { code: `${ghostfolioPrefix}${this.generateCouponCode(14)}`, + createdAt: new Date().toISOString(), duration: this.couponDuration }; + const hasCopiedCouponCode = this.clipboard.copy(newCoupon.code); + const coupons = [...this.couponsDataSource.data, newCoupon]; - this.saveCoupons({ coupons, codeToCopy: newCoupon.code }); + this.saveCoupons({ + coupons, + snackBarMessage: hasCopiedCouponCode + ? '✅ ' + $localize`${newCoupon.code} has been copied to the clipboard` + : '✅ ' + $localize`Coupon ${newCoupon.code} has been created` + }); } protected onChangeCouponDuration(aCouponDuration: StringValue) { @@ -250,9 +258,15 @@ export class GfAdminOverviewComponent implements OnInit { .flush() .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { - setTimeout(() => { - window.location.reload(); - }, 300); + this.dataService.updateInfo(); + + this.snackBar.open( + '✅ ' + $localize`Cache has been flushed.`, + undefined, + { + duration: ms('3 seconds') + } + ); }); }, confirmType: ConfirmationDialogType.Warn, @@ -322,10 +336,17 @@ export class GfAdminOverviewComponent implements OnInit { this.isDataGatheringEnabled = settings[PROPERTY_IS_DATA_GATHERING_ENABLED] === false ? false : true; + this.isReadOnlyMode = settings[PROPERTY_IS_READ_ONLY_MODE] === true; + + this.isUserSignupEnabled = + settings[PROPERTY_IS_USER_SIGNUP_ENABLED] === false ? false : true; + this.systemMessage = settings[PROPERTY_SYSTEM_MESSAGE] as SystemMessage; this.userCount = userCount; this.version = version; + this.isLoading = false; + this.changeDetectorRef.markForCheck(); }); } @@ -348,37 +369,49 @@ export class GfAdminOverviewComponent implements OnInit { .putAdminSetting(key, { value: value || value === false ? JSON.stringify(value) : undefined }) - .pipe(takeUntilDestroyed(this.destroyRef)) + .pipe( + switchMap(() => { + return this.userService.get(true); + }), + catchError(() => { + // Refresh anyway to reflect the actual state of the settings + return of(undefined); + }), + takeUntilDestroyed(this.destroyRef) + ) .subscribe(() => { - setTimeout(() => { - window.location.reload(); - }, 300); + this.dataService.updateInfo(); + + this.fetchAdminData(); }); } private saveCoupons({ - codeToCopy, - coupons + coupons, + snackBarMessage }: { - codeToCopy?: string; coupons: Coupon[]; + snackBarMessage?: string; }) { + this.isSavingCoupons.set(true); + this.dataService .putAdminSetting(PROPERTY_COUPONS, { value: JSON.stringify(coupons) }) - .pipe(takeUntilDestroyed(this.destroyRef)) + .pipe( + finalize(() => { + this.isSavingCoupons.set(false); + }), + takeUntilDestroyed(this.destroyRef) + ) .subscribe(() => { this.couponsDataSource.data = coupons; - if (codeToCopy) { - this.clipboard.copy(codeToCopy); - - this.snackBar.open( - '✅ ' + $localize`${codeToCopy} has been copied to the clipboard`, - undefined, - { duration: ms('3 seconds') } - ); + if (snackBarMessage) { + this.snackBar.open(snackBarMessage, undefined, { + duration: ms('3 seconds') + }); } this.changeDetectorRef.markForCheck(); diff --git a/apps/client/src/app/components/admin-overview/admin-overview.html b/apps/client/src/app/components/admin-overview/admin-overview.html index bccedd2513..269fe291ac 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.html +++ b/apps/client/src/app/components/admin-overview/admin-overview.html @@ -7,6 +7,7 @@ i18n size="large" [enableCopyToClipboardButton]="true" + [isLoading]="isLoading" [value]="version" >Version @@ -19,6 +20,7 @@ Users
@@ -66,7 +68,8 @@
@@ -79,6 +82,7 @@ color="primary" hideIcon="true" [checked]="isDataGatheringEnabled" + [disabled]="isLoading" (change)="onEnableDataGatheringChange($event)" />
@@ -89,7 +93,9 @@
@if (systemMessage) {
-
{{ systemMessage | json }}
+
+ {{ systemMessage | json }} +
} - @if (!info?.systemMessage) { + @if (!systemMessage) { } @@ -124,12 +130,12 @@ mat-flat-button (click)="onSyncDemoUserAccount()" > - + Sync Demo User Account }
@@ -160,7 +166,7 @@ @@ -168,29 +174,38 @@ - + Duration - + {{ formatStringValue(element.duration) }} + + + Creation + + + @if (element.createdAt) { + + } @else { + - + } + + + - + @@ -226,11 +241,22 @@ mat-row > + + @if (isLoading) { + + }
- + Add diff --git a/apps/client/src/app/components/admin-platform/admin-platform.component.html b/apps/client/src/app/components/admin-platform/admin-platform.component.html index 44f5a6eab6..6ce9656f52 100644 --- a/apps/client/src/app/components/admin-platform/admin-platform.component.html +++ b/apps/client/src/app/components/admin-platform/admin-platform.component.html @@ -9,90 +9,113 @@ Add Platform
- - - - - -
- Name - - @if (element.url) { +
+ + + + + + - - - - + + + + - - - - + + + + - - - + + + + + + - + + +
+ +
+ + + + + +
- } - {{ element.name }} - - Url - - {{ element.url }} - + Name + + {{ element.name }} + - Accounts - - - + Url + + {{ element.url }} + - - - - - -
+ Accounts +
+ + - -
+
+ +@if (isLoading) { + +} -
+ diff --git a/apps/client/src/app/components/admin-platform/admin-platform.component.ts b/apps/client/src/app/components/admin-platform/admin-platform.component.ts index a9d1350683..10634d5dfb 100644 --- a/apps/client/src/app/components/admin-platform/admin-platform.component.ts +++ b/apps/client/src/app/components/admin-platform/admin-platform.component.ts @@ -1,10 +1,13 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; import { CreatePlatformDto, UpdatePlatformDto } from '@ghostfolio/common/dtos'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; -import { getLocale } from '@ghostfolio/common/helper'; +import { getLocale, getLowercase } from '@ghostfolio/common/helper'; +import { PlatformsResponse } from '@ghostfolio/common/interfaces'; +import type { Platform } from '@ghostfolio/prisma/browser'; import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo'; import { NotificationService } from '@ghostfolio/ui/notifications'; -import { AdminService, DataService } from '@ghostfolio/ui/services'; +import { DataService } from '@ghostfolio/ui/services'; import { GfValueComponent } from '@ghostfolio/ui/value'; import { @@ -22,19 +25,19 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; import { MatMenuModule } from '@angular/material/menu'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { Platform } from '@prisma/client'; import { addIcons } from 'ionicons'; import { createOutline, ellipsisHorizontal, trashOutline } from 'ionicons/icons'; -import { get } from 'lodash'; import { DeviceDetectorService } from 'ngx-device-detector'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { GfCreateOrUpdatePlatformDialogComponent } from './create-or-update-platform-dialog/create-or-update-platform-dialog.component'; import { CreateOrUpdatePlatformDialogParams } from './create-or-update-platform-dialog/interfaces/interfaces'; @@ -47,8 +50,10 @@ import { CreateOrUpdatePlatformDialogParams } from './create-or-update-platform- IonIcon, MatButtonModule, MatMenuModule, + MatPaginatorModule, MatSortModule, MatTableModule, + NgxSkeletonLoaderModule, RouterModule ], selector: 'gf-admin-platform', @@ -58,16 +63,29 @@ import { CreateOrUpdatePlatformDialogParams } from './create-or-update-platform- export class GfAdminPlatformComponent implements OnInit { public readonly locale = input(getLocale()); - protected dataSource = new MatTableDataSource(); - protected readonly displayedColumns = ['name', 'url', 'accounts', 'actions']; - protected platforms: Platform[]; + protected dataSource = new MatTableDataSource< + PlatformsResponse['platforms'][0] + >(); + + protected readonly displayedColumns = [ + 'icon', + 'name', + 'url', + 'accounts', + 'actions' + ]; + + protected isLoading = false; + protected readonly pageSize = DEFAULT_PAGE_SIZE; + protected platforms: PlatformsResponse['platforms']; private readonly deviceType = computed( () => this.deviceDetectorService.deviceInfo().deviceType ); + + private readonly paginator = viewChild.required(MatPaginator); private readonly sort = viewChild.required(MatSort); - private readonly adminService = inject(AdminService); private readonly changeDetectorRef = inject(ChangeDetectorRef); private readonly dataService = inject(DataService); private readonly destroyRef = inject(DestroyRef); @@ -123,7 +141,7 @@ export class GfAdminPlatformComponent implements OnInit { } private deletePlatform(aId: string) { - this.adminService + this.dataService .deletePlatform(aId) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe({ @@ -139,18 +157,23 @@ export class GfAdminPlatformComponent implements OnInit { } private fetchPlatforms() { - this.adminService + this.isLoading = true; + + this.dataService .fetchPlatforms() .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((platforms) => { + .subscribe(({ platforms }) => { this.platforms = platforms; this.dataSource = new MatTableDataSource(platforms); + this.dataSource.paginator = this.paginator(); this.dataSource.sort = this.sort(); - this.dataSource.sortingDataAccessor = get; + this.dataSource.sortingDataAccessor = getLowercase; this.dataService.updateInfo(); + this.isLoading = false; + this.changeDetectorRef.markForCheck(); }); } @@ -170,7 +193,7 @@ export class GfAdminPlatformComponent implements OnInit { .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((platform: CreatePlatformDto | null) => { if (platform) { - this.adminService + this.dataService .postPlatform(platform) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe({ @@ -210,7 +233,7 @@ export class GfAdminPlatformComponent implements OnInit { .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((platform: UpdatePlatformDto | null) => { if (platform) { - this.adminService + this.dataService .putPlatform(platform) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe({ diff --git a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html index f923b95a6e..4109fd3cb4 100644 --- a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html +++ b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html @@ -28,12 +28,8 @@ matInput (keydown.enter)="$event.stopPropagation()" /> - @if (platformForm.get('url')?.value) { - + @if (platformForm.get('url')?.value; as url) { + } diff --git a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/interfaces/interfaces.ts index d3b9ae5288..206cc14e79 100644 --- a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/interfaces/interfaces.ts @@ -1,4 +1,4 @@ -import { Platform } from '@prisma/client'; +import type { Platform } from '@ghostfolio/prisma/browser'; export interface CreateOrUpdatePlatformDialogParams { platform?: Platform; diff --git a/apps/client/src/app/components/admin-settings/admin-settings.component.html b/apps/client/src/app/components/admin-settings/admin-settings.component.html index 76af96c4e0..a991b8a0f3 100644 --- a/apps/client/src/app/components/admin-settings/admin-settings.component.html +++ b/apps/client/src/app/components/admin-settings/admin-settings.component.html @@ -3,7 +3,11 @@

Data Providers

@if (isGhostfolioApiKeyValid === false) { - + Ghostfolio Premium @@ -21,12 +25,12 @@ Get Access -
+
or
} - - - - + +
- Name - -
- -
- @if (isGhostfolioDataProvider(element)) { - - Ghostfolio Premium - - @if (isGhostfolioApiKeyValid === false) { - new - } - - @if (isGhostfolioApiKeyValid === true) { -
- - Valid until - {{ - ghostfolioApiStatus?.subscription?.expiresAt - | date: defaultDateFormat - }} - -
+
+ + + + + + + + + - - - - - - + } @else { + {{ element.name }} + } + + - - - - + + + + - - - + - - - - + + - + + + + + + + - + + - - -
+ + + Name + + @if (isGhostfolioDataProvider(element)) { + + Ghostfolio Premium + + @if (isGhostfolioApiKeyValid === false) { + popular } - } @else { - {{ element.name }} + + @if (isGhostfolioApiKeyValid === true) { +
+ + Valid until + {{ + ghostfolioApiStatus?.subscription?.expiresAt + | date: defaultDateFormat + }} + +
} - - -
- Status - - @if ( - !isGhostfolioDataProvider(element) || - isGhostfolioApiKeyValid === true - ) { - - } - - Asset Profiles - - - + Status + + @if ( + hasGhostfolioApiKey && + isGhostfolioApiKeyValid === false && + isGhostfolioDataProvider(element) + ) { + Invalid API key + } @else if ( + hasGhostfolioApiKey || !isGhostfolioDataProvider(element) + ) { + + } + - @if ( - isGhostfolioDataProvider(element) && - isGhostfolioApiKeyValid === true - ) { - + + Asset Profiles + + - - {{ ghostfolioApiStatus.dailyRequests }} - of - {{ ghostfolioApiStatus.dailyRequestsMax }} - daily requests - - } - - @if (isGhostfolioDataProvider(element)) { - @if (isGhostfolioApiKeyValid === true) { - + @if ( + isGhostfolioDataProvider(element) && + isGhostfolioApiKeyValid === true + ) { +
- - - -
+ } +
+ @if (isGhostfolioDataProvider(element)) { + @if (hasGhostfolioApiKey) { + - - } @else if (isGhostfolioApiKeyValid === false) { - + + + + } @else if (hasGhostfolioApiKey === false) { + + } } - } -
+
+
@if (isLoading) {

Platforms

- +

Tags

- +
diff --git a/apps/client/src/app/components/admin-settings/admin-settings.component.scss b/apps/client/src/app/components/admin-settings/admin-settings.component.scss index 1c0a17624b..29340ea0df 100644 --- a/apps/client/src/app/components/admin-settings/admin-settings.component.scss +++ b/apps/client/src/app/components/admin-settings/admin-settings.component.scss @@ -10,7 +10,33 @@ } .mat-mdc-card { - --mat-card-outlined-container-color: whitesmoke; + --gradient-opacity: 50%; + --mat-card-outlined-outline-color: rgb(193, 219, 254); + + background-color: white; + background-image: linear-gradient( + 109.6deg, + color-mix(in srgb, rgba(255, 255, 255, 1) 100%, transparent) 11.2%, + color-mix( + in srgb, + rgba(221, 108, 241, 0.26) var(--gradient-opacity), + transparent + ) + 42%, + color-mix( + in srgb, + rgba(229, 106, 253, 0.71) var(--gradient-opacity), + transparent + ) + 71.5%, + color-mix( + in srgb, + rgba(123, 183, 253, 1) var(--gradient-opacity), + transparent + ) + 100% + ); + color: rgb(var(--dark-primary-text)); .mat-mdc-card-actions { min-height: 0; @@ -32,6 +58,6 @@ :host-context(.theme-dark) { .mat-mdc-card { - --mat-card-outlined-container-color: #222222; + --mat-card-outlined-outline-color: white; } } diff --git a/apps/client/src/app/components/admin-settings/admin-settings.component.ts b/apps/client/src/app/components/admin-settings/admin-settings.component.ts index d030abb829..d49f3fb0aa 100644 --- a/apps/client/src/app/components/admin-settings/admin-settings.component.ts +++ b/apps/client/src/app/components/admin-settings/admin-settings.component.ts @@ -2,7 +2,11 @@ import { GfAdminPlatformComponent } from '@ghostfolio/client/components/admin-pl import { GfAdminTagComponent } from '@ghostfolio/client/components/admin-tag/admin-tag.component'; import { GfDataProviderStatusComponent } from '@ghostfolio/client/components/data-provider-status/data-provider-status.component'; import { UserService } from '@ghostfolio/client/services/user/user.service'; -import { PROPERTY_API_KEY_GHOSTFOLIO } from '@ghostfolio/common/config'; +import { + DEFAULT_LOCALE, + E_MAIL_LINE_BREAK, + PROPERTY_API_KEY_GHOSTFOLIO +} from '@ghostfolio/common/config'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { getDateFormatString } from '@ghostfolio/common/helper'; import { @@ -33,11 +37,12 @@ import { MatMenuModule } from '@angular/material/menu'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; import { addIcons } from 'ionicons'; import { ellipsisHorizontal, trashOutline } from 'ionicons/icons'; -import { get } from 'lodash'; +import { get } from 'lodash-es'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { catchError, filter, of } from 'rxjs'; @@ -58,6 +63,7 @@ import { catchError, filter, of } from 'rxjs'; MatProgressBarModule, MatSortModule, MatTableModule, + MatTooltipModule, NgxSkeletonLoaderModule, RouterModule ], @@ -71,6 +77,7 @@ export class GfAdminSettingsComponent implements OnInit { public dataSource = new MatTableDataSource(); public defaultDateFormat: string; public displayedColumns = [ + 'icon', 'name', 'status', 'assetProfileCount', @@ -78,11 +85,22 @@ export class GfAdminSettingsComponent implements OnInit { 'actions' ]; public ghostfolioApiStatus: DataProviderGhostfolioStatusResponse; + public readonly ghostfolioApiStatusTooltip = $localize`Additional requests are granted while you are setting up your instance`; + public hasGhostfolioApiKey: boolean; public isGhostfolioApiKeyValid: boolean; public isLoading = false; + public readonly premiumDataProviderMailHref = `mailto:hi@ghostfol.io?subject=Ghostfolio Premium Data Provider&body=${[ + 'Hello,', + '', + 'I am interested in the Ghostfolio Premium data provider. Could you please give me access so I can try it for some time?', + '', + 'Kind regards' + ].join(E_MAIL_LINE_BREAK)}`; public pricingUrl: string; public user: User; + protected readonly DEFAULT_LOCALE = DEFAULT_LOCALE; + public constructor( private adminService: AdminService, private changeDetectorRef: ChangeDetectorRef, @@ -174,6 +192,8 @@ export class GfAdminSettingsComponent implements OnInit { PROPERTY_API_KEY_GHOSTFOLIO ] as string; + this.hasGhostfolioApiKey = !!ghostfolioApiKey; + if (ghostfolioApiKey) { this.adminService .fetchGhostfolioDataProviderStatus(ghostfolioApiKey) diff --git a/apps/client/src/app/components/admin-tag/admin-tag.component.html b/apps/client/src/app/components/admin-tag/admin-tag.component.html index 3c125d5c0e..908a140c1b 100644 --- a/apps/client/src/app/components/admin-tag/admin-tag.component.html +++ b/apps/client/src/app/components/admin-tag/admin-tag.component.html @@ -9,83 +9,151 @@ Add Tag
- - - - - +
+
- Name - - {{ element.name }} -
+ + + + - - - - + + + + - - - - + + + + - - - + + + + + + + + + + + - + + +
+ +
+ + + + + +
+ Name + + {{ translate(element.name) }} + - User - - {{ element.userId }} - + User + + {{ element.userId }} + - Activities - - - + Accounts + + + - - - - - -
+ Activities +
+ + + Total + + + - -
+ + +@if (isLoading) { + +} - - - + diff --git a/apps/client/src/app/components/admin-tag/admin-tag.component.ts b/apps/client/src/app/components/admin-tag/admin-tag.component.ts index c00fe3a618..e46044d1e4 100644 --- a/apps/client/src/app/components/admin-tag/admin-tag.component.ts +++ b/apps/client/src/app/components/admin-tag/admin-tag.component.ts @@ -1,7 +1,14 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; import { CreateTagDto, UpdateTagDto } from '@ghostfolio/common/dtos'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; -import { getLocale } from '@ghostfolio/common/helper'; +import { + getLocale, + getLowercase, + isSystemTag +} from '@ghostfolio/common/helper'; +import { TagWithAccountAndActivityCount } from '@ghostfolio/common/types'; +import { translate } from '@ghostfolio/ui/i18n'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { DataService } from '@ghostfolio/ui/services'; import { GfValueComponent } from '@ghostfolio/ui/value'; @@ -21,19 +28,19 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; import { MatMenuModule } from '@angular/material/menu'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { Tag } from '@prisma/client'; import { addIcons } from 'ionicons'; import { createOutline, ellipsisHorizontal, trashOutline } from 'ionicons/icons'; -import { get } from 'lodash'; import { DeviceDetectorService } from 'ngx-device-detector'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { GfCreateOrUpdateTagDialogComponent } from './create-or-update-tag-dialog/create-or-update-tag-dialog.component'; import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/interfaces/interfaces'; @@ -45,8 +52,10 @@ import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/int IonIcon, MatButtonModule, MatMenuModule, + MatPaginatorModule, MatSortModule, MatTableModule, + NgxSkeletonLoaderModule, RouterModule ], selector: 'gf-admin-tag', @@ -56,18 +65,29 @@ import { CreateOrUpdateTagDialogParams } from './create-or-update-tag-dialog/int export class GfAdminTagComponent implements OnInit { public readonly locale = input(getLocale()); - protected dataSource = new MatTableDataSource(); + protected dataSource = + new MatTableDataSource(); + protected readonly displayedColumns = [ 'name', 'userId', + 'accounts', 'activities', + 'total', 'actions' ]; - protected tags: Tag[]; + + protected isLoading = false; + protected readonly isSystemTag = isSystemTag; + protected readonly pageSize = DEFAULT_PAGE_SIZE; + protected tags: TagWithAccountAndActivityCount[]; + protected readonly translate = translate; private readonly deviceType = computed( () => this.deviceDetectorService.deviceInfo().deviceType ); + + private readonly paginator = viewChild.required(MatPaginator); private readonly sort = viewChild.required(MatSort); private readonly changeDetectorRef = inject(ChangeDetectorRef); @@ -92,7 +112,7 @@ export class GfAdminTagComponent implements OnInit { return id === params['tagId']; }); - if (tag) { + if (tag && !isSystemTag(tag)) { this.openUpdateTagDialog(tag); } } else { @@ -108,6 +128,13 @@ export class GfAdminTagComponent implements OnInit { this.fetchTags(); } + protected getTotalCount({ + accountCount, + activityCount + }: TagWithAccountAndActivityCount) { + return accountCount + activityCount; + } + protected onDeleteTag(aId: string) { this.notificationService.confirm({ confirmFn: () => { @@ -118,7 +145,7 @@ export class GfAdminTagComponent implements OnInit { }); } - protected onUpdateTag({ id }: Tag) { + protected onUpdateTag({ id }: TagWithAccountAndActivityCount) { this.router.navigate([], { queryParams: { editTagDialog: true, tagId: id } }); @@ -141,6 +168,8 @@ export class GfAdminTagComponent implements OnInit { } private fetchTags() { + this.isLoading = true; + this.dataService .fetchTags() .pipe(takeUntilDestroyed(this.destroyRef)) @@ -148,11 +177,23 @@ export class GfAdminTagComponent implements OnInit { this.tags = tags; this.dataSource = new MatTableDataSource(this.tags); + this.dataSource.paginator = this.paginator(); this.dataSource.sort = this.sort(); - this.dataSource.sortingDataAccessor = get; + + this.dataSource.sortingDataAccessor = (tag, path) => { + if (path === 'name') { + return translate(tag.name).toLocaleLowerCase(); + } else if (path === 'totalCount') { + return this.getTotalCount(tag); + } + + return getLowercase(tag, path) as number | string; + }; this.dataService.updateInfo(); + this.isLoading = false; + this.changeDetectorRef.markForCheck(); }); } diff --git a/apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts index f4b1104d00..b866ea47dd 100644 --- a/apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/interfaces/interfaces.ts @@ -1,4 +1,4 @@ -import { Tag } from '@prisma/client'; +import type { Tag } from '@ghostfolio/prisma/browser'; export interface CreateOrUpdateTagDialogParams { tag?: Pick; diff --git a/apps/client/src/app/components/admin-users/admin-users.component.ts b/apps/client/src/app/components/admin-users/admin-users.component.ts index f477776a50..8e459b4a40 100644 --- a/apps/client/src/app/components/admin-users/admin-users.component.ts +++ b/apps/client/src/app/components/admin-users/admin-users.component.ts @@ -5,10 +5,12 @@ import { import { GfUserDetailDialogComponent } from '@ghostfolio/client/components/user-detail-dialog/user-detail-dialog.component'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; -import { DEFAULT_PAGE_SIZE, locale } from '@ghostfolio/common/config'; +import { formatRelativeTime } from '@ghostfolio/client/util/date.util'; +import { DEFAULT_LOCALE, DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { - getDateFnsLocale, + canDeleteUser, + getCountryName, getDateFormatString, getEmojiFlag } from '@ghostfolio/common/helper'; @@ -19,6 +21,8 @@ import { } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { RequestClient } from '@ghostfolio/prisma/enums'; +import { translate } from '@ghostfolio/ui/i18n'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { AdminService, DataService } from '@ghostfolio/ui/services'; @@ -26,6 +30,7 @@ import { GfValueComponent } from '@ghostfolio/ui/value'; import { CommonModule } from '@angular/common'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, computed, @@ -46,26 +51,26 @@ import { import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { - differenceInSeconds, - formatDistanceToNowStrict, - parseISO -} from 'date-fns'; import { addIcons } from 'ionicons'; import { + codeSlashOutline, contractOutline, ellipsisHorizontal, + globeOutline, keyOutline, personOutline, + serverOutline, + sparklesOutline, trashOutline } from 'ionicons/icons'; import ms from 'ms'; import { DeviceDetectorService } from 'ngx-device-detector'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { interval } from 'rxjs'; -import { switchMap, tap } from 'rxjs/operators'; +import { distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [ CommonModule, GfPremiumIndicatorComponent, @@ -86,17 +91,31 @@ export class GfAdminUsersComponent implements OnInit { protected dataSource = new MatTableDataSource< AdminUsersResponse['users'][0] >(); + protected defaultDateFormat: string; protected displayedColumns: string[] = []; + protected readonly canDeleteUser = canDeleteUser; + protected readonly formatRelativeTime = formatRelativeTime; + protected readonly getCountryName = getCountryName; protected readonly getEmojiFlag = getEmojiFlag; protected hasPermissionForSubscription: boolean; protected hasPermissionToImpersonateAllUsers: boolean; protected info: InfoItem; protected isLoading = false; protected readonly pageSize = DEFAULT_PAGE_SIZE; + + protected readonly requestClientIcons: Record = { + API: 'code-slash-outline', + MCP: 'sparkles-outline', + SELF_HOSTING: 'server-outline', + WEB: 'globe-outline' + }; + protected readonly routerLinkAdminControlUsers = internalRoutes.adminControl.subRoutes.users.routerLink; + protected totalItems = 0; + protected readonly translate = translate; protected user: User; private readonly deviceType = computed( @@ -110,9 +129,11 @@ export class GfAdminUsersComponent implements OnInit { private readonly destroyRef = inject(DestroyRef); private readonly deviceDetectorService = inject(DeviceDetectorService); private readonly dialog = inject(MatDialog); + private readonly impersonationStorageService = inject( ImpersonationStorageService ); + private readonly notificationService = inject(NotificationService); private readonly route = inject(ActivatedRoute); private readonly router = inject(Router); @@ -163,23 +184,31 @@ export class GfAdminUsersComponent implements OnInit { this.user.permissions, permissions.impersonateAllUsers ); + + this.changeDetectorRef.markForCheck(); } }), - switchMap(() => this.route.paramMap) + switchMap(() => this.route.paramMap), + map((params) => { + return params.get('userId'); + }), + distinctUntilChanged() ) - .subscribe((params) => { - const userId = params.get('userId'); - + .subscribe((userId) => { if (userId) { this.openUserDetailDialog(userId); } }); addIcons({ + codeSlashOutline, contractOutline, ellipsisHorizontal, + globeOutline, keyOutline, personOutline, + serverOutline, + sparklesOutline, trashOutline }); } @@ -194,23 +223,9 @@ export class GfAdminUsersComponent implements OnInit { pageIndex: this.paginator().pageIndex, showLoading: false }); - }); - } - protected formatDistanceToNow(aDateString: string) { - if (aDateString) { - const distanceString = formatDistanceToNowStrict(parseISO(aDateString), { - addSuffix: true, - locale: getDateFnsLocale(this.user?.settings?.language) + this.changeDetectorRef.markForCheck(); }); - - return Math.abs(differenceInSeconds(parseISO(aDateString), new Date())) < - 60 - ? 'just now' - : distanceString; - } - - return ''; } protected onChangePage(page: PageEvent) { @@ -226,12 +241,17 @@ export class GfAdminUsersComponent implements OnInit { .deleteUser(aId) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { - this.router.navigate(['..'], { relativeTo: this.route }); + this.router.navigate(this.routerLinkAdminControlUsers); + + this.fetchUsers({ + pageIndex: this.paginator().pageIndex, + showLoading: false + }); }); }, confirmType: ConfirmationDialogType.Warn, discardFn: () => { - this.router.navigate(['..'], { relativeTo: this.route }); + this.router.navigate(this.routerLinkAdminControlUsers); }, title: $localize`Do you really want to delete this user?` }); @@ -273,9 +293,7 @@ export class GfAdminUsersComponent implements OnInit { } protected onOpenUserDetailDialog(userId: string) { - this.router.navigate( - internalRoutes.adminControl.subRoutes.users.routerLink.concat(userId) - ); + this.router.navigate(this.routerLinkAdminControlUsers.concat(userId)); } private fetchUsers({ @@ -317,7 +335,8 @@ export class GfAdminUsersComponent implements OnInit { currentUserId: this.user?.id, deviceType: this.deviceType(), hasPermissionForSubscription: this.hasPermissionForSubscription, - locale: this.user?.settings?.locale ?? locale, + language: this.user?.settings?.language, + locale: this.user?.settings?.locale ?? DEFAULT_LOCALE, userId: aUserId } satisfies UserDetailDialogParams, height: this.deviceType() === 'mobile' ? '98vh' : '60vh', @@ -331,9 +350,7 @@ export class GfAdminUsersComponent implements OnInit { if (data?.action === 'delete' && data?.userId) { this.onDeleteUser(data.userId); } else { - this.router.navigate( - internalRoutes.adminControl.subRoutes.users.routerLink - ); + this.router.navigate(this.routerLinkAdminControlUsers); } }); } diff --git a/apps/client/src/app/components/admin-users/admin-users.html b/apps/client/src/app/components/admin-users/admin-users.html index 87ab9defc9..98056f00f7 100644 --- a/apps/client/src/app/components/admin-users/admin-users.html +++ b/apps/client/src/app/components/admin-users/admin-users.html @@ -16,29 +16,33 @@ class="mat-mdc-cell px-1 py-2" mat-cell > -
+
{{ element.id }} {{ `${(element.id | slice: 0 : 5)}...` }} @if (element.subscription?.expiresAt) { } @@ -60,9 +64,11 @@ class="mat-mdc-cell px-1 py-2" mat-cell > - {{ - getEmojiFlag(element.country) - }} + {{ getEmojiFlag(element.country) }} } @@ -77,24 +83,29 @@ - {{ formatDistanceToNow(element.createdAt) }} + {{ + formatRelativeTime({ + date: element.createdAt, + language: user?.settings?.language + }) + }} Accounts Activities Engagement per Day API Requests Today - Last Request + Last Request - {{ formatDistanceToNow(element.lastActivity) }} +
+ @if (element.lastRequestClient) { + + } @else { +
} @@ -194,12 +220,12 @@ @@ -235,19 +261,24 @@ (click)="onGenerateAccessToken(element.id)" > - + Generate Security Token
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 328cccba1f..04adcdeca7 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 @@ -1,18 +1,18 @@
-
+
Performance @if (user()?.subscription?.type === 'Basic') { - + }
-
+
Compare with... @@ -31,7 +31,10 @@ @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 8d13fb91d3..6a00e1a35e 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 @@ -1,20 +1,23 @@ import { - getTooltipOptions, - getVerticalHoverLinePlugin + getChartBorderColor, + getChartElementsOptions, + getTimeAxisOptions, + getValueAxisOptions, + getVerticalHoverLinePlugin, + getZeroLineAnnotation } from '@ghostfolio/common/chart-helper'; import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; -import { - getBackgroundColor, - getDateFormatString, - getLocale, - getTextColor, - parseDate -} from '@ghostfolio/common/helper'; +import { getLocale, parseDate } from '@ghostfolio/common/helper'; import { LineChartItem, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { ColorScheme } from '@ghostfolio/common/types'; -import { registerChartConfiguration } from '@ghostfolio/ui/chart'; +import type { SymbolProfile } from '@ghostfolio/prisma/browser'; +import { + getTimeSeriesTooltipOptions, + onPrefersColorSchemeChange, + registerChartConfiguration +} from '@ghostfolio/ui/chart'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { @@ -25,13 +28,13 @@ import { OnChanges, OnDestroy, output, + SimpleChanges, viewChild } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSelectModule } from '@angular/material/select'; import { RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { SymbolProfile } from '@prisma/client'; import { Chart, ChartData, @@ -44,7 +47,6 @@ import { type TooltipOptions } from 'chart.js'; import 'chartjs-adapter-date-fns'; -import annotationPlugin from 'chartjs-plugin-annotation'; import { addIcons } from 'ionicons'; import { arrowForwardOutline } from 'ionicons/icons'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @@ -68,15 +70,21 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { public readonly benchmark = input>(); public readonly benchmarkDataItems = input([]); public readonly benchmarks = input[]>(); - public readonly colorScheme = input.required(); + public readonly colorScheme = input(); public readonly isLoading = input(); - public readonly locale = input(getLocale()); + + public readonly locale = input(getLocale(), { + transform: (value?: string) => { + return value ?? getLocale(); + } + }); + public readonly performanceDataItems = input.required(); public readonly user = input(); public readonly benchmarkChanged = output(); - protected chart: Chart<'line'>; + protected chart?: Chart<'line'>; protected hasPermissionToAccessAdminControl: boolean; protected readonly routerLinkAdminControlMarketData = internalRoutes.adminControl.subRoutes.marketData.routerLink; @@ -86,7 +94,6 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { public constructor() { Chart.register( - annotationPlugin, LinearScale, LineController, LineElement, @@ -97,10 +104,24 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { registerChartConfiguration(); + onPrefersColorSchemeChange(() => { + if (this.chart && !this.colorScheme()) { + this.chart.destroy(); + this.chart = undefined; + + this.initialize(); + } + }); + addIcons({ arrowForwardOutline }); } - public ngOnChanges() { + public ngOnChanges(changes: SimpleChanges) { + if (changes.colorScheme && this.chart) { + this.chart.destroy(); + this.chart = undefined; + } + this.hasPermissionToAccessAdminControl = hasPermission( this.user()?.permissions, permissions.accessAdminControl @@ -150,7 +171,7 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { y: benchmarkDataValues[date] }; }), - label: this.benchmark?.name ?? $localize`Benchmark` + label: this.benchmark()?.name ?? $localize`Benchmark` } ] }; @@ -168,28 +189,13 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { data, options: { animation: false, - elements: { - line: { - tension: 0 - }, - point: { - hoverBackgroundColor: getBackgroundColor(this.colorScheme()), - hoverRadius: 2, - radius: 0 - } - }, + elements: getChartElementsOptions(this.colorScheme()), interaction: { intersect: false, mode: 'index' }, maintainAspectRatio: true, plugins: { annotation: { annotations: { - yAxis: { - borderColor: `rgba(${getTextColor(this.colorScheme())}, 0.1)`, - borderWidth: 1, - scaleID: 'y', - type: 'line', - value: 0 - } + yAxis: getZeroLineAnnotation(this.colorScheme()) } }, legend: { @@ -197,54 +203,21 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { }, tooltip: this.getTooltipPluginConfiguration(), verticalHoverLine: { - color: `rgba(${getTextColor(this.colorScheme())}, 0.1)` + color: getChartBorderColor(this.colorScheme()) } }, responsive: true, scales: { - x: { - border: { - color: `rgba(${getTextColor(this.colorScheme())}, 0.1)`, - width: 1 - }, - display: true, - grid: { - display: false - }, - type: 'time', - time: { - tooltipFormat: getDateFormatString(this.locale()), - unit: 'year' + x: getTimeAxisOptions({ + colorScheme: this.colorScheme(), + locale: this.locale() + }), + y: getValueAxisOptions({ + colorScheme: this.colorScheme(), + tickCallback: (tickValue) => { + return `${Number(tickValue).toFixed(2)} %`; } - }, - y: { - border: { - width: 0 - }, - display: true, - grid: { - color: ({ scale, tick }) => { - if ( - tick.value === 0 || - tick.value === scale.max || - tick.value === scale.min - ) { - return `rgba(${getTextColor(this.colorScheme())}, 0.1)`; - } - - return 'transparent'; - } - }, - position: 'right', - ticks: { - callback: (value: number) => { - return `${value.toFixed(2)} %`; - }, - display: true, - mirror: true, - z: 1 - } - } + }) } }, plugins: [ @@ -257,16 +230,10 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy { } private getTooltipPluginConfiguration(): Partial> { - return { - ...getTooltipOptions({ - colorScheme: this.colorScheme(), - locale: this.locale(), - unit: '%' - }), - mode: 'index', - position: 'top', - xAlign: 'center', - yAlign: 'bottom' - }; + return getTimeSeriesTooltipOptions<'line'>({ + colorScheme: this.colorScheme(), + locale: this.locale(), + unit: '%' + }); } } diff --git a/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts b/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts index a77d65961a..13218623a0 100644 --- a/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts +++ b/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts @@ -1,3 +1,4 @@ +import type { DataSource } from '@ghostfolio/prisma/enums'; import { DataService } from '@ghostfolio/ui/services'; import { CommonModule } from '@angular/common'; @@ -9,7 +10,6 @@ import { OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import type { DataSource } from '@prisma/client'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { catchError, map, type Observable, of } from 'rxjs'; diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.html b/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.html deleted file mode 100644 index 67274ae381..0000000000 --- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
{{ fearAndGreedIndexEmoji }}
-
-
- {{ fearAndGreedIndexText }} - {{ fearAndGreedIndex }}/100 -
- Current Market Mood -
-
- @if (!fearAndGreedIndex) { - - } -
diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scss b/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scss deleted file mode 100644 index dfe024a035..0000000000 --- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -:host { - display: block; - - ngx-skeleton-loader { - bottom: 0; - top: 0; - } -} diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.ts b/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.ts deleted file mode 100644 index 32e2cc29ae..0000000000 --- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { resolveFearAndGreedIndex } from '@ghostfolio/common/helper'; -import { translate } from '@ghostfolio/ui/i18n'; - -import { - ChangeDetectionStrategy, - Component, - Input, - OnChanges -} from '@angular/core'; -import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; - -@Component({ - changeDetection: ChangeDetectionStrategy.OnPush, - imports: [NgxSkeletonLoaderModule], - selector: 'gf-fear-and-greed-index', - styleUrls: ['./fear-and-greed-index.component.scss'], - templateUrl: './fear-and-greed-index.component.html' -}) -export class GfFearAndGreedIndexComponent implements OnChanges { - @Input() fearAndGreedIndex: number; - - public fearAndGreedIndexEmoji: string; - public fearAndGreedIndexText: string; - - public ngOnChanges() { - const { emoji, key } = resolveFearAndGreedIndex(this.fearAndGreedIndex); - - this.fearAndGreedIndexEmoji = emoji; - this.fearAndGreedIndexText = translate(key); - } -} diff --git a/apps/client/src/app/components/footer/footer.component.html b/apps/client/src/app/components/footer/footer.component.html index 45626620ef..143fe27a7a 100644 --- a/apps/client/src/app/components/footer/footer.component.html +++ b/apps/client/src/app/components/footer/footer.component.html @@ -6,7 +6,7 @@
Personal Finance
    - @if (hasPermissionToAccessFearAndGreedIndex) { + @if (hasPermissionToAccessFearAndGreedIndex()) {
  • Markets
  • @@ -18,7 +18,7 @@
    Ghostfolio
    • About
    • - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • Blog
    • @@ -27,50 +27,50 @@ Changelog
    • Features
    • - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • Frequently Asked Questions (FAQ)
    • } - @if (!hasPermissionForSubscription) { + @if (!hasPermissionForSubscription()) {
    • License
    • } - @if (hasPermissionForStatistics) { + @if (hasPermissionForStatistics()) {
    • Open Startup
    • } - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • Pricing
    • } - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • Privacy Policy
    • } - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • Terms of Service
    • } - @if (hasPermissionForSubscription) { + @if (hasPermissionForSubscription()) {
    • StatusStatus
    • } @@ -85,7 +85,7 @@ href="https://github.com/ghostfolio/ghostfolio" target="_blank" title="Find Ghostfolio on GitHub" - >GitHubGitHub
    • @@ -94,7 +94,7 @@ href="https://linkedin.com/company/ghostfolio" target="_blank" title="Follow Ghostfolio on LinkedIn" - >LinkedInLinkedIn
    • @@ -103,7 +103,7 @@ href="https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg" target="_blank" title="Join the Ghostfolio Slack community" - >SlackSlack
    • @@ -112,7 +112,7 @@ href="https://x.com/ghostfolio_" target="_blank" title="Follow Ghostfolio on X (formerly Twitter)" - >X (formerly Twitter)X (formerly Twitter)
    •  
    • @@ -143,11 +143,16 @@ +
    • + Korean (한국어) +
    • Nederlands
    • @@ -176,7 +181,7 @@ Ghostfolio
-
+
The risk of loss in trading can be substantial. It is not advisable to @@ -186,7 +191,7 @@
-
-
Ghostfolio
+
+
Ghostfolio
diff --git a/apps/client/src/app/components/footer/footer.component.ts b/apps/client/src/app/components/footer/footer.component.ts index 48f010565b..2d9ee58309 100644 --- a/apps/client/src/app/components/footer/footer.component.ts +++ b/apps/client/src/app/components/footer/footer.component.ts @@ -1,4 +1,4 @@ -import { InfoItem, User } from '@ghostfolio/common/interfaces'; +import { InfoItem } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfLogoComponent } from '@ghostfolio/ui/logo'; @@ -6,9 +6,9 @@ import { GfLogoComponent } from '@ghostfolio/ui/logo'; import { ChangeDetectionStrategy, Component, + computed, CUSTOM_ELEMENTS_SCHEMA, - Input, - OnChanges + input } from '@angular/core'; import { RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; @@ -23,51 +23,53 @@ import { openOutline } from 'ionicons/icons'; styleUrls: ['./footer.component.scss'], templateUrl: './footer.component.html' }) -export class GfFooterComponent implements OnChanges { - @Input() public info: InfoItem; - @Input() public user: User; +export class GfFooterComponent { + public readonly info = input.required(); - public currentYear = new Date().getFullYear(); - public hasPermissionForStatistics: boolean; - public hasPermissionForSubscription: boolean; - public hasPermissionToAccessFearAndGreedIndex: boolean; - public routerLinkAbout = publicRoutes.about.routerLink; - public routerLinkAboutChangelog = - publicRoutes.about.subRoutes.changelog.routerLink; - public routerLinkAboutLicense = - publicRoutes.about.subRoutes.license.routerLink; - public routerLinkAboutPrivacyPolicy = - publicRoutes.about.subRoutes.privacyPolicy.routerLink; - public routerLinkAboutTermsOfService = - publicRoutes.about.subRoutes.termsOfService.routerLink; - public routerLinkBlog = publicRoutes.blog.routerLink; - public routerLinkFaq = publicRoutes.faq.routerLink; - public routerLinkFeatures = publicRoutes.features.routerLink; - public routerLinkMarkets = publicRoutes.markets.routerLink; - public routerLinkOpenStartup = publicRoutes.openStartup.routerLink; - public routerLinkPricing = publicRoutes.pricing.routerLink; - public routerLinkResources = publicRoutes.resources.routerLink; - - public constructor() { - addIcons({ - openOutline - }); - } + protected readonly currentYear = new Date().getFullYear(); - public ngOnChanges() { - this.hasPermissionForStatistics = hasPermission( - this.info?.globalPermissions, + protected readonly hasPermissionForStatistics = computed(() => { + return hasPermission( + this.info()?.globalPermissions, permissions.enableStatistics ); + }); - this.hasPermissionForSubscription = hasPermission( - this.info?.globalPermissions, + protected readonly hasPermissionForSubscription = computed(() => { + return hasPermission( + this.info()?.globalPermissions, permissions.enableSubscription ); + }); - this.hasPermissionToAccessFearAndGreedIndex = hasPermission( - this.info?.globalPermissions, + protected readonly hasPermissionToAccessFearAndGreedIndex = computed(() => { + return hasPermission( + this.info()?.globalPermissions, permissions.enableFearAndGreedIndex ); + }); + + protected readonly routerLinkAbout = publicRoutes.about.routerLink; + protected readonly routerLinkAboutChangelog = + publicRoutes.about.subRoutes.changelog.routerLink; + protected readonly routerLinkAboutLicense = + publicRoutes.about.subRoutes.license.routerLink; + protected readonly routerLinkAboutPrivacyPolicy = + publicRoutes.about.subRoutes.privacyPolicy.routerLink; + protected readonly routerLinkAboutTermsOfService = + publicRoutes.about.subRoutes.termsOfService.routerLink; + protected readonly routerLinkBlog = publicRoutes.blog.routerLink; + protected readonly routerLinkFaq = publicRoutes.faq.routerLink; + protected readonly routerLinkFeatures = publicRoutes.features.routerLink; + protected readonly routerLinkMarkets = publicRoutes.markets.routerLink; + protected readonly routerLinkOpenStartup = + publicRoutes.openStartup.routerLink; + protected readonly routerLinkPricing = publicRoutes.pricing.routerLink; + protected readonly routerLinkResources = publicRoutes.resources.routerLink; + + public constructor() { + addIcons({ + openOutline + }); } } diff --git a/apps/client/src/app/components/header/header.component.html b/apps/client/src/app/components/header/header.component.html index ae3121861f..88ab9f09fc 100644 --- a/apps/client/src/app/components/header/header.component.html +++ b/apps/client/src/app/components/header/header.component.html @@ -19,7 +19,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': + 'fw-bold': currentRoute() === internalRoutes.home.path || currentRoute() === internalRoutes.zen.path, 'text-decoration-underline': @@ -36,8 +36,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': - currentRoute() === internalRoutes.portfolio.path, + 'fw-bold': currentRoute() === internalRoutes.portfolio.path, 'text-decoration-underline': currentRoute() === internalRoutes.portfolio.path }" @@ -51,7 +50,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': currentRoute() === internalRoutes.accounts.path, + 'fw-bold': currentRoute() === internalRoutes.accounts.path, 'text-decoration-underline': currentRoute() === internalRoutes.accounts.path }" @@ -66,8 +65,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': - currentRoute() === internalRoutes.adminControl.path, + 'fw-bold': currentRoute() === internalRoutes.adminControl.path, 'text-decoration-underline': currentRoute() === internalRoutes.adminControl.path }" @@ -82,7 +80,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': currentRoute() === routeResources, + 'fw-bold': currentRoute() === routeResources, 'text-decoration-underline': currentRoute() === routeResources }" [routerLink]="routerLinkResources" @@ -97,7 +95,7 @@ class="d-none d-sm-block rounded" mat-button [class]="{ - 'font-weight-bold': currentRoute() === routePricing, + 'fw-bold': currentRoute() === routePricing, 'text-decoration-underline': currentRoute() === routePricing }" [routerLink]="routerLinkPricing" @@ -105,7 +103,7 @@ Pricing @if (currentRoute() !== routePricing && hasPromotion()) { - % + % } @@ -117,14 +115,14 @@ i18n mat-button [class]="{ - 'font-weight-bold': currentRoute() === routeAbout, + 'fw-bold': currentRoute() === routeAbout, 'text-decoration-underline': currentRoute() === routeAbout }" [routerLink]="routerLinkAbout" >About - @if (hasPermissionToAccessAssistant) { + @if (hasPermissionToAccessAssistant && user(); as user) {
  • } - @if (user() === null) { + @if (!user()) {
    Pricing @if (currentRoute() !== routePricing && hasPromotion()) { - % + % } @@ -401,7 +393,7 @@ i18n mat-button [class]="{ - 'font-weight-bold': currentRoute() === routeMarkets, + 'fw-bold': currentRoute() === routeMarkets, 'text-decoration-underline': currentRoute() === routeMarkets }" [routerLink]="routerLinkMarkets" @@ -427,7 +419,7 @@ @if (currentRoute() !== 'register' && hasPermissionToCreateUser) { -
  • +
  • { - this.notificationService.alert({ - title: $localize`Oops! Incorrect Security Token.` - }); + catchError((error: HttpErrorResponse) => { + if (error.status !== StatusCodes.TOO_MANY_REQUESTS) { + // The notification for too many requests is handled in the + // HttpResponseInterceptor + + this.notificationService.alert({ + title: $localize`Oops! Incorrect Security Token.` + }); + } return EMPTY; }), diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts index 416e9106d9..e08e4bfed6 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts +++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts @@ -1,8 +1,11 @@ +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { DEFAULT_PAGE_SIZE, + E_MAIL_LINE_BREAK, NUMERICAL_PRECISION_THRESHOLD_3_FIGURES, - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES, + TAG_ID_DRAFT } from '@ghostfolio/common/config'; import { CreateOrderDto } from '@ghostfolio/common/dtos'; import { @@ -13,13 +16,16 @@ import { import { Activity, DataProviderInfo, - EnhancedSymbolProfile, + EnhancedAssetProfile, Filter, LineChartItem, + NullableLineChartItem, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { AccountWithValue } from '@ghostfolio/common/types'; +import type { MarketData, Tag } from '@ghostfolio/prisma/browser'; import { GfAccountsTableComponent } from '@ghostfolio/ui/accounts-table'; import { GfActivitiesTableComponent } from '@ghostfolio/ui/activities-table'; import { GfDataProviderCreditsComponent } from '@ghostfolio/ui/data-provider-credits'; @@ -29,21 +35,26 @@ import { GfHistoricalMarketDataEditorComponent } from '@ghostfolio/ui/historical import { translate } from '@ghostfolio/ui/i18n'; import { GfLineChartComponent } from '@ghostfolio/ui/line-chart'; import { GfPortfolioProportionChartComponent } from '@ghostfolio/ui/portfolio-proportion-chart'; +import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { DataService } from '@ghostfolio/ui/services'; import { GfTagsSelectorComponent } from '@ghostfolio/ui/tags-selector'; import { GfValueComponent } from '@ghostfolio/ui/value'; import { - CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, - Inject, - OnInit + OnInit, + inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'; +import { + FormBuilder, + FormControl, + FormGroup, + ReactiveFormsModule +} from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatChipsModule } from '@angular/material/chips'; import { @@ -56,9 +67,8 @@ import { PageEvent } from '@angular/material/paginator'; import { SortDirection } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { MatTabsModule } from '@angular/material/tabs'; -import { Router, RouterModule } from '@angular/router'; +import { NavigationStart, Router, RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { Account, MarketData, Tag } from '@prisma/client'; import { isUUID } from 'class-validator'; import { format, isSameMonth, isToday, parseISO } from 'date-fns'; import { addIcons } from 'ionicons'; @@ -71,10 +81,14 @@ import { swapVerticalOutline, walletOutline } from 'ionicons/icons'; +import { isNumber, round, uniqBy } from 'lodash-es'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { switchMap } from 'rxjs/operators'; +import { filter, switchMap } from 'rxjs/operators'; -import { HoldingDetailDialogParams } from './interfaces/interfaces'; +import { + HoldingDetailDialogParams, + HoldingDetailDialogResult +} from './interfaces/interfaces'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -88,6 +102,7 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces'; GfHistoricalMarketDataEditorComponent, GfLineChartComponent, GfPortfolioProportionChartComponent, + GfPremiumIndicatorComponent, GfTagsSelectorComponent, GfValueComponent, IonIcon, @@ -100,81 +115,115 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces'; ReactiveFormsModule, RouterModule ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-holding-detail-dialog', styleUrls: ['./holding-detail-dialog.component.scss'], templateUrl: 'holding-detail-dialog.html' }) export class GfHoldingDetailDialogComponent implements OnInit { - public activitiesCount: number; - public accounts: Account[]; - public assetClass: string; - public assetSubClass: string; - public averagePrice: number; - public averagePricePrecision = 2; - public benchmarkDataItems: LineChartItem[]; - public benchmarkLabel = $localize`Average Unit Price`; - public countries: { + protected accounts: AccountWithValue[]; + protected activitiesCount: number; + protected assetClass: string; + protected assetProfile: Pick< + EnhancedAssetProfile, + | 'assetClass' + | 'assetSubClass' + | 'countries' + | 'currency' + | 'dataSource' + | 'isin' + | 'name' + | 'sectors' + | 'symbol' + | 'userId' + >; + protected assetSubClass: string; + protected averagePrice: number; + protected averagePricePrecision = 2; + protected benchmarkDataItems: NullableLineChartItem[]; + protected readonly benchmarkLabel = $localize`Average Unit Price`; + protected countries: { [code: string]: { name: string; value: number }; }; - public dataProviderInfo: DataProviderInfo; - public dataSource: MatTableDataSource; - public dateOfFirstActivity: string; - public dividendInBaseCurrency: number; - public dividendInBaseCurrencyPrecision = 2; - public dividendYieldPercentWithCurrencyEffect: number; - public feeInBaseCurrency: number; - public getCountryName = getCountryName; - public hasPermissionToCreateOwnTag: boolean; - public hasPermissionToReadMarketDataOfOwnAssetProfile: boolean; - public historicalDataItems: LineChartItem[]; - public holdingForm: FormGroup; - public investmentInBaseCurrencyWithCurrencyEffect: number; - public investmentInBaseCurrencyWithCurrencyEffectPrecision = 2; - public isUUID = isUUID; - public marketDataItems: MarketData[] = []; - public marketPrice: number; - public marketPriceMax: number; - public marketPriceMaxPrecision = 2; - public marketPriceMin: number; - public marketPriceMinPrecision = 2; - public marketPricePrecision = 2; - public netPerformance: number; - public netPerformancePrecision = 2; - public netPerformancePercent: number; - public netPerformancePercentWithCurrencyEffect: number; - public netPerformancePercentWithCurrencyEffectPrecision = 2; - public netPerformanceWithCurrencyEffect: number; - public netPerformanceWithCurrencyEffectPrecision = 2; - public pageIndex = 0; - public pageSize = DEFAULT_PAGE_SIZE; - public quantity: number; - public quantityPrecision = 2; - public reportDataGlitchMail: string; - public routerLinkAdminControlMarketData = - internalRoutes.adminControl.subRoutes.marketData.routerLink; - public sectors: { + protected dataProviderInfo: DataProviderInfo; + protected dataSource: MatTableDataSource; + protected dateOfFirstActivity: Date; + protected dividendInBaseCurrency: number; + protected dividendInBaseCurrencyPrecision = 2; + protected dividendYieldPercentWithCurrencyEffect: number; + protected feeInBaseCurrency: number; + protected readonly getCountryName = getCountryName; + protected hasPermissionToCreateOwnTag: boolean; + protected hasPermissionToReadMarketDataOfOwnAssetProfile: boolean; + protected historicalDataItems: LineChartItem[]; + protected holdingForm: FormGroup<{ + tags: FormControl; + }>; + protected investmentInBaseCurrencyWithCurrencyEffect: number; + protected investmentInBaseCurrencyWithCurrencyEffectPrecision = 2; + protected isLoading = true; + protected isOwnAssetProfile: boolean; + protected readonly isUUID = isUUID; + protected marketDataItems: MarketData[] = []; + protected marketPrice: number; + protected marketPriceMax: number; + protected marketPriceMaxPrecision = 2; + protected marketPriceMin: number; + protected marketPriceMinPrecision = 2; + protected marketPricePrecision = 2; + protected netPerformancePercentWithCurrencyEffect: number; + protected netPerformancePercentWithCurrencyEffectPrecision = 2; + protected netPerformanceWithCurrencyEffect: number; + protected netPerformanceWithCurrencyEffectPrecision = 2; + protected pageIndex = 0; + protected readonly pageSize = DEFAULT_PAGE_SIZE; + protected quantity: number; + protected quantityPrecision = 2; + protected reportDataGlitchMailHref: string; + protected readonly round = round; + protected readonly routerLinkAdminControlMarketDataUpdate = + internalRoutes.adminControl.subRoutes.marketData.subRoutes.update + .routerLink; + protected sectors: { [name: string]: { name: string; value: number }; }; - public sortColumn = 'date'; - public sortDirection: SortDirection = 'desc'; - public SymbolProfile: EnhancedSymbolProfile; - public tags: Tag[]; - public tagsAvailable: Tag[]; - public translate = translate; - public user: User; - public value: number; - - public constructor( - private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService, - private destroyRef: DestroyRef, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: HoldingDetailDialogParams, - private formBuilder: FormBuilder, - private router: Router, - private userService: UserService - ) { + protected sortColumn = 'date'; + protected sortDirection: SortDirection = 'desc'; + protected tagsAvailable: Tag[]; + protected tagsOfAccounts: Tag[]; + protected readonly translate = translate; + protected user: User; + protected value: number; + + protected readonly data = inject(MAT_DIALOG_DATA); + protected readonly dialogRef = + inject< + MatDialogRef + >(MatDialogRef); + + private tags: Tag[]; + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly formBuilder = inject(FormBuilder); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public constructor() { + this.router.events + .pipe( + filter((event) => { + return event instanceof NavigationStart; + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(() => { + this.dialogRef.close({ isNavigating: true }); + }); + addIcons({ arrowDownCircleOutline, createOutline, @@ -190,12 +239,11 @@ export class GfHoldingDetailDialogComponent implements OnInit { const filters = this.getActivityFilters(); this.holdingForm = this.formBuilder.group({ - tags: [] as string[] + tags: new FormControl([]) }); - this.holdingForm - .get('tags') - .valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) + this.holdingForm.controls.tags.valueChanges + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((tags: Tag[]) => { const newTag = tags.find(({ id }) => { return id === undefined; @@ -243,6 +291,18 @@ export class GfHoldingDetailDialogComponent implements OnInit { .subscribe(({ accounts }) => { this.accounts = accounts; + this.tagsOfAccounts = uniqBy( + accounts.flatMap(({ tags }) => { + return tags ?? []; + }), + 'id' + ).map((tag) => { + return { + ...tag, + name: translate(tag.name) + }; + }); + this.changeDetectorRef.markForCheck(); }); @@ -257,6 +317,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { .subscribe( ({ activitiesCount, + assetProfile, averagePrice, dataProviderInfo, dateOfFirstActivity, @@ -268,20 +329,18 @@ export class GfHoldingDetailDialogComponent implements OnInit { marketPrice, marketPriceMax, marketPriceMin, - netPerformance, - netPerformancePercent, netPerformancePercentWithCurrencyEffect, netPerformanceWithCurrencyEffect, quantity, - SymbolProfile, tags, value }) => { this.activitiesCount = activitiesCount; + this.assetProfile = assetProfile; this.averagePrice = averagePrice; if ( - this.averagePrice >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES && + this.averagePrice >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES && this.data.deviceType === 'mobile' ) { this.averagePricePrecision = 0; @@ -290,13 +349,17 @@ export class GfHoldingDetailDialogComponent implements OnInit { this.benchmarkDataItems = []; this.countries = {}; this.dataProviderInfo = dataProviderInfo; - this.dateOfFirstActivity = dateOfFirstActivity; + + if (dateOfFirstActivity) { + this.dateOfFirstActivity = dateOfFirstActivity; + } + this.dividendInBaseCurrency = dividendInBaseCurrency; if ( this.data.deviceType === 'mobile' && this.dividendInBaseCurrency >= - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.dividendInBaseCurrencyPrecision = 0; } @@ -306,24 +369,21 @@ export class GfHoldingDetailDialogComponent implements OnInit { this.feeInBaseCurrency = feeInBaseCurrency; - this.hasPermissionToReadMarketDataOfOwnAssetProfile = - hasPermission( - this.user?.permissions, - permissions.readMarketDataOfOwnAssetProfile - ) && - SymbolProfile?.dataSource === 'MANUAL' && - SymbolProfile?.userId === this.user?.id; + this.hasPermissionToReadMarketDataOfOwnAssetProfile = hasPermission( + this.user?.permissions, + permissions.readMarketDataOfOwnAssetProfile + ); this.historicalDataItems = historicalData.map( ({ averagePrice, date, marketPrice }) => { this.benchmarkDataItems.push({ date, - value: averagePrice + value: isNumber(averagePrice) ? averagePrice : null }); return { date, - value: marketPrice + value: marketPrice ?? 0 }; } ); @@ -334,17 +394,21 @@ export class GfHoldingDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && this.investmentInBaseCurrencyWithCurrencyEffect >= - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.investmentInBaseCurrencyWithCurrencyEffectPrecision = 0; } + this.isOwnAssetProfile = + assetProfile?.dataSource === 'MANUAL' && + assetProfile?.userId === this.user?.id; + this.marketPrice = marketPrice; this.marketPriceMax = marketPriceMax; if ( this.data.deviceType === 'mobile' && - this.marketPriceMax >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + this.marketPriceMax >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.marketPriceMaxPrecision = 0; } @@ -353,29 +417,18 @@ export class GfHoldingDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && - this.marketPriceMin >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + this.marketPriceMin >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.marketPriceMinPrecision = 0; } if ( this.data.deviceType === 'mobile' && - this.marketPrice >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + this.marketPrice >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.marketPricePrecision = 0; } - this.netPerformance = netPerformance; - - if ( - this.data.deviceType === 'mobile' && - this.netPerformance >= NUMERICAL_PRECISION_THRESHOLD_5_FIGURES - ) { - this.netPerformancePrecision = 0; - } - - this.netPerformancePercent = netPerformancePercent; - this.netPerformancePercentWithCurrencyEffect = netPerformancePercentWithCurrencyEffect; @@ -393,7 +446,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { if ( this.data.deviceType === 'mobile' && this.netPerformanceWithCurrencyEffect >= - NUMERICAL_PRECISION_THRESHOLD_5_FIGURES + NUMERICAL_PRECISION_THRESHOLD_4_FIGURES ) { this.netPerformanceWithCurrencyEffectPrecision = 0; } @@ -402,7 +455,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { if (Number.isInteger(this.quantity)) { this.quantityPrecision = 0; - } else if (SymbolProfile?.assetSubClass === 'CRYPTOCURRENCY') { + } else if (assetProfile?.assetSubClass === 'CRYPTOCURRENCY') { if (this.quantity < 10) { this.quantityPrecision = 8; } else if (this.quantity < 1000) { @@ -412,9 +465,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { } } - this.reportDataGlitchMail = `mailto:hi@ghostfol.io?Subject=Ghostfolio Data Glitch Report&body=Hello%0D%0DI would like to report a data glitch for%0D%0DSymbol: ${SymbolProfile?.symbol}%0DData Source: ${SymbolProfile?.dataSource}%0D%0DAdditional notes:%0D%0DCan you please take a look?%0D%0DKind regards`; this.sectors = {}; - this.SymbolProfile = SymbolProfile; this.tags = tags.map((tag) => { return { @@ -427,28 +478,44 @@ export class GfHoldingDetailDialogComponent implements OnInit { this.value = value; - if (SymbolProfile?.assetClass) { - this.assetClass = translate(SymbolProfile?.assetClass); + const reportDataGlitchSubject = `Ghostfolio Data Glitch Report${ + this.assetProfile?.symbol ? ` (${this.assetProfile.symbol})` : '' + }`; + + this.reportDataGlitchMailHref = `mailto:hi@ghostfol.io?subject=${reportDataGlitchSubject}&body=${[ + 'Hello', + '', + 'I would like to report a data glitch for', + '', + `Symbol: ${this.assetProfile?.symbol}`, + `Data Source: ${this.assetProfile?.dataSource}`, + '', + 'Additional notes:', + '', + 'Can you please take a look?', + '', + 'Kind regards' + ].join(E_MAIL_LINE_BREAK)}`; + + if (this.assetProfile?.assetClass) { + this.assetClass = translate(this.assetProfile?.assetClass); } - if (SymbolProfile?.assetSubClass) { - this.assetSubClass = translate(SymbolProfile?.assetSubClass); + if (this.assetProfile?.assetSubClass) { + this.assetSubClass = translate(this.assetProfile?.assetSubClass); } - if (SymbolProfile?.countries?.length > 0) { - for (const country of SymbolProfile.countries) { + if (this.assetProfile?.countries?.length > 0) { + for (const country of this.assetProfile.countries) { this.countries[country.code] = { - name: getCountryName({ - code: country.code, - locale: this.data.locale - }), + name: getCountryName({ code: country.code }), value: country.weight }; } } - if (SymbolProfile?.sectors?.length > 0) { - for (const sector of SymbolProfile.sectors) { + if (this.assetProfile?.sectors?.length > 0) { + for (const sector of this.assetProfile.sectors) { this.sectors[sector.name] = { name: translate(sector.name), value: sector.weight @@ -456,16 +523,16 @@ export class GfHoldingDetailDialogComponent implements OnInit { } } - if (isToday(parseISO(this.dateOfFirstActivity))) { + if (isToday(this.dateOfFirstActivity)) { // Add average price this.historicalDataItems.push({ - date: this.dateOfFirstActivity, + date: this.dateOfFirstActivity.toISOString(), value: this.averagePrice }); // Add benchmark 1 this.benchmarkDataItems.push({ - date: this.dateOfFirstActivity, + date: this.dateOfFirstActivity.toISOString(), value: averagePrice }); @@ -496,7 +563,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { if ( this.benchmarkDataItems[0]?.value === undefined && - isSameMonth(parseISO(this.dateOfFirstActivity), new Date()) + isSameMonth(this.dateOfFirstActivity, new Date()) ) { this.benchmarkDataItems[0].value = this.averagePrice; } @@ -510,10 +577,15 @@ export class GfHoldingDetailDialogComponent implements OnInit { } ); - if (this.hasPermissionToReadMarketDataOfOwnAssetProfile) { + if ( + this.hasPermissionToReadMarketDataOfOwnAssetProfile && + this.isOwnAssetProfile + ) { this.fetchMarketData(); } + this.isLoading = false; + this.changeDetectorRef.markForCheck(); } ); @@ -524,56 +596,54 @@ export class GfHoldingDetailDialogComponent implements OnInit { if (state?.user) { this.user = state.user; + // A tag created during an impersonation belongs to the authenticated + // user, hence it cannot be assigned to the data of the impersonated + // user this.hasPermissionToCreateOwnTag = - hasPermission(this.user.permissions, permissions.createOwnTag) && - this.user?.settings?.isExperimentalFeatures; + !this.impersonationStorageService.getId() && + hasPermission(this.user?.permissions, permissions.createOwnTag); this.tagsAvailable = - this.user?.tags?.map((tag) => { - return { - ...tag, - name: translate(tag.name) - }; - }) ?? []; + this.user?.tags + ?.filter(({ id }) => { + // The "DRAFT" tag qualifies an individual activity and cannot + // be assigned to all activities of a holding + return id !== TAG_ID_DRAFT; + }) + .map((tag) => { + return { + ...tag, + name: translate(tag.name) + }; + }) ?? []; this.changeDetectorRef.markForCheck(); } }); } - public onChangePage(page: PageEvent) { + protected onChangePage(page: PageEvent) { this.pageIndex = page.pageIndex; this.fetchActivities(); } - public onCloneActivity(aActivity: Activity) { - this.router.navigate( - internalRoutes.portfolio.subRoutes.activities.routerLink, - { - queryParams: { activityId: aActivity.id, createDialog: true } - } - ); - + protected onClose() { this.dialogRef.close(); } - public onClose() { - this.dialogRef.close(); - } - - public onCloseHolding() { + protected onCloseHolding() { const today = new Date(); const activity: CreateOrderDto = { - accountId: this.accounts.length === 1 ? this.accounts[0].id : null, - comment: null, - currency: this.SymbolProfile.currency, - dataSource: this.SymbolProfile.dataSource, + accountId: this.accounts.length === 1 ? this.accounts[0].id : undefined, + comment: undefined, + currency: this.assetProfile?.currency ?? '', + dataSource: this.assetProfile?.dataSource, date: today.toISOString(), fee: 0, quantity: this.quantity, - symbol: this.SymbolProfile.symbol, + symbol: this.assetProfile?.symbol ?? '', tags: this.tags.map(({ id }) => { return id; }), @@ -585,15 +655,13 @@ export class GfHoldingDetailDialogComponent implements OnInit { .postActivity(activity) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { - this.router.navigate( - internalRoutes.portfolio.subRoutes.activities.routerLink - ); + this.userService.get(true).subscribe(); - this.dialogRef.close(); + this.navigateToActivities(); }); } - public onExport() { + protected onExport() { const activityIds = this.dataSource.data.map(({ id }) => { return id; }); @@ -604,7 +672,7 @@ export class GfHoldingDetailDialogComponent implements OnInit { .subscribe((data) => { downloadAsFile({ content: data, - fileName: `ghostfolio-export-${this.SymbolProfile?.symbol}-${format( + fileName: `ghostfolio-export-${this.assetProfile?.symbol}-${format( parseISO(data.meta.date), 'yyyyMMddHHmm' )}.json`, @@ -613,23 +681,12 @@ export class GfHoldingDetailDialogComponent implements OnInit { }); } - public onMarketDataChanged(withRefresh = false) { + protected onMarketDataChanged(withRefresh = false) { if (withRefresh) { this.fetchMarketData(); } } - public onUpdateActivity(aActivity: Activity) { - this.router.navigate( - internalRoutes.portfolio.subRoutes.activities.routerLink, - { - queryParams: { activityId: aActivity.id, editDialog: true } - } - ); - - this.dialogRef.close(); - } - private fetchActivities(filters: Filter[] = this.getActivityFilters()) { this.dataService .fetchActivities({ @@ -676,4 +733,12 @@ export class GfHoldingDetailDialogComponent implements OnInit { { id: this.data.symbol, type: 'SYMBOL' } ]; } + + private navigateToActivities() { + this.router.navigate( + internalRoutes.portfolio.subRoutes.activities.routerLink + ); + + this.dialogRef.close(); + } } diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html index 609eec3c08..ad9fb58f54 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html +++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html @@ -1,7 +1,7 @@ @@ -12,6 +12,7 @@ -
    Overview
    +
    Overview
    -
    -
    +
    +
    @if ( - SymbolProfile?.currency && - data.baseCurrency !== SymbolProfile?.currency + assetProfile?.currency && + data.baseCurrency !== assetProfile?.currency ) { Change with currency effect } @else { @@ -74,14 +77,15 @@ i18n size="medium" [colorizeSign]="true" + [isLoading]="isLoading" [isPercent]="true" [locale]="data.locale" [precision]="netPerformancePercentWithCurrencyEffectPrecision" [value]="netPerformancePercentWithCurrencyEffect" > @if ( - SymbolProfile?.currency && - data.baseCurrency !== SymbolProfile?.currency + assetProfile?.currency && + data.baseCurrency !== assetProfile?.currency ) { Performance with currency effect } @else { @@ -94,9 +98,10 @@ i18n size="medium" [isCurrency]="true" + [isLoading]="isLoading" [locale]="data.locale" [precision]="averagePricePrecision" - [unit]="SymbolProfile?.currency" + [unit]="assetProfile?.currency" [value]="averagePrice" >Average Unit Price @@ -106,9 +111,10 @@ i18n size="medium" [isCurrency]="true" + [isLoading]="isLoading" [locale]="data.locale" [precision]="marketPricePrecision" - [unit]="SymbolProfile?.currency" + [unit]="assetProfile?.currency" [value]="marketPrice" >Market Price @@ -118,13 +124,16 @@ i18n size="medium" [class.text-danger]=" - marketPriceMin?.toFixed(2) === marketPrice?.toFixed(2) && - marketPriceMax?.toFixed(2) !== marketPriceMin?.toFixed(2) + round(marketPriceMin, marketPriceMinPrecision) === + round(marketPrice, marketPricePrecision) && + round(marketPriceMax, marketPriceMaxPrecision) !== + round(marketPriceMin, marketPriceMinPrecision) " [isCurrency]="true" + [isLoading]="isLoading" [locale]="data.locale" [precision]="marketPriceMinPrecision" - [unit]="SymbolProfile?.currency" + [unit]="assetProfile?.currency" [value]="marketPriceMin" >Minimum Price @@ -134,13 +143,16 @@ i18n size="medium" [class.text-success]=" - marketPriceMax?.toFixed(2) === marketPrice?.toFixed(2) && - marketPriceMax?.toFixed(2) !== marketPriceMin?.toFixed(2) + round(marketPriceMax, marketPriceMaxPrecision) === + round(marketPrice, marketPricePrecision) && + round(marketPriceMax, marketPriceMaxPrecision) !== + round(marketPriceMin, marketPriceMinPrecision) " [isCurrency]="true" + [isLoading]="isLoading" [locale]="data.locale" [precision]="marketPriceMaxPrecision" - [unit]="SymbolProfile?.currency" + [unit]="assetProfile?.currency" [value]="marketPriceMax" >Maximum Price @@ -149,6 +161,7 @@ InvestmentInvested Capital
    - @if ( - dividendInBaseCurrency && user?.settings?.isExperimentalFeatures - ) { + @if (dividendInBaseCurrency) {
    First Activity @@ -250,23 +267,23 @@ >
    @if ( - SymbolProfile?.countries?.length > 0 || - SymbolProfile?.sectors?.length > 0 + assetProfile?.countries?.length > 0 || + assetProfile?.sectors?.length > 0 ) { @if ( - SymbolProfile?.countries?.length === 1 && - SymbolProfile?.sectors?.length === 1 + assetProfile?.countries?.length === 1 && + assetProfile?.sectors?.length === 1 ) {
    Sector
    - @if (SymbolProfile?.countries?.length === 1) { + @if (assetProfile?.countries?.length === 1) {
    CountrySymbol
    @@ -323,13 +339,24 @@ ISIN
    +
    + + + +
    - @if (dataProviderInfo) { + @if (dataProviderInfo?.name) {

    -
    Activities
    +
    Activities
    @@ -380,7 +405,7 @@ -
    Accounts
    +
    Accounts
    - @if ( - hasPermissionToReadMarketDataOfOwnAssetProfile && - user?.settings?.isExperimentalFeatures - ) { - + @if (isOwnAssetProfile && user?.settings?.isExperimentalFeatures) { + -
    Market Data
    +
    Market Data
    + @if (user?.subscription?.type === 'Basic') { + + }
    } -
    - - - @if ( data.hasPermissionToAccessAdminControl || (dataSource?.data.length > 0 && @@ -442,7 +458,7 @@ mat-stroked-button (click)="onCloseHolding()" > - Close Holding @@ -452,8 +468,11 @@ dataSource?.data.length > 0 && data.hasPermissionToReportDataGlitch === true ) { -
    Report Data Glitch... @@ -461,14 +480,14 @@ @if (data.hasPermissionToAccessAdminControl) { Manage Asset Profile... diff --git a/apps/client/src/app/components/holding-detail-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/holding-detail-dialog/interfaces/interfaces.ts index 527b13636f..a03fd93992 100644 --- a/apps/client/src/app/components/holding-detail-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/holding-detail-dialog/interfaces/interfaces.ts @@ -1,17 +1,20 @@ import { ColorScheme } from '@ghostfolio/common/types'; - -import { DataSource } from '@prisma/client'; +import { DataSource } from '@ghostfolio/prisma/enums'; export interface HoldingDetailDialogParams { baseCurrency: string; - colorScheme: ColorScheme; + colorScheme?: ColorScheme; dataSource: DataSource; deviceType: string; - hasImpersonationId: boolean; hasPermissionToAccessAdminControl: boolean; hasPermissionToCreateActivity: boolean; hasPermissionToReportDataGlitch: boolean; hasPermissionToUpdateActivity: boolean; + impersonationId: string | null; locale: string; symbol: string; } + +export interface HoldingDetailDialogResult { + isNavigating?: boolean; +} 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 661e21163a..333a24d5d6 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 @@ -1,46 +1,52 @@ -import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { + DEFAULT_CURRENCY, + DEFAULT_DATE_RANGE, + DEFAULT_LOCALE +} from '@ghostfolio/common/config'; import { AssetProfileIdentifier, PortfolioPosition, - ToggleOption, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; -import { HoldingType, HoldingsViewMode } from '@ghostfolio/common/types'; +import { hasScope, scopes } from '@ghostfolio/common/scopes'; +import { + HoldingType, + HoldingsViewMode, + ToggleOption +} from '@ghostfolio/common/types'; import { GfHoldingsTableComponent } from '@ghostfolio/ui/holdings-table'; import { DataService } from '@ghostfolio/ui/services'; import { GfToggleComponent } from '@ghostfolio/ui/toggle'; import { GfTreemapChartComponent } from '@ghostfolio/ui/treemap-chart'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, + computed, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, - OnInit + inject, + OnInit, + signal } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; -import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { Router, RouterModule } from '@angular/router'; -import { IonIcon } from '@ionic/angular/standalone'; import { addIcons } from 'ionicons'; import { gridOutline, reorderFourOutline } from 'ionicons/icons'; import { DeviceDetectorService } from 'ngx-device-detector'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [ - FormsModule, GfHoldingsTableComponent, GfToggleComponent, GfTreemapChartComponent, - IonIcon, MatButtonModule, - MatButtonToggleModule, - ReactiveFormsModule, RouterModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -51,95 +57,118 @@ import { DeviceDetectorService } from 'ngx-device-detector'; export class GfHomeHoldingsComponent implements OnInit { public static DEFAULT_HOLDINGS_VIEW_MODE: HoldingsViewMode = 'TABLE'; - public deviceType: string; - public hasImpersonationId: boolean; - public hasPermissionToAccessHoldingsChart: boolean; - public hasPermissionToCreateActivity: boolean; - public holdings: PortfolioPosition[]; - public holdingType: HoldingType = 'ACTIVE'; - public holdingTypeOptions: ToggleOption[] = [ + protected readonly baseCurrency = computed(() => { + return this.user()?.settings?.baseCurrency ?? DEFAULT_CURRENCY; + }); + + protected readonly colorScheme = computed(() => { + return this.user()?.settings?.colorScheme; + }); + + protected readonly dateRange = computed(() => { + return this.user()?.settings?.dateRange ?? DEFAULT_DATE_RANGE; + }); + + protected readonly deviceType = computed(() => { + return this.deviceDetectorService.deviceInfo().deviceType; + }); + + protected hasPermissionToAccessHoldingsChart: boolean; + protected hasPermissionToCreateActivity: boolean; + protected holdings: PortfolioPosition[] | undefined; + protected holdingsViewMode: HoldingsViewMode = + GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE; + protected readonly holdingsViewModeOptions: ToggleOption[] = + [ + { + iconName: 'reorder-four-outline', + title: $localize`Table`, + value: 'TABLE' + }, + { + iconName: 'grid-outline', + title: $localize`Chart`, + value: 'CHART' + } + ]; + protected holdingType: HoldingType = 'ACTIVE'; + protected readonly holdingTypeOptions: ToggleOption[] = [ { label: $localize`Active`, value: 'ACTIVE' }, { label: $localize`Closed`, value: 'CLOSED' } ]; - public routerLinkPortfolioActivities = + protected isHoldingsViewModeToggleDisabled = true; + + protected readonly locale = computed(() => { + return this.user()?.settings?.locale ?? DEFAULT_LOCALE; + }); + + protected readonly routerLinkPortfolioActivities = internalRoutes.portfolio.subRoutes.activities.routerLink; - public user: User; - public viewModeFormControl = new FormControl( - GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE - ); - - public constructor( - private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService, - private destroyRef: DestroyRef, - private deviceDetectorService: DeviceDetectorService, - private impersonationStorageService: ImpersonationStorageService, - private router: Router, - private userService: UserService - ) { + protected readonly user = signal(null); + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public constructor() { addIcons({ gridOutline, reorderFourOutline }); } public ngOnInit() { - this.deviceType = this.deviceDetectorService.getDeviceInfo().deviceType; - - this.impersonationStorageService - .onChangeHasImpersonation() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((impersonationId) => { - this.hasImpersonationId = !!impersonationId; - }); - this.userService.stateChanged .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((state) => { if (state?.user) { - this.user = state.user; + const user = state.user; + + this.user.set(user); this.hasPermissionToAccessHoldingsChart = hasPermission( - this.user.permissions, + user.permissions, permissions.accessHoldingsChart ); - this.hasPermissionToCreateActivity = hasPermission( - this.user.permissions, - permissions.createActivity - ); + this.hasPermissionToCreateActivity = + hasPermission(user.permissions, permissions.createActivity) && + hasScope(user.scopes, scopes.activityCreate); this.initialize(); - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); + } + + protected onChangeHoldingsViewMode(aHoldingsViewMode: HoldingsViewMode) { + this.holdingsViewMode = aHoldingsViewMode; - this.viewModeFormControl.valueChanges + this.dataService + .putUserSetting({ holdingsViewMode: aHoldingsViewMode }) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((holdingsViewMode) => { - this.dataService - .putUserSetting({ holdingsViewMode }) + .subscribe(() => { + this.userService + .get(true) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - this.userService - .get(true) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((user) => { - this.user = user; - - this.changeDetectorRef.markForCheck(); - }); + .subscribe((user) => { + this.user.set(user); + + this.changeDetectorRef.markForCheck(); }); }); } - public onChangeHoldingType(aHoldingType: HoldingType) { + protected onChangeHoldingType(aHoldingType: HoldingType) { this.holdingType = aHoldingType; this.initialize(); } - public onHoldingClicked({ dataSource, symbol }: AssetProfileIdentifier) { + protected onHoldingClicked({ dataSource, symbol }: AssetProfileIdentifier) { if (dataSource && symbol) { - this.router.navigate([], { + void this.router.navigate([], { queryParams: { dataSource, symbol, holdingDetailDialog: true } }); } @@ -148,37 +177,31 @@ export class GfHomeHoldingsComponent implements OnInit { private fetchHoldings() { const filters = this.userService.getFilters(); - if (this.holdingType === 'CLOSED') { - filters.push({ id: 'CLOSED', type: 'HOLDING_TYPE' }); - } + filters.push({ id: this.holdingType, type: 'HOLDING_TYPE' }); return this.dataService.fetchPortfolioHoldings({ filters, - range: this.user?.settings?.dateRange + range: this.user()?.settings?.dateRange }); } private initialize() { - this.viewModeFormControl.disable({ emitEvent: false }); + this.isHoldingsViewModeToggleDisabled = true; if ( this.hasPermissionToAccessHoldingsChart && this.holdingType === 'ACTIVE' ) { - this.viewModeFormControl.enable({ emitEvent: false }); + this.isHoldingsViewModeToggleDisabled = false; - this.viewModeFormControl.setValue( - this.deviceType === 'mobile' + this.holdingsViewMode = + this.deviceType() === 'mobile' ? GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE - : this.user?.settings?.holdingsViewMode || - GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE, - { emitEvent: false } - ); - } else if (this.holdingType === 'CLOSED') { - this.viewModeFormControl.setValue( - GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE, - { emitEvent: false } - ); + : (this.user()?.settings?.holdingsViewMode ?? + GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE); + } else { + this.holdingsViewMode = + GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE; } this.holdings = undefined; 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 c44df40b3b..7c533b2835 100644 --- a/apps/client/src/app/components/home-holdings/home-holdings.html +++ b/apps/client/src/app/components/home-holdings/home-holdings.html @@ -7,54 +7,41 @@
    -
    -
    - - - - - - - - -
    -
    +
    - @if (viewModeFormControl.value === 'CHART') { + @if (holdingsViewMode === 'CHART') { } -
    +
    - @if ( - !hasImpersonationId && - hasPermissionToCreateActivity && - holdings?.length > 0 - ) { + @if (hasPermissionToCreateActivity && (holdings?.length ?? 0) > 0) {
    ([]); - protected readonly deviceType = computed( - () => this.deviceDetectorService.deviceInfo().deviceType - ); - protected readonly fearAndGreedIndex = signal(undefined); - protected readonly fearLabel = $localize`Fear`; - protected readonly greedLabel = $localize`Greed`; - protected hasPermissionToAccessFearAndGreedIndex: boolean; - protected readonly historicalDataItems = signal([]); - protected readonly numberOfDays = 365; - protected user: User; - - private readonly info: InfoItem; - - private readonly changeDetectorRef = inject(ChangeDetectorRef); - private readonly dataService = inject(DataService); - private readonly destroyRef = inject(DestroyRef); - private readonly deviceDetectorService = inject(DeviceDetectorService); - private readonly userService = inject(UserService); - - public constructor() { - this.info = this.dataService.fetchInfo(); - - this.userService.stateChanged - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((state) => { - if (state?.user) { - this.user = state.user; - - this.changeDetectorRef.markForCheck(); - } - }); - } - - public ngOnInit() { - this.hasPermissionToAccessFearAndGreedIndex = hasPermission( - this.info?.globalPermissions, - permissions.enableFearAndGreedIndex - ); - - if ( - this.hasPermissionToAccessFearAndGreedIndex && - this.info.fearAndGreedDataSource - ) { - this.dataService - .fetchSymbolItem({ - dataSource: this.info.fearAndGreedDataSource, - includeHistoricalData: this.numberOfDays, - symbol: ghostfolioFearAndGreedIndexSymbol - }) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ historicalData, marketPrice }) => { - this.fearAndGreedIndex.set(marketPrice); - this.historicalDataItems.set([ - ...historicalData, - { - date: resetHours(new Date()).toISOString(), - value: marketPrice - } - ]); - }); - } - - this.dataService - .fetchBenchmarks() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ benchmarks }) => { - this.benchmarks.set(benchmarks); - }); - } -} diff --git a/apps/client/src/app/components/home-market/home-market.html b/apps/client/src/app/components/home-market/home-market.html deleted file mode 100644 index a782526eee..0000000000 --- a/apps/client/src/app/components/home-market/home-market.html +++ /dev/null @@ -1,52 +0,0 @@ -
    -

    Markets

    - @if (hasPermissionToAccessFearAndGreedIndex) { -
    -
    -
    - Last {{ numberOfDays }} Days -
    - - -
    -
    - } - -
    -
    - - @if (benchmarks()?.length > 0) { -
    - - Calculations are based on delayed market data and may not be - displayed in real-time. -
    - } -
    -
    -
    diff --git a/apps/client/src/app/components/home-market/home-market.scss b/apps/client/src/app/components/home-market/home-market.scss deleted file mode 100644 index 5b523160d5..0000000000 --- a/apps/client/src/app/components/home-market/home-market.scss +++ /dev/null @@ -1,7 +0,0 @@ -:host { - display: block; - - gf-line-chart { - aspect-ratio: 16 / 9; - } -} 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 ad35565369..5e6601886c 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 @@ -5,16 +5,21 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; import { DEFAULT_CURRENCY, DEFAULT_DATE_RANGE, + DEFAULT_LOCALE, NUMERICAL_PRECISION_THRESHOLD_6_FIGURES } from '@ghostfolio/common/config'; +import { isCashPosition } from '@ghostfolio/common/helper'; import { AssetProfileIdentifier, LineChartItem, PortfolioPerformance, + PortfolioPosition, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { hasScope, scopes } from '@ghostfolio/common/scopes'; +import { GfHoldingsTableComponent } from '@ghostfolio/ui/holdings-table'; import { GfLineChartComponent } from '@ghostfolio/ui/line-chart'; import { DataService } from '@ghostfolio/ui/services'; @@ -29,15 +34,22 @@ import { } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; -import { RouterModule } from '@angular/router'; +import { MatCardModule } from '@angular/material/card'; +import { Router, RouterModule } from '@angular/router'; +import { IonIcon } from '@ionic/angular/standalone'; +import { addIcons } from 'ionicons'; +import { arrowForwardOutline } from 'ionicons/icons'; import { DeviceDetectorService } from 'ngx-device-detector'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, imports: [ + GfHoldingsTableComponent, GfLineChartComponent, GfPortfolioPerformanceComponent, + IonIcon, MatButtonModule, + MatCardModule, RouterModule ], selector: 'gf-home-overview', @@ -48,37 +60,69 @@ export class GfHomeOverviewComponent implements OnInit { protected readonly errors = signal([]); protected readonly hasImpersonationId = signal(false); protected readonly historicalDataItems = signal(null); + protected readonly holdings = signal( + undefined + ); protected readonly isLoadingPerformance = signal(true); + + protected readonly locale = computed(() => { + return this.user()?.settings?.locale ?? DEFAULT_LOCALE; + }); + protected readonly performance = signal(null); protected readonly performanceLabel = $localize`Performance`; protected readonly precision = signal(2); protected readonly user = signal(null); protected readonly routerLinkAccounts = internalRoutes.accounts.routerLink; + + protected readonly routerLinkHomeHoldings = + internalRoutes.home.subRoutes.holdings.routerLink; + protected readonly routerLinkPortfolio = internalRoutes.portfolio.routerLink; + protected readonly routerLinkPortfolioActivities = internalRoutes.portfolio.subRoutes.activities.routerLink; + protected readonly routerLinkPortfolioActivitiesCreate = + internalRoutes.portfolio.subRoutes.activities.subRoutes.create.routerLink; + protected readonly deviceType = computed( () => this.deviceDetectorService.deviceInfo().deviceType ); protected readonly hasPermissionToCreateActivity = computed(() => { - return hasPermission(this.user()?.permissions, permissions.createActivity); + return ( + hasPermission(this.user()?.permissions, permissions.createActivity) && + hasScope(this.user()?.scopes, scopes.activityCreate) + ); }); protected readonly showDetails = computed(() => { const user = this.user(); return user - ? !user.settings.isRestrictedView && user.settings.viewMode !== 'ZEN' + ? !user?.settings?.isRestrictedView && user?.settings?.viewMode !== 'ZEN' : false; }); + protected readonly showExperimentalHoldings = computed(() => { + const user = this.user(); + + return ( + user?.settings?.isExperimentalFeatures === true && + user?.settings?.viewMode !== 'ZEN' + ); + }); + protected readonly unit = computed(() => { - return this.showDetails() - ? (this.user()?.settings?.baseCurrency ?? DEFAULT_CURRENCY) - : '%'; + if (!this.showDetails()) { + return '%'; + } + + return this.deviceType() === 'mobile' + ? undefined + : (this.user()?.settings?.baseCurrency ?? DEFAULT_CURRENCY); }); private readonly dataService = inject(DataService); @@ -88,6 +132,7 @@ export class GfHomeOverviewComponent implements OnInit { ImpersonationStorageService ); private readonly layoutService = inject(LayoutService); + private readonly router = inject(Router); private readonly userService = inject(UserService); public constructor() { @@ -99,6 +144,8 @@ export class GfHomeOverviewComponent implements OnInit { this.update(); } }); + + addIcons({ arrowForwardOutline }); } public ngOnInit() { @@ -116,13 +163,47 @@ export class GfHomeOverviewComponent implements OnInit { }); } + protected onHoldingClicked({ dataSource, symbol }: AssetProfileIdentifier) { + if (dataSource && symbol) { + void this.router.navigate([], { + queryParams: { dataSource, symbol, holdingDetailDialog: true } + }); + } + } + private update() { + const userSettings = this.user()?.settings; + this.historicalDataItems.set(null); this.isLoadingPerformance.set(true); + if (this.showExperimentalHoldings()) { + this.holdings.set(undefined); + + this.dataService + .fetchPortfolioHoldings({ + filters: [{ id: 'ACTIVE', type: 'HOLDING_TYPE' }], + range: userSettings?.dateRange + }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(({ holdings }) => { + const baseCurrency = userSettings?.baseCurrency ?? DEFAULT_CURRENCY; + + this.holdings.set( + holdings.filter(({ assetProfile }) => { + return !( + isCashPosition(assetProfile) && + assetProfile.currency === baseCurrency && + assetProfile.symbol === baseCurrency + ); + }) + ); + }); + } + this.dataService .fetchPortfolioPerformance({ - range: this.user()?.settings?.dateRange ?? DEFAULT_DATE_RANGE + range: userSettings?.dateRange ?? DEFAULT_DATE_RANGE }) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(({ chart, errors, performance }) => { 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 8361c5b889..0f9e1bcfae 100644 --- a/apps/client/src/app/components/home-overview/home-overview.html +++ b/apps/client/src/app/components/home-overview/home-overview.html @@ -1,5 +1,5 @@
    } @else { -
    -
    +
    +
    +
    + +
    -
    -
    -
    - -
    + @if (showExperimentalHoldings()) { +
    + + + Holdings + + + + + + + + +
    + }
    }
    diff --git a/apps/client/src/app/components/home-overview/home-overview.scss b/apps/client/src/app/components/home-overview/home-overview.scss index 3a692b28d6..b074bc6261 100644 --- a/apps/client/src/app/components/home-overview/home-overview.scss +++ b/apps/client/src/app/components/home-overview/home-overview.scss @@ -30,6 +30,33 @@ } } + mat-card { + &.holdings { + --mat-card-title-text-size: var(--mat-sys-title-medium-size); + + mat-card-header { + a[mat-icon-button] { + --mat-icon-button-icon-size: 1rem; + + margin-right: -0.125rem; + margin-top: -0.5rem; + } + + mat-card-title { + padding-left: 0.1875rem; + } + } + + mat-card-content { + scrollbar-width: none; + + &::-webkit-scrollbar { + display: none; + } + } + } + } + .introduction { max-width: 50rem; } diff --git a/apps/client/src/app/components/home-summary/home-summary.html b/apps/client/src/app/components/home-summary/home-summary.html index a6da72b03e..d17fc97c73 100644 --- a/apps/client/src/app/components/home-summary/home-summary.html +++ b/apps/client/src/app/components/home-summary/home-summary.html @@ -1,7 +1,7 @@

    Summary

    -
    +
    { - this.hasImpersonationId = !!impersonationId; - }); - - this.route.queryParams + this.homeWatchlistService.refresh$ .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((params) => { - if (params['createWatchlistItemDialog']) { - this.openCreateWatchlistItemDialog(); - } + .subscribe(() => { + this.loadWatchlistData(); }); this.userService.stateChanged @@ -89,17 +77,15 @@ export class GfHomeWatchlistComponent implements OnInit { this.user = state.user; this.hasPermissionToCreateWatchlistItem = - !this.hasImpersonationId && hasPermission( this.user.permissions, permissions.createWatchlistItem - ); + ) && hasScope(this.user.scopes, scopes.watchlistCreate); this.hasPermissionToDeleteWatchlistItem = - !this.hasImpersonationId && hasPermission( this.user.permissions, permissions.deleteWatchlistItem - ); + ) && hasScope(this.user.scopes, scopes.watchlistDelete); this.changeDetectorRef.markForCheck(); } @@ -128,47 +114,17 @@ export class GfHomeWatchlistComponent implements OnInit { this.dataService .fetchWatchlist() .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ watchlist }) => { - this.watchlist = watchlist; - - this.changeDetectorRef.markForCheck(); - }); - } - - private openCreateWatchlistItemDialog() { - this.userService - .get() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((user) => { - this.user = user; - - const dialogRef = this.dialog.open< - GfCreateWatchlistItemDialogComponent, - CreateWatchlistItemDialogParams - >(GfCreateWatchlistItemDialogComponent, { - autoFocus: false, - data: { - deviceType: this.deviceType(), - locale: this.user?.settings?.locale ?? defaultLocale - }, - width: this.deviceType() === 'mobile' ? '100vw' : '50rem' - }); + .subscribe({ + error: () => { + this.watchlist = []; - dialogRef - .afterClosed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ dataSource, symbol } = {}) => { - if (dataSource && symbol) { - this.dataService - .postWatchlistItem({ dataSource, symbol }) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe({ - next: () => this.loadWatchlistData() - }); - } + this.changeDetectorRef.markForCheck(); + }, + next: ({ watchlist }) => { + this.watchlist = watchlist ?? []; - this.router.navigate(['.'], { relativeTo: this.route }); - }); + this.changeDetectorRef.markForCheck(); + } }); } } diff --git a/apps/client/src/app/components/home-watchlist/home-watchlist.html b/apps/client/src/app/components/home-watchlist/home-watchlist.html index e2865b9cfd..1bc93986af 100644 --- a/apps/client/src/app/components/home-watchlist/home-watchlist.html +++ b/apps/client/src/app/components/home-watchlist/home-watchlist.html @@ -3,17 +3,17 @@ Watchlist @if (user?.subscription?.type === 'Basic') { - + }
    -
    +
    -@if (!hasImpersonationId && hasPermissionToCreateWatchlistItem) { - +@if (hasPermissionToCreateWatchlistItem) { + } + + diff --git a/apps/client/src/app/components/home-watchlist/home-watchlist.service.ts b/apps/client/src/app/components/home-watchlist/home-watchlist.service.ts new file mode 100644 index 0000000000..47eafe6059 --- /dev/null +++ b/apps/client/src/app/components/home-watchlist/home-watchlist.service.ts @@ -0,0 +1,15 @@ +import { Service } from '@angular/core'; +import { Subject } from 'rxjs'; + +@Service({ autoProvided: false }) +export class HomeWatchlistService { + private readonly refreshSubject = new Subject(); + + public get refresh$() { + return this.refreshSubject.asObservable(); + } + + public triggerRefresh() { + this.refreshSubject.next(); + } +} diff --git a/apps/client/src/app/components/home-watchlist/watchlist-dialog-host/watchlist-dialog-host.component.ts b/apps/client/src/app/components/home-watchlist/watchlist-dialog-host/watchlist-dialog-host.component.ts new file mode 100644 index 0000000000..9e1887e278 --- /dev/null +++ b/apps/client/src/app/components/home-watchlist/watchlist-dialog-host/watchlist-dialog-host.component.ts @@ -0,0 +1,114 @@ +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { DEFAULT_LOCALE } from '@ghostfolio/common/config'; +import { User } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { hasScope, scopes } from '@ghostfolio/common/scopes'; +import { DataService } from '@ghostfolio/ui/services'; + +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + inject, + OnDestroy, + OnInit +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { Router } from '@angular/router'; +import { DeviceDetectorService } from 'ngx-device-detector'; + +import { GfCreateWatchlistItemDialogComponent } from '../create-watchlist-item-dialog/create-watchlist-item-dialog.component'; +import { CreateWatchlistItemDialogParams } from '../create-watchlist-item-dialog/interfaces/interfaces'; +import { HomeWatchlistService } from '../home-watchlist.service'; + +@Component({ + changeDetection: ChangeDetectionStrategy.OnPush, + selector: 'gf-watchlist-dialog-host', + template: '' +}) +export class GfWatchlistDialogHostComponent implements OnDestroy, OnInit { + private dialogRef: MatDialogRef; + + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly dialog = inject(MatDialog); + private readonly homeWatchlistService = inject(HomeWatchlistService); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public ngOnInit() { + this.userService + .get() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((user) => { + if ( + !hasPermission(user?.permissions, permissions.createWatchlistItem) || + !hasScope(user?.scopes, scopes.watchlistCreate) + ) { + this.navigateBack(); + + return; + } + + this.openDialog(user); + }); + } + + public ngOnDestroy() { + // The dialog lives in an overlay outside of this component, so it needs to + // be closed explicitly when leaving the route (for example via the browser + // navigation) + this.dialogRef?.close(); + } + + private navigateBack() { + void this.router.navigate( + internalRoutes.home.subRoutes.watchlist.routerLink + ); + } + + private openDialog(user: User) { + const deviceType = this.deviceDetectorService.getDeviceInfo().deviceType; + + const dialogRef = this.dialog.open< + GfCreateWatchlistItemDialogComponent, + CreateWatchlistItemDialogParams + >(GfCreateWatchlistItemDialogComponent, { + data: { + deviceType, + locale: user?.settings?.locale ?? DEFAULT_LOCALE + }, + width: deviceType === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(({ dataSource, symbol } = {}) => { + if (!dataSource || !symbol) { + this.navigateBack(); + + return; + } + + this.dataService + .postWatchlistItem({ dataSource, symbol }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe({ + error: () => { + this.navigateBack(); + }, + next: () => { + this.homeWatchlistService.triggerRefresh(); + + this.navigateBack(); + } + }); + }); + } +} diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html index 4f4bb18678..48405cbe3c 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html @@ -30,7 +30,7 @@ @if ( data.hasPermissionToUseAuthGoogle && data.hasPermissionToUseAuthToken ) { -
    or
    +
    or
    } @if (data.hasPermissionToUseAuthGoogle) { @@ -40,7 +40,8 @@ href="../api/v1/auth/google" mat-stroked-button >Sign in with Google(undefined); + + protected readonly deviceType = computed( + () => this.deviceDetectorService.deviceInfo().deviceType + ); + + protected readonly fearAndGreedIndexModeOptions: ToggleOption[] = + [ + { label: $localize`Stocks`, value: 'STOCKS' }, + { label: $localize`Cryptocurrencies`, value: 'CRYPTOCURRENCIES' } + ]; + + protected readonly fearLabel = $localize`Fear`; + protected readonly greedLabel = $localize`Greed`; + protected readonly numberOfDays = 365; + + protected fearAndGreedIndex: number | undefined; + protected fearAndGreedIndexMode: FearAndGreedIndexMode = 'STOCKS'; + protected hasPermissionToAccessFearAndGreedIndex: boolean; + protected hasPermissionToOpenBenchmarkDetails = false; + protected hasPermissionToReadMarketDataOfMarkets: boolean; + protected historicalDataItems: LineChartItem[]; + protected isLoadingFearAndGreedIndex = true; + protected user: User; + + private fearAndGreedIndexData: MarketDataOfMarketsResponse['fearAndGreedIndex']; + + private readonly info: InfoItem; + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly userService = inject(UserService); + + public constructor() { + this.info = this.dataService.fetchInfo(); + + this.hasPermissionToAccessFearAndGreedIndex = hasPermission( + this.info?.globalPermissions, + permissions.enableFearAndGreedIndex + ); + + if (this.hasPermissionToAccessFearAndGreedIndex) { + this.fearAndGreedIndex = this.info.fearAndGreedStocksMarketPrice; + } this.userService.stateChanged .pipe(takeUntilDestroyed(this.destroyRef)) @@ -69,6 +100,22 @@ export class GfMarketsComponent implements OnInit { if (state?.user) { this.user = state.user; + this.hasPermissionToOpenBenchmarkDetails = true; + + this.hasPermissionToReadMarketDataOfMarkets = hasPermission( + this.user.permissions, + permissions.readMarketDataOfMarkets + ); + + if ( + this.hasPermissionToReadMarketDataOfMarkets && + !this.fearAndGreedIndexData + ) { + this.fetchMarketDataOfMarkets(); + } else { + this.isLoadingFearAndGreedIndex = false; + } + this.changeDetectorRef.markForCheck(); } }); @@ -76,45 +123,59 @@ export class GfMarketsComponent implements OnInit { public ngOnInit() { this.dataService - .fetchMarketDataOfMarkets({ includeHistoricalData: this.numberOfDays }) + .fetchBenchmarks() .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ fearAndGreedIndex }) => { - this.fearAndGreedIndexData = fearAndGreedIndex; + .subscribe({ + error: () => { + this.benchmarks.set([]); + }, + next: ({ benchmarks }) => { + this.benchmarks.set(benchmarks ?? []); + } + }); + } - this.initialize(); + protected onChangeFearAndGreedIndexMode( + aFearAndGreedIndexMode: FearAndGreedIndexMode + ) { + this.fearAndGreedIndexMode = aFearAndGreedIndexMode; - this.changeDetectorRef.markForCheck(); - }); + this.initializeFearAndGreedIndex(); + } + private fetchMarketDataOfMarkets() { this.dataService - .fetchBenchmarks() + .fetchMarketDataOfMarkets({ includeHistoricalData: this.numberOfDays }) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(({ benchmarks }) => { - this.benchmarks = benchmarks; + .subscribe(({ fearAndGreedIndex }) => { + this.fearAndGreedIndexData = fearAndGreedIndex; + + this.initializeFearAndGreedIndex(); + + this.isLoadingFearAndGreedIndex = false; this.changeDetectorRef.markForCheck(); }); } - public initialize() { + private initializeFearAndGreedIndex() { this.fearAndGreedIndex = this.fearAndGreedIndexData[this.fearAndGreedIndexMode]?.marketPrice; - this.historicalDataItems = [ - ...(this.fearAndGreedIndexData[this.fearAndGreedIndexMode] - ?.historicalData ?? []), - { + const historicalDataItems = ( + this.fearAndGreedIndexData[this.fearAndGreedIndexMode]?.historicalData ?? + [] + ).filter((item): item is LineChartItem => { + return isNumber(item.value); + }); + + if (isNumber(this.fearAndGreedIndex)) { + historicalDataItems.push({ date: resetHours(new Date()).toISOString(), value: this.fearAndGreedIndex - } - ]; - } - - public onChangeFearAndGreedIndexMode( - aFearAndGreedIndexMode: FearAndGreedIndexMode - ) { - this.fearAndGreedIndexMode = aFearAndGreedIndexMode; + }); + } - this.initialize(); + this.historicalDataItems = historicalDataItems; } } diff --git a/apps/client/src/app/components/markets/markets.html b/apps/client/src/app/components/markets/markets.html index 38234a7850..eafb3224f2 100644 --- a/apps/client/src/app/components/markets/markets.html +++ b/apps/client/src/app/components/markets/markets.html @@ -1,54 +1,65 @@

    Markets

    -
    -
    - @if (user?.settings?.isExperimentalFeatures) { -
    - +
    + @if (hasPermissionToReadMarketDataOfMarkets) { + @if (user?.settings?.isExperimentalFeatures) { +
    + +
    + } +
    + Last {{ numberOfDays }} Days +
    + -
    - } -
    - Last {{ numberOfDays }} Days + } +
    - -
    -
    + }
    -
    +
    - @if (benchmarks?.length > 0) { + @if (benchmarks()?.length) {
    Calculations are based on delayed market data and may not be diff --git a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html index e8bcfea0e4..c458080e3c 100644 --- a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html +++ b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html @@ -1,8 +1,9 @@
    -
    -
    - @if (errors?.length > 0 && !isLoading) { +
    +
    + @if ((errors()?.length ?? 0) > 0 && !isLoading()) { }
    - @if (isLoading) { + @if (isLoading()) {
    }
    - {{ unit }} + {{ unit() }}
    - @if (showDetails) { -
    + @if (showDetails()) { +
    diff --git a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.scss b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.scss index 6f703255f8..35c8af5d7c 100644 --- a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.scss +++ b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.scss @@ -4,15 +4,10 @@ .currency-container, .status-container { flex: 1; - min-width: 2.5rem; } .status-container { font-size: 1.33rem; - - ion-icon { - pointer-events: all; - } } .value-container { diff --git a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts index 56e75ec1e3..04929e03a6 100644 --- a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts +++ b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts @@ -13,16 +13,17 @@ import { GfValueComponent } from '@ghostfolio/ui/value'; import { ChangeDetectionStrategy, Component, + effect, ElementRef, - Input, - OnChanges, - ViewChild + inject, + input, + viewChild } from '@angular/core'; import { IonIcon } from '@ionic/angular/standalone'; import { CountUp } from 'countup.js'; import { addIcons } from 'ionicons'; import { timeOutline } from 'ionicons/icons'; -import { isNumber } from 'lodash'; +import { isNumber } from 'lodash-es'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @Component({ @@ -32,58 +33,70 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; styleUrls: ['./portfolio-performance.component.scss'], templateUrl: './portfolio-performance.component.html' }) -export class GfPortfolioPerformanceComponent implements OnChanges { - @Input() deviceType: string; - @Input() errors: ResponseError['errors']; - @Input() isLoading: boolean; - @Input() locale = getLocale(); - @Input() performance: PortfolioPerformance; - @Input() precision: number; - @Input() showDetails: boolean; - @Input() unit: string; +export class GfPortfolioPerformanceComponent { + public readonly errors = input(); + public readonly isLoading = input(false); + public readonly locale = input(getLocale()); + public readonly performance = input.required(); + public readonly precision = input.required({ + transform: (value) => { + return value >= 0 ? value : 2; + } + }); + public readonly showDetails = input(false); + public readonly unit = input.required(); + + private readonly value = + viewChild.required>('value'); - @ViewChild('value') value: ElementRef; + private readonly notificationService = inject(NotificationService); - public constructor(private notificationService: NotificationService) { + public constructor() { addIcons({ timeOutline }); - } - public ngOnChanges() { - this.precision = this.precision >= 0 ? this.precision : 2; + effect(() => { + if (this.isLoading()) { + if (this.value().nativeElement) { + this.value().nativeElement.innerHTML = ''; + } + } else { + const performance = this.performance(); - if (this.isLoading) { - if (this.value?.nativeElement) { - this.value.nativeElement.innerHTML = ''; - } - } else { - if (isNumber(this.performance?.currentValueInBaseCurrency)) { - new CountUp('value', this.performance?.currentValueInBaseCurrency, { - decimal: getNumberFormatDecimal(this.locale), - decimalPlaces: this.precision, - duration: 1, - separator: getNumberFormatGroup(this.locale) - }).start(); - } else if (this.showDetails === false) { - new CountUp( - 'value', - this.performance?.netPerformancePercentageWithCurrencyEffect * 100, - { - decimal: getNumberFormatDecimal(this.locale), - decimalPlaces: 2, + if (isNumber(performance?.currentValueInBaseCurrency)) { + new CountUp('value', performance.currentValueInBaseCurrency, { + decimal: getNumberFormatDecimal(this.locale()), + decimalPlaces: this.precision(), duration: 1, - separator: getNumberFormatGroup(this.locale) - } - ).start(); - } else { - this.value.nativeElement.innerHTML = '*****'; + separator: getNumberFormatGroup(this.locale()) + }).start(); + } else if (this.showDetails() === false && performance) { + new CountUp( + 'value', + performance.netPerformancePercentageWithCurrencyEffect * 100, + { + decimal: getNumberFormatDecimal(this.locale()), + decimalPlaces: 2, + duration: 1, + separator: getNumberFormatGroup(this.locale()) + } + ).start(); + } else { + this.value().nativeElement.innerHTML = '*****'; + } } - } + }); } - public onShowErrors() { - const errorMessageParts = []; + protected onShowErrors() { + const errors = this.errors(); + + if (!errors?.length) { + return; + } + + const errorMessageParts: string[] = []; - for (const error of this.errors) { + for (const error of errors) { errorMessageParts.push(`${error.symbol} (${error.dataSource})`); } diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html index e144794256..f608e1e7be 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html @@ -1,339 +1,442 @@
    -
    +
    Time in Market
    - +
    -
    -
    - {{ summary?.activityCount }} - {summary?.activityCount, plural, - =1 {activity} - other {activities} - } - - - + @if (isLoading) { +
    +
    + +
    -
    + } @else { +
    +
    + {{ summary?.activityCount }} + {summary?.activityCount, plural, + =1 {activity} + other {activities} + } + + + +
    +
    + }

    -
    +
    Buy
    -
    +
    Sell

    -
    -
    Investment
    +
    +
    Invested Capital
    -
    +
    Absolute Gross Performance
    +
    +
    +
    +
    thereof Dividend
    +
    +
    -
    +
    Fees
    - @if (summary?.fees || summary?.fees === 0) { - - + @if (isNumber(summary?.fees)) { + - }

    -
    +
    Absolute Net Performance
    -
    -
    +
    +
    Net Performance - (ROAI) + @switch (user?.settings?.performanceCalculationType) { + @case (PerformanceCalculationType.ROAI) { + (ROAI) + } + @case (PerformanceCalculationType.ROI) { + (ROI) + } + }
    +
    +
    +
    +
    + thereof Dividend Performance +
    +
    +

    -
    +
    Total Assets
    -
    -
    - Emergency Fund +
    +
    + @if (hasHoldingsBreakdown) { + + + + } + Holdings @if ( !hasImpersonationId && - summary?.totalValueInBaseCurrency > 0 && + (summary?.totalValueInBaseCurrency ?? 0) > 0 && user?.settings?.isExperimentalFeatures ) { }
    -
    - @if ( - hasPermissionToUpdateUserSettings && - !isLoading && - !user?.settings?.isRestrictedView && - user?.subscription?.type !== 'Basic' - ) { - - } - -
    -
    -
    -
    Cash
    -
    -
    Assets
    -
    - + @if (hasHoldingsBreakdown && isHoldingsExpanded) { +
    +
    Investments
    +
    + +
    -
    -
    -
    - Buying Power +
    +
    Emergency Fund
    +
    + +
    +
    + } +
    +
    + @if (hasCashBreakdown) { + + + + } + Cash @if ( !hasImpersonationId && - summary?.totalValueInBaseCurrency > 0 && + (summary?.totalValueInBaseCurrency ?? 0) > 0 && user?.settings?.isExperimentalFeatures ) { }
    -
    +
    -
    + @if (hasCashBreakdown && isCashExpanded) { +
    +
    Buying Power
    +
    + +
    +
    +
    +
    Emergency Fund
    +
    + +
    +
    + } +
    Excluded from Analysis @if ( !hasImpersonationId && - summary?.totalValueInBaseCurrency > 0 && + (summary?.totalValueInBaseCurrency ?? 0) > 0 && user?.settings?.isExperimentalFeatures ) { }

    -
    +
    Liabilities
    - @if ( - summary?.liabilitiesInBaseCurrency || - summary?.liabilitiesInBaseCurrency === 0 - ) { - - + @if (isNumber(summary?.liabilitiesInBaseCurrency)) { + - }

    -
    -
    Net Worth
    +
    +
    Net Worth
    -
    -
    +
    +
    Annualized Performance
    @@ -341,42 +444,83 @@ class="justify-content-end" position="end" [colorizeSign]="true" + [isLoading]="isLoading" [isPercent]="true" [locale]="locale" - [value]=" - isLoading - ? undefined - : summary?.annualizedPerformancePercentWithCurrencyEffect - " + [value]="summary?.annualizedPerformancePercentWithCurrencyEffect" />

    -
    -
    Interest
    -
    +
    +
    + Emergency Fund + @if ( + !hasImpersonationId && + (summary?.totalValueInBaseCurrency ?? 0) > 0 && + user?.settings?.isExperimentalFeatures + ) { + + } +
    +
    + @if ( + hasPermissionToUpdateUserSettings && + !isLoading && + !user?.settings?.isRestrictedView && + user?.subscription?.type !== 'Basic' + ) { + + }
    -
    -
    Dividend
    +
    +
    Interest
    diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.scss b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.scss index 5d4e87f30f..498a07e63e 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.scss +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.scss @@ -1,3 +1,25 @@ :host { display: block; + + .caret-container { + margin-left: -1rem; + width: 1rem; + + .caret { + font-size: 0.7rem; + transition: transform 150ms ease-in-out; + + &.caret-expanded { + transform: rotate(90deg); + } + } + } + + .indent-1 { + margin-left: 1rem; + } + + .indent-2 { + margin-left: 2rem; + } } diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts index 3d2760202c..6dea74eb5d 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts @@ -1,6 +1,7 @@ import { NUMERICAL_PRECISION_THRESHOLD_6_FIGURES } from '@ghostfolio/common/config'; import { getDateFnsLocale, getLocale } from '@ghostfolio/common/helper'; import { PortfolioSummary, User } from '@ghostfolio/common/interfaces'; +import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; import { translate } from '@ghostfolio/ui/i18n'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { GfValueComponent } from '@ghostfolio/ui/value'; @@ -8,76 +9,139 @@ import { GfValueComponent } from '@ghostfolio/ui/value'; import { ChangeDetectionStrategy, Component, - EventEmitter, + inject, Input, OnChanges, - Output + output } from '@angular/core'; import { MatTooltipModule } from '@angular/material/tooltip'; import { IonIcon } from '@ionic/angular/standalone'; import { formatDistanceToNow } from 'date-fns'; import { addIcons } from 'ionicons'; import { + caretForwardOutline, ellipsisHorizontalCircleOutline, informationCircleOutline } from 'ionicons/icons'; +import { isNumber } from 'lodash-es'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, - imports: [GfValueComponent, IonIcon, MatTooltipModule], + imports: [ + GfValueComponent, + IonIcon, + MatTooltipModule, + NgxSkeletonLoaderModule + ], selector: 'gf-portfolio-summary', styleUrls: ['./portfolio-summary.component.scss'], templateUrl: './portfolio-summary.component.html' }) export class GfPortfolioSummaryComponent implements OnChanges { - @Input() baseCurrency: string; - @Input() deviceType: string; - @Input() hasImpersonationId: boolean; - @Input() hasPermissionToUpdateUserSettings: boolean; - @Input() isLoading: boolean; - @Input() language: string; - @Input() locale = getLocale(); - @Input() summary: PortfolioSummary; - @Input() user: User; - - @Output() emergencyFundChanged = new EventEmitter(); - - public buyAndSellActivitiesTooltip = translate( + @Input() public baseCurrency?: string; + @Input() public deviceType: string; + @Input() public hasImpersonationId: boolean; + @Input() public hasPermissionToUpdateUserSettings: boolean; + @Input() public isLoading: boolean; + @Input() public language?: string; + @Input() public locale?: string = getLocale(); + @Input() public summary?: PortfolioSummary; + @Input() public user?: User; + + public emergencyFundChanged = output(); + + protected readonly buyAndSellActivitiesTooltip = translate( 'BUY_AND_SELL_ACTIVITIES_TOOLTIP' ); - public precision = 2; - public timeInMarket: string; + protected readonly isNumber = isNumber; + protected readonly PerformanceCalculationType = PerformanceCalculationType; + + protected isCashExpanded = false; + protected isHoldingsExpanded = false; + protected precision = 2; + protected timeInMarket: string | undefined; + + private readonly notificationService = inject(NotificationService); + + public constructor() { + addIcons({ + caretForwardOutline, + ellipsisHorizontalCircleOutline, + informationCircleOutline + }); + } - public get buyingPowerPercentage() { + protected get cashPercentage() { return this.summary?.totalValueInBaseCurrency - ? this.summary.cash / this.summary.totalValueInBaseCurrency + ? this.summary.totalCashInBaseCurrency / + this.summary.totalValueInBaseCurrency : 0; } - public get emergencyFundPercentage() { + protected get displayedCurrency() { + return this.deviceType === 'mobile' ? undefined : this.baseCurrency; + } + + protected get emergencyFundPercentage() { return this.summary?.totalValueInBaseCurrency ? (this.summary.emergencyFund?.total || 0) / this.summary.totalValueInBaseCurrency : 0; } - public get excludedFromAnalysisPercentage() { + protected get excludedFromAnalysisPercentage() { return this.summary?.totalValueInBaseCurrency ? this.summary.excludedAccountsAndActivities / this.summary.totalValueInBaseCurrency : 0; } - public constructor(private notificationService: NotificationService) { - addIcons({ ellipsisHorizontalCircleOutline, informationCircleOutline }); + protected get hasCashBreakdown() { + return !this.isLoading && (this.summary?.emergencyFund?.cash ?? 0) > 0; + } + + protected get hasHoldingsBreakdown() { + return !this.isLoading && (this.summary?.emergencyFund?.assets ?? 0) > 0; + } + + protected get holdingsInBaseCurrency() { + if ( + !isNumber(this.summary?.totalAssetsInBaseCurrency) || + !isNumber(this.summary?.totalCashInBaseCurrency) + ) { + return null; + } + + return ( + this.summary.totalAssetsInBaseCurrency - + this.summary.totalCashInBaseCurrency + ); + } + + protected get holdingsPercentage() { + return this.summary?.totalValueInBaseCurrency && + isNumber(this.holdingsInBaseCurrency) + ? this.holdingsInBaseCurrency / this.summary.totalValueInBaseCurrency + : 0; + } + + protected get investmentsInBaseCurrency() { + if (!isNumber(this.holdingsInBaseCurrency)) { + return null; + } + + return ( + this.holdingsInBaseCurrency - (this.summary?.emergencyFund?.assets ?? 0) + ); } public ngOnChanges() { if (this.summary) { if ( this.deviceType === 'mobile' && - this.summary.totalValueInBaseCurrency >= + (this.summary.totalValueInBaseCurrency ?? 0) >= NUMERICAL_PRECISION_THRESHOLD_6_FIGURES ) { this.precision = 0; @@ -91,14 +155,14 @@ export class GfPortfolioSummaryComponent implements OnChanges { } ); } else { - this.timeInMarket = '-'; + this.timeInMarket = '–'; } } else { this.timeInMarket = undefined; } } - public onEditEmergencyFund() { + protected onEditEmergencyFund() { this.notificationService.prompt({ confirmFn: (value) => { const emergencyFund = parseFloat(value.trim()) || 0; @@ -106,8 +170,17 @@ export class GfPortfolioSummaryComponent implements OnChanges { this.emergencyFundChanged.emit(emergencyFund); }, confirmLabel: $localize`Save`, - defaultValue: this.summary.emergencyFund?.total?.toString() ?? '0', - title: $localize`Please set the amount of your emergency fund.` + defaultValue: this.summary?.emergencyFund?.total?.toString() ?? '0', + title: $localize`Please set the amount of your emergency fund.`, + valueSuffix: this.baseCurrency }); } + + protected onToggleCash() { + this.isCashExpanded = !this.isCashExpanded; + } + + protected onToggleHoldings() { + this.isHoldingsExpanded = !this.isHoldingsExpanded; + } } diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts index 90a0039cf0..0c66f5d4e4 100644 --- a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts @@ -5,7 +5,7 @@ import { export interface RuleSettingsDialogParams { categoryName: string; - locale: string; + locale?: string; rule: PortfolioReportRule; settings: XRayRulesSettings['AccountClusterRiskCurrentInvestment']; } diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts index 5c2f3be790..aa8d6fbfd2 100644 --- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts +++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts @@ -1,8 +1,7 @@ -import { XRayRulesSettings } from '@ghostfolio/common/interfaces'; import { GfValueComponent } from '@ghostfolio/ui/value'; -import { Component, Inject } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; +import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, @@ -14,22 +13,37 @@ import { MatSliderModule } from '@angular/material/slider'; import { RuleSettingsDialogParams } from './interfaces/interfaces'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [ - FormsModule, GfValueComponent, MatButtonModule, MatDialogModule, - MatSliderModule + MatSliderModule, + ReactiveFormsModule ], selector: 'gf-rule-settings-dialog', - styleUrls: ['./rule-settings-dialog.scss'], templateUrl: './rule-settings-dialog.html' }) export class GfRuleSettingsDialogComponent { - public settings: XRayRulesSettings['AccountClusterRiskCurrentInvestment']; + protected readonly settingsForm: FormGroup; - public constructor( - @Inject(MAT_DIALOG_DATA) public data: RuleSettingsDialogParams, - public dialogRef: MatDialogRef - ) {} + protected readonly data = inject(MAT_DIALOG_DATA); + protected readonly dialogRef = + inject>(MatDialogRef); + private readonly formBuilder = inject(FormBuilder); + + public constructor() { + this.settingsForm = this.formBuilder.group({ + thresholdMax: [this.data.settings?.thresholdMax], + thresholdMin: [this.data.settings?.thresholdMin] + }); + } + + protected onSubmit() { + this.dialogRef.close({ + ...this.data.settings, + thresholdMax: this.settingsForm.get('thresholdMax')?.value, + thresholdMin: this.settingsForm.get('thresholdMin')?.value + }); + } } diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html index c88a9dc9d9..978fc9f03f 100644 --- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html +++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html @@ -1,132 +1,150 @@
    {{ data.categoryName }} › {{ data.rule.name }}
    -
    - @if ( - data.rule.configuration.thresholdMin && data.rule.configuration.thresholdMax - ) { -
    -
    - Threshold range: - - - - -
    -
    - - +
    + @if (data.rule.configuration?.threshold; as threshold) { + @if ( + data.rule.configuration.thresholdMin && + data.rule.configuration.thresholdMax + ) { +
    +
    + Threshold range: + + - + +
    +
    + + + + + + +
    +
    + } @else { +
    - - - - -
    -
    - } @else { -
    -
    - Threshold Min: - -
    -
    - - + Threshold Min: + + +
    + + + + + +
    +
    +
    - - - -
    -
    -
    -
    - Threshold Max: - -
    -
    - - - - - -
    -
    - } -
    +
    + Threshold Max: + +
    +
    + + + + + +
    +
    + } + } +
    -
    - - -
    +
    + + +
    + diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.scss b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.scss deleted file mode 100644 index 0f6fce3d2d..0000000000 --- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.scss +++ /dev/null @@ -1,5 +0,0 @@ -:host { - label { - margin-bottom: 0; - } -} diff --git a/apps/client/src/app/components/rule/rule.component.html b/apps/client/src/app/components/rule/rule.component.html index 9f256d5ae2..f9fc603830 100644 --- a/apps/client/src/app/components/rule/rule.component.html +++ b/apps/client/src/app/components/rule/rule.component.html @@ -1,10 +1,10 @@
    -
    +
    @if (isLoading) {
    } @else { - + }
    } @@ -65,7 +65,7 @@ @if (rule?.isActive && rule?.configuration) { @@ -74,12 +74,12 @@ + + Try Premium +
    } diff --git a/apps/client/src/app/components/user-account-access/access-dialog-host/access-dialog-host.component.ts b/apps/client/src/app/components/user-account-access/access-dialog-host/access-dialog-host.component.ts new file mode 100644 index 0000000000..1adafb118b --- /dev/null +++ b/apps/client/src/app/components/user-account-access/access-dialog-host/access-dialog-host.component.ts @@ -0,0 +1,180 @@ +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { Access } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { DataService } from '@ghostfolio/ui/services'; + +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + OnDestroy, + OnInit, + inject +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DeviceDetectorService } from 'ngx-device-detector'; +import { EMPTY, Observable, Subject, of } from 'rxjs'; +import { + catchError, + distinctUntilChanged, + map, + switchMap, + takeUntil, + tap +} from 'rxjs/operators'; + +import { GfCreateOrUpdateAccessDialogComponent } from '../create-or-update-access-dialog/create-or-update-access-dialog.component'; +import { CreateOrUpdateAccessDialogParams } from '../create-or-update-access-dialog/interfaces/interfaces'; +import { AccessDialogMode } from './types/access-dialog-mode.type'; + +@Component({ + changeDetection: ChangeDetectionStrategy.OnPush, + selector: 'gf-access-dialog-host', + template: '' +}) +export class GfAccessDialogHostComponent implements OnDestroy, OnInit { + private dialogRef: MatDialogRef; + + private readonly deviceType = computed(() => { + return this.deviceDetectorService.deviceInfo().deviceType; + }); + + private readonly dialogClosed = new Subject(); + + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly dialog = inject(MatDialog); + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public ngOnInit() { + const mode = this.route.snapshot.data.mode as AccessDialogMode; + + // The router reuses this component when only the access id changes, so + // the parameters are observed instead of read from the snapshot once + this.route.paramMap + .pipe( + map((paramMap) => { + return paramMap.get('accessId'); + }), + distinctUntilChanged(), + tap(() => { + this.closeDialog(); + }), + switchMap((accessId) => { + const access$: Observable = + mode === 'update' && accessId + ? this.fetchAccess(accessId) + : of(undefined); + + return this.userService.get().pipe( + switchMap((user) => { + return access$.pipe( + map((access) => { + return { access, user }; + }) + ); + }), + catchError(() => { + this.navigateBack(); + + return EMPTY; + }) + ); + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(({ access, user }) => { + if (mode === 'update') { + if ( + !access || + !hasPermission(user?.permissions, permissions.updateAccess) + ) { + this.navigateBack(); + + return; + } + + this.openCreateOrUpdateAccessDialog({ access }); + + return; + } + + if (!hasPermission(user?.permissions, permissions.createAccess)) { + this.navigateBack(); + + return; + } + + this.openCreateOrUpdateAccessDialog({}); + }); + } + + public ngOnDestroy() { + // The dialog lives in an overlay outside of this component, so it needs to + // be closed explicitly when leaving the route (for example via the browser + // navigation) + this.dialogRef?.close(); + + this.dialogClosed.complete(); + } + + private closeDialog() { + // Tear down the subscription of the dialog which is about to be replaced, + // so that its result is not mistaken for the user closing it + this.dialogClosed.next(); + + this.dialogRef?.close(); + } + + private fetchAccess(aAccessId: string) { + return this.dataService.fetchAccesses().pipe( + map(({ accesses }) => { + return accesses.find(({ id }) => { + return id === aAccessId; + }); + }) + ); + } + + private navigateBack() { + void this.router.navigate( + internalRoutes.account.subRoutes.access.routerLink + ); + } + + private openCreateOrUpdateAccessDialog( + data: CreateOrUpdateAccessDialogParams + ) { + const dialogRef = this.dialog.open< + GfCreateOrUpdateAccessDialogComponent, + CreateOrUpdateAccessDialogParams + >(GfCreateOrUpdateAccessDialogComponent, { + data, + height: this.deviceType() === 'mobile' ? '98vh' : undefined, + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((result) => { + if (result) { + // Deliberately not bound to the destroy reference: navigating back + // destroys this component and the refreshed user is what makes the + // access page reload its data + this.userService.get(true).subscribe(); + } + + this.navigateBack(); + }); + } +} diff --git a/apps/client/src/app/components/user-account-access/access-dialog-host/types/access-dialog-mode.type.ts b/apps/client/src/app/components/user-account-access/access-dialog-host/types/access-dialog-mode.type.ts new file mode 100644 index 0000000000..163b53d9e4 --- /dev/null +++ b/apps/client/src/app/components/user-account-access/access-dialog-host/types/access-dialog-mode.type.ts @@ -0,0 +1 @@ +export type AccessDialogMode = 'create' | 'update'; diff --git a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts index 51bc765025..11b82ac881 100644 --- a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts +++ b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts @@ -1,8 +1,35 @@ +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { MCP_ENDPOINT } from '@ghostfolio/common/config'; import { CreateAccessDto, UpdateAccessDto } from '@ghostfolio/common/dtos'; +import { canApplyFiltersToAccess } from '@ghostfolio/common/helper'; +import { Filter, PortfolioPosition } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { + Scope, + canGrantRestrictedWriteAccess, + canGrantUnrestrictedReadAccess, + getAccessLevel, + getScopesOfAccess, + getScopesOfAccessLevel, + hasScope, + scopes +} from '@ghostfolio/common/scopes'; +import { AccessLevel, AccountWithPlatform } from '@ghostfolio/common/types'; import { validateObjectForForm } from '@ghostfolio/common/utils'; +import { AccessType } from '@ghostfolio/prisma/enums'; +import { GfAccessLevelIconComponent } from '@ghostfolio/ui/access-level-icon'; import { NotificationService } from '@ghostfolio/ui/notifications'; +import { + GfPortfolioFilterFormComponent, + getAssetClassFilters, + getFiltersFromPortfolioFilterFormValue, + getHoldingsForFilter, + getPortfolioFilterFormValue, + getTagFilters +} from '@ghostfolio/ui/portfolio-filter-form'; import { DataService } from '@ghostfolio/ui/services'; +import { JsonPipe } from '@angular/common'; import type { HttpErrorResponse } from '@angular/common/http'; import { ChangeDetectionStrategy, @@ -10,7 +37,8 @@ import { Component, DestroyRef, inject, - OnInit + OnInit, + signal } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { @@ -21,6 +49,7 @@ import { Validators } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; +import { MatDatepickerModule } from '@angular/material/datepicker'; import { MAT_DIALOG_DATA, MatDialogModule, @@ -29,9 +58,12 @@ import { import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select'; -import { AccessPermission } from '@prisma/client'; +import { IonIcon } from '@ionic/angular/standalone'; +import { addDays, endOfDay, isValid, startOfDay } from 'date-fns'; import { StatusCodes } from 'http-status-codes'; -import { EMPTY, catchError } from 'rxjs'; +import { addIcons } from 'ionicons'; +import { calendarClearOutline } from 'ionicons/icons'; +import { EMPTY, catchError, finalize } from 'rxjs'; import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; @@ -40,7 +72,12 @@ import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; host: { class: 'h-100' }, imports: [ FormsModule, + GfAccessLevelIconComponent, + GfPortfolioFilterFormComponent, + IonIcon, + JsonPipe, MatButtonModule, + MatDatepickerModule, MatDialogModule, MatFormFieldModule, MatInputModule, @@ -52,8 +89,20 @@ import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; templateUrl: 'create-or-update-access-dialog.html' }) export class GfCreateOrUpdateAccessDialogComponent implements OnInit { + public accounts: AccountWithPlatform[] = []; + public assetClasses: Filter[] = []; + public holdings: PortfolioPosition[] = []; + public tags: Filter[] = []; + protected accessForm: FormGroup; + protected readonly baseUrl = window.location.origin; + protected readonly isSubmitting = signal(false); + protected minExpiresAt: Date; protected readonly mode: 'create' | 'update'; + protected readonly today = startOfDay(new Date()); + + private hasExperimentalFeatures = false; + private hasPermissionToEnableMcp = false; private readonly changeDetectorRef = inject(ChangeDetectorRef); @@ -68,52 +117,161 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { private readonly formBuilder = inject(FormBuilder); private readonly notificationService = inject(NotificationService); + private readonly userService = inject(UserService); public constructor() { this.mode = this.data.access ? 'update' : 'create'; + + addIcons({ calendarClearOutline }); + } + + public get canApplyFilters() { + return ( + canApplyFiltersToAccess({ type: this.accessType }) && + this.hasExperimentalFeatures + ); + } + + public get canGrantMcpAccess() { + return this.hasExperimentalFeatures && this.hasPermissionToEnableMcp; + } + + public get canGrantRestrictedWriteAccess() { + return canGrantRestrictedWriteAccess({ type: this.accessType }); + } + + public get canGrantUnrestrictedReadAccess() { + return canGrantUnrestrictedReadAccess({ type: this.accessType }); + } + + public get canGrantWriteAccess() { + return this.hasExperimentalFeatures; } public ngOnInit() { const access = this.data?.access; - const isPublic = access?.type === 'PUBLIC'; + const isPrivate = (access?.type ?? 'PRIVATE') === 'PRIVATE'; + + const { globalPermissions } = this.dataService.fetchInfo(); + + this.hasPermissionToEnableMcp = hasPermission( + globalPermissions, + permissions.enableMcp + ); this.accessForm = this.formBuilder.group({ + accessLevel: getAccessLevel(access?.scopes), alias: [access?.alias ?? ''], - granteeUserId: [ - access?.grantee ?? null, - isPublic ? null : Validators.required - ], - permissions: [ - access?.permissions[0] ?? AccessPermission.READ_RESTRICTED, + expiresAt: [ + access?.expiresAt ? new Date(access.expiresAt) : addDays(this.today, 1), Validators.required ], + filters: [null], + granteeUserId: [ + isPrivate ? (access?.grantee ?? null) : null, + isPrivate ? Validators.required : null + ], type: [ { disabled: this.mode === 'update', value: access?.type ?? 'PRIVATE' }, Validators.required ] }); + this.assetClasses = getAssetClassFilters(); + + this.minExpiresAt = addDays(this.today, 1); + + this.userService + .get() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(({ accounts, settings, tags }) => { + this.accounts = accounts; + this.hasExperimentalFeatures = settings.isExperimentalFeatures ?? false; + this.tags = getTagFilters(tags); + + this.changeDetectorRef.markForCheck(); + }); + this.accessForm .get('type') ?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((accessType) => { + .subscribe((accessType: AccessType) => { const granteeUserIdControl = this.accessForm.get('granteeUserId'); - const permissionsControl = this.accessForm.get('permissions'); if (accessType === 'PRIVATE') { granteeUserIdControl?.setValidators(Validators.required); } else { granteeUserIdControl?.clearValidators(); granteeUserIdControl?.setValue(null); - permissionsControl?.setValue( - access?.permissions[0] ?? AccessPermission.READ_RESTRICTED - ); + } + + // Narrow the permission to the scopes which the type permits and drop + // the monetary values, which have to be granted after the type + this.accessForm.get('accessLevel')?.setValue( + getAccessLevel( + getScopesOfAccess({ + scopes: getScopesOfAccessLevel(this.accessLevel).filter( + (scope) => { + return scope !== scopes.portfolioReadValues; + } + ), + type: accessType + }) + ) + ); + + if (!canApplyFiltersToAccess({ type: accessType })) { + this.accessForm.get('filters')?.setValue(null); } granteeUserIdControl?.updateValueAndValidity(); this.changeDetectorRef.markForCheck(); }); + + this.loadHoldings(); + } + + protected get accessId() { + return this.data.access?.id; + } + + protected get accessLevel(): AccessLevel { + return this.accessForm?.get('accessLevel')?.value as AccessLevel; + } + + protected get accessType(): AccessType { + return this.accessForm?.get('type')?.value as AccessType; + } + + protected get isPublicAccess() { + return this.accessType === 'PUBLIC'; + } + + protected get mcpConfiguration() { + return { + headers: { + Authorization: `Bearer ${this.accessId}` + }, + type: 'http', + url: `${this.baseUrl}${MCP_ENDPOINT}` + }; + } + + protected get showExpiresAtErrorMessage() { + return this.accessForm?.get('expiresAt')?.invalid === true; + } + + protected get showMcpDetails() { + return this.canGrantMcpAccess && this.isMcpAccess && this.mode === 'update'; + } + + protected get showPublicDetails() { + return ( + this.hasExperimentalFeatures && + this.isPublicAccess && + this.mode === 'update' + ); } protected onCancel() { @@ -128,11 +286,20 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { } } + private get isMcpAccess() { + return this.accessType === 'MCP'; + } + private async createAccess() { + const filters = this.getFilters(); + const access: CreateAccessDto = { alias: this.accessForm.get('alias')?.value, + expiresAt: this.getExpiresAt(), + filters: filters.length > 0 ? filters : undefined, granteeUserId: this.accessForm.get('granteeUserId')?.value, - permissions: [this.accessForm.get('permissions')?.value] + scopes: this.getScopes(), + type: this.accessForm.get('type')?.value }; try { @@ -142,6 +309,8 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { object: access }); + this.isSubmitting.set(true); + this.dataService .postAccess(access) .pipe( @@ -154,6 +323,9 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { return EMPTY; }), + finalize(() => { + this.isSubmitting.set(false); + }), takeUntilDestroyed(this.destroyRef) ) .subscribe(() => { @@ -164,18 +336,75 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { } } + private getExpiresAt() { + const expiresAtControl = this.accessForm.get('expiresAt'); + const expiresAtOfAccess = this.data.access?.expiresAt; + + if ( + this.mode === 'update' && + !expiresAtControl?.dirty && + expiresAtOfAccess + ) { + return new Date(expiresAtOfAccess).toISOString(); + } + + const expiresAt = expiresAtControl?.value as Date; + + return isValid(expiresAt) ? endOfDay(expiresAt).toISOString() : ''; + } + + private getFilters(): Filter[] { + return getFiltersFromPortfolioFilterFormValue( + this.accessForm.get('filters')?.value + ); + } + + private getScopes(): Scope[] { + const scopesOfAccess = this.data.access?.scopes ?? []; + + if ( + scopesOfAccess.length > 0 && + this.accessLevel === getAccessLevel(scopesOfAccess) + ) { + return Object.values(scopes).filter((scope) => { + return hasScope(scopesOfAccess, scope); + }); + } + + return getScopesOfAccessLevel(this.accessLevel); + } + + private loadHoldings() { + this.dataService + .fetchPortfolioHoldings({ + filters: [{ id: 'ACTIVE', type: 'HOLDING_TYPE' }] + }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(({ holdings }) => { + this.holdings = getHoldingsForFilter(holdings); + + this.updateFiltersFormControl(this.data.access?.settings?.filters); + + this.changeDetectorRef.markForCheck(); + }); + } + private async updateAccess() { - const accessId = this.data.access?.id; + const accessId = this.accessId; if (!accessId) { return; } + const filters = this.getFilters(); + const access: UpdateAccessDto = { alias: this.accessForm.get('alias')?.value, + expiresAt: this.getExpiresAt(), + filters: filters.length > 0 ? filters : undefined, granteeUserId: this.accessForm.get('granteeUserId')?.value, id: accessId, - permissions: [this.accessForm.get('permissions')?.value] + scopes: this.getScopes() }; try { @@ -185,6 +414,8 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { object: access }); + this.isSubmitting.set(true); + this.dataService .putAccess(access) .pipe( @@ -197,6 +428,9 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { return EMPTY; }), + finalize(() => { + this.isSubmitting.set(false); + }), takeUntilDestroyed(this.destroyRef) ) .subscribe(() => { @@ -206,4 +440,14 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { console.error(error); } } + + private updateFiltersFormControl(filters: Filter[] | undefined) { + if (!filters?.length) { + return; + } + + this.accessForm + .get('filters') + ?.setValue(getPortfolioFilterFormValue(filters, this.holdings)); + } } diff --git a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html index 93614b55a2..6489865cf2 100644 --- a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html +++ b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html @@ -1,7 +1,7 @@

    @@ -23,23 +23,85 @@ />

    -
    - +
    + Type Private Public + @if (canGrantMcpAccess) { + Model Context Protocol (MCP) + } + @if (isPublicAccess) { + Any person who has the link can view the data. + } + +
    + +
    + + Expiration Date + + + + + + @if (showExpiresAtErrorMessage) { + Date must be in the future. + }
    Permission - - Restricted view - @if (accessForm.get('type')?.value === 'PRIVATE') { - View + + + + + + + + @if (canGrantRestrictedWriteAccess) { + + + + } + @if (canGrantUnrestrictedReadAccess) { + + + + + + } @@ -59,6 +121,30 @@
    } + @if (canApplyFilters) { +

    Portfolio Filters

    + + } + @if (showMcpDetails || showPublicDetails) { +

    Details

    + @if (showMcpDetails) { +
    {{ mcpConfiguration | json }}
    + } @else if (showPublicDetails) { +
    + GET {{ baseUrl }}/api/v1/public/{{ accessId }}/portfolio +
    + } + }
    -
    +
    + + diff --git a/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts b/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts index b13a983fcf..20425d831e 100644 --- a/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts +++ b/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts @@ -1,9 +1,9 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { TRY_SUBSCRIPTION_MAIL_HREF } from '@ghostfolio/common/config'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { getDateFormatString } from '@ghostfolio/common/helper'; import { User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; -import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfMembershipCardComponent } from '@ghostfolio/ui/membership-card'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; @@ -14,7 +14,8 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, - DestroyRef + DestroyRef, + inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; @@ -23,7 +24,7 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { RouterModule } from '@angular/router'; import ms, { StringValue } from 'ms'; import { EMPTY } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { catchError, switchMap } from 'rxjs/operators'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -40,29 +41,28 @@ import { catchError } from 'rxjs/operators'; templateUrl: './user-account-membership.html' }) export class GfUserAccountMembershipComponent { - public baseCurrency: string; - public coupon: number; - public couponId: string; - public defaultDateFormat: string; - public durationExtension: StringValue; - public hasPermissionForSubscription: boolean; - public hasPermissionToCreateApiKey: boolean; - public hasPermissionToUpdateUserSettings: boolean; - public price: number; - public priceId: string; - public routerLinkPricing = publicRoutes.pricing.routerLink; - public trySubscriptionMail = - 'mailto:hi@ghostfol.io?Subject=Ghostfolio Premium Trial&body=Hello%0D%0DI am interested in Ghostfolio Premium. Can you please send me a coupon code to try it for some time?%0D%0DKind regards'; - public user: User; - - public constructor( - private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService, - private destroyRef: DestroyRef, - private notificationService: NotificationService, - private snackBar: MatSnackBar, - private userService: UserService - ) { + protected readonly baseCurrency: string; + protected coupon: number | undefined; + protected defaultDateFormat: string; + protected durationExtension: StringValue | undefined; + protected readonly hasPermissionForSubscription: boolean; + protected hasPermissionToCreateApiKey: boolean; + protected hasPermissionToUpdateUserSettings: boolean; + protected price: number; + protected readonly trySubscriptionMailHref = TRY_SUBSCRIPTION_MAIL_HREF; + protected user: User; + + private couponId: string | undefined; + private priceId: string; + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly notificationService = inject(NotificationService); + private readonly snackBar = inject(MatSnackBar); + private readonly userService = inject(UserService); + + public constructor() { const { baseCurrency, globalPermissions } = this.dataService.fetchInfo(); this.baseCurrency = baseCurrency; @@ -104,7 +104,7 @@ export class GfUserAccountMembershipComponent { }); } - public onCheckout() { + protected onCheckout() { this.dataService .createStripeCheckoutSession({ couponId: this.couponId, @@ -125,7 +125,7 @@ export class GfUserAccountMembershipComponent { }); } - public onGenerateApiKey() { + protected onGenerateApiKey() { this.notificationService.confirm({ confirmFn: () => { this.dataService @@ -146,11 +146,9 @@ export class GfUserAccountMembershipComponent { ) .subscribe(({ apiKey }) => { this.notificationService.alert({ - discardLabel: $localize`Okay`, - message: - $localize`Set this API key in your self-hosted environment:` + - '
    ' + - apiKey, + copyValue: apiKey, + discardLabel: $localize`Close`, + message: $localize`Set this API key in your self-hosted environment:`, title: $localize`Ghostfolio Premium Data Provider API Key` }); }); @@ -160,7 +158,7 @@ export class GfUserAccountMembershipComponent { }); } - public onRedeemCoupon() { + protected onRedeemCoupon() { this.notificationService.prompt({ confirmFn: (value) => { const couponCode = value?.trim(); @@ -169,6 +167,9 @@ export class GfUserAccountMembershipComponent { this.dataService .redeemCoupon(couponCode) .pipe( + switchMap(() => { + return this.userService.get(true); + }), catchError(() => { this.snackBar.open( '😞 ' + $localize`Could not redeem coupon code`, @@ -183,27 +184,13 @@ export class GfUserAccountMembershipComponent { takeUntilDestroyed(this.destroyRef) ) .subscribe(() => { - const snackBarRef = this.snackBar.open( + this.snackBar.open( '✅ ' + $localize`Coupon code has been redeemed`, - $localize`Reload`, + undefined, { duration: ms('3 seconds') } ); - - snackBarRef - .afterDismissed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - window.location.reload(); - }); - - snackBarRef - .onAction() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - window.location.reload(); - }); }); } }, diff --git a/apps/client/src/app/components/user-account-membership/user-account-membership.html b/apps/client/src/app/components/user-account-membership/user-account-membership.html index 31d2392154..336f386139 100644 --- a/apps/client/src/app/components/user-account-membership/user-account-membership.html +++ b/apps/client/src/app/components/user-account-membership/user-account-membership.html @@ -3,7 +3,9 @@
    @if (coupon) { - {{ baseCurrency }} {{ price }} {{ baseCurrency }} {{ price - coupon }} } @else { @@ -36,7 +38,7 @@ @if (durationExtension) {
    Limited Offer!   @@ -48,11 +50,17 @@ } }
    - @if (!user?.subscription?.expiresAt) { - Try Premium @@ -70,7 +78,7 @@
    } @else { -
    +
    No auto-renewal on membership.
    } diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts index 72bbfc2c61..b47818638f 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts @@ -1,3 +1,4 @@ +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { KEY_STAY_SIGNED_IN, KEY_TOKEN, @@ -5,26 +6,35 @@ import { } from '@ghostfolio/client/services/settings-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; +import { + DEFAULT_LANGUAGE_CODE, + E_MAIL_LINE_BREAK +} from '@ghostfolio/common/config'; import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { downloadAsFile } from '@ghostfolio/common/helper'; import { User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { GfCurrencySelectorComponent } from '@ghostfolio/ui/currency-selector'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { DataService } from '@ghostfolio/ui/services'; +import { GfValueComponent } from '@ghostfolio/ui/value'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + computed, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, + inject, OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { - FormBuilder, - FormsModule, + FormControl, + FormGroup, + NonNullableFormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; @@ -44,13 +54,15 @@ import { format, parseISO } from 'date-fns'; import { addIcons } from 'ionicons'; import { eyeOffOutline, eyeOutline } from 'ionicons/icons'; import ms from 'ms'; +import { DeviceDetectorService } from 'ngx-device-detector'; import { EMPTY, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, imports: [ - FormsModule, + GfCurrencySelectorComponent, + GfValueComponent, IonIcon, MatButtonModule, MatCardModule, @@ -67,20 +79,31 @@ import { catchError } from 'rxjs/operators'; templateUrl: './user-account-settings.html' }) export class GfUserAccountSettingsComponent implements OnInit { - public appearancePlaceholder = $localize`Auto`; - public baseCurrency: string; - public currencies: string[] = []; - public deleteOwnUserForm = this.formBuilder.group({ + protected readonly appearancePlaceholder = $localize`Auto`; + protected readonly baseCurrencyForm = new FormGroup({ + baseCurrency: new FormControl({ + disabled: true, + value: null + }) + }); + protected closeUserAccountMailHref: string; + protected readonly currencies: string[] = []; + protected readonly deleteOwnUserForm = inject(NonNullableFormBuilder).group({ accessToken: ['', Validators.required] }); - public hasPermissionToDeleteOwnUser: boolean; - public hasPermissionToUpdateViewMode: boolean; - public hasPermissionToUpdateUserSettings: boolean; - public isAccessTokenHidden = true; - public isFingerprintSupported = this.doesBrowserSupportAuthn(); - public isWebAuthnEnabled: boolean; - public language = document.documentElement.lang; - public locales = [ + protected hasImpersonationId: boolean; + protected hasPermissionToDeleteOwnUser: boolean; + protected hasPermissionToEnableGhostfolioAi: boolean; + protected hasPermissionToRequestOwnUserDeletion: boolean; + protected hasPermissionToUpdateOwnAccessToken: boolean; + protected hasPermissionToUpdateViewMode: boolean; + protected hasPermissionToUpdateUserSettings: boolean; + protected isAccessTokenHidden = true; + protected readonly isFingerprintSupported = this.doesBrowserSupportAuthn(); + protected isLoading = true; + protected isWebAuthnEnabled: boolean; + protected readonly language = document.documentElement.lang; + protected locales = [ 'ca', 'de', 'de-CH', @@ -89,6 +112,7 @@ export class GfUserAccountSettingsComponent implements OnInit { 'es', 'fr', 'it', + // 'ja', 'ko', 'nl', 'pl', @@ -97,35 +121,91 @@ export class GfUserAccountSettingsComponent implements OnInit { 'uk', 'zh' ]; - public user: User; - - public constructor( - private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService, - private destroyRef: DestroyRef, - private formBuilder: FormBuilder, - private notificationService: NotificationService, - private settingsStorageService: SettingsStorageService, - private snackBar: MatSnackBar, - private userService: UserService, - public webAuthnService: WebAuthnService - ) { - const { baseCurrency, currencies } = this.dataService.fetchInfo(); - - this.baseCurrency = baseCurrency; + protected readonly previewDate = new Date().toISOString(); + protected readonly previewValue = 9999.99; + protected user: User; + + protected readonly deviceType = computed( + () => this.deviceDetectorService.deviceInfo().deviceType + ); + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly destroyRef = inject(DestroyRef); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); + private readonly notificationService = inject(NotificationService); + private readonly settingsStorageService = inject(SettingsStorageService); + private readonly snackBar = inject(MatSnackBar); + private readonly userService = inject(UserService); + private readonly webAuthnService = inject(WebAuthnService); + + public constructor() { + const { currencies } = this.dataService.fetchInfo(); + this.currencies = currencies; + this.impersonationStorageService + .onChangeHasImpersonation() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((impersonationId) => { + this.hasImpersonationId = !!impersonationId; + + this.updateBaseCurrencyFormState(); + + this.changeDetectorRef.markForCheck(); + }); + this.userService.stateChanged .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((state) => { if (state?.user) { this.user = state.user; + const userDetailUrl = [ + window.location.origin, + DEFAULT_LANGUAGE_CODE, + internalRoutes.adminControl.path, + internalRoutes.adminControl.subRoutes.users.path, + this.user.id + ].join('/'); + + this.closeUserAccountMailHref = `mailto:hi@ghostfol.io?subject=Delete Account&body=${[ + 'Hello', + '', + 'Please delete my Ghostfolio account.', + '', + `User ID: ${this.user.id}`, + '', + 'Kind regards', + '', + '', + '---', + userDetailUrl + ].join(E_MAIL_LINE_BREAK)}`; + this.hasPermissionToDeleteOwnUser = hasPermission( this.user.permissions, permissions.deleteOwnUser ); + this.hasPermissionToEnableGhostfolioAi = hasPermission( + this.user.permissions, + permissions.enableGhostfolioAi + ); + + this.hasPermissionToRequestOwnUserDeletion = hasPermission( + this.user.permissions, + permissions.requestOwnUserDeletion + ); + + this.hasPermissionToUpdateOwnAccessToken = hasPermission( + this.user.permissions, + permissions.updateOwnAccessToken + ); + this.hasPermissionToUpdateUserSettings = hasPermission( this.user.permissions, permissions.updateUserSettings @@ -136,13 +216,34 @@ export class GfUserAccountSettingsComponent implements OnInit { permissions.updateViewMode ); - this.locales.push(this.user.settings.locale); + this.baseCurrencyForm.setValue({ + baseCurrency: this.user.settings.baseCurrency ?? null + }); + + this.updateBaseCurrencyFormState(); + + if (this.user.settings.locale) { + this.locales.push(this.user.settings.locale); + } + this.locales = Array.from(new Set(this.locales)).sort(); + this.isLoading = false; + this.changeDetectorRef.markForCheck(); } }); + this.baseCurrencyForm.controls.baseCurrency.valueChanges + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((value) => { + // The currency selector emits null while the user is typing and only + // emits a currency once an option has been selected + if (value && value !== this.user?.settings.baseCurrency) { + this.onChangeUserSetting('baseCurrency', value); + } + }); + addIcons({ eyeOffOutline, eyeOutline }); } @@ -150,11 +251,11 @@ export class GfUserAccountSettingsComponent implements OnInit { this.update(); } - public isCommunityLanguage() { + protected isCommunityLanguage() { return !['de', 'en'].includes(this.language); } - public onChangeUserSetting(aKey: string, aValue: string) { + protected onChangeUserSetting(aKey: string, aValue: string) { this.dataService .putUserSetting({ [aKey]: aValue }) .pipe(takeUntilDestroyed(this.destroyRef)) @@ -178,17 +279,23 @@ export class GfUserAccountSettingsComponent implements OnInit { }); } - public onCloseAccount() { + protected onCloseAccount() { this.notificationService.confirm({ confirmFn: () => { this.dataService - .deleteOwnUser({ - accessToken: this.deleteOwnUserForm.get('accessToken').value - }) + .deleteOwnUser( + this.hasPermissionToUpdateOwnAccessToken + ? { + accessToken: this.deleteOwnUserForm.controls.accessToken.value + } + : {} + ) .pipe( catchError(() => { this.notificationService.alert({ - title: $localize`Oops! Incorrect Security Token.` + title: this.hasPermissionToUpdateOwnAccessToken + ? $localize`Oops! Incorrect Security Token.` + : $localize`Oops! Something went wrong.` }); return EMPTY; @@ -206,7 +313,7 @@ export class GfUserAccountSettingsComponent implements OnInit { }); } - public onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) { + protected onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) { this.dataService .putUserSetting({ isExperimentalFeatures: aEvent.checked }) .pipe(takeUntilDestroyed(this.destroyRef)) @@ -222,15 +329,11 @@ export class GfUserAccountSettingsComponent implements OnInit { }); } - public onExport() { + protected onExport() { this.dataService .fetchExport() .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((data) => { - for (const activity of data.activities) { - delete activity.id; - } - downloadAsFile({ content: data, fileName: `ghostfolio-export-${format( @@ -242,7 +345,23 @@ export class GfUserAccountSettingsComponent implements OnInit { }); } - public onRestrictedViewChange(aEvent: MatSlideToggleChange) { + protected onGhostfolioAiChange(aEvent: MatSlideToggleChange) { + this.dataService + .putUserSetting({ isGhostfolioAiEnabled: aEvent.checked }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + this.userService + .get(true) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((user) => { + this.user = user; + + this.changeDetectorRef.markForCheck(); + }); + }); + } + + protected onRestrictedViewChange(aEvent: MatSlideToggleChange) { this.dataService .putUserSetting({ isRestrictedView: aEvent.checked }) .pipe(takeUntilDestroyed(this.destroyRef)) @@ -258,7 +377,7 @@ export class GfUserAccountSettingsComponent implements OnInit { }); } - public async onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { + protected async onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { if (aEvent.checked) { try { await this.registerDevice(); @@ -281,7 +400,7 @@ export class GfUserAccountSettingsComponent implements OnInit { } } - public onViewModeChange(aEvent: MatSlideToggleChange) { + protected onViewModeChange(aEvent: MatSlideToggleChange) { this.dataService .putUserSetting({ viewMode: aEvent.checked === true ? 'ZEN' : 'DEFAULT' }) .pipe(takeUntilDestroyed(this.destroyRef)) @@ -358,4 +477,14 @@ export class GfUserAccountSettingsComponent implements OnInit { this.changeDetectorRef.markForCheck(); } + + private updateBaseCurrencyFormState() { + // The base currency belongs to the impersonated user while a change would be + // applied to the authenticated user + if (!this.hasImpersonationId && this.hasPermissionToUpdateUserSettings) { + this.baseCurrencyForm.enable({ emitEvent: false }); + } else { + this.baseCurrencyForm.disable({ emitEvent: false }); + } + } } diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.html b/apps/client/src/app/components/user-account-settings/user-account-settings.html index f646ef0fd4..577497848a 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.html +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.html @@ -3,38 +3,46 @@
    - -
    -
    +
    +
    +
    Base Currency
    -
    - - - @for (currency of currencies; track currency) { - {{ currency }} - } - +
    + + + @if (hasImpersonationId) { + Derived from the portfolio you are viewing + }
    - @if (user?.settings?.isExperimentalFeatures && !user?.subscription) { -
    -
    + @if (user?.settings?.isExperimentalFeatures) { +
    +
    Performance Calculation
    -
    +
    Return on Average Investment (ROAI) + Return on Investment (ROI)
    } -
    -
    +
    +
    Language
    @if (isCommunityLanguage()) { -
    +
    If a translation is missing, kindly support us in extending it +
    Italiano (Community) + @if (user?.settings?.isExperimentalFeatures) { Korean / 한국어 (
    -
    -
    +
    +
    Locale
    -
    +
    Date and number format
    -
    - +
    + {{ locale }} } + + + · + +
    -
    -
    +
    +
    Appearance
    -
    +
    - +
    -
    -
    +
    +
    Presenter View
    -
    +
    Protection for sensitive information like absolute performances and quantity values
    -
    +
    -
    -
    +
    +
    Zen Mode
    -
    +
    Distraction-free experience for turbulent times
    -
    +
    -
    -
    +
    +
    Biometric Authentication
    -
    Sign in with fingerprint
    +
    + Sign in with fingerprint +
    -
    +
    -
    -
    +
    +
    Experimental Features
    -
    +
    Sneak peek at upcoming functionality
    -
    +
    + @if (deviceType() !== 'mobile' && hasPermissionToEnableGhostfolioAi) { +
    +
    +
    Ghostfolio AI
    +
    + Powered by third-party AI providers +
    +
    +
    + +
    +
    + }
    -
    +
    Ghostfolio User ID
    -
    {{ user?.id }}
    +
    + +
    -
    -
    -
    - @if (hasPermissionToDeleteOwnUser) { + @if ( + hasPermissionToDeleteOwnUser || hasPermissionToRequestOwnUserDeletion + ) {
    -
    -
    -
    Danger Zone
    -
    - +
    Danger Zone
    +
    + @if ( + hasPermissionToDeleteOwnUser && + hasPermissionToUpdateOwnAccessToken + ) { + - Security Token - - + + - + + } @else if (hasPermissionToDeleteOwnUser && !hasImpersonationId) { -
    + } @else if ( + hasPermissionToRequestOwnUserDeletion && + (user?.accounts?.length > 0 || user?.activitiesCount > 0) + ) { + +
    + For security reasons, please delete all activities and accounts + first before your Ghostfolio account can be closed. +
    + } @else if (hasPermissionToRequestOwnUserDeletion) { + Close Account + }
    - +
    }
    diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.scss b/apps/client/src/app/components/user-account-settings/user-account-settings.scss index 53ea0acb7f..2c1637f52f 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.scss +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.scss @@ -11,6 +11,15 @@ } } + mat-form-field:has(gf-currency-selector) { + --mat-form-field-outlined-disabled-input-text-color: rgba( + var(--dark-secondary-text) + ); + --mat-form-field-outlined-disabled-outline-color: rgba( + var(--dark-disabled-text) + ); + } + .hint-text { font-size: 90%; line-height: 1.2; @@ -19,4 +28,13 @@ :host-context(.theme-dark) { color: rgb(var(--light-primary-text)); + + mat-form-field:has(gf-currency-selector) { + --mat-form-field-outlined-disabled-input-text-color: rgba( + var(--light-secondary-text) + ); + --mat-form-field-outlined-disabled-outline-color: rgba( + var(--light-disabled-text) + ); + } } diff --git a/apps/client/src/app/components/user-detail-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/user-detail-dialog/interfaces/interfaces.ts index 41b2b210f1..2b2f85fbde 100644 --- a/apps/client/src/app/components/user-detail-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/user-detail-dialog/interfaces/interfaces.ts @@ -2,6 +2,7 @@ export interface UserDetailDialogParams { currentUserId: string; deviceType: string; hasPermissionForSubscription: boolean; + language?: string; locale: string; userId: string; } diff --git a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.scss b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.scss index 542c252a57..f18a5d9be6 100644 --- a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.scss +++ b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.scss @@ -6,6 +6,8 @@ } .mat-mdc-dialog-title { - padding-right: 0.5rem !important; + button[mat-icon-button] { + --mat-icon-button-icon-size: 1rem; + } } } diff --git a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts index 05001a6bb8..f34555efc2 100644 --- a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts +++ b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts @@ -1,5 +1,13 @@ +import { formatRelativeTime } from '@ghostfolio/client/util/date.util'; +import { + canDeleteUser, + getCountryName, + getSum +} from '@ghostfolio/common/helper'; import { AdminUserResponse } from '@ghostfolio/common/interfaces'; -import { AdminService } from '@ghostfolio/ui/services'; +import type { Subscription } from '@ghostfolio/prisma/browser'; +import { translate } from '@ghostfolio/ui/i18n'; +import { AdminService, DataService } from '@ghostfolio/ui/services'; import { GfValueComponent } from '@ghostfolio/ui/value'; import { @@ -8,7 +16,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, - Inject, + inject, OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @@ -16,7 +24,10 @@ import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog'; import { MatMenuModule } from '@angular/material/menu'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { IonIcon } from '@ionic/angular/standalone'; +import { Big } from 'big.js'; +import { differenceInDays } from 'date-fns'; import { addIcons } from 'ionicons'; import { ellipsisVertical } from 'ionicons/icons'; import { EMPTY } from 'rxjs'; @@ -35,7 +46,8 @@ import { IonIcon, MatButtonModule, MatDialogModule, - MatMenuModule + MatMenuModule, + MatTableModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-user-detail-dialog', @@ -43,24 +55,81 @@ import { templateUrl: './user-detail-dialog.html' }) export class GfUserDetailDialogComponent implements OnInit { - public user: AdminUserResponse; - - public constructor( - private adminService: AdminService, - private changeDetectorRef: ChangeDetectorRef, - @Inject(MAT_DIALOG_DATA) public data: UserDetailDialogParams, - private destroyRef: DestroyRef, - public dialogRef: MatDialogRef< - GfUserDetailDialogComponent, - UserDetailDialogResult - > - ) { + protected readonly baseCurrency: string; + protected readonly canDeleteUser = canDeleteUser; + protected readonly formatRelativeTime = formatRelativeTime; + protected readonly getCountryName = getCountryName; + protected isLoading = true; + + protected readonly subscriptionsDataSource = + new MatTableDataSource(); + + protected readonly subscriptionsDisplayedColumns = [ + 'createdAt', + 'type', + 'price', + 'expiresAt' + ]; + + protected readonly translate = translate; + protected user: AdminUserResponse; + + protected readonly data = inject(MAT_DIALOG_DATA); + + private readonly adminService = inject(AdminService); + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + + private readonly dialogRef = + inject>( + MatDialogRef + ); + + public constructor() { + this.baseCurrency = this.dataService.fetchInfo().baseCurrency; + addIcons({ ellipsisVertical }); } public ngOnInit() { + this.initialize(); + } + + protected deleteUser() { + this.dialogRef.close({ + action: 'delete', + userId: this.data.userId + }); + } + + protected getSum() { + return getSum( + this.subscriptionsDataSource.data + .filter(({ price }) => { + return price !== null; + }) + .map(({ price }) => { + return new Big(price ?? 0); + }) + ).toNumber(); + } + + protected getType({ createdAt, expiresAt, price }: Subscription) { + if (price) { + return $localize`Paid`; + } + + return differenceInDays(expiresAt, createdAt) <= 90 + ? $localize`Trial` + : $localize`Coupon`; + } + + protected initialize() { + this.isLoading = true; + this.adminService .fetchUserById(this.data.userId) .pipe( @@ -74,18 +143,15 @@ export class GfUserDetailDialogComponent implements OnInit { .subscribe((user) => { this.user = user; + this.subscriptionsDataSource.data = this.user.subscriptions ?? []; + + this.isLoading = false; + this.changeDetectorRef.markForCheck(); }); } - public deleteUser() { - this.dialogRef.close({ - action: 'delete', - userId: this.data.userId - }); - } - - public onClose() { + protected onClose() { this.dialogRef.close(); } } diff --git a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.html b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.html index caf1679ebf..d952cca540 100644 --- a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.html +++ b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.html @@ -1,22 +1,33 @@
    + +
    - Role + Role
    @@ -46,6 +64,7 @@ i18n size="medium" [isDate]="true" + [isLoading]="isLoading" [locale]="data.locale" [value]="user?.createdAt" >Registration DateAuthenticationMembership
    - Country
    @@ -86,6 +113,7 @@ AccountsActivitiesAPI Requests Today
    + +
    +
    + Last Request +
    +
    + Client +
    +
    + + @if (subscriptionsDataSource.data.length > 0) { +
    +
    +

    Subscription History

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Creation + + + + Total + + Type + + {{ getType(element) }} + + Price + + @if (element.price === null) { + – + {{ baseCurrency }} + } @else { + + } + + + + Expiration + + +
    +
    +
    +
    + } }
    diff --git a/apps/client/src/app/core/auth.guard.ts b/apps/client/src/app/core/auth.guard.ts index 6ac3417db8..fdb50c9adb 100644 --- a/apps/client/src/app/core/auth.guard.ts +++ b/apps/client/src/app/core/auth.guard.ts @@ -3,16 +3,16 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes'; import { DataService } from '@ghostfolio/ui/services'; -import { inject, Injectable } from '@angular/core'; +import { inject, Service } from '@angular/core'; import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; import { EMPTY } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { catchError, finalize } from 'rxjs/operators'; -@Injectable({ providedIn: 'root' }) +@Service() export class AuthGuard { private readonly dataService = inject(DataService); private readonly router = inject(Router); @@ -34,9 +34,11 @@ export class AuthGuard { if (utmSource === 'ios') { this.router.navigate(publicRoutes.demo.routerLink); resolve(false); + return EMPTY; } else if (utmSource === 'trusted-web-activity') { this.router.navigate(publicRoutes.register.routerLink); resolve(false); + return EMPTY; } else if ( Object.values(publicRoutes) .map(({ path }) => { @@ -57,6 +59,9 @@ export class AuthGuard { resolve(true); return EMPTY; + }), + finalize(() => { + resolve(false); }) ) .subscribe((user) => { @@ -77,13 +82,13 @@ export class AuthGuard { return; } else if ( state.url.startsWith(`/${internalRoutes.home.path}`) && - user.settings.viewMode === 'ZEN' + user?.settings?.viewMode === 'ZEN' ) { this.router.navigate(internalRoutes.zen.routerLink); resolve(false); return; } else if (state.url.startsWith(`/${publicRoutes.start.path}`)) { - if (user.settings.viewMode === 'ZEN') { + if (user?.settings?.viewMode === 'ZEN') { this.router.navigate(internalRoutes.zen.routerLink); } else { this.router.navigate(internalRoutes.home.routerLink); @@ -93,7 +98,7 @@ export class AuthGuard { return; } else if ( state.url.startsWith(`/${internalRoutes.zen.path}`) && - user.settings.viewMode === 'DEFAULT' + user?.settings?.viewMode === 'DEFAULT' ) { this.router.navigate(internalRoutes.home.routerLink); resolve(false); diff --git a/apps/client/src/app/core/auth.interceptor.ts b/apps/client/src/app/core/auth.interceptor.ts index 9c06a11d5d..b42c372be1 100644 --- a/apps/client/src/app/core/auth.interceptor.ts +++ b/apps/client/src/app/core/auth.interceptor.ts @@ -13,10 +13,10 @@ import { HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { inject, Injectable } from '@angular/core'; +import { inject, Service } from '@angular/core'; import { Observable } from 'rxjs'; -@Injectable() +@Service({ autoProvided: false }) export class AuthInterceptor implements HttpInterceptor { private readonly impersonationStorageService = inject( ImpersonationStorageService @@ -38,10 +38,13 @@ export class AuthInterceptor implements HttpInterceptor { return next.handle(request); } - let headers = request.headers.set( - HEADER_KEY_TIMEZONE, - Intl?.DateTimeFormat().resolvedOptions().timeZone - ); + let headers = request.headers; + + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + + if (timezone) { + headers = headers.set(HEADER_KEY_TIMEZONE, timezone); + } const token = this.tokenStorageService.getToken(); diff --git a/apps/client/src/app/core/http-response.interceptor.ts b/apps/client/src/app/core/http-response.interceptor.ts index 17927a9249..f5735fc115 100644 --- a/apps/client/src/app/core/http-response.interceptor.ts +++ b/apps/client/src/app/core/http-response.interceptor.ts @@ -1,5 +1,7 @@ +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; +import { HTTP_RESPONSE_MESSAGE_IMPERSONATION_UNRESOLVED } from '@ghostfolio/common/config'; import { InfoItem } from '@ghostfolio/common/interfaces'; import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes'; import { DataService } from '@ghostfolio/ui/services'; @@ -12,7 +14,7 @@ import { HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { inject, Injectable } from '@angular/core'; +import { inject, Service } from '@angular/core'; import { MatSnackBar, MatSnackBarRef, @@ -24,12 +26,15 @@ import ms from 'ms'; import { Observable, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; -@Injectable() +@Service({ autoProvided: false }) export class HttpResponseInterceptor implements HttpInterceptor { private readonly info: InfoItem; private snackBarRef: MatSnackBarRef | undefined; private readonly dataService = inject(DataService); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); private readonly router = inject(Router); private readonly snackBar = inject(MatSnackBar); private readonly userService = inject(UserService); @@ -46,6 +51,19 @@ export class HttpResponseInterceptor implements HttpInterceptor { return next.handle(request).pipe( catchError((error: HttpErrorResponse) => { if (error.status === StatusCodes.FORBIDDEN) { + if ( + error.error?.message === + HTTP_RESPONSE_MESSAGE_IMPERSONATION_UNRESOLVED + ) { + // A stale identifier fails every guarded request, hence it is + // removed to make the application usable again + this.impersonationStorageService.removeId(); + + window.location.reload(); + + return throwError(error); + } + if (!this.snackBarRef) { if (this.info.isReadOnlyMode) { this.snackBarRef = this.snackBar.open( @@ -98,15 +116,23 @@ export class HttpResponseInterceptor implements HttpInterceptor { }); } } else if (error.status === StatusCodes.TOO_MANY_REQUESTS) { - if (!this.snackBarRef) { - this.snackBarRef = this.snackBar.open( - $localize`Oops! It looks like you’re making too many requests. Please slow down a bit.` - ); + // Replace an already visible snack bar so that the rate limiting + // feedback is not swallowed + const snackBarRef = this.snackBar.open( + $localize`Oops! It looks like you’re making too many requests. Please slow down a bit.`, + undefined, + { + duration: ms('6 seconds') + } + ); - this.snackBarRef?.afterDismissed().subscribe(() => { + snackBarRef.afterDismissed().subscribe(() => { + if (this.snackBarRef === snackBarRef) { this.snackBarRef = undefined; - }); - } + } + }); + + this.snackBarRef = snackBarRef; } else if (error.status === StatusCodes.UNAUTHORIZED) { if (!error.url?.includes('/data-providers/ghostfolio/status')) { if (this.webAuthnService.isEnabled()) { diff --git a/apps/client/src/app/core/language.service.ts b/apps/client/src/app/core/language.service.ts deleted file mode 100644 index ebd0e21dc8..0000000000 --- a/apps/client/src/app/core/language.service.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable() -export class LanguageService {} diff --git a/apps/client/src/app/core/layout.service.ts b/apps/client/src/app/core/layout.service.ts index 2624c4dd6a..afb7161d62 100644 --- a/apps/client/src/app/core/layout.service.ts +++ b/apps/client/src/app/core/layout.service.ts @@ -1,24 +1,22 @@ import { NotificationService } from '@ghostfolio/ui/notifications'; -import { Injectable } from '@angular/core'; +import { inject, Service } from '@angular/core'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Observable, Subject } from 'rxjs'; -@Injectable({ - providedIn: 'root' -}) +@Service() export class LayoutService { public static readonly DEFAULT_NOTIFICATION_MAX_WIDTH = '50rem'; public static readonly DEFAULT_NOTIFICATION_WIDTH = '75vw'; - public shouldReloadContent$: Observable; + public readonly shouldReloadContent$: Observable; - private shouldReloadSubject = new Subject(); + private readonly shouldReloadSubject = new Subject(); - public constructor( - private deviceDetectorService: DeviceDetectorService, - private notificationService: NotificationService - ) { + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly notificationService = inject(NotificationService); + + public constructor() { this.shouldReloadContent$ = this.shouldReloadSubject.asObservable(); const deviceType = this.deviceDetectorService.getDeviceInfo().deviceType; diff --git a/apps/client/src/app/core/module-preload.service.ts b/apps/client/src/app/core/module-preload.service.ts index 85d9c5e33c..4f9290eded 100644 --- a/apps/client/src/app/core/module-preload.service.ts +++ b/apps/client/src/app/core/module-preload.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from '@angular/core'; +import { Service } from '@angular/core'; import { PreloadingStrategy, Route } from '@angular/router'; import { Observable, of } from 'rxjs'; -@Injectable() +@Service({ autoProvided: false }) export class ModulePreloadService implements PreloadingStrategy { /** * Preloads all lazy loading modules with the attribute 'preload' set to true diff --git a/apps/client/src/app/directives/file-drop/file-drop.directive.ts b/apps/client/src/app/directives/file-drop/file-drop.directive.ts deleted file mode 100644 index b46357005c..0000000000 --- a/apps/client/src/app/directives/file-drop/file-drop.directive.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Directive, output } from '@angular/core'; - -@Directive({ - host: { - '(dragenter)': 'onDragEnter($event)', - '(dragover)': 'onDragOver($event)', - '(drop)': 'onDrop($event)' - }, - selector: '[gfFileDrop]' -}) -export class GfFileDropDirective { - public readonly filesDropped = output(); - - public onDragEnter(event: DragEvent) { - event.preventDefault(); - event.stopPropagation(); - } - - public onDragOver(event: DragEvent) { - event.preventDefault(); - event.stopPropagation(); - } - - public onDrop(event: DragEvent) { - event.preventDefault(); - event.stopPropagation(); - - if (event.dataTransfer) { - // Prevent the browser's default behavior for handling the file drop - event.dataTransfer.dropEffect = 'copy'; - this.filesDropped.emit(event.dataTransfer.files); - } - } -} diff --git a/apps/client/src/app/interfaces/interfaces.ts b/apps/client/src/app/interfaces/interfaces.ts index 493eff4ab4..191fb42290 100644 --- a/apps/client/src/app/interfaces/interfaces.ts +++ b/apps/client/src/app/interfaces/interfaces.ts @@ -1,5 +1,6 @@ +import type { DataSource } from '@ghostfolio/prisma/enums'; + import type { Params } from '@angular/router'; -import type { DataSource } from '@prisma/client'; export interface GfAppQueryParams extends Params { dataSource?: DataSource; diff --git a/apps/client/src/app/pages/about/about-page.component.ts b/apps/client/src/app/pages/about/about-page.component.ts index 616977d806..615c0897d8 100644 --- a/apps/client/src/app/pages/about/about-page.component.ts +++ b/apps/client/src/app/pages/about/about-page.component.ts @@ -8,7 +8,12 @@ import { } from '@ghostfolio/ui/page-tabs'; import { DataService } from '@ghostfolio/ui/services'; -import { ChangeDetectorRef, Component, DestroyRef } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + DestroyRef +} from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { addIcons } from 'ionicons'; import { @@ -21,6 +26,7 @@ import { } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPageTabsComponent], selector: 'gf-about-page', @@ -83,8 +89,6 @@ export class AboutPageComponent { }); this.user = state.user; - - this.changeDetectorRef.markForCheck(); } this.tabs.push({ @@ -92,6 +96,8 @@ export class AboutPageComponent { label: publicRoutes.about.subRoutes.ossFriends.title, routerLink: publicRoutes.about.subRoutes.ossFriends.routerLink }); + + this.changeDetectorRef.markForCheck(); }); addIcons({ diff --git a/apps/client/src/app/pages/about/changelog/changelog-page.component.ts b/apps/client/src/app/pages/about/changelog/changelog-page.component.ts index d7f583bd13..24265f2eff 100644 --- a/apps/client/src/app/pages/about/changelog/changelog-page.component.ts +++ b/apps/client/src/app/pages/about/changelog/changelog-page.component.ts @@ -1,8 +1,9 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MarkdownModule } from 'ngx-markdown'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [MarkdownModule, NgxSkeletonLoaderModule], selector: 'gf-changelog-page', styleUrls: ['./changelog-page.scss'], diff --git a/apps/client/src/app/pages/about/license/license-page.component.ts b/apps/client/src/app/pages/about/license/license-page.component.ts index d530d04180..80f4eb0c0a 100644 --- a/apps/client/src/app/pages/about/license/license-page.component.ts +++ b/apps/client/src/app/pages/about/license/license-page.component.ts @@ -1,7 +1,8 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MarkdownModule } from 'ngx-markdown'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [MarkdownModule], selector: 'gf-license-page', styleUrls: ['./license-page.scss'], diff --git a/apps/client/src/app/pages/about/oss-friends/oss-friends-page.component.ts b/apps/client/src/app/pages/about/oss-friends/oss-friends-page.component.ts index c2e500a529..cb2aa6b07a 100644 --- a/apps/client/src/app/pages/about/oss-friends/oss-friends-page.component.ts +++ b/apps/client/src/app/pages/about/oss-friends/oss-friends-page.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { IonIcon } from '@ionic/angular/standalone'; @@ -8,6 +8,7 @@ import { arrowForwardOutline } from 'ionicons/icons'; const ossFriends = require('../../../../assets/oss-friends.json'); @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [IonIcon, MatButtonModule, MatCardModule], selector: 'gf-oss-friends-page', styleUrls: ['./oss-friends-page.scss'], diff --git a/apps/client/src/app/pages/about/oss-friends/oss-friends-page.html b/apps/client/src/app/pages/about/oss-friends/oss-friends-page.html index 48985eaa3f..b53b5096d1 100644 --- a/apps/client/src/app/pages/about/oss-friends/oss-friends-page.html +++ b/apps/client/src/app/pages/about/oss-friends/oss-friends-page.html @@ -1,17 +1,17 @@
    -

    +

    Our OSS Friends - Discover other exciting Open Source Software projects

    @for (ossFriend of ossFriends; track ossFriend) { -
    +
    @@ -27,7 +27,7 @@ Visit {{ ossFriend.name }} + > 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 92a98598b9..5af3c48ecc 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 @@ -5,6 +5,7 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { DataService } from '@ghostfolio/ui/services'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, @@ -25,6 +26,7 @@ import { } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [IonIcon, MatButtonModule, RouterModule], schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-about-overview-page', @@ -68,9 +70,9 @@ export class GfAboutOverviewPageComponent implements OnInit { .subscribe((state) => { if (state?.user) { this.user = state.user; - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); } } 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 c28a63be2f..7b271426b4 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 @@ -16,6 +16,7 @@ >The source code is fully available as open source software @@ -49,6 +50,7 @@ >and is driven by the efforts of its contributorsSlack community, post to @ghostfolio_or start a discussion at   GitHubBuy me a coffee @if (hasPermissionForSubscription) { -
    + diff --git a/apps/client/src/app/pages/about/overview/about-overview-page.scss b/apps/client/src/app/pages/about/overview/about-overview-page.scss index 8b9853f3e2..07faaf7ad4 100644 --- a/apps/client/src/app/pages/about/overview/about-overview-page.scss +++ b/apps/client/src/app/pages/about/overview/about-overview-page.scss @@ -22,6 +22,10 @@ width: 10rem; } } + + .sponsor-logo-light { + display: none; + } } :host-context(.theme-dark) { @@ -33,4 +37,12 @@ opacity: 1; } } + + .sponsor-logo-dark { + display: none; + } + + .sponsor-logo-light { + display: inline; + } } diff --git a/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.component.ts b/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.component.ts index 50e4e3e2fb..cf205533a2 100644 --- a/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.component.ts +++ b/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.component.ts @@ -1,7 +1,8 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MarkdownModule } from 'ngx-markdown'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [MarkdownModule], selector: 'gf-privacy-policy-page', styleUrls: ['./privacy-policy-page.scss'], diff --git a/apps/client/src/app/pages/about/terms-of-service/terms-of-service-page.component.ts b/apps/client/src/app/pages/about/terms-of-service/terms-of-service-page.component.ts index 7899f0187d..77f29c07e7 100644 --- a/apps/client/src/app/pages/about/terms-of-service/terms-of-service-page.component.ts +++ b/apps/client/src/app/pages/about/terms-of-service/terms-of-service-page.component.ts @@ -1,7 +1,8 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MarkdownModule } from 'ngx-markdown'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, imports: [MarkdownModule], selector: 'gf-terms-of-service-page', styleUrls: ['./terms-of-service-page.scss'], diff --git a/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts b/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts new file mode 100644 index 0000000000..0cc9476e3b --- /dev/null +++ b/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts @@ -0,0 +1,381 @@ +import { GfAccountDetailDialogComponent } from '@ghostfolio/client/components/account-detail-dialog/account-detail-dialog.component'; +import { + AccountDetailDialogParams, + AccountDetailDialogResult +} from '@ghostfolio/client/components/account-detail-dialog/interfaces/interfaces'; +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { + CreateAccountDto, + TransferBalanceDto, + UpdateAccountDto +} from '@ghostfolio/common/dtos'; +import { AccountResponse, User } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { Scope, hasScope, scopes } from '@ghostfolio/common/scopes'; +import { AccountWithPlatform } from '@ghostfolio/common/types'; +import { NotificationService } from '@ghostfolio/ui/notifications'; +import { DataService } from '@ghostfolio/ui/services'; + +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + OnDestroy, + OnInit, + inject +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DeviceDetectorService } from 'ngx-device-detector'; +import { Observable, of, Subject } from 'rxjs'; +import { + distinctUntilChanged, + map, + switchMap, + takeUntil, + tap +} from 'rxjs/operators'; + +import { GfCreateOrUpdateAccountDialogComponent } from '../create-or-update-account-dialog/create-or-update-account-dialog.component'; +import { CreateOrUpdateAccountDialogParams } from '../create-or-update-account-dialog/interfaces/interfaces'; +import { TransferBalanceDialogParams } from '../transfer-balance/interfaces/interfaces'; +import { GfTransferBalanceDialogComponent } from '../transfer-balance/transfer-balance-dialog.component'; +import { AccountDialogMode } from './types/account-dialog-mode.type'; + +@Component({ + changeDetection: ChangeDetectionStrategy.OnPush, + selector: 'gf-account-dialog-host', + template: '' +}) +export class GfAccountDialogHostComponent implements OnDestroy, OnInit { + private dialogRef: MatDialogRef< + | GfAccountDetailDialogComponent + | GfCreateOrUpdateAccountDialogComponent + | GfTransferBalanceDialogComponent + >; + + private readonly deviceType = computed(() => { + return this.deviceDetectorService.deviceInfo().deviceType; + }); + + private readonly dialogClosed = new Subject(); + + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly deviceDetectorService = inject(DeviceDetectorService); + private readonly dialog = inject(MatDialog); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); + private readonly notificationService = inject(NotificationService); + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); + private readonly userService = inject(UserService); + + public ngOnInit() { + const mode = this.route.snapshot.data.mode as AccountDialogMode; + + // The router reuses this component when only the account id changes, so + // the parameters are observed instead of read from the snapshot once + this.route.paramMap + .pipe( + map((paramMap) => { + return paramMap.get('accountId'); + }), + distinctUntilChanged(), + tap(() => { + this.closeDialog(); + }), + switchMap((accountId) => { + const account$: Observable = + mode === 'update' && accountId + ? this.dataService.fetchAccount(accountId) + : of(undefined); + + return this.userService.get().pipe( + switchMap((user) => { + return account$.pipe( + map((account) => { + return { account, accountId, user }; + }) + ); + }) + ); + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe({ + error: () => { + this.navigateBack(); + }, + next: ({ account, accountId, user }) => { + if (mode === 'detail') { + this.openAccountDetailDialog({ accountId, user }); + + return; + } + + if (mode === 'transferCashBalance') { + const accounts = user?.accounts ?? []; + + if ( + accounts.length < 2 || + !hasPermission(user?.permissions, permissions.updateAccount) || + this.isWriteRestricted(user, scopes.accountUpdate) + ) { + this.navigateBack(); + + return; + } + + this.openTransferBalanceDialog({ accounts }); + + return; + } + + if (mode === 'update') { + if ( + !account || + !hasPermission(user?.permissions, permissions.updateAccount) || + this.isWriteRestricted(user, scopes.accountUpdate) + ) { + this.navigateBack(); + + return; + } + + const { balance, comment, currency, id, name, platformId, tags } = + account; + + this.openCreateOrUpdateAccountDialog({ + user, + account: { + balance, + comment, + currency, + id, + name, + platformId, + tags + }, + isUpdate: true + }); + + return; + } + + if ( + !hasPermission(user?.permissions, permissions.createAccount) || + this.isWriteRestricted(user, scopes.accountCreate) + ) { + this.navigateBack(); + + return; + } + + this.openCreateOrUpdateAccountDialog({ + user, + account: { + balance: 0, + comment: null, + currency: user?.settings?.baseCurrency ?? null, + id: null, + name: null, + platformId: null, + tags: [] + }, + isUpdate: false + }); + } + }); + } + + public ngOnDestroy() { + // The dialog lives in an overlay outside of this component, so it needs to + // be closed explicitly when leaving the route (for example via the browser + // navigation) + this.dialogRef?.close(); + + this.dialogClosed.complete(); + } + + private closeDialog() { + // Tear down the subscription of the dialog which is about to be replaced, + // so that its result is not mistaken for the user closing it + this.dialogClosed.next(); + + this.dialogRef?.close(); + } + + private isWriteRestricted(user: User, requiredScope: Scope) { + return ( + !hasScope(user?.scopes, requiredScope) || + !!user?.settings?.isRestrictedView + ); + } + + private navigateBack() { + void this.router.navigate(internalRoutes.accounts.routerLink); + } + + private openAccountDetailDialog({ + accountId, + user + }: { + accountId: string | null; + user: User; + }) { + if (!accountId) { + this.navigateBack(); + + return; + } + + const impersonationId = this.impersonationStorageService.getId(); + + const dialogRef = this.dialog.open< + GfAccountDetailDialogComponent, + AccountDetailDialogParams, + AccountDetailDialogResult + >(GfAccountDetailDialogComponent, { + autoFocus: false, + data: { + accountId, + impersonationId, + deviceType: this.deviceType(), + hasPermissionToCreateActivity: + !impersonationId && + hasPermission(user?.permissions, permissions.createActivity) && + !user?.settings?.isRestrictedView, + hasPermissionToUpdateActivity: + !impersonationId && + hasPermission(user?.permissions, permissions.updateActivity) && + !user?.settings?.isRestrictedView + }, + height: this.deviceType() === 'mobile' ? '98vh' : '80vh', + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((result) => { + if (result?.isNavigating) { + return; + } + + this.navigateBack(); + }); + } + + private openCreateOrUpdateAccountDialog({ + account, + isUpdate, + user + }: { + account: CreateOrUpdateAccountDialogParams['account']; + isUpdate: boolean; + user: User; + }) { + const dialogRef = this.dialog.open< + GfCreateOrUpdateAccountDialogComponent, + CreateOrUpdateAccountDialogParams, + CreateAccountDto | UpdateAccountDto | null + >(GfCreateOrUpdateAccountDialogComponent, { + data: { + account, + user + }, + height: this.deviceType() === 'mobile' ? '98vh' : '80vh', + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((result) => { + if (!result) { + this.navigateBack(); + + return; + } + + const request$: Observable = isUpdate + ? this.dataService.putAccount(result as UpdateAccountDto) + : this.dataService.postAccount(result as CreateAccountDto); + + request$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({ + error: () => { + this.navigateBack(); + }, + next: () => { + // Deliberately not bound to the destroy reference: navigating back + // destroys this component and the refreshed user is what makes the + // accounts page reload its data + this.userService.get(true).subscribe(); + + this.navigateBack(); + } + }); + }); + } + + private openTransferBalanceDialog({ + accounts + }: { + accounts: AccountWithPlatform[]; + }) { + const dialogRef = this.dialog.open< + GfTransferBalanceDialogComponent, + TransferBalanceDialogParams, + TransferBalanceDto | null + >(GfTransferBalanceDialogComponent, { + data: { + accounts + }, + width: this.deviceType() === 'mobile' ? '100vw' : '50rem' + }); + + this.dialogRef = dialogRef; + + dialogRef + .afterClosed() + .pipe(takeUntil(this.dialogClosed), takeUntilDestroyed(this.destroyRef)) + .subscribe((result) => { + if (!result) { + this.navigateBack(); + + return; + } + + this.dataService + .transferAccountBalance(result) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe({ + error: () => { + this.notificationService.alert({ + title: $localize`Oops, cash balance transfer has failed.` + }); + + this.navigateBack(); + }, + next: () => { + // Deliberately not bound to the destroy reference: navigating + // back destroys this component and the refreshed user is what + // makes the accounts page reload its data + this.userService.get(true).subscribe(); + + this.navigateBack(); + } + }); + }); + } +} diff --git a/apps/client/src/app/pages/accounts/account-dialog-host/types/account-dialog-mode.type.ts b/apps/client/src/app/pages/accounts/account-dialog-host/types/account-dialog-mode.type.ts new file mode 100644 index 0000000000..4cdf112a77 --- /dev/null +++ b/apps/client/src/app/pages/accounts/account-dialog-host/types/account-dialog-mode.type.ts @@ -0,0 +1,2 @@ +export type AccountDialogMode = + 'create' | 'detail' | 'transferCashBalance' | 'update'; diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts index cca1eda038..f731962a5e 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.component.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts @@ -1,39 +1,29 @@ -import { GfAccountDetailDialogComponent } from '@ghostfolio/client/components/account-detail-dialog/account-detail-dialog.component'; -import { AccountDetailDialogParams } from '@ghostfolio/client/components/account-detail-dialog/interfaces/interfaces'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; -import { - CreateAccountDto, - TransferBalanceDto, - UpdateAccountDto -} from '@ghostfolio/common/dtos'; -import { User } from '@ghostfolio/common/interfaces'; +import { DEFAULT_LOCALE } from '@ghostfolio/common/config'; +import { AccountsResponse, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; +import { hasScope, scopes } from '@ghostfolio/common/scopes'; +import { AccountWithValue } from '@ghostfolio/common/types'; import { GfAccountsTableComponent } from '@ghostfolio/ui/accounts-table'; import { GfFabComponent } from '@ghostfolio/ui/fab'; -import { NotificationService } from '@ghostfolio/ui/notifications'; import { DataService } from '@ghostfolio/ui/services'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, + inject, OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { MatDialog } from '@angular/material/dialog'; -import { ActivatedRoute, Router, RouterModule } from '@angular/router'; -import { Account as AccountModel } from '@prisma/client'; -import { DeviceDetectorService } from 'ngx-device-detector'; -import { EMPTY, Subscription } from 'rxjs'; -import { catchError } from 'rxjs/operators'; - -import { GfCreateOrUpdateAccountDialogComponent } from './create-or-update-account-dialog/create-or-update-account-dialog.component'; -import { CreateOrUpdateAccountDialogParams } from './create-or-update-account-dialog/interfaces/interfaces'; -import { TransferBalanceDialogParams } from './transfer-balance/interfaces/interfaces'; -import { GfTransferBalanceDialogComponent } from './transfer-balance/transfer-balance-dialog.component'; +import { Router, RouterModule } from '@angular/router'; +import { filter, switchMap, tap } from 'rxjs'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfAccountsTableComponent, GfFabComponent, RouterModule], selector: 'gf-accounts-page', @@ -41,58 +31,30 @@ import { GfTransferBalanceDialogComponent } from './transfer-balance/transfer-ba templateUrl: './accounts-page.html' }) export class GfAccountsPageComponent implements OnInit { - public accounts: AccountModel[]; - public activitiesCount = 0; - public deviceType: string; - public hasImpersonationId: boolean; - public hasPermissionToCreateAccount: boolean; - public hasPermissionToUpdateAccount: boolean; - public routeQueryParams: Subscription; - public totalBalanceInBaseCurrency = 0; - public totalValueInBaseCurrency = 0; - public user: User; - - public constructor( - private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService, - private destroyRef: DestroyRef, - private deviceDetectorService: DeviceDetectorService, - private dialog: MatDialog, - private impersonationStorageService: ImpersonationStorageService, - private notificationService: NotificationService, - private route: ActivatedRoute, - private router: Router, - private userService: UserService - ) { - this.route.queryParams - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((params) => { - if (params['accountId'] && params['accountDetailDialog']) { - this.openAccountDetailDialog(params['accountId']); - } else if ( - params['createDialog'] && - this.hasPermissionToCreateAccount - ) { - this.openCreateAccountDialog(); - } else if (params['editDialog']) { - if (this.accounts) { - const account = this.accounts.find(({ id }) => { - return id === params['accountId']; - }); - - this.openUpdateAccountDialog(account); - } else { - this.router.navigate(['.'], { relativeTo: this.route }); - } - } else if (params['transferBalanceDialog']) { - this.openTransferBalanceDialog(); - } - }); - } + protected readonly DEFAULT_LOCALE = DEFAULT_LOCALE; + + protected accounts: AccountWithValue[] | undefined; + protected activitiesCount = 0; + protected hasPermissionToCreateAccount: boolean; + protected hasPermissionToDeleteAccount: boolean; + protected hasPermissionToUpdateAccount: boolean; + protected readonly internalRoutes = internalRoutes; + protected totalBalanceInBaseCurrency = 0; + protected totalValueInBaseCurrency = 0; + protected user: User; + + private hasImpersonationId: boolean; + + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); + private readonly router = inject(Router); + private readonly userService = inject(UserService); public ngOnInit() { - this.deviceType = this.deviceDetectorService.getDeviceInfo().deviceType; - this.impersonationStorageService .onChangeHasImpersonation() .pipe(takeUntilDestroyed(this.destroyRef)) @@ -101,53 +63,38 @@ export class GfAccountsPageComponent implements OnInit { }); this.userService.stateChanged - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((state) => { - if (state?.user) { + .pipe( + filter((state) => { + return !!state?.user; + }), + tap((state) => { this.user = state.user; - this.hasPermissionToCreateAccount = hasPermission( - this.user.permissions, - permissions.createAccount - ); - this.hasPermissionToUpdateAccount = hasPermission( - this.user.permissions, - permissions.updateAccount - ); + this.hasPermissionToCreateAccount = + hasPermission(this.user.permissions, permissions.createAccount) && + hasScope(this.user.scopes, scopes.accountCreate); - this.changeDetectorRef.markForCheck(); - } - }); + this.hasPermissionToDeleteAccount = + hasPermission(this.user.permissions, permissions.deleteAccount) && + hasScope(this.user.scopes, scopes.accountDelete); - this.fetchAccounts(); - } + this.hasPermissionToUpdateAccount = + hasPermission(this.user.permissions, permissions.updateAccount) && + hasScope(this.user.scopes, scopes.accountUpdate); - public fetchAccounts() { - this.dataService - .fetchAccounts() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe( - ({ - accounts, - activitiesCount, - totalBalanceInBaseCurrency, - totalValueInBaseCurrency - }) => { - this.accounts = accounts; - this.activitiesCount = activitiesCount; - this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency; - this.totalValueInBaseCurrency = totalValueInBaseCurrency; - - if (this.accounts?.length <= 0) { - this.router.navigate([], { queryParams: { createDialog: true } }); - } + this.reset(); this.changeDetectorRef.markForCheck(); - } - ); + }), + switchMap(() => this.fetchAccounts()), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe((response) => { + this.updateAccounts(response); + }); } - public onDeleteAccount(aId: string) { + protected onDeleteAccount(aId: string) { this.reset(); this.dataService @@ -158,204 +105,43 @@ export class GfAccountsPageComponent implements OnInit { .get(true) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(); - - this.fetchAccounts(); }); } - public onTransferBalance() { - this.router.navigate([], { - queryParams: { transferBalanceDialog: true } + private fetchAccounts() { + return this.dataService.fetchAccounts({ + filters: this.userService.getFilters() }); } - public onUpdateAccount(aAccount: AccountModel) { - this.router.navigate([], { - queryParams: { accountId: aAccount.id, editDialog: true } - }); - } - - public openUpdateAccountDialog({ - balance, - comment, - currency, - id, - isExcluded, - name, - platformId - }: AccountModel) { - const dialogRef = this.dialog.open< - GfCreateOrUpdateAccountDialogComponent, - CreateOrUpdateAccountDialogParams - >(GfCreateOrUpdateAccountDialogComponent, { - data: { - account: { - balance, - comment, - currency, - id, - isExcluded, - name, - platformId - } - }, - height: this.deviceType === 'mobile' ? '98vh' : '80vh', - width: this.deviceType === 'mobile' ? '100vw' : '50rem' - }); - - dialogRef - .afterClosed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((account: UpdateAccountDto | null) => { - if (account) { - this.reset(); - - this.dataService - .putAccount(account) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - this.userService - .get(true) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(); - - this.fetchAccounts(); - }); - - this.changeDetectorRef.markForCheck(); - } - - this.router.navigate(['.'], { relativeTo: this.route }); - }); - } - - private openAccountDetailDialog(aAccountId: string) { - const dialogRef = this.dialog.open< - GfAccountDetailDialogComponent, - AccountDetailDialogParams - >(GfAccountDetailDialogComponent, { - autoFocus: false, - data: { - accountId: aAccountId, - deviceType: this.deviceType, - hasImpersonationId: this.hasImpersonationId, - hasPermissionToCreateActivity: - !this.hasImpersonationId && - hasPermission(this.user?.permissions, permissions.createActivity) && - !this.user?.settings?.isRestrictedView - }, - height: this.deviceType === 'mobile' ? '98vh' : '80vh', - width: this.deviceType === 'mobile' ? '100vw' : '50rem' - }); - - dialogRef - .afterClosed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - this.fetchAccounts(); - - this.router.navigate(['.'], { relativeTo: this.route }); - }); - } - - private openCreateAccountDialog() { - const dialogRef = this.dialog.open< - GfCreateOrUpdateAccountDialogComponent, - CreateOrUpdateAccountDialogParams - >(GfCreateOrUpdateAccountDialogComponent, { - data: { - account: { - balance: 0, - comment: null, - currency: this.user?.settings?.baseCurrency, - id: null, - isExcluded: false, - name: null, - platformId: null - } - }, - height: this.deviceType === 'mobile' ? '98vh' : '80vh', - width: this.deviceType === 'mobile' ? '100vw' : '50rem' - }); - - dialogRef - .afterClosed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((account: CreateAccountDto | null) => { - if (account) { - this.reset(); - - this.dataService - .postAccount(account) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - this.userService - .get(true) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(); - - this.fetchAccounts(); - }); - - this.changeDetectorRef.markForCheck(); - } - - this.router.navigate(['.'], { relativeTo: this.route }); - }); - } - - private openTransferBalanceDialog() { - const dialogRef = this.dialog.open< - GfTransferBalanceDialogComponent, - TransferBalanceDialogParams - >(GfTransferBalanceDialogComponent, { - data: { - accounts: this.accounts - }, - width: this.deviceType === 'mobile' ? '100vw' : '50rem' - }); - - dialogRef - .afterClosed() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((data: any) => { - if (data) { - this.reset(); - - const { accountIdFrom, accountIdTo, balance }: TransferBalanceDto = - data?.account; - - this.dataService - .transferAccountBalance({ - accountIdFrom, - accountIdTo, - balance - }) - .pipe( - catchError(() => { - this.notificationService.alert({ - title: $localize`Oops, cash balance transfer has failed.` - }); - - return EMPTY; - }), - takeUntilDestroyed(this.destroyRef) - ) - .subscribe(() => { - this.fetchAccounts(); - }); - - this.changeDetectorRef.markForCheck(); - } - - this.router.navigate(['.'], { relativeTo: this.route }); - }); - } - private reset() { this.accounts = undefined; this.activitiesCount = 0; this.totalBalanceInBaseCurrency = 0; this.totalValueInBaseCurrency = 0; } + + private updateAccounts({ + accounts, + activitiesCount, + totalBalanceInBaseCurrency, + totalValueInBaseCurrency + }: AccountsResponse) { + this.accounts = accounts; + this.activitiesCount = activitiesCount; + this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency; + this.totalValueInBaseCurrency = totalValueInBaseCurrency; + + if ( + !this.hasImpersonationId && + this.hasPermissionToCreateAccount && + this.user?.accounts?.length === 0 + ) { + void this.router.navigate( + internalRoutes.accounts.subRoutes.create.routerLink + ); + } + + this.changeDetectorRef.markForCheck(); + } } diff --git a/apps/client/src/app/pages/accounts/accounts-page.html b/apps/client/src/app/pages/accounts/accounts-page.html index 1bdedbbb93..a9a344ce70 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.html +++ b/apps/client/src/app/pages/accounts/accounts-page.html @@ -6,26 +6,25 @@ [accounts]="accounts" [activitiesCount]="activitiesCount" [baseCurrency]="user?.settings?.baseCurrency" - [locale]="user?.settings?.locale" + [hasPermissionToDeleteAccount]="hasPermissionToDeleteAccount" + [hasPermissionToUpdateAccount]="hasPermissionToUpdateAccount" + [locale]="user?.settings?.locale ?? DEFAULT_LOCALE" [showActions]=" - !hasImpersonationId && - hasPermissionToUpdateAccount && + (hasPermissionToDeleteAccount || hasPermissionToUpdateAccount) && !user.settings.isRestrictedView " [totalBalanceInBaseCurrency]="totalBalanceInBaseCurrency" [totalValueInBaseCurrency]="totalValueInBaseCurrency" (accountDeleted)="onDeleteAccount($event)" - (accountToUpdate)="onUpdateAccount($event)" - (transferBalance)="onTransferBalance()" />
    - @if ( - !hasImpersonationId && - hasPermissionToCreateAccount && - !user.settings.isRestrictedView - ) { - + @if (hasPermissionToCreateAccount && !user.settings.isRestrictedView) { + }
    + + diff --git a/apps/client/src/app/pages/accounts/accounts-page.routes.ts b/apps/client/src/app/pages/accounts/accounts-page.routes.ts index e4edc39c14..74ebb3a775 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.routes.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.routes.ts @@ -3,11 +3,46 @@ import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { Routes } from '@angular/router'; +import { GfAccountDialogHostComponent } from './account-dialog-host/account-dialog-host.component'; import { GfAccountsPageComponent } from './accounts-page.component'; +const { create, detail, transferCashBalance, update } = + internalRoutes.accounts.subRoutes; + export const routes: Routes = [ { canActivate: [AuthGuard], + children: [ + { + component: GfAccountDialogHostComponent, + data: { mode: 'create' }, + path: create.path, + title: create.title + }, + { + component: GfAccountDialogHostComponent, + data: { mode: 'transferCashBalance' }, + path: transferCashBalance.path, + title: transferCashBalance.title + }, + { + children: [ + { + component: GfAccountDialogHostComponent, + data: { mode: 'detail' }, + path: '', + title: detail.title + }, + { + component: GfAccountDialogHostComponent, + data: { mode: 'update' }, + path: update.path, + title: update.title + } + ], + path: ':accountId' + } + ], component: GfAccountsPageComponent, path: '', title: internalRoutes.accounts.title diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts index 8319999eb9..12f9075247 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts @@ -1,11 +1,28 @@ +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; +import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { + COMMENT_MAXIMUM_LENGTH, + TAG_ID_DRAFT +} from '@ghostfolio/common/config'; import { CreateAccountDto, UpdateAccountDto } from '@ghostfolio/common/dtos'; +import { getStringOrNull } from '@ghostfolio/common/helper'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { validateObjectForForm } from '@ghostfolio/common/utils'; +import type { Platform, Tag } from '@ghostfolio/prisma/browser'; import { GfCurrencySelectorComponent } from '@ghostfolio/ui/currency-selector'; import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo'; +import { translate } from '@ghostfolio/ui/i18n'; import { DataService } from '@ghostfolio/ui/services'; +import { GfTagsSelectorComponent } from '@ghostfolio/ui/tags-selector'; import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + inject +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { AbstractControl, FormBuilder, @@ -16,7 +33,6 @@ import { } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatButtonModule } from '@angular/material/button'; -import { MatCheckboxModule } from '@angular/material/checkbox'; import { MAT_DIALOG_DATA, MatDialogModule, @@ -24,7 +40,6 @@ import { } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; -import { Platform } from '@prisma/client'; import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; @@ -37,9 +52,9 @@ import { CreateOrUpdateAccountDialogParams } from './interfaces/interfaces'; CommonModule, GfCurrencySelectorComponent, GfEntityLogoComponent, + GfTagsSelectorComponent, MatAutocompleteModule, MatButtonModule, - MatCheckboxModule, MatDialogModule, MatFormFieldModule, MatInputModule, @@ -50,32 +65,105 @@ import { CreateOrUpdateAccountDialogParams } from './interfaces/interfaces'; templateUrl: 'create-or-update-account-dialog.html' }) export class GfCreateOrUpdateAccountDialogComponent { + protected readonly COMMENT_MAXIMUM_LENGTH = COMMENT_MAXIMUM_LENGTH; + protected accountForm: FormGroup; protected currencies: string[] = []; protected filteredPlatforms: Observable | undefined; + protected hasPermissionToCreateOwnTag: boolean; protected platforms: Platform[] = []; + protected tagsAvailable: Tag[] = []; protected readonly data = inject(MAT_DIALOG_DATA); private readonly dataService = inject(DataService); + private readonly destroyRef = inject(DestroyRef); private readonly dialogRef = inject>(MatDialogRef); private readonly formBuilder = inject(FormBuilder); + private readonly impersonationStorageService = inject( + ImpersonationStorageService + ); + private readonly userService = inject(UserService); + + protected get selectedPlatform() { + const platform = this.accountForm.get('platformId')?.value; + + return typeof platform === 'string' ? undefined : (platform as Platform); + } public ngOnInit() { const { currencies } = this.dataService.fetchInfo(); this.currencies = currencies; + // A tag created during an impersonation belongs to the authenticated user, + // hence it cannot be assigned to the data of the impersonated user + this.hasPermissionToCreateOwnTag = + !this.impersonationStorageService.getId() && + hasPermission(this.data.user?.permissions, permissions.createOwnTag); + + this.tagsAvailable = + this.data.user?.tags + ?.filter(({ id }) => { + // The "DRAFT" tag qualifies an individual activity and cannot be + // assigned to an account + return id !== TAG_ID_DRAFT; + }) + .map((tag) => { + return { + ...tag, + name: translate(tag.name) + }; + }) ?? []; + this.accountForm = this.formBuilder.group({ accountId: [{ disabled: true, value: this.data.account.id }], balance: [this.data.account.balance, Validators.required], comment: [this.data.account.comment], currency: [this.data.account.currency, Validators.required], - isExcluded: [this.data.account.isExcluded], name: [this.data.account.name, Validators.required], - platformId: [null, this.autocompleteObjectValidator()] + platformId: [null, this.autocompleteObjectValidator()], + tags: [ + this.data.account.tags?.map(({ id, name }) => { + return { + id, + name: translate(name) + }; + }) + ] }); + this.accountForm + .get('tags') + ?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((tags: Tag[]) => { + const newTag = tags.find(({ id }) => { + return id === undefined; + }); + + if (newTag && this.hasPermissionToCreateOwnTag) { + this.dataService + .postTag({ ...newTag, userId: this.data.user.id }) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((tag) => { + this.accountForm.get('tags')?.setValue( + tags.map((currentTag) => { + if (currentTag.id === undefined) { + return tag; + } + + return currentTag; + }) + ); + + this.userService + .get(true) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(); + }); + } + }); + this.dataService.fetchPlatforms().subscribe(({ platforms }) => { this.platforms = platforms; @@ -127,12 +215,20 @@ export class GfCreateOrUpdateAccountDialogComponent { protected async onSubmit() { const account: CreateAccountDto | UpdateAccountDto = { balance: this.accountForm.get('balance')?.value, - comment: this.accountForm.get('comment')?.value || null, + comment: getStringOrNull(this.accountForm.get('comment')?.value), currency: this.accountForm.get('currency')?.value, id: this.accountForm.get('accountId')?.value, - isExcluded: this.accountForm.get('isExcluded')?.value, name: this.accountForm.get('name')?.value, - platformId: this.accountForm.get('platformId')?.value?.id || null + platformId: this.accountForm.get('platformId')?.value?.id ?? null, + tags: this.accountForm + .get('tags') + ?.value?.filter(({ id }: Tag) => { + // Skip tags which have not been created yet + return !!id; + }) + .map(({ id }: Tag) => { + return id; + }) }; try { diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html index c90c9c4406..46b8fcc8f2 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html @@ -38,14 +38,23 @@ type="number" (keydown.enter)="$event.stopPropagation()" /> - {{ + {{ accountForm.get('currency')?.value }}
    -
    +
    Platform + @if (selectedPlatform) { + + } {{ platformEntry.name }} @@ -81,14 +91,17 @@ cdkTextareaAutosize formControlName="comment" matInput + [maxlength]="COMMENT_MAXIMUM_LENGTH" (keyup.enter)="$event.stopPropagation()" >
    -
    - Exclude from Analysis +
    +
    @if (data.account.id) {
    diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/interfaces/interfaces.ts b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/interfaces/interfaces.ts index a3e6272f86..c99cd17b7a 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/interfaces/interfaces.ts @@ -1,5 +1,14 @@ -import { Account } from '@prisma/client'; +import { User } from '@ghostfolio/common/interfaces'; +import { AccountWithBalance } from '@ghostfolio/common/types'; +import type { Tag } from '@ghostfolio/prisma/browser'; export interface CreateOrUpdateAccountDialogParams { - account: Omit; + account: Omit< + AccountWithBalance, + 'createdAt' | 'id' | 'updatedAt' | 'userId' + > & { + id: string | null; + tags?: Tag[]; + }; + user: User; } diff --git a/apps/client/src/app/pages/accounts/transfer-balance/interfaces/interfaces.ts b/apps/client/src/app/pages/accounts/transfer-balance/interfaces/interfaces.ts index 3a0b921fd1..53f8f522e5 100644 --- a/apps/client/src/app/pages/accounts/transfer-balance/interfaces/interfaces.ts +++ b/apps/client/src/app/pages/accounts/transfer-balance/interfaces/interfaces.ts @@ -1,5 +1,13 @@ -import { Account } from '@prisma/client'; +import { AccountWithPlatform } from '@ghostfolio/common/types'; + +import { FormControl, FormGroup } from '@angular/forms'; export interface TransferBalanceDialogParams { - accounts: Account[]; + accounts: AccountWithPlatform[]; } + +export type TransferBalanceForm = FormGroup<{ + balance: FormControl; + fromAccount: FormControl; + toAccount: FormControl; +}>; diff --git a/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts b/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts index 34a66b156a..cdfa7181c4 100644 --- a/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts +++ b/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts @@ -1,13 +1,18 @@ import { TransferBalanceDto } from '@ghostfolio/common/dtos'; -import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo'; +import { AccountWithPlatform } from '@ghostfolio/common/types'; +import { GfAccountSelectorComponent } from '@ghostfolio/ui/account-selector'; -import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; import { - AbstractControl, - FormBuilder, + ChangeDetectionStrategy, + Component, + computed, + inject, + signal +} from '@angular/core'; +import { + FormControl, FormGroup, ReactiveFormsModule, - ValidationErrors, Validators } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; @@ -18,21 +23,21 @@ import { } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; -import { MatSelectModule } from '@angular/material/select'; -import { Account } from '@prisma/client'; -import { TransferBalanceDialogParams } from './interfaces/interfaces'; +import { + TransferBalanceDialogParams, + TransferBalanceForm +} from './interfaces/interfaces'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'h-100' }, imports: [ - GfEntityLogoComponent, + GfAccountSelectorComponent, MatButtonModule, MatDialogModule, MatFormFieldModule, MatInputModule, - MatSelectModule, ReactiveFormsModule ], selector: 'gf-transfer-balance-dialog', @@ -40,57 +45,72 @@ import { TransferBalanceDialogParams } from './interfaces/interfaces'; templateUrl: 'transfer-balance-dialog.html' }) export class GfTransferBalanceDialogComponent { - public accounts: Account[] = []; - public currency: string; - public transferBalanceForm: FormGroup; + protected readonly accounts: AccountWithPlatform[] = + inject(MAT_DIALOG_DATA).accounts; + + protected currency: string; + + protected readonly labelFrom = $localize`From`; + protected readonly labelTo = $localize`To`; + + protected readonly toAccounts = computed(() => { + const fromAccountId = this.fromAccountId(); + + return this.accounts.filter(({ id }) => { + return id !== fromAccountId; + }); + }); + + protected readonly transferBalanceForm: TransferBalanceForm = new FormGroup({ + balance: new FormControl('', Validators.required), + fromAccount: new FormControl(null, Validators.required), + toAccount: new FormControl(null, Validators.required) + }); + + private readonly dialogRef = + inject>(MatDialogRef); - public constructor( - @Inject(MAT_DIALOG_DATA) public data: TransferBalanceDialogParams, - public dialogRef: MatDialogRef, - private formBuilder: FormBuilder - ) {} + private readonly fromAccountId = signal(null); public ngOnInit() { - this.accounts = this.data.accounts; - - this.transferBalanceForm = this.formBuilder.group( - { - balance: ['', Validators.required], - fromAccount: ['', Validators.required], - toAccount: ['', Validators.required] - }, - { - validators: this.compareAccounts + this.transferBalanceForm.controls.fromAccount.valueChanges.subscribe( + (id) => { + this.fromAccountId.set(id); + + const currency = this.getAccountById(id)?.currency; + + if (currency) { + this.currency = currency; + } + + const toAccountControl = this.transferBalanceForm.controls.toAccount; + + if (id && toAccountControl.value === id) { + toAccountControl.setValue(null); + toAccountControl.markAsPristine(); + toAccountControl.markAsUntouched(); + } } ); - - this.transferBalanceForm.get('fromAccount').valueChanges.subscribe((id) => { - this.currency = this.accounts.find((account) => { - return account.id === id; - }).currency; - }); } - public onCancel() { + protected onCancel() { this.dialogRef.close(); } - public onSubmit() { - const account: TransferBalanceDto = { - accountIdFrom: this.transferBalanceForm.get('fromAccount').value, - accountIdTo: this.transferBalanceForm.get('toAccount').value, - balance: this.transferBalanceForm.get('balance').value + protected onSubmit() { + const transferBalance: TransferBalanceDto = { + accountIdFrom: this.transferBalanceForm.controls.fromAccount.value ?? '', + accountIdTo: this.transferBalanceForm.controls.toAccount.value ?? '', + balance: Number(this.transferBalanceForm.controls.balance.value) }; - this.dialogRef.close({ account }); + this.dialogRef.close(transferBalance); } - private compareAccounts(control: AbstractControl): ValidationErrors { - const accountFrom = control.get('fromAccount'); - const accountTo = control.get('toAccount'); - - if (accountFrom.value === accountTo.value) { - return { invalid: true }; - } + private getAccountById(aId: string | null) { + return this.accounts.find(({ id }) => { + return id === aId; + }); } } diff --git a/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.html b/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.html index 50c96be860..11d7eaedcc 100644 --- a/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.html +++ b/apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.html @@ -7,46 +7,18 @@

    Transfer Cash Balance

    - - From - - @for (account of accounts; track account) { - -
    - @if (account.platform?.url) { - - } - {{ account.name }} -
    -
    - } -
    -
    +
    - - To - - @for (account of accounts; track account) { - -
    - @if (account.platform?.url) { - - } - {{ account.name }} -
    -
    - } -
    -
    +
    @@ -57,7 +29,7 @@ type="number" (keydown.enter)="$event.stopPropagation()" /> - {{ currency }} + {{ currency }}
    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 c5da0fb0c9..15957d346f 100644 --- a/apps/client/src/app/pages/admin/admin-page.component.ts +++ b/apps/client/src/app/pages/admin/admin-page.component.ts @@ -12,7 +12,12 @@ import { TabConfiguration } from '@ghostfolio/ui/page-tabs'; -import { Component, inject } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + inject +} from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { addIcons } from 'ionicons'; import { @@ -24,6 +29,7 @@ import { } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPageTabsComponent], selector: 'gf-admin-page', @@ -35,6 +41,7 @@ export class AdminPageComponent { private user: User; + private readonly changeDetectorRef = inject(ChangeDetectorRef); private readonly tokenStorageService = inject(TokenStorageService); private readonly userService = inject(UserService); @@ -45,6 +52,8 @@ export class AdminPageComponent { this.user = state?.user; this.initializeTabs(); + + this.changeDetectorRef.markForCheck(); }); addIcons({ @@ -103,7 +112,7 @@ export class AdminPageComponent { const token = this.tokenStorageService.getToken(); document.cookie = [ - `${BULL_BOARD_COOKIE_NAME}=${encodeURIComponent(token)}`, + `${BULL_BOARD_COOKIE_NAME}=${encodeURIComponent(token ?? '')}`, 'path=/', 'SameSite=Strict' ].join('; '); diff --git a/apps/client/src/app/pages/admin/admin-page.routes.ts b/apps/client/src/app/pages/admin/admin-page.routes.ts index c5309edbbe..8e480d3fd0 100644 --- a/apps/client/src/app/pages/admin/admin-page.routes.ts +++ b/apps/client/src/app/pages/admin/admin-page.routes.ts @@ -1,15 +1,40 @@ import { GfAdminJobsComponent } from '@ghostfolio/client/components/admin-jobs/admin-jobs.component'; import { GfAdminMarketDataComponent } from '@ghostfolio/client/components/admin-market-data/admin-market-data.component'; +import { GfAssetProfileDialogHostComponent } from '@ghostfolio/client/components/admin-market-data/asset-profile-dialog-host/asset-profile-dialog-host.component'; import { GfAdminOverviewComponent } from '@ghostfolio/client/components/admin-overview/admin-overview.component'; import { GfAdminSettingsComponent } from '@ghostfolio/client/components/admin-settings/admin-settings.component'; import { GfAdminUsersComponent } from '@ghostfolio/client/components/admin-users/admin-users.component'; import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; -import { Routes } from '@angular/router'; +import { Routes, UrlMatcher, UrlSegment } from '@angular/router'; import { AdminPageComponent } from './admin-page.component'; +const { create, update } = + internalRoutes.adminControl.subRoutes.marketData.subRoutes; + +// Matches both the users list and the user detail dialog route within a single +// route configuration so that the component is reused (and not re-created) when +// the user detail dialog is opened or closed +const usersMatcher: UrlMatcher = (segments: UrlSegment[]) => { + if ( + segments[0]?.path !== internalRoutes.adminControl.subRoutes.users.path || + segments.length > 2 + ) { + return null; + } + + if (segments.length === 2) { + return { + consumed: segments, + posParams: { userId: segments[1] } + }; + } + + return { consumed: segments }; +}; + export const routes: Routes = [ { canActivate: [AuthGuard], @@ -25,8 +50,27 @@ export const routes: Routes = [ title: internalRoutes.adminControl.subRoutes.jobs.title }, { - path: internalRoutes.adminControl.subRoutes.marketData.path, + children: [ + { + component: GfAssetProfileDialogHostComponent, + data: { mode: 'create' }, + path: create.path, + title: create.title + }, + { + children: [ + { + component: GfAssetProfileDialogHostComponent, + data: { mode: 'update' }, + path: update.path, + title: update.title + } + ], + path: ':dataSource/:symbol' + } + ], component: GfAdminMarketDataComponent, + path: internalRoutes.adminControl.subRoutes.marketData.path, title: internalRoutes.adminControl.subRoutes.marketData.title }, { @@ -35,13 +79,8 @@ export const routes: Routes = [ title: internalRoutes.adminControl.subRoutes.settings.title }, { - path: internalRoutes.adminControl.subRoutes.users.path, - component: GfAdminUsersComponent, - title: internalRoutes.adminControl.subRoutes.users.title - }, - { - path: `${internalRoutes.adminControl.subRoutes.users.path}/:userId`, component: GfAdminUsersComponent, + matcher: usersMatcher, title: internalRoutes.adminControl.subRoutes.users.title } ], diff --git a/apps/client/src/app/pages/api/api-page.component.ts b/apps/client/src/app/pages/api/api-page.component.ts index e75a51c733..6bdd8ba30f 100644 --- a/apps/client/src/app/pages/api/api-page.component.ts +++ b/apps/client/src/app/pages/api/api-page.component.ts @@ -1,3 +1,4 @@ +import { UserService } from '@ghostfolio/client/services/user/user.service'; import { HEADER_KEY_SKIP_INTERCEPTOR, HEADER_KEY_TOKEN @@ -10,8 +11,11 @@ import { DividendsResponse, HistoricalResponse, LookupResponse, + MarketDataOfMarketsResponse, QuotesResponse } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { GfFearAndGreedIndexComponent } from '@ghostfolio/ui/fear-and-greed-index'; import { CommonModule } from '@angular/common'; import { @@ -20,46 +24,77 @@ import { HttpHeaders, HttpParams } from '@angular/common/http'; -import { Component, DestroyRef, OnInit } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + DestroyRef, + inject, + OnInit +} from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatCardModule } from '@angular/material/card'; import { format, startOfYear } from 'date-fns'; -import { isObject } from 'lodash'; +import { isObject } from 'lodash-es'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { catchError, map, Observable, of, OperatorFunction } from 'rxjs'; import { FetchFailure, FetchResult } from './interfaces/interfaces'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, - imports: [CommonModule, MatCardModule, NgxSkeletonLoaderModule], + imports: [ + CommonModule, + GfFearAndGreedIndexComponent, + MatCardModule, + NgxSkeletonLoaderModule + ], selector: 'gf-api-page', styleUrls: ['./api-page.scss'], templateUrl: './api-page.html' }) export class GfApiPageComponent implements OnInit { - public aiServiceHealth$: Observable>; - public assetProfile$: Observable< + protected aiServiceHealth$: Observable>; + protected assetProfile$: Observable< FetchResult >; - public dividends$: Observable>; - public historicalData$: Observable< + protected dividends$: Observable>; + protected hasPermissionToAccessAdminControl: boolean; + protected historicalData$: Observable< FetchResult >; - public isinLookupItems$: Observable>; - public lookupItems$: Observable>; - public quotes$: Observable>; - public status$: Observable>; + protected isinLookupItems$: Observable>; + protected lookupItems$: Observable>; + protected marketDataOfMarkets$: Observable< + FetchResult + >; + protected quotes$: Observable>; + protected status$: Observable< + FetchResult + >; private apiKey: string; - public constructor( - private destroyRef: DestroyRef, - private http: HttpClient - ) {} + private readonly changeDetectorRef = inject(ChangeDetectorRef); + private readonly destroyRef = inject(DestroyRef); + private readonly http = inject(HttpClient); + private readonly userService = inject(UserService); public ngOnInit() { - this.apiKey = prompt($localize`Please enter your Ghostfolio API key:`); + this.apiKey = + prompt($localize`Please enter your Ghostfolio API key:`) ?? ''; + + this.userService.stateChanged + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((state) => { + this.hasPermissionToAccessAdminControl = hasPermission( + state?.user?.permissions, + permissions.accessAdminControl + ); + + this.changeDetectorRef.markForCheck(); + }); this.aiServiceHealth$ = this.fetchAiServiceHealth(); this.assetProfile$ = this.fetchAssetProfile({ symbol: 'AAPL' }); @@ -67,11 +102,12 @@ export class GfApiPageComponent implements OnInit { this.historicalData$ = this.fetchHistoricalData({ symbol: 'AAPL' }); this.isinLookupItems$ = this.fetchLookupItems({ query: 'US0378331005' }); this.lookupItems$ = this.fetchLookupItems({ query: 'apple' }); + this.marketDataOfMarkets$ = this.fetchMarketDataOfMarkets(); this.quotes$ = this.fetchQuotes({ symbols: ['AAPL', 'VOO'] }); this.status$ = this.fetchStatus(); } - public isFetchFailure(value: unknown): value is FetchFailure { + protected isFetchFailure(value: unknown): value is FetchFailure { return isObject(value) && value !== null && 'fetchError' in value; } @@ -94,7 +130,7 @@ export class GfApiPageComponent implements OnInit { private fetchAssetProfile({ symbol }: { symbol: string }) { return this.http .get( - `/api/v1/data-providers/ghostfolio/asset-profile/${symbol}`, + `/api/v1/data-providers/ghostfolio/asset-profile/${encodeURIComponent(symbol)}`, { headers: this.getHeaders() } ) .pipe(this.catchFetchFailure(), takeUntilDestroyed(this.destroyRef)); @@ -107,7 +143,7 @@ export class GfApiPageComponent implements OnInit { return this.http .get( - `/api/v2/data-providers/ghostfolio/dividends/${symbol}`, + `/api/v2/data-providers/ghostfolio/dividends/${encodeURIComponent(symbol)}`, { params, headers: this.getHeaders() @@ -129,7 +165,7 @@ export class GfApiPageComponent implements OnInit { return this.http .get( - `/api/v2/data-providers/ghostfolio/historical/${symbol}`, + `/api/v2/data-providers/ghostfolio/historical/${encodeURIComponent(symbol)}`, { params, headers: this.getHeaders() @@ -171,6 +207,15 @@ export class GfApiPageComponent implements OnInit { ); } + private fetchMarketDataOfMarkets() { + return this.http + .get( + '/api/v1/data-providers/ghostfolio/markets', + { headers: this.getHeaders() } + ) + .pipe(this.catchFetchFailure(), takeUntilDestroyed(this.destroyRef)); + } + private fetchQuotes({ symbols }: { symbols: string[] }) { const params = new HttpParams().set('symbols', symbols.join(',')); diff --git a/apps/client/src/app/pages/api/api-page.html b/apps/client/src/app/pages/api/api-page.html index 07f5ec9814..d532368167 100644 --- a/apps/client/src/app/pages/api/api-page.html +++ b/apps/client/src/app/pages/api/api-page.html @@ -1,24 +1,26 @@
    - - - AI Service Health - - - @let aiServiceHealth = aiServiceHealth$ | async; - @if (isFetchFailure(aiServiceHealth)) { - 🔴 {{ aiServiceHealth.fetchError }} - } @else if (aiServiceHealth) { - 🟢 {{ aiServiceHealth.status }} - } @else { - - } - - + @if (hasPermissionToAccessAdminControl) { + + + AI Service Health + + + @let aiServiceHealth = aiServiceHealth$ | async; + @if (isFetchFailure(aiServiceHealth)) { + 🔴 {{ aiServiceHealth.fetchError }} + } @else if (aiServiceHealth) { + 🟢 {{ aiServiceHealth.status }} + } @else { + + } + + + } Status @@ -168,6 +170,50 @@ } +
    + @let marketDataOfMarkets = marketDataOfMarkets$ | async; +
    + + + Markets + Stocks + + + @if (isFetchFailure(marketDataOfMarkets)) { + 🔴 {{ marketDataOfMarkets.fetchError }} + } @else { + + } + + +
    +
    + + + Markets + Cryptocurrencies + + + @if (isFetchFailure(marketDataOfMarkets)) { + 🔴 {{ marketDataOfMarkets.fetchError }} + } @else { + + } + + +
    +
    diff --git a/apps/client/src/app/pages/auth/auth-page.component.ts b/apps/client/src/app/pages/auth/auth-page.component.ts index 1b0b4a67ca..7c501403ed 100644 --- a/apps/client/src/app/pages/auth/auth-page.component.ts +++ b/apps/client/src/app/pages/auth/auth-page.component.ts @@ -4,11 +4,17 @@ import { } from '@ghostfolio/client/services/settings-storage.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; -import { Component, DestroyRef, OnInit } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + OnInit +} from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, Router } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'gf-auth-page', styleUrls: ['./auth-page.scss'], templateUrl: './auth-page.html' 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 597c8d9983..ac6ec5c9e4 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 @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hallo-ghostfolio-page', 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 28e30d16b9..0aab341645 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 @@ -4,7 +4,7 @@

    Hallo Ghostfolio 👋

    -
    2021-07-31
    +
    2021-07-31

    @@ -143,58 +143,58 @@

    • - Aktie + Aktie
    • - Altersvorsorge + Altersvorsorge
    • - Anlage + Anlage
    • - App + App
    • - Cryptocurrency + Cryptocurrency
    • - Feedback + Feedback
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Investition + Investition
    • - Open Source + Open Source
    • - OSS + OSS
    • - Portfolio + Portfolio
    • - Software + Software
    • - Strategie + Strategie
    • - Trading + Trading
    • - TypeScript + TypeScript
    • - Vermögen + Vermögen
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.component.ts b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.component.ts index dd29cfd807..22fe858538 100644 --- a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.component.ts +++ b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hello-ghostfolio-page', diff --git a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html index 1084fe32f8..49a8c97631 100644 --- a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html +++ b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html @@ -4,7 +4,7 @@

    Hello Ghostfolio 👋

    -
    2021-07-31
    +
    2021-07-31

    @@ -138,43 +138,43 @@

    • - Cryptocurrency + Cryptocurrency
    • - ETF + ETF
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Portfolio + Portfolio
    • - Software + Software
    • - Stock + Stock
    • - Strategy + Strategy
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.component.ts b/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.component.ts index 91b05896d8..2ab59f5ce8 100644 --- a/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-first-months-in-open-source-page', diff --git a/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.html b/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.html index 00db76df90..655f70a471 100644 --- a/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.html +++ b/apps/client/src/app/pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.html @@ -7,7 +7,7 @@ 👻 Ghostfolio – First months in Open Source -
    2022-01-05
    +
    2022-01-05

    @@ -120,61 +120,61 @@

    • - BuildInPublic + BuildInPublic
    • - Community + Community
    • - Cryptocurrency + Cryptocurrency
    • - Docker + Docker
    • - ETF + ETF
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Image + Image
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Portfolio + Portfolio
    • - Progress + Progress
    • - SaaS + SaaS
    • - Software + Software
    • - Stock + Stock
    • - Strategy + Strategy
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.component.ts b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.component.ts index c410dd2b26..2f24091318 100644 --- a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-meets-internet-identity-page', diff --git a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html index c5ca932972..0f1ddff1a9 100644 --- a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html +++ b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html @@ -4,7 +4,7 @@

    Ghostfolio meets Internet Identity

    -
    2022-07-23
    +
    2022-07-23
    Ghostfolio meets Internet Identity Teaser
    • - Anonymity + Anonymity
    • - App + App
    • - Auth Provider + Auth Provider
    • - Authentication + Authentication
    • - Blockchain + Blockchain
    • - Cryptography + Cryptography
    • - dfinity + dfinity
    • - Face ID + Face ID
    • - Fingerprint + Fingerprint
    • - Ghostfolio + Ghostfolio
    • - Internet Computer + Internet Computer
    • - Internet Identity + Internet Identity
    • - OAuth + OAuth
    • - Open Source + Open Source
    • - OSS + OSS
    • - Password + Password
    • - passwordless + passwordless
    • - Portfolio + Portfolio
    • - Security + Security
    • - Software + Software
    • - Technology + Technology
    • - Touch ID + Touch ID
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - WebAuthn + WebAuthn
    diff --git a/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.component.ts b/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.component.ts index 8121516003..f40170ba67 100644 --- a/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-how-do-i-get-my-finances-in-order-page', diff --git a/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.html b/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.html index 896ca87b9e..237f057868 100644 --- a/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.html +++ b/apps/client/src/app/pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.html @@ -4,7 +4,7 @@

    How do I get my finances in order?

    -
    2022-07-14
    +
    2022-07-14

    @@ -115,91 +115,91 @@

    • - App + App
    • - Assets + Assets
    • - Budget + Budget
    • - Cash + Cash
    • - Debt + Debt
    • - Equity + Equity
    • - ETF + ETF
    • - Expense + Expense
    • - Finance + Finance
    • - Fintech + Fintech
    • - Fund + Fund
    • - Ghostfolio + Ghostfolio
    • - Goal + Goal
    • - Guide + Guide
    • - Income + Income
    • - Investment + Investment
    • - Money + Money
    • - Net Worth + Net Worth
    • - Pension + Pension
    • - Personal Finance + Personal Finance
    • - Planning + Planning
    • - Portfolio + Portfolio
    • - Salary + Salary
    • - Saving + Saving
    • - Software + Software
    • - Spreadsheet + Spreadsheet
    • - Stock + Stock
    • - Strategy + Strategy
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.component.ts b/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.component.ts index 9004ac0e26..2627f41341 100644 --- a/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-500-stars-on-github-page', diff --git a/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.html b/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.html index 0de5154e21..bcd76f245c 100644 --- a/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.html +++ b/apps/client/src/app/pages/blog/2022/08/500-stars-on-github/500-stars-on-github-page.html @@ -4,7 +4,7 @@

    500 Stars

    -
    2022-08-18
    +
    2022-08-18
    500 Stars on GitHub Teaser
    • - Blockchain + Blockchain
    • - BuildInPublic + BuildInPublic
    • - Cloud + Cloud
    • - Community + Community
    • - Finance + Finance
    • - Fintech + Fintech
    • - Future + Future
    • - Goal + Goal
    • - Internet Identity + Internet Identity
    • - Investment + Investment
    • - Message Queue + Message Queue
    • - OpenSaaS + OpenSaaS
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Planning + Planning
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Progress + Progress
    • - SaaS + SaaS
    • - Software + Software
    • - User Feedback + User Feedback
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    • - Worker + Worker
    diff --git a/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.component.ts b/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.component.ts index fd34a64705..9e9fc2f8d5 100644 --- a/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hacktoberfest-2022-page', diff --git a/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.html b/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.html index 9486abbdc0..7ba19e1c89 100644 --- a/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.html +++ b/apps/client/src/app/pages/blog/2022/10/hacktoberfest-2022/hacktoberfest-2022-page.html @@ -4,7 +4,7 @@

    Hacktoberfest 2022

    -
    2022-10-01
    +
    2022-10-01
    Hacktoberfest 2022 with Ghostfolio Teaser
    • - Angular + Angular
    • - Community + Community
    • - Cryptocurrency + Cryptocurrency
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - Hacktoberfest + Hacktoberfest
    • - Investment + Investment
    • - NestJS + NestJS
    • - Nx + Nx
    • - October + October
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Prisma + Prisma
    • - Software + Software
    • - Stock + Stock
    • - TypeScript + TypeScript
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.component.ts b/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.component.ts index dd13d5b4d0..2b57cb09ea 100644 --- a/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.component.ts @@ -1,11 +1,12 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPremiumIndicatorComponent, MatButtonModule, RouterModule], selector: 'gf-black-friday-2022-page', diff --git a/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.html b/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.html index 4366da93eb..cac7bc56bf 100644 --- a/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.html +++ b/apps/client/src/app/pages/blog/2022/11/black-friday-2022/black-friday-2022-page.html @@ -4,7 +4,7 @@

    Black Friday 2022

    -
    2022-11-13
    +
    2022-11-13
    Black Friday 2022 TeaserGhostfolio Premium @@ -56,82 +56,82 @@
    • - 2022 + 2022
    • - Black Friday + Black Friday
    • - Cloud + Cloud
    • - Cryptocurrency + Cryptocurrency
    • - Deal + Deal
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio Premium + Ghostfolio Premium
    • - Hosting + Hosting
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Pricing + Pricing
    • - SaaS + SaaS
    • - Software + Software
    • - Stock + Stock
    • - Subscription + Subscription
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.component.ts b/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.component.ts index 6e5a19f3c8..4df232ea39 100644 --- a/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.component.ts +++ b/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-the-importance-of-tracking-your-personal-finances-page', diff --git a/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.html b/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.html index 4c9a4d9617..a4b18b6717 100644 --- a/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.html +++ b/apps/client/src/app/pages/blog/2022/12/the-importance-of-tracking-your-personal-finances/the-importance-of-tracking-your-personal-finances-page.html @@ -6,7 +6,7 @@

    The importance of tracking your personal finances

    -
    2022-12-26
    +
    2022-12-26
    The importance of tracking your personal finances Teaser
    • - App + App
    • - Assets + Assets
    • - Decision + Decision
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Goal + Goal
    • - Investment + Investment
    • - Management + Management
    • - Monitoring + Monitoring
    • - Net Worth + Net Worth
    • - Opportunity + Opportunity
    • - Performance + Performance
    • - Personal Finance + Personal Finance
    • - Portfolio Tracker + Portfolio Tracker
    • - Progress + Progress
    • - Risk + Risk
    • - Software + Software
    • - Spreadsheet + Spreadsheet
    • - Strategy + Strategy
    • - Success + Success
    • - Wealth + Wealth
    diff --git a/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.component.ts b/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.component.ts index 53d670184a..fb3f226cac 100644 --- a/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-auf-sackgeld-vorgestellt-page', diff --git a/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.html b/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.html index ee6db41226..48f4fd29d3 100644 --- a/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.html +++ b/apps/client/src/app/pages/blog/2023/01/ghostfolio-auf-sackgeld-vorgestellt/ghostfolio-auf-sackgeld-vorgestellt-page.html @@ -4,7 +4,7 @@

    Ghostfolio auf Sackgeld.com vorgestellt

    -
    2023-01-21
    +
    2023-01-21
    Ghostfolio auf Sackgeld.com vorgestellt Teaser
    • - AGPL-3.0 + AGPL-3.0
    • - Aktie + Aktie
    • - Altersvorsorge + Altersvorsorge
    • - Anlage + Anlage
    • - App + App
    • - Asset + Asset
    • - Feedback + Feedback
    • - Finanzwissen + Finanzwissen
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Immobilien + Immobilien
    • - Innovation + Innovation
    • - Investieren + Investieren
    • - Lizenz + Lizenz
    • - Media + Media
    • - Open Source + Open Source
    • - OSS + OSS
    • - P2P + P2P
    • - Performance + Performance
    • - Portfolio + Portfolio
    • - Presse + Presse
    • - Sackgeld + Sackgeld
    • - Säule 3a + Säule 3a
    • - Schweiz + Schweiz
    • - Software + Software
    • - Taschengeld + Taschengeld
    • - Tool + Tool
    • - Vermögen + Vermögen
    • - Vorsorge + Vorsorge
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.component.ts b/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.component.ts index cb8dffcd3f..3533af5c48 100644 --- a/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-meets-umbrel-page', diff --git a/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.html b/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.html index f53f610502..12c750b2d9 100644 --- a/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.html +++ b/apps/client/src/app/pages/blog/2023/02/ghostfolio-meets-umbrel/ghostfolio-meets-umbrel-page.html @@ -4,7 +4,7 @@

    Ghostfolio meets Umbrel

    -
    2023-02-25
    +
    2023-02-25
    Ghostfolio meets Umbrel Teaser
    • - Announcement + Announcement
    • - App Store + App Store
    • - Assets + Assets
    • - Cloud + Cloud
    • - Commodity + Commodity
    • - Cryptocurrency + Cryptocurrency
    • - Debian + Debian
    • - Development + Development
    • - Docker + Docker
    • - ETF + ETF
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Home Server + Home Server
    • - Investing + Investing
    • - Linux + Linux
    • - Open Source + Open Source
    • - Operating System + Operating System
    • - OS + OS
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Personal Server + Personal Server
    • - Portfolio + Portfolio
    • - Privacy + Privacy
    • - Raspberry Pi + Raspberry Pi
    • - Security + Security
    • - Software + Software
    • - Spreadsheet + Spreadsheet
    • - Stocks + Stocks
    • - Ubuntu + Ubuntu
    • - Umbrel + Umbrel
    • - VPS + VPS
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.component.ts b/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.component.ts index 60cc4177d5..7a7d0197cd 100644 --- a/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-1000-stars-on-github-page', diff --git a/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.html b/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.html index e678f7b3e1..19a0c0fb24 100644 --- a/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.html +++ b/apps/client/src/app/pages/blog/2023/03/1000-stars-on-github/1000-stars-on-github-page.html @@ -4,7 +4,7 @@

    Ghostfolio reaches 1’000 Stars on GitHub

    -
    2023-03-25
    +
    2023-03-25
    1000 Stars on GitHub Teaser
    • - Achievement + Achievement
    • - Analysis + Analysis
    • - Asset + Asset
    • - BuildInPublic + BuildInPublic
    • - Collaboration + Collaboration
    • - Community + Community
    • - Cryptocurrency + Cryptocurrency
    • - Development + Development
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - GUI + GUI
    • - i18n + i18n
    • - Import + Import
    • - Innovation + Innovation
    • - Internationalization + Internationalization
    • - Investment + Investment
    • - Investor + Investor
    • - Milestone + Milestone
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Platform + Platform
    • - Portfolio + Portfolio
    • - Progress + Progress
    • - SaaS + SaaS
    • - Software + Software
    • - Stock + Stock
    • - Tool + Tool
    • - Translation + Translation
    • - Umbrel + Umbrel
    • - Unraid + Unraid
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    diff --git a/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.component.ts b/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.component.ts index 5781674a66..de4d9a3c28 100644 --- a/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-unlock-your-financial-potential-with-ghostfolio-page', diff --git a/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.html b/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.html index a0b9049abd..c20350264d 100644 --- a/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.html +++ b/apps/client/src/app/pages/blog/2023/05/unlock-your-financial-potential-with-ghostfolio/unlock-your-financial-potential-with-ghostfolio-page.html @@ -4,7 +4,7 @@

    Unlock your Financial Potential with Ghostfolio

    -
    2023-05-20
    +
    2023-05-20
    Unlock your financial potential with Ghostfolio Teaser
    • - App + App
    • - Analysis + Analysis
    • - Assets + Assets
    • - Budgeting + Budgeting
    • - Buy & Hold + Buy & Hold
    • - Cryptocurrencies + Cryptocurrencies
    • - Diversification + Diversification
    • - ETFs + ETFs
    • - Finance + Finance
    • - Fintech + Fintech
    • - FIRE + FIRE
    • - Ghostfolio + Ghostfolio
    • - Investment + Investment
    • - Management + Management
    • - Minimalism + Minimalism
    • - Monitoring + Monitoring
    • - Open Source + Open Source
    • - Personal Finance + Personal Finance
    • - Planning + Planning
    • - Portfolio Tracker + Portfolio Tracker
    • - Privacy + Privacy
    • - Retirement + Retirement
    • - Software + Software
    • - Spreadsheet + Spreadsheet
    • - Stock + Stock
    • - Strategy + Strategy
    • - Wealth + Wealth
    diff --git a/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.component.ts b/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.component.ts index 6c7bb2ae21..79adc0e937 100644 --- a/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-exploring-the-path-to-fire-page-page', diff --git a/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.html b/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.html index 71da65923c..e11055385e 100644 --- a/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.html +++ b/apps/client/src/app/pages/blog/2023/07/exploring-the-path-to-fire/exploring-the-path-to-fire-page.html @@ -7,7 +7,7 @@ Exploring the Path to Financial Independence and Retiring Early (FIRE) -
    2023-07-01
    +
    2023-07-01
    Exploring the Path to Financial Independence and Retiring Early (FIRE) Teaser
    • - App + App
    • - Budgeting + Budgeting
    • - Calculator + Calculator
    • - FIRE + FIRE
    • - Frugality + Frugality
    • - Ghostfolio + Ghostfolio
    • - Health + Health
    • - Independence + Independence
    • - Index Fund + Index Fund
    • - Investment + Investment
    • - Lifestyle + Lifestyle
    • - Management + Management
    • - Movement + Movement
    • - Open Source + Open Source
    • - Personal Finance + Personal Finance
    • - Planning + Planning
    • - Portfolio + Portfolio
    • - Retirement + Retirement
    • - Savings + Savings
    • - Simulation + Simulation
    • - Software + Software
    • - Strategy + Strategy
    • - Trinity Study + Trinity Study
    • - Wealth + Wealth
    • - Withdrawal + Withdrawal
    • - Work-Life Balance + Work-Life Balance
    diff --git a/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.component.ts b/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.component.ts index c5a9cf1786..937212d0cf 100644 --- a/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-joins-oss-friends-page', diff --git a/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.html b/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.html index e7caaf4ad7..dbd6a8d906 100644 --- a/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.html +++ b/apps/client/src/app/pages/blog/2023/08/ghostfolio-joins-oss-friends/ghostfolio-joins-oss-friends-page.html @@ -4,7 +4,7 @@

    Ghostfolio joins OSS Friends

    -
    2023-08-23
    +
    2023-08-23
    Ghostfolio joins OSS Friends Teaser
    • - Asset + Asset
    • - Collaboration + Collaboration
    • - Cryptocurrency + Cryptocurrency
    • - Community + Community
    • - Dashboard + Dashboard
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Initiative + Initiative
    • - Innovation + Innovation
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - OSS Friends + OSS Friends
    • - Personal Finance + Personal Finance
    • - Platform + Platform
    • - Portfolio + Portfolio
    • - Privacy + Privacy
    • - Software + Software
    • - Stock + Stock
    • - Technology + Technology
    • - Tracking + Tracking
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    diff --git a/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.component.ts b/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.component.ts index 197bc3e6bd..3971b725b3 100644 --- a/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-2-page', diff --git a/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.html b/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.html index 5606deb167..a2a215f158 100644 --- a/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.html +++ b/apps/client/src/app/pages/blog/2023/09/ghostfolio-2/ghostfolio-2-page.html @@ -4,7 +4,7 @@

    Ghostfolio 2.0

    -
    2023-09-09
    +
    2023-09-09
    Ghostfolio 2.0 Teaser
    • - Angular + Angular
    • - Announcement + Announcement
    • - Collaboration + Collaboration
    • - Community + Community
    • - Contribution + Contribution
    • - Evolution + Evolution
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio 2.0 + Ghostfolio 2.0
    • - Investment + Investment
    • - Nest.js + Nest.js
    • - Nx + Nx
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Platform + Platform
    • - Portfolio + Portfolio
    • - Prisma + Prisma
    • - Privacy + Privacy
    • - Release + Release
    • - Software + Software
    • - Stack + Stack
    • - Technology + Technology
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    diff --git a/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.component.ts b/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.component.ts index 1cf3f20a53..77d8f7ee05 100644 --- a/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hacktoberfest-2023-page', diff --git a/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.html b/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.html index e97b93753b..ca2ded06fb 100644 --- a/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.html +++ b/apps/client/src/app/pages/blog/2023/09/hacktoberfest-2023/hacktoberfest-2023-page.html @@ -4,7 +4,7 @@

    Hacktoberfest 2023

    -
    2023-09-26
    +
    2023-09-26
    Hacktoberfest 2023 with Ghostfolio Teaser
    • - Angular + Angular
    • - Community + Community
    • - Docker + Docker
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - Hacktoberfest + Hacktoberfest
    • - Investment + Investment
    • - NestJS + NestJS
    • - Nx + Nx
    • - October + October
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Prisma + Prisma
    • - Software + Software
    • - TypeScript + TypeScript
    • - UX + UX
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.component.ts b/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.component.ts index 09c13cfa27..a4503c99b5 100644 --- a/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.component.ts @@ -1,11 +1,12 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPremiumIndicatorComponent, MatButtonModule, RouterModule], selector: 'gf-black-week-2023-page', diff --git a/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.html b/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.html index 5ad9193b4a..049a7b6e78 100644 --- a/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.html +++ b/apps/client/src/app/pages/blog/2023/11/black-week-2023/black-week-2023-page.html @@ -4,7 +4,7 @@

    Black Week 2023

    -
    2023-11-19
    +
    2023-11-19
    Black Week 2023 TeaserGhostfolio Premium @@ -60,85 +60,85 @@
    • - 2023 + 2023
    • - Black Friday + Black Friday
    • - Black Week + Black Week
    • - Cloud + Cloud
    • - Cryptocurrency + Cryptocurrency
    • - Deal + Deal
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio Premium + Ghostfolio Premium
    • - Hosting + Hosting
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Pricing + Pricing
    • - SaaS + SaaS
    • - Software + Software
    • - Stock + Stock
    • - Subscription + Subscription
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.component.ts b/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.component.ts index 7c8b379310..14ff67a04c 100644 --- a/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.component.ts +++ b/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hacktoberfest-2023-debriefing-page', diff --git a/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.html b/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.html index c44617201b..ad5519a733 100644 --- a/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.html +++ b/apps/client/src/app/pages/blog/2023/11/hacktoberfest-2023-debriefing/hacktoberfest-2023-debriefing-page.html @@ -4,7 +4,7 @@

    Hacktoberfest 2023 Debriefing

    -
    2023-11-05
    +
    2023-11-05
    Hacktoberfest 2023 with Ghostfolio Teaser
    • - Code + Code
    • - Collaboration + Collaboration
    • - Community + Community
    • - Development + Development
    • - Feature + Feature
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - Hacktoberfest + Hacktoberfest
    • - Investing + Investing
    • - Investment + Investment
    • - Learning + Learning
    • - Lessons learned + Lessons learned
    • - Mindset + Mindset
    • - October + October
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Programming + Programming
    • - Software + Software
    • - Takeaways + Takeaways
    • - User Experience + User Experience
    • - UX + UX
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.component.ts b/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.component.ts index 47f61adad2..abfa39ffca 100644 --- a/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.component.ts +++ b/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hacktoberfest-2024-page', diff --git a/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.html b/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.html index 4d4fadd8a0..f45aeaf2f3 100644 --- a/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.html +++ b/apps/client/src/app/pages/blog/2024/09/hacktoberfest-2024/hacktoberfest-2024-page.html @@ -4,7 +4,7 @@

    Hacktoberfest 2024

    -
    2024-09-24
    +
    2024-09-24
    Hacktoberfest 2024 with Ghostfolio Teaser
    • - Angular + Angular
    • - Community + Community
    • - Docker + Docker
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - Hacktoberfest + Hacktoberfest
    • - Hacktoberfest 2024 + Hacktoberfest 2024
    • - Investment + Investment
    • - NestJS + NestJS
    • - Nx + Nx
    • - October + October
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Prisma + Prisma
    • - Software + Software
    • - TypeScript + TypeScript
    • - UX + UX
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.component.ts b/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.component.ts index d15f081f8c..38b7b80c4b 100644 --- a/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.component.ts +++ b/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.component.ts @@ -1,11 +1,12 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPremiumIndicatorComponent, MatButtonModule, RouterModule], selector: 'gf-black-weeks-2024-page', diff --git a/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.html b/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.html index f975737226..9060b2f9a3 100644 --- a/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.html +++ b/apps/client/src/app/pages/blog/2024/11/black-weeks-2024/black-weeks-2024-page.html @@ -4,7 +4,7 @@

    Black Weeks 2024

    -
    2024-11-16
    +
    2024-11-16
    Black Week 2024 TeaserGhostfolio Premium @@ -70,94 +70,94 @@
    • - 2024 + 2024
    • - Black Friday + Black Friday
    • - Black Weeks + Black Weeks
    • - Cryptocurrency + Cryptocurrency
    • - Dashboard + Dashboard
    • - Deal + Deal
    • - DeFi + DeFi
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio Premium + Ghostfolio Premium
    • - Hosting + Hosting
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Pricing + Pricing
    • - Promotion + Promotion
    • - SaaS + SaaS
    • - Sale + Sale
    • - Software + Software
    • - Stock + Stock
    • - Subscription + Subscription
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web3 + Web3
    • - Web 3.0 + Web 3.0
    diff --git a/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.component.ts b/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.component.ts index 72990ca475..88c70723de 100644 --- a/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.component.ts +++ b/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-hacktoberfest-2025-page', diff --git a/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.html b/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.html index bde5a2fee9..35361a8b36 100644 --- a/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.html +++ b/apps/client/src/app/pages/blog/2025/09/hacktoberfest-2025/hacktoberfest-2025-page.html @@ -4,7 +4,7 @@

    Hacktoberfest 2025

    -
    2025-09-27
    +
    2025-09-27
    Hacktoberfest 2025 with Ghostfolio Teaser
    • - Angular + Angular
    • - Community + Community
    • - Dashboard + Dashboard
    • - Docker + Docker
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - GitHub + GitHub
    • - Hacktoberfest + Hacktoberfest
    • - Hacktoberfest 2025 + Hacktoberfest 2025
    • - Investment + Investment
    • - NestJS + NestJS
    • - Nx + Nx
    • - October + October
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Prisma + Prisma
    • - Redis + Redis
    • - Software + Software
    • - TypeScript + TypeScript
    • - UX + UX
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    • - Web Application + Web Application
    diff --git a/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.component.ts b/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.component.ts index c5947abf49..b98be9c761 100644 --- a/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.component.ts +++ b/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.component.ts @@ -1,11 +1,12 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPremiumIndicatorComponent, MatButtonModule, RouterModule], selector: 'gf-black-weeks-2025-page', diff --git a/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.html b/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.html index c92616d668..33b35077eb 100644 --- a/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.html +++ b/apps/client/src/app/pages/blog/2025/11/black-weeks-2025/black-weeks-2025-page.html @@ -4,7 +4,7 @@

    Black Weeks 2025

    -
    2025-11-16
    +
    2025-11-16
    Black Week 2025 TeaserGhostfolio Premium @@ -58,85 +58,85 @@
    • - 2025 + 2025
    • - Black Friday + Black Friday
    • - Black Weeks + Black Weeks
    • - Cryptocurrency + Cryptocurrency
    • - Deal + Deal
    • - Discount + Discount
    • - ETF + ETF
    • - Finance + Finance
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio Premium + Ghostfolio Premium
    • - Investment + Investment
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Portfolio + Portfolio
    • - Portfolio Tracker + Portfolio Tracker
    • - Pricing + Pricing
    • - Promotion + Promotion
    • - SaaS + SaaS
    • - Sale + Sale
    • - Savings + Savings
    • - Software + Software
    • - Stock + Stock
    • - Subscription + Subscription
    • - Wealth + Wealth
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.component.ts b/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.component.ts index 63cd09d9c7..e8e0c6da97 100644 --- a/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.component.ts +++ b/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.component.ts @@ -1,10 +1,11 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [MatButtonModule, RouterModule], selector: 'gf-ghostfolio-3-page', diff --git a/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.html b/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.html index 3cd3c9b569..0acf12bca0 100644 --- a/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.html +++ b/apps/client/src/app/pages/blog/2026/04/ghostfolio-3/ghostfolio-3-page.html @@ -4,7 +4,7 @@

    Ghostfolio 3.0

    -
    2026-04-23
    +
    2026-04-23
    Ghostfolio 3.0 Teaser
    • - Angular + Angular
    • - Announcement + Announcement
    • - Collaboration + Collaboration
    • - Community + Community
    • - Contribution + Contribution
    • - Evolution + Evolution
    • - Fintech + Fintech
    • - Ghostfolio + Ghostfolio
    • - Ghostfolio 3.0 + Ghostfolio 3.0
    • - Ghostfolio Premium + Ghostfolio Premium
    • - Internationalization + Internationalization
    • - Investment + Investment
    • - Nest.js + Nest.js
    • - Nx + Nx
    • - Open Source + Open Source
    • - OSS + OSS
    • - Personal Finance + Personal Finance
    • - Platform + Platform
    • - Portfolio + Portfolio
    • - Prisma + Prisma
    • - Privacy + Privacy
    • - Release + Release
    • - Self-Hosting + Self-Hosting
    • - Software + Software
    • - Stack + Stack
    • - Technology + Technology
    • - Wealth Management + Wealth Management
    diff --git a/apps/client/src/app/pages/blog/blog-page.component.ts b/apps/client/src/app/pages/blog/blog-page.component.ts index 7f2c56d2d4..f3227e3b07 100644 --- a/apps/client/src/app/pages/blog/blog-page.component.ts +++ b/apps/client/src/app/pages/blog/blog-page.component.ts @@ -1,7 +1,11 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { DataService } from '@ghostfolio/ui/services'; -import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + CUSTOM_ELEMENTS_SCHEMA +} from '@angular/core'; import { MatCardModule } from '@angular/material/card'; import { RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; @@ -9,6 +13,7 @@ import { addIcons } from 'ionicons'; import { chevronForwardOutline } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [IonIcon, MatCardModule, RouterModule], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/apps/client/src/app/pages/blog/blog-page.html b/apps/client/src/app/pages/blog/blog-page.html index d60fd1bcf1..3a09b108d4 100644 --- a/apps/client/src/app/pages/blog/blog-page.html +++ b/apps/client/src/app/pages/blog/blog-page.html @@ -1,9 +1,9 @@
    -

    +

    Blog - Discover the latest Ghostfolio updates and insights on personal finance @@ -11,7 +11,7 @@
    -
    @@ -38,18 +38,18 @@
    -
    +
    Black Weeks 2025
    -
    2025-11-15
    +
    2025-11-15
    @@ -63,18 +63,18 @@
    -
    +
    Hacktoberfest 2025
    -
    2025-09-27
    +
    2025-09-27
    @@ -88,18 +88,18 @@
    -
    +
    Black Weeks 2024
    -
    2024-11-16
    +
    2024-11-16
    @@ -113,18 +113,18 @@
    -
    +
    Hacktoberfest 2024
    -
    2024-09-24
    +
    2024-09-24
    @@ -138,18 +138,18 @@
    -
    +
    Black Week 2023
    -
    2023-11-19
    +
    2023-11-19
    @@ -163,7 +163,7 @@
    -
    @@ -189,18 +189,18 @@
    -
    +
    Hacktoberfest 2023
    -
    2023-09-26
    +
    2023-09-26
    @@ -213,7 +213,7 @@
    -
    @@ -239,7 +239,7 @@
    -
    @@ -265,7 +265,7 @@
    -
    +
    @@ -292,7 +292,7 @@
    -
    @@ -318,7 +318,7 @@
    -
    @@ -344,7 +344,7 @@
    -
    @@ -370,7 +370,7 @@
    -
    @@ -396,7 +396,7 @@
    -
    @@ -423,18 +423,18 @@
    -
    +
    Black Friday 2022
    -
    2022-11-13
    +
    2022-11-13
    @@ -448,18 +448,18 @@
    -
    +
    Hacktoberfest 2022
    -
    2022-10-01
    +
    2022-10-01
    @@ -472,18 +472,18 @@
    -
    +
    500 Stars on GitHub
    -
    2022-08-18
    +
    2022-08-18
    @@ -496,7 +496,7 @@
    -
    @@ -522,7 +522,7 @@
    -
    @@ -548,7 +548,7 @@
    -
    @@ -574,18 +574,18 @@
    -
    +
    Hello Ghostfolio
    -
    2021-07-31
    +
    2021-07-31
    @@ -598,18 +598,18 @@
    -
    +
    Hallo Ghostfolio
    -
    2021-07-31
    +
    2021-07-31
    diff --git a/apps/client/src/app/pages/demo/demo-page.component.ts b/apps/client/src/app/pages/demo/demo-page.component.ts index 235805dcc2..871efcd73a 100644 --- a/apps/client/src/app/pages/demo/demo-page.component.ts +++ b/apps/client/src/app/pages/demo/demo-page.component.ts @@ -3,13 +3,13 @@ import { InfoItem } from '@ghostfolio/common/interfaces'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { DataService } from '@ghostfolio/ui/services'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { Router } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, selector: 'gf-demo-page', - standalone: true, templateUrl: './demo-page.html' }) export class GfDemoPageComponent { @@ -25,7 +25,7 @@ export class GfDemoPageComponent { } public ngOnInit() { - const hasToken = this.tokenStorageService.getToken()?.length > 0; + const hasToken = !!this.tokenStorageService.getToken(); if (hasToken) { this.notificationService.alert({ diff --git a/apps/client/src/app/pages/faq/faq-page.component.ts b/apps/client/src/app/pages/faq/faq-page.component.ts index 60081687aa..17f70d1389 100644 --- a/apps/client/src/app/pages/faq/faq-page.component.ts +++ b/apps/client/src/app/pages/faq/faq-page.component.ts @@ -6,11 +6,12 @@ import { } from '@ghostfolio/ui/page-tabs'; import { DataService } from '@ghostfolio/ui/services'; -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { addIcons } from 'ionicons'; import { cloudyOutline, readerOutline, serverOutline } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPageTabsComponent], selector: 'gf-faq-page', diff --git a/apps/client/src/app/pages/faq/overview/faq-overview-page.component.ts b/apps/client/src/app/pages/faq/overview/faq-overview-page.component.ts index 1d59e67e81..17d93e795a 100644 --- a/apps/client/src/app/pages/faq/overview/faq-overview-page.component.ts +++ b/apps/client/src/app/pages/faq/overview/faq-overview-page.component.ts @@ -4,6 +4,7 @@ import { publicRoutes } from '@ghostfolio/common/routes/routes'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, @@ -14,6 +15,7 @@ import { MatCardModule } from '@angular/material/card'; import { RouterModule } from '@angular/router'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPremiumIndicatorComponent, MatCardModule, RouterModule], schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -38,9 +40,9 @@ export class GfFaqOverviewPageComponent { .subscribe((state) => { if (state?.user) { this.user = state.user; - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); } } diff --git a/apps/client/src/app/pages/faq/overview/faq-overview-page.html b/apps/client/src/app/pages/faq/overview/faq-overview-page.html index 3b43ac0966..fd94810a30 100644 --- a/apps/client/src/app/pages/faq/overview/faq-overview-page.html +++ b/apps/client/src/app/pages/faq/overview/faq-overview-page.html @@ -4,7 +4,7 @@

    Frequently Asked Questions (FAQ)

    -

    +

    Find quick answers to commonly asked questions about Ghostfolio in our Frequently Asked Questions (FAQ) section. Discover what Ghostfolio is, explore its features, and learn about our privacy practices. Get all the @@ -52,10 +52,69 @@ calculation method based on the average amount of capital invested over time. ROAI aims to provide a more insightful view of investment performance than simpler approaches, especially when contributions are - made over time. Dividends are not part of the - calculation. + + + How can I import activities from + Interactive Brokers (IBKR)? + + +

      +
    1. Log in to your Interactive Brokers Client Portal
    2. +
    3. + Navigate to Performance & Reports in the top + menu, then select Flex Queries +
    4. +
    5. + Click the + button next to Activity Flex Query +
    6. +
    7. Select Trades under Sections
    8. +
    9. Select Executions on the pop-up window
    10. +
    11. + Click SELECT ALL and then Save +
    12. +
    13. Enter a Query Name (e.g., "Ghostfolio Export")
    14. +
    15. + Under Delivery Configuration, set Format to + CSV, + Include header and trailer records to + No, Include column headers to + Yes and + Display single column header row to + Yes +
    16. +
    17. Click Create
    18. +
    19. Run the Activity Flex Query
    20. +
    21. + Under Period, select Custom Date Range and choose + the dates you want to export. Run separate exports for longer + histories if necessary +
    22. +
    23. + Set Format to CSV, click + Run and download your trades +
    24. +
    25. + Import the CSV file in Ghostfolio: Portfolio → + Activities → + Import Activities... +
    26. +
    +

    + Please note: The export contains trades only. It does not contain + dividends, interest or taxes. Keep only rows with the asset class + STK. Remove all other rows before the import, for + example currency conversions (CASH, such as + EUR.USD). Symbols from exchanges outside the US might + need a manual change. +

    + + Can I use Ghostfolio anonymously? @@ -77,7 +136,7 @@ fully available as open source software (OSS). Thanks to our generous
    Ghostfolio Premium users and @@ -105,7 +164,7 @@ >By offering Ghostfolio Premium, a subscription plan with a managed hosting service and enhanced features, we fund our business while providing added value to our @@ -131,7 +190,7 @@ >Any support for Ghostfolio is welcome. Be it with a Ghostfolio Premium subscription to finance the operational costs for the hosting @@ -193,7 +252,7 @@ } or start a discussion at GitHub. { if (state?.user) { this.user = state.user; - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); } } diff --git a/apps/client/src/app/pages/faq/saas/saas-page.html b/apps/client/src/app/pages/faq/saas/saas-page.html index 8e9cdaff77..7ad514e146 100644 --- a/apps/client/src/app/pages/faq/saas/saas-page.html +++ b/apps/client/src/app/pages/faq/saas/saas-page.html @@ -4,7 +4,7 @@

    Frequently Asked Questions (FAQ)

    -

    +

    Find quick answers to commonly asked questions about the fully managed Ghostfolio cloud offering in our Frequently Asked Questions (FAQ) section. @@ -54,7 +54,7 @@ target="_blank" [href]="pricingUrl" >Ghostfolio Premium is a fully managed Ghostfolio cloud offering for ambitious investors. @@ -78,7 +78,7 @@ target="_blank" [href]="pricingUrl" >Ghostfolio Premium by signing up for Ghostfolio and applying for a trial (see @@ -96,7 +96,7 @@ Request your student discount - here with + here with your university e-mail address. @@ -114,7 +114,7 @@ target="_blank" [href]="pricingUrl" >Ghostfolio Premium does not include auto-renewal. Upon expiration, you can choose whether @@ -186,7 +186,7 @@ } or start a discussion at GitHub. Frequently Asked Questions (FAQ)

    -

    +

    Find quick answers to commonly asked questions about self-hosting Ghostfolio in our Frequently Asked Questions (FAQ) section.

    @@ -30,7 +30,7 @@ systems, including CasaOS, + >, Easypanel, Home Assistant, Runtipi, @@ -145,7 +145,7 @@ target="_blank" [href]="pricingUrl" >Ghostfolio Premium), MANUAL, and YAHOO are officially supported while all other data providers are considered @@ -166,7 +166,7 @@ target="_blank" [href]="pricingUrl" >Ghostfolio Premium subscription via an API key. or start a discussion at GitHub. { if (state?.user) { this.user = state.user; - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); this.hasPermissionForSubscription = hasPermission( diff --git a/apps/client/src/app/pages/features/features-page.html b/apps/client/src/app/pages/features/features-page.html index efe96aec66..2c3e25d0da 100644 --- a/apps/client/src/app/pages/features/features-page.html +++ b/apps/client/src/app/pages/features/features-page.html @@ -1,14 +1,14 @@
    -

    +

    Features - + Check out the numerous features of Ghostfolio to manage your wealth

    -
    +
    @@ -18,7 +18,7 @@
    -
    +
    @@ -31,7 +31,7 @@
    -
    +
    @@ -44,7 +44,7 @@
    -
    +
    @@ -56,7 +56,7 @@
    -
    +
    @@ -69,7 +69,7 @@
    -
    +
    @@ -82,7 +82,7 @@
    -
    +
    @@ -95,7 +95,7 @@
    -
    +
    @@ -108,7 +108,7 @@
    -
    +
    @@ -120,7 +120,7 @@
    -
    +
    @@ -133,34 +133,34 @@
    -
    +
    -

    +

    Portfolio Calculations @if (hasPermissionForSubscription) { - + }

    Check the rate of return of your portfolio for Today, WTD, MTD, YTD, 1Y, 5Y, and - Max. + Max, and compare it against benchmarks.

    -
    +
    -

    +

    Portfolio Allocations @if (hasPermissionForSubscription) { - + }

    @@ -171,14 +171,14 @@

    -
    +
    -

    +

    Static Analysis @if (hasPermissionForSubscription) { - + }

    @@ -189,14 +189,14 @@

    -
    +
    -

    +

    Watchlist @if (hasPermissionForSubscription) { - + }

    @@ -206,14 +206,39 @@

    +
    + + +
    +

    + + Ghostfolio MCP + @if (hasPermissionForSubscription) { + + } + + new +

    +

    + Let your AI client analyze your portfolio and import + activities into it via the Model Context Protocol (MCP). +

    +
    +
    +
    +
    @if (hasPermissionForSubscription) { -
    +
    -

    +

    Market Mood - +

    Check the current market mood (

    } -
    +
    @@ -239,7 +264,7 @@
    -
    +
    @@ -252,7 +277,7 @@
    -
    +
    @@ -270,7 +295,7 @@
    -
    +
    @@ -289,7 +314,7 @@
    -
    +
    diff --git a/apps/client/src/app/pages/features/features-page.scss b/apps/client/src/app/pages/features/features-page.scss index c3109fdf7d..6c38386e1a 100644 --- a/apps/client/src/app/pages/features/features-page.scss +++ b/apps/client/src/app/pages/features/features-page.scss @@ -10,6 +10,14 @@ color: rgba(var(--palette-primary-300), 1); } } + + gf-premium-indicator { + vertical-align: -0.125em; + } + + .badge { + font-size: 0.75rem; + } } :host-context(.theme-dark) { 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 8c5caab22b..4ef7741def 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,6 @@ import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { User } from '@ghostfolio/common/interfaces'; -import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { GfPageTabsComponent, @@ -9,6 +8,7 @@ import { } from '@ghostfolio/ui/page-tabs'; import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, @@ -25,6 +25,7 @@ import { } from 'ionicons/icons'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, imports: [GfPageTabsComponent], selector: 'gf-home-page', @@ -71,23 +72,13 @@ export class GfHomePageComponent implements OnInit { }, { iconName: 'newspaper-outline', - label: hasPermission( - this.user?.permissions, - permissions.readMarketDataOfMarkets - ) - ? internalRoutes.home.subRoutes.marketsPremium.title - : internalRoutes.home.subRoutes.markets.title, - routerLink: hasPermission( - this.user?.permissions, - permissions.readMarketDataOfMarkets - ) - ? internalRoutes.home.subRoutes.marketsPremium.routerLink - : internalRoutes.home.subRoutes.markets.routerLink + label: internalRoutes.home.subRoutes.markets.title, + routerLink: internalRoutes.home.subRoutes.markets.routerLink } ]; - - this.changeDetectorRef.markForCheck(); } + + this.changeDetectorRef.markForCheck(); }); addIcons({ diff --git a/apps/client/src/app/pages/home/home-page.routes.ts b/apps/client/src/app/pages/home/home-page.routes.ts index 82ef1e521f..3e0ce7b266 100644 --- a/apps/client/src/app/pages/home/home-page.routes.ts +++ b/apps/client/src/app/pages/home/home-page.routes.ts @@ -1,8 +1,8 @@ import { GfHomeHoldingsComponent } from '@ghostfolio/client/components/home-holdings/home-holdings.component'; -import { GfHomeMarketComponent } from '@ghostfolio/client/components/home-market/home-market.component'; import { GfHomeOverviewComponent } from '@ghostfolio/client/components/home-overview/home-overview.component'; import { GfHomeSummaryComponent } from '@ghostfolio/client/components/home-summary/home-summary.component'; import { GfHomeWatchlistComponent } from '@ghostfolio/client/components/home-watchlist/home-watchlist.component'; +import { GfWatchlistDialogHostComponent } from '@ghostfolio/client/components/home-watchlist/watchlist-dialog-host/watchlist-dialog-host.component'; import { GfMarketsComponent } from '@ghostfolio/client/components/markets/markets.component'; import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; import { internalRoutes } from '@ghostfolio/common/routes/routes'; @@ -31,15 +31,18 @@ export const routes: Routes = [ }, { path: internalRoutes.home.subRoutes.markets.path, - component: GfHomeMarketComponent, - title: internalRoutes.home.subRoutes.markets.title - }, - { - path: internalRoutes.home.subRoutes.marketsPremium.path, component: GfMarketsComponent, - title: internalRoutes.home.subRoutes.marketsPremium.title + title: internalRoutes.home.subRoutes.markets.title }, { + children: [ + { + component: GfWatchlistDialogHostComponent, + path: internalRoutes.home.subRoutes.watchlist.subRoutes.create.path, + title: + internalRoutes.home.subRoutes.watchlist.subRoutes.create.title + } + ], path: internalRoutes.home.subRoutes.watchlist.path, component: GfHomeWatchlistComponent, title: internalRoutes.home.subRoutes.watchlist.title diff --git a/apps/client/src/app/pages/i18n/i18n-page.component.ts b/apps/client/src/app/pages/i18n/i18n-page.component.ts index 76d123914e..0cf305bf96 100644 --- a/apps/client/src/app/pages/i18n/i18n-page.component.ts +++ b/apps/client/src/app/pages/i18n/i18n-page.component.ts @@ -1,9 +1,9 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'page' }, selector: 'gf-i18n-page', - standalone: true, styleUrls: ['./i18n-page.scss'], templateUrl: './i18n-page.html' }) diff --git a/apps/client/src/app/pages/i18n/i18n-page.html b/apps/client/src/app/pages/i18n/i18n-page.html index 99ef3039ea..707c3a0b4e 100644 --- a/apps/client/src/app/pages/i18n/i18n-page.html +++ b/apps/client/src/app/pages/i18n/i18n-page.html @@ -1,6 +1,8 @@

    Self-hosted, update manually.

    -

    Free

    +

    Free

    @if (user?.subscription?.type === 'Basic') { -
  • - + Unlimited Transactions
  • - + Unlimited Accounts
  • - + Portfolio Performance
  • - + Data Import and Export @@ -148,24 +152,24 @@
  • Fully managed Ghostfolio cloud offering.

    -

    Free

    +

    Free

    @if (user?.subscription?.type === 'Basic') { -