diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts index 51c96a829..f5d796f54 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts @@ -1,5 +1,6 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { DataService } from '@ghostfolio/client/services/data.service'; +import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { PortfolioReportRule, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; @@ -20,6 +21,7 @@ export class FirePageComponent implements OnDestroy, OnInit { public deviceType: string; public feeRules: PortfolioReportRule[]; public fireWealth: Big; + public hasImpersonationId: boolean; public hasPermissionToCreateOrder: boolean; public hasPermissionToUpdateUserSettings: boolean; public isLoading = false; @@ -33,6 +35,7 @@ export class FirePageComponent implements OnDestroy, OnInit { private changeDetectorRef: ChangeDetectorRef, private dataService: DataService, private deviceService: DeviceDetectorService, + private impersonationStorageService: ImpersonationStorageService, private userService: UserService ) {} @@ -70,6 +73,13 @@ export class FirePageComponent implements OnDestroy, OnInit { this.changeDetectorRef.markForCheck(); }); + this.impersonationStorageService + .onChangeHasImpersonation() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((impersonationId) => { + this.hasImpersonationId = !!impersonationId; + }); + this.userService.stateChanged .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((state) => { diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.html b/apps/client/src/app/pages/portfolio/fire/fire-page.html index bbc8cbfc8..4269c3d70 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.html +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.html @@ -16,7 +16,7 @@ [currency]="user?.settings?.baseCurrency" [deviceType]="deviceType" [fireWealth]="fireWealth?.toNumber()" - [hasPermissionToUpdateUserSettings]="hasPermissionToUpdateUserSettings" + [hasPermissionToUpdateUserSettings]="!hasImpersonationId && hasPermissionToUpdateUserSettings" [locale]="user?.settings?.locale" [projectedTotalAmount]="user?.settings?.projectedTotalAmount" [retirementDate]="user?.settings?.retirementDate" diff --git a/libs/ui/src/lib/fire-calculator/fire-calculator.component.html b/libs/ui/src/lib/fire-calculator/fire-calculator.component.html index 3982cbeb8..8037c9ad9 100644 --- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.html +++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.html @@ -30,20 +30,27 @@ Retirement Date +
+ {{ + calculatorForm.controls['retirementDate'].value + | date : 'MMMM YYYY' + }} +
diff --git a/libs/ui/src/lib/fire-calculator/fire-calculator.component.scss b/libs/ui/src/lib/fire-calculator/fire-calculator.component.scss index e02c91e3d..d44f914f4 100644 --- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.scss +++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.scss @@ -8,4 +8,31 @@ height: 100%; } } + + ::ng-deep { + .mdc-text-field--disabled { + .mdc-floating-label, + .mdc-text-field__input { + color: inherit; + } + + .mdc-notched-outline__leading, + .mdc-notched-outline__notch, + .mdc-notched-outline__trailing { + border-color: rgba(var(--dark-disabled-text)); + } + } + } +} + +:host-context(.is-dark-theme) { + ::ng-deep { + .mdc-text-field--disabled { + .mdc-notched-outline__leading, + .mdc-notched-outline__notch, + .mdc-notched-outline__trailing { + border-color: rgba(var(--dark-disabled-text)); + } + } + } } diff --git a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts index c20d1695f..f336d19d9 100644 --- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts +++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts @@ -1,7 +1,6 @@ import 'chartjs-adapter-date-fns'; import { - AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -49,9 +48,7 @@ import { FireCalculatorService } from './fire-calculator.service'; styleUrls: ['./fire-calculator.component.scss'], templateUrl: './fire-calculator.component.html' }) -export class FireCalculatorComponent - implements AfterViewInit, OnChanges, OnDestroy -{ +export class FireCalculatorComponent implements OnChanges, OnDestroy { @Input() annualInterestRate = 5; @Input() colorScheme: ColorScheme; @Input() currency: string; @@ -145,47 +142,9 @@ export class FireCalculatorComponent }); } - public ngAfterViewInit() { - if (isNumber(this.fireWealth) && this.fireWealth >= 0) { - setTimeout(() => { - // Wait for the chartCanvas - this.calculatorForm.patchValue( - { - annualInterestRate: this.annualInterestRate, - paymentPerPeriod: this.getPMT(), - principalInvestmentAmount: this.getP(), - projectedTotalAmount: - Number(this.getProjectedTotalAmount().toFixed(0)) ?? 0, - retirementDate: - this.getRetirementDate() ?? this.DEFAULT_RETIREMENT_DATE - }, - { - emitEvent: false - } - ); - this.calculatorForm.get('principalInvestmentAmount').disable(); - - this.changeDetectorRef.markForCheck(); - }); - } - - if (this.hasPermissionToUpdateUserSettings === true) { - this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false }); - this.calculatorForm - .get('projectedTotalAmount') - .enable({ emitEvent: false }); - } else { - this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false }); - this.calculatorForm - .get('projectedTotalAmount') - .disable({ emitEvent: false }); - } - - this.calculatorForm.get('retirementDate').disable({ emitEvent: false }); - } - public ngOnChanges() { this.periodsToRetire = this.getPeriodsToRetire(); + if (isNumber(this.fireWealth) && this.fireWealth >= 0) { setTimeout(() => { // Wait for the chartCanvas @@ -210,11 +169,17 @@ export class FireCalculatorComponent } if (this.hasPermissionToUpdateUserSettings === true) { + this.calculatorForm + .get('annualInterestRate') + .enable({ emitEvent: false }); this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false }); this.calculatorForm .get('projectedTotalAmount') .enable({ emitEvent: false }); } else { + this.calculatorForm + .get('annualInterestRate') + .disable({ emitEvent: false }); this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false }); this.calculatorForm .get('projectedTotalAmount')