Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🀍

Various improvements (#807)

Thomas Kaul2a854e25743e
diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts
index 1bb42a0ede..272721e76e 100644
--- a/apps/api/src/app/portfolio/portfolio.controller.ts
+++ b/apps/api/src/app/portfolio/portfolio.controller.ts
@@ -320,6 +320,16 @@ export class PortfolioController {
public async getSummary(
@Headers('impersonation-id') impersonationId
): Promise<PortfolioSummary> {
+ if (
+ this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') &&
+ this.request.user.subscription.type === 'Basic'
+ ) {
+ throw new HttpException(
+ getReasonPhrase(StatusCodes.FORBIDDEN),
+ StatusCodes.FORBIDDEN
+ );
+ }
+
let summary = await this.portfolioServiceStrategy
.get()
.getSummary(impersonationId);
diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts
index a4e9267ef9..c94c5a458c 100644
--- a/apps/api/src/app/user/user.service.ts
+++ b/apps/api/src/app/user/user.service.ts
@@ -67,7 +67,7 @@ export class UserService {
settings: {
...(<UserSettings>Settings.settings),
baseCurrency: Settings?.currency ?? UserService.DEFAULT_CURRENCY,
- locale: (<UserSettings>Settings.settings).locale ?? aLocale,
+ locale: (<UserSettings>Settings.settings)?.locale ?? aLocale,
viewMode: Settings?.viewMode ?? ViewMode.DEFAULT
}
};
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 f1daa7e723..aae5e5f5e3 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
@@ -70,9 +70,10 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
'value',
this.performance?.currentNetPerformancePercent * 100,
{
+ decimal: getNumberFormatDecimal(this.locale),
decimalPlaces: 2,
- duration: 0.75,
- separator: `'`
+ duration: 1,
+ separator: getNumberFormatGroup(this.locale)
}
).start();
}
diff --git a/apps/client/src/app/core/http-response.interceptor.ts b/apps/client/src/app/core/http-response.interceptor.ts
index 9ac221e623..b76884ffad 100644
--- a/apps/client/src/app/core/http-response.interceptor.ts
+++ b/apps/client/src/app/core/http-response.interceptor.ts
@@ -17,12 +17,14 @@ import { DataService } from '@ghostfolio/client/services/data.service';
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service';
import { InfoItem } from '@ghostfolio/common/interfaces';
+import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { StatusCodes } from 'http-status-codes';
import { Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
@Injectable()
export class HttpResponseInterceptor implements HttpInterceptor {
+ public hasPermissionForSubscription: boolean;
public info: InfoItem;
public snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
@@ -34,6 +36,11 @@ export class HttpResponseInterceptor implements HttpInterceptor {
private webAuthnService: WebAuthnService
) {
this.info = this.dataService.fetchInfo();
+
+ this.hasPermissionForSubscription = hasPermission(
+ this.info?.globalPermissions,
+ permissions.enableSubscription
+ );
}
public intercept(
@@ -56,7 +63,7 @@ export class HttpResponseInterceptor implements HttpInterceptor {
} else {
this.snackBarRef = this.snackBar.open(
'This feature requires a subscription.',
- 'Upgrade Plan',
+ this.hasPermissionForSubscription ? 'Upgrade Plan' : undefined,
{ duration: 6000 }
);
}
diff --git a/apps/client/src/app/pages/portfolio/portfolio-page.html b/apps/client/src/app/pages/portfolio/portfolio-page.html
index d0717805db..f7bc75f91b 100644
--- a/apps/client/src/app/pages/portfolio/portfolio-page.html
+++ b/apps/client/src/app/pages/portfolio/portfolio-page.html
@@ -25,7 +25,7 @@
<h4 class="align-items-center d-flex">
<span i18n>Allocations</span>
<ion-icon
- *ngIf="hasPermissionForSubscription"
+ *ngIf="user?.subscription?.type === 'Basic'"
class="ml-1 text-muted"
name="diamond-outline"
></ion-icon>
@@ -38,7 +38,6 @@
<a
color="primary"
mat-button
- [disabled]="hasPermissionForSubscription && user?.settings?.viewMode !== 'DEFAULT'"
[routerLink]="['/portfolio', 'allocations']"
>
<span i18n>Open Allocations</span>
@@ -52,7 +51,7 @@
<h4 class="align-items-center d-flex">
<span i18n>Analysis</span>
<ion-icon
- *ngIf="hasPermissionForSubscription"
+ *ngIf="user?.subscription?.type === 'Basic'"
class="ml-1 text-muted"
name="diamond-outline"
></ion-icon>
@@ -65,7 +64,6 @@
<a
color="primary"
mat-button
- [disabled]="hasPermissionForSubscription && user?.settings?.viewMode !== 'DEFAULT'"
[routerLink]="['/portfolio', 'analysis']"
>
<span i18n>Open Analysis</span>
@@ -79,7 +77,7 @@
<h4 class="align-items-center d-flex">
<span i18n>X-ray</span>
<ion-icon
- *ngIf="hasPermissionForSubscription"
+ *ngIf="user?.subscription?.type === 'Basic'"
class="ml-1 text-muted"
name="diamond-outline"
></ion-icon>
@@ -89,12 +87,7 @@
risks in your portfolio.
</div>
<div class="mt-2 text-right">
- <a
- color="primary"
- mat-button
- [disabled]="hasPermissionForSubscription && user?.settings?.viewMode !== 'DEFAULT'"
- [routerLink]="['/portfolio', 'report']"
- >
+ <a color="primary" mat-button [routerLink]="['/portfolio', 'report']">
<span i18n>Open X-ray</span>
<ion-icon class="ml-1" name="arrow-forward-outline"></ion-icon>
</a>
@@ -106,7 +99,7 @@
<h4 class="align-items-center d-flex">
<span i18n>FIRE</span>
<ion-icon
- *ngIf="hasPermissionForSubscription"
+ *ngIf="user?.subscription?.type === 'Basic'"
class="ml-1 text-muted"
name="diamond-outline"
></ion-icon>
@@ -116,12 +109,7 @@
<i>Financial Independence, Retire Early</i> lifestyle.
</div>
<div class="mt-2 text-right">
- <a
- color="primary"
- mat-button
- [disabled]="hasPermissionForSubscription && user?.settings?.viewMode !== 'DEFAULT'"
- [routerLink]="['/portfolio', 'fire']"
- >
+ <a color="primary" mat-button [routerLink]="['/portfolio', 'fire']">
<span i18n>Open FIRE</span>
<ion-icon class="ml-1" name="arrow-forward-outline"></ion-icon>
</a>
diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts
index 08fdb413ea..7bd15076fa 100644
--- a/libs/ui/src/lib/value/value.component.ts
+++ b/libs/ui/src/lib/value/value.component.ts
@@ -119,5 +119,9 @@ export class ValueComponent implements OnChanges {
if (this.formattedValue === '0.00') {
this.useAbsoluteValue = true;
}
+
+ if (this.isPercent) {
+ this.formattedValue = '– ';
+ }
}
}