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