|
@ -13,13 +13,23 @@ import { |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { Title } from '@angular/platform-browser'; |
|
|
import { Title } from '@angular/platform-browser'; |
|
|
import { NavigationEnd, PRIMARY_OUTLET, Router } from '@angular/router'; |
|
|
import { |
|
|
|
|
|
ActivatedRoute, |
|
|
|
|
|
NavigationEnd, |
|
|
|
|
|
PRIMARY_OUTLET, |
|
|
|
|
|
Router |
|
|
|
|
|
} from '@angular/router'; |
|
|
|
|
|
import { DataSource } from '@prisma/client'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { filter, takeUntil } from 'rxjs/operators'; |
|
|
import { filter, takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
import { PositionDetailDialogParams } from './components/position-detail-dialog/interfaces/interfaces'; |
|
|
|
|
|
import { PositionDetailDialog } from './components/position-detail-dialog/position-detail-dialog.component'; |
|
|
import { DataService } from './services/data.service'; |
|
|
import { DataService } from './services/data.service'; |
|
|
|
|
|
import { ImpersonationStorageService } from './services/impersonation-storage.service'; |
|
|
import { TokenStorageService } from './services/token-storage.service'; |
|
|
import { TokenStorageService } from './services/token-storage.service'; |
|
|
import { UserService } from './services/user/user.service'; |
|
|
import { UserService } from './services/user/user.service'; |
|
|
|
|
|
|
|
@ -38,6 +48,7 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
public currentRoute: string; |
|
|
public currentRoute: string; |
|
|
public currentYear = new Date().getFullYear(); |
|
|
public currentYear = new Date().getFullYear(); |
|
|
public deviceType: string; |
|
|
public deviceType: string; |
|
|
|
|
|
public hasImpersonationId: boolean; |
|
|
public hasInfoMessage: boolean; |
|
|
public hasInfoMessage: boolean; |
|
|
public hasPermissionForStatistics: boolean; |
|
|
public hasPermissionForStatistics: boolean; |
|
|
public hasPermissionForSubscription: boolean; |
|
|
public hasPermissionForSubscription: boolean; |
|
@ -67,7 +78,10 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
|
|
|
private dialog: MatDialog, |
|
|
@Inject(DOCUMENT) private document: Document, |
|
|
@Inject(DOCUMENT) private document: Document, |
|
|
|
|
|
private impersonationStorageService: ImpersonationStorageService, |
|
|
|
|
|
private route: ActivatedRoute, |
|
|
private router: Router, |
|
|
private router: Router, |
|
|
private title: Title, |
|
|
private title: Title, |
|
|
private tokenStorageService: TokenStorageService, |
|
|
private tokenStorageService: TokenStorageService, |
|
@ -75,6 +89,21 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
) { |
|
|
) { |
|
|
this.initializeTheme(); |
|
|
this.initializeTheme(); |
|
|
this.user = undefined; |
|
|
this.user = undefined; |
|
|
|
|
|
|
|
|
|
|
|
this.route.queryParams |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((params) => { |
|
|
|
|
|
if ( |
|
|
|
|
|
params['dataSource'] && |
|
|
|
|
|
params['holdingDetailDialog'] && |
|
|
|
|
|
params['symbol'] |
|
|
|
|
|
) { |
|
|
|
|
|
this.openHoldingDetailDialog({ |
|
|
|
|
|
dataSource: params['dataSource'], |
|
|
|
|
|
symbol: params['symbol'] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnInit() { |
|
|
public ngOnInit() { |
|
@ -96,6 +125,13 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
permissions.enableFearAndGreedIndex |
|
|
permissions.enableFearAndGreedIndex |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.impersonationStorageService |
|
|
|
|
|
.onChangeHasImpersonation() |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((impersonationId) => { |
|
|
|
|
|
this.hasImpersonationId = !!impersonationId; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.router.events |
|
|
this.router.events |
|
|
.pipe(filter((event) => event instanceof NavigationEnd)) |
|
|
.pipe(filter((event) => event instanceof NavigationEnd)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
@ -197,6 +233,55 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private openHoldingDetailDialog({ |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol |
|
|
|
|
|
}: { |
|
|
|
|
|
dataSource: DataSource; |
|
|
|
|
|
symbol: string; |
|
|
|
|
|
}) { |
|
|
|
|
|
this.userService |
|
|
|
|
|
.get() |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((user) => { |
|
|
|
|
|
this.user = user; |
|
|
|
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(PositionDetailDialog, { |
|
|
|
|
|
autoFocus: false, |
|
|
|
|
|
data: <PositionDetailDialogParams>{ |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol, |
|
|
|
|
|
baseCurrency: this.user?.settings?.baseCurrency, |
|
|
|
|
|
colorScheme: this.user?.settings?.colorScheme, |
|
|
|
|
|
deviceType: this.deviceType, |
|
|
|
|
|
hasImpersonationId: this.hasImpersonationId, |
|
|
|
|
|
hasPermissionToReportDataGlitch: hasPermission( |
|
|
|
|
|
this.user?.permissions, |
|
|
|
|
|
permissions.reportDataGlitch |
|
|
|
|
|
), |
|
|
|
|
|
locale: this.user?.settings?.locale |
|
|
|
|
|
}, |
|
|
|
|
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh', |
|
|
|
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
dialogRef |
|
|
|
|
|
.afterClosed() |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe(() => { |
|
|
|
|
|
this.router.navigate([], { |
|
|
|
|
|
queryParams: { |
|
|
|
|
|
dataSource: null, |
|
|
|
|
|
holdingDetailDialog: null, |
|
|
|
|
|
symbol: null |
|
|
|
|
|
}, |
|
|
|
|
|
queryParamsHandling: 'merge', |
|
|
|
|
|
relativeTo: this.route |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private toggleTheme(isDarkTheme: boolean) { |
|
|
private toggleTheme(isDarkTheme: boolean) { |
|
|
const themeColor = getCssVariable( |
|
|
const themeColor = getCssVariable( |
|
|
isDarkTheme ? '--dark-background' : '--light-background' |
|
|
isDarkTheme ? '--dark-background' : '--light-background' |
|
|