Extend support for feature flags (#39)
This commit is contained in:
parent
15a70abf67
commit
39cfb4603b
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Extended the support for feature flags to simplify the initial project setup
|
||||||
|
|
||||||
## 0.90.0 - 22.04.2021
|
## 0.90.0 - 22.04.2021
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -26,7 +26,11 @@ export class InfoService {
|
|||||||
const globalPermissions: string[] = [];
|
const globalPermissions: string[] = [];
|
||||||
|
|
||||||
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||||
globalPermissions.push(permissions.useSocialLogin);
|
globalPermissions.push(permissions.enableSocialLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
||||||
|
globalPermissions.push(permissions.enableSubscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -15,6 +15,7 @@ export class ConfigurationService {
|
|||||||
ENABLE_FEATURE_CUSTOM_SYMBOLS: bool({ default: false }),
|
ENABLE_FEATURE_CUSTOM_SYMBOLS: bool({ default: false }),
|
||||||
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
|
||||||
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
|
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
|
||||||
|
ENABLE_FEATURE_SUBSCRIPTION: bool({ default: false }),
|
||||||
GOOGLE_CLIENT_ID: str({ default: 'dummyClientId' }),
|
GOOGLE_CLIENT_ID: str({ default: 'dummyClientId' }),
|
||||||
GOOGLE_SECRET: str({ default: 'dummySecret' }),
|
GOOGLE_SECRET: str({ default: 'dummySecret' }),
|
||||||
JWT_SECRET_KEY: str({}),
|
JWT_SECRET_KEY: str({}),
|
||||||
|
@ -7,6 +7,7 @@ export interface Environment extends CleanedEnvAccessors {
|
|||||||
ENABLE_FEATURE_CUSTOM_SYMBOLS: boolean;
|
ENABLE_FEATURE_CUSTOM_SYMBOLS: boolean;
|
||||||
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
|
||||||
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
|
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
|
||||||
|
ENABLE_FEATURE_SUBSCRIPTION: boolean;
|
||||||
GOOGLE_CLIENT_ID: string;
|
GOOGLE_CLIENT_ID: string;
|
||||||
GOOGLE_SECRET: string;
|
GOOGLE_SECRET: string;
|
||||||
JWT_SECRET_KEY: string;
|
JWT_SECRET_KEY: string;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
>Transactions</a
|
>Transactions</a
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
*ngIf="canAccessAdminAccessControl"
|
*ngIf="hasPermissionToAccessAdminControl"
|
||||||
class="d-none d-sm-block mx-1"
|
class="d-none d-sm-block mx-1"
|
||||||
[routerLink]="['/admin']"
|
[routerLink]="['/admin']"
|
||||||
i18n
|
i18n
|
||||||
@ -150,7 +150,7 @@
|
|||||||
>Account</a
|
>Account</a
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
*ngIf="canAccessAdminAccessControl"
|
*ngIf="hasPermissionForAdminControl"
|
||||||
class="d-block d-sm-none"
|
class="d-block d-sm-none"
|
||||||
[routerLink]="['/admin']"
|
[routerLink]="['/admin']"
|
||||||
i18n
|
i18n
|
||||||
|
@ -27,8 +27,8 @@ export class HeaderComponent implements OnChanges {
|
|||||||
@Input() info: InfoItem;
|
@Input() info: InfoItem;
|
||||||
@Input() user: User;
|
@Input() user: User;
|
||||||
|
|
||||||
public canAccessAdminAccessControl: boolean;
|
public hasPermissionToAccessAdminControl: boolean;
|
||||||
public hasPermissionToUseSocialLogin: boolean;
|
public hasPermissionForSocialLogin: boolean;
|
||||||
public impersonationId: string;
|
public impersonationId: string;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -49,15 +49,15 @@ export class HeaderComponent implements OnChanges {
|
|||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
this.canAccessAdminAccessControl = hasPermission(
|
this.hasPermissionToAccessAdminControl = hasPermission(
|
||||||
this.user.permissions,
|
this.user.permissions,
|
||||||
permissions.accessAdminControl
|
permissions.accessAdminControl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasPermissionToUseSocialLogin = hasPermission(
|
this.hasPermissionForSocialLogin = hasPermission(
|
||||||
this.info?.globalPermissions,
|
this.info?.globalPermissions,
|
||||||
permissions.useSocialLogin
|
permissions.enableSocialLogin
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export class HeaderComponent implements OnChanges {
|
|||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
data: {
|
data: {
|
||||||
accessToken: '',
|
accessToken: '',
|
||||||
hasPermissionToUseSocialLogin: this.hasPermissionToUseSocialLogin
|
hasPermissionToUseSocialLogin: this.hasPermissionForSocialLogin
|
||||||
},
|
},
|
||||||
width: '30rem'
|
width: '30rem'
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
|
import { InfoItem } from '@ghostfolio/api/app/info/interfaces/info-item.interface';
|
||||||
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
||||||
import { baseCurrency } from '@ghostfolio/helper';
|
import { baseCurrency, hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ import { environment } from '../../../environments/environment';
|
|||||||
})
|
})
|
||||||
export class AboutPageComponent implements OnInit {
|
export class AboutPageComponent implements OnInit {
|
||||||
public baseCurrency = baseCurrency;
|
public baseCurrency = baseCurrency;
|
||||||
|
public hasPermissionForSubscription: boolean;
|
||||||
public isLoggedIn: boolean;
|
public isLoggedIn: boolean;
|
||||||
public lastPublish = environment.lastPublish;
|
public lastPublish = environment.lastPublish;
|
||||||
public user: User;
|
public user: User;
|
||||||
@ -35,6 +37,13 @@ export class AboutPageComponent implements OnInit {
|
|||||||
* Initializes the controller
|
* Initializes the controller
|
||||||
*/
|
*/
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
this.dataService.fetchInfo().subscribe((info) => {
|
||||||
|
this.hasPermissionForSubscription = hasPermission(
|
||||||
|
info.globalPermissions,
|
||||||
|
permissions.enableSubscription
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
this.isLoggedIn = !!this.tokenStorageService.getToken();
|
this.isLoggedIn = !!this.tokenStorageService.getToken();
|
||||||
|
|
||||||
if (this.isLoggedIn)
|
if (this.isLoggedIn)
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-5 row">
|
<div *ngIf="hasPermissionForSubscription" class="mb-5 row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3 class="mb-3 text-center" i18n>Pricing Plans</h3>
|
<h3 class="mb-3 text-center" i18n>Pricing Plans</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -3,7 +3,11 @@ import { Access } from '@ghostfolio/api/app/access/interfaces/access.interface';
|
|||||||
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
||||||
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/helper';
|
import {
|
||||||
|
DEFAULT_DATE_FORMAT,
|
||||||
|
hasPermission,
|
||||||
|
permissions
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -19,6 +23,7 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
public baseCurrency: Currency;
|
public baseCurrency: Currency;
|
||||||
public currencies: Currency[] = [];
|
public currencies: Currency[] = [];
|
||||||
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
||||||
|
public hasPermissionForSubscription: boolean;
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -34,8 +39,13 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
this.dataService
|
this.dataService
|
||||||
.fetchInfo()
|
.fetchInfo()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe(({ currencies }) => {
|
.subscribe(({ currencies, globalPermissions }) => {
|
||||||
this.currencies = currencies;
|
this.currencies = currencies;
|
||||||
|
|
||||||
|
this.hasPermissionForSubscription = hasPermission(
|
||||||
|
globalPermissions,
|
||||||
|
permissions.enableSubscription
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tokenStorageService
|
this.tokenStorageService
|
||||||
@ -70,6 +80,11 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
private update() {
|
private update() {
|
||||||
this.dataService
|
this.dataService
|
||||||
.fetchAccesses()
|
.fetchAccesses()
|
||||||
@ -80,9 +95,4 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
|
||||||
this.unsubscribeSubject.next();
|
|
||||||
this.unsubscribeSubject.complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<div class="w-50" i18n>Alias</div>
|
<div class="w-50" i18n>Alias</div>
|
||||||
<div class="w-50">{{ user.alias }}</div>
|
<div class="w-50">{{ user.alias }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex py-1">
|
<div *ngIf="hasPermissionForSubscription" class="d-flex py-1">
|
||||||
<div class="w-50" i18n>Membership</div>
|
<div class="w-50" i18n>Membership</div>
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<div class="align-items-center d-flex mb-1">
|
<div class="align-items-center d-flex mb-1">
|
||||||
|
@ -10,10 +10,11 @@ export const permissions = {
|
|||||||
createAccount: 'createAccount',
|
createAccount: 'createAccount',
|
||||||
createOrder: 'createOrder',
|
createOrder: 'createOrder',
|
||||||
deleteOrder: 'deleteOrder',
|
deleteOrder: 'deleteOrder',
|
||||||
|
enableSocialLogin: 'enableSocialLogin',
|
||||||
|
enableSubscription: 'enableSubscription',
|
||||||
readForeignPortfolio: 'readForeignPortfolio',
|
readForeignPortfolio: 'readForeignPortfolio',
|
||||||
updateOrder: 'updateOrder',
|
updateOrder: 'updateOrder',
|
||||||
updateUserSettings: 'updateUserSettings',
|
updateUserSettings: 'updateUserSettings'
|
||||||
useSocialLogin: 'useSocialLogin'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function hasPermission(
|
export function hasPermission(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user