From 00d865fe065e027e16bc7e9ecccdd33ef0bbb5b5 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 20 Feb 2022 13:40:58 +0100 Subject: [PATCH] Display features based on permissions --- .../pages/features/features-page.component.ts | 16 ++++++++++++++-- .../src/app/pages/features/features-page.html | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/client/src/app/pages/features/features-page.component.ts b/apps/client/src/app/pages/features/features-page.component.ts index 3137443cc..ff71a5259 100644 --- a/apps/client/src/app/pages/features/features-page.component.ts +++ b/apps/client/src/app/pages/features/features-page.component.ts @@ -1,6 +1,8 @@ import { ChangeDetectorRef, Component, OnDestroy } from '@angular/core'; +import { DataService } from '@ghostfolio/client/services/data.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; -import { User } from '@ghostfolio/common/interfaces'; +import { InfoItem, User } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { Subject, takeUntil } from 'rxjs'; @Component({ @@ -10,6 +12,8 @@ import { Subject, takeUntil } from 'rxjs'; templateUrl: './features-page.html' }) export class FeaturesPageComponent implements OnDestroy { + public hasPermissionForSubscription: boolean; + public info: InfoItem; public user: User; private unsubscribeSubject = new Subject(); @@ -19,8 +23,11 @@ export class FeaturesPageComponent implements OnDestroy { */ public constructor( private changeDetectorRef: ChangeDetectorRef, + private dataService: DataService, private userService: UserService - ) {} + ) { + this.info = this.dataService.fetchInfo(); + } /** * Initializes the controller @@ -35,6 +42,11 @@ export class FeaturesPageComponent implements OnDestroy { this.changeDetectorRef.markForCheck(); } }); + + this.hasPermissionForSubscription = hasPermission( + this.info?.globalPermissions, + permissions.enableSubscription + ); } public ngOnDestroy() { diff --git a/apps/client/src/app/pages/features/features-page.html b/apps/client/src/app/pages/features/features-page.html index baa2aa844..42c460542 100644 --- a/apps/client/src/app/pages/features/features-page.html +++ b/apps/client/src/app/pages/features/features-page.html @@ -89,6 +89,7 @@

Portfolio Calculations @@ -107,6 +108,7 @@

Portfolio Allocations @@ -139,7 +141,10 @@ -
+

@@ -163,6 +168,7 @@

Static Analysis