mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.6 KiB
85 lines
2.6 KiB
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
|
import { TabConfiguration, User } from '@ghostfolio/common/interfaces';
|
|
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
import { Subject } from 'rxjs';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
@Component({
|
|
host: { class: 'page has-tabs' },
|
|
selector: 'gf-home-page',
|
|
styleUrls: ['./home-page.scss'],
|
|
templateUrl: './home-page.html',
|
|
standalone: false
|
|
})
|
|
export class HomePageComponent implements OnDestroy, OnInit {
|
|
public deviceType: string;
|
|
public hasImpersonationId: boolean;
|
|
public tabs: TabConfiguration[] = [];
|
|
public user: User;
|
|
|
|
private unsubscribeSubject = new Subject<void>();
|
|
|
|
public constructor(
|
|
private changeDetectorRef: ChangeDetectorRef,
|
|
private deviceService: DeviceDetectorService,
|
|
private impersonationStorageService: ImpersonationStorageService,
|
|
private userService: UserService
|
|
) {
|
|
this.userService.stateChanged
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
.subscribe((state) => {
|
|
if (state?.user) {
|
|
this.tabs = [
|
|
{
|
|
iconName: 'analytics-outline',
|
|
label: $localize`Overview`,
|
|
path: ['/home']
|
|
},
|
|
{
|
|
iconName: 'wallet-outline',
|
|
label: $localize`Holdings`,
|
|
path: ['/home', 'holdings']
|
|
},
|
|
{
|
|
iconName: 'reader-outline',
|
|
label: $localize`Summary`,
|
|
path: ['/home', 'summary']
|
|
},
|
|
{
|
|
iconName: 'newspaper-outline',
|
|
label: $localize`Markets`,
|
|
path: ['/home', 'market']
|
|
},
|
|
{
|
|
iconName: 'star-outline',
|
|
label: $localize`Watchlist`,
|
|
path: ['/home', 'watchlist'],
|
|
showCondition: this.user?.settings?.isExperimentalFeatures
|
|
}
|
|
];
|
|
this.user = state.user;
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
}
|
|
});
|
|
}
|
|
|
|
public ngOnInit() {
|
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
|
|
|
this.impersonationStorageService
|
|
.onChangeHasImpersonation()
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
.subscribe((impersonationId) => {
|
|
this.hasImpersonationId = !!impersonationId;
|
|
});
|
|
}
|
|
|
|
public ngOnDestroy() {
|
|
this.unsubscribeSubject.next();
|
|
this.unsubscribeSubject.complete();
|
|
}
|
|
}
|
|
|