From 921d38a706f5dd2682f3cb3bce1e675decd889db Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:21:14 +0200 Subject: [PATCH 1/3] Feature/harmonize style of granted access user interface (#2326) * Harmonize style * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/user/user.service.ts | 7 ++++++- .../access-table/access-table.component.html | 12 +++++++++++ .../access-table/access-table.component.ts | 1 + .../access-table/access-table.module.ts | 9 +++++++- .../pages/user-account/user-account-page.html | 21 +++++++------------ .../pages/user-account/user-account-page.scss | 7 ------- 7 files changed, 36 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c48622011..e8b973b06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Harmonized the style of the user interface for granting and revoking public access to share the portfolio - Improved the logger output of the info service - Harmonized the logger output: () - Improved the language localization for Italian (`it`) diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index c5cc3c8ce..a2710bfd5 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -19,7 +19,7 @@ import { UserWithSettings } from '@ghostfolio/common/types'; import { Injectable } from '@nestjs/common'; import { Prisma, Role, User } from '@prisma/client'; import { differenceInDays } from 'date-fns'; -import { sortBy } from 'lodash'; +import { sortBy, without } from 'lodash'; const crypto = require('crypto'); @@ -188,6 +188,11 @@ export class UserService { currentPermissions.push(permissions.enableSubscriptionInterstitial); } + currentPermissions = without( + currentPermissions, + permissions.createAccess + ); + // Reset benchmark user.Settings.settings.benchmark = undefined; } diff --git a/apps/client/src/app/components/access-table/access-table.component.html b/apps/client/src/app/components/access-table/access-table.component.html index 589c67e1f..498e73bf0 100644 --- a/apps/client/src/app/components/access-table/access-table.component.html +++ b/apps/client/src/app/components/access-table/access-table.component.html @@ -1,3 +1,15 @@ + + 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 c0db8fb2f..298a02069 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 @@ -19,6 +19,7 @@ import { Access } from '@ghostfolio/common/interfaces'; }) export class AccessTableComponent implements OnChanges, OnInit { @Input() accesses: Access[]; + @Input() hasPermissionToCreateAccess = false; @Input() showActions: boolean; @Output() accessDeleted = new EventEmitter(); diff --git a/apps/client/src/app/components/access-table/access-table.module.ts b/apps/client/src/app/components/access-table/access-table.module.ts index 111f0e2f4..2ace3cfc1 100644 --- a/apps/client/src/app/components/access-table/access-table.module.ts +++ b/apps/client/src/app/components/access-table/access-table.module.ts @@ -3,13 +3,20 @@ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatMenuModule } from '@angular/material/menu'; import { MatTableModule } from '@angular/material/table'; +import { RouterModule } from '@angular/router'; import { AccessTableComponent } from './access-table.component'; @NgModule({ declarations: [AccessTableComponent], exports: [AccessTableComponent], - imports: [CommonModule, MatButtonModule, MatMenuModule, MatTableModule], + imports: [ + CommonModule, + MatButtonModule, + MatMenuModule, + MatTableModule, + RouterModule + ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) export class GfPortfolioAccessTableModule {} diff --git a/apps/client/src/app/pages/user-account/user-account-page.html b/apps/client/src/app/pages/user-account/user-account-page.html index 24cfce6e1..33c4e497e 100644 --- a/apps/client/src/app/pages/user-account/user-account-page.html +++ b/apps/client/src/app/pages/user-account/user-account-page.html @@ -287,24 +287,19 @@
-

Granted Access

+

+ Granted Access + +

- -
- - - -
diff --git a/apps/client/src/app/pages/user-account/user-account-page.scss b/apps/client/src/app/pages/user-account/user-account-page.scss index 6a010a85d..6dddf0e35 100644 --- a/apps/client/src/app/pages/user-account/user-account-page.scss +++ b/apps/client/src/app/pages/user-account/user-account-page.scss @@ -6,13 +6,6 @@ overflow-x: auto; } - .fab-container { - position: fixed; - right: 2rem; - bottom: 2rem; - z-index: 999; - } - .hint-text { font-size: 90%; line-height: 1.2; From 1fe1e2fe0c5d08a0442c57cb8c12a796f9120c75 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:22:39 +0200 Subject: [PATCH 2/3] Feature/improve read only mode (#2322) * Improve read-only mode * Update changelog --- CHANGELOG.md | 3 ++- apps/api/src/app/admin/admin.service.ts | 8 ++++++-- .../src/app/pages/pricing/pricing-page.component.ts | 7 +++++++ apps/client/src/app/pages/pricing/pricing-page.html | 2 +- .../src/app/pages/user-account/user-account-page.html | 10 +++++----- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b973b06..1e6ad9bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Harmonized the logger output: () - Improved the language localization for Italian (`it`) - Improved the language localization for Dutch (`nl`) +- Improved the read-only mode ### Fixed @@ -2950,7 +2951,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Supported the management of additional currencies in the admin control panel - Introduced the system message -- Introduced the read only mode +- Introduced the read-only mode ### Changed diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index b1b6b9418..a45fbe634 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -8,7 +8,9 @@ import { PropertyService } from '@ghostfolio/api/services/property/property.serv import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; import { DEFAULT_CURRENCY, - PROPERTY_CURRENCIES + PROPERTY_CURRENCIES, + PROPERTY_IS_READ_ONLY_MODE, + PROPERTY_IS_USER_SIGNUP_ENABLED } from '@ghostfolio/common/config'; import { AdminData, @@ -305,7 +307,9 @@ export class AdminService { response = await this.propertyService.delete({ key }); } - if (key === PROPERTY_CURRENCIES) { + if (key === PROPERTY_IS_READ_ONLY_MODE && value === 'true') { + await this.putSetting(PROPERTY_IS_USER_SIGNUP_ENABLED, 'false'); + } else if (key === PROPERTY_CURRENCIES) { await this.exchangeRateDataService.initialize(); } diff --git a/apps/client/src/app/pages/pricing/pricing-page.component.ts b/apps/client/src/app/pages/pricing/pricing-page.component.ts index 6f19a9b46..f7776f871 100644 --- a/apps/client/src/app/pages/pricing/pricing-page.component.ts +++ b/apps/client/src/app/pages/pricing/pricing-page.component.ts @@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } 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 { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { translate } from '@ghostfolio/ui/i18n'; import { StripeService } from 'ngx-stripe'; import { Subject } from 'rxjs'; @@ -17,6 +18,7 @@ export class PricingPageComponent implements OnDestroy, OnInit { public baseCurrency: string; public coupon: number; public couponId: string; + public hasPermissionToUpdateUserSettings: boolean; public importAndExportTooltipBasic = translate( 'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC' ); @@ -55,6 +57,11 @@ export class PricingPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; + this.hasPermissionToUpdateUserSettings = hasPermission( + this.user.permissions, + permissions.updateUserSettings + ); + this.coupon = subscriptions?.[this.user?.subscription?.offer]?.coupon; this.couponId = subscriptions?.[this.user.subscription.offer]?.couponId; diff --git a/apps/client/src/app/pages/pricing/pricing-page.html b/apps/client/src/app/pages/pricing/pricing-page.html index abd169a5e..1c1bb6c41 100644 --- a/apps/client/src/app/pages/pricing/pricing-page.html +++ b/apps/client/src/app/pages/pricing/pricing-page.html @@ -333,7 +333,7 @@ >

Alias