|
|
|
@ -7,7 +7,7 @@ import {
|
|
|
|
|
} from '@angular/core';
|
|
|
|
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
|
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
|
|
|
|
import { InfoItem, User } from '@ghostfolio/common/interfaces';
|
|
|
|
|
import { TabConfiguration, User } from '@ghostfolio/common/interfaces';
|
|
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
@ -24,13 +24,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|
|
|
|
|
|
|
|
|
public hasMessage: boolean;
|
|
|
|
|
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
|
|
|
|
public info: InfoItem;
|
|
|
|
|
public tabs: {
|
|
|
|
|
iconName: string;
|
|
|
|
|
label: string;
|
|
|
|
|
path: string;
|
|
|
|
|
showCondition?: boolean;
|
|
|
|
|
}[] = [];
|
|
|
|
|
public tabs: TabConfiguration[] = [];
|
|
|
|
|
public user: User;
|
|
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>();
|
|
|
|
@ -40,7 +34,12 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|
|
|
|
private dataService: DataService,
|
|
|
|
|
private userService: UserService
|
|
|
|
|
) {
|
|
|
|
|
this.info = this.dataService.fetchInfo();
|
|
|
|
|
const { globalPermissions, systemMessage } = this.dataService.fetchInfo();
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
|
|
|
|
|
globalPermissions,
|
|
|
|
|
permissions.enableFearAndGreedIndex
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.userService.stateChanged
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
@ -50,17 +49,23 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|
|
|
|
{
|
|
|
|
|
iconName: 'analytics-outline',
|
|
|
|
|
label: $localize`Overview`,
|
|
|
|
|
path: 'overview'
|
|
|
|
|
path: ['/home']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
iconName: 'wallet-outline',
|
|
|
|
|
label: $localize`Holdings`,
|
|
|
|
|
path: 'holdings'
|
|
|
|
|
path: ['/home', 'holdings']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
iconName: 'reader-outline',
|
|
|
|
|
label: $localize`Summary`,
|
|
|
|
|
path: 'summary'
|
|
|
|
|
path: ['/home', 'summary']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
iconName: 'newspaper-outline',
|
|
|
|
|
label: $localize`Markets`,
|
|
|
|
|
path: ['/home', 'market'],
|
|
|
|
|
showCondition: this.hasPermissionToAccessFearAndGreedIndex
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
this.user = state.user;
|
|
|
|
@ -69,20 +74,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|
|
|
|
hasPermission(
|
|
|
|
|
this.user?.permissions,
|
|
|
|
|
permissions.createUserAccount
|
|
|
|
|
) || !!this.info.systemMessage;
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
|
|
|
|
|
this.info?.globalPermissions,
|
|
|
|
|
permissions.enableFearAndGreedIndex
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
|
|
|
|
this.tabs.push({
|
|
|
|
|
iconName: 'newspaper-outline',
|
|
|
|
|
label: $localize`Markets`,
|
|
|
|
|
path: 'market'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
) || !!systemMessage;
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
|
}
|
|
|
|
|