@ -1,5 +1,6 @@
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service' ;
import { UserService } from '@ghostfolio/client/services/user/user.service' ;
import { locale as defaultLocale } from '@ghostfolio/common/config' ;
import {
AssetProfileIdentifier ,
Benchmark ,
@ -14,8 +15,10 @@ import {
ChangeDetectionStrategy ,
ChangeDetectorRef ,
Component ,
computed ,
CUSTOM_ELEMENTS_SCHEMA ,
DestroyRef ,
inject ,
OnInit
} from '@angular/core' ;
import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
@ -45,26 +48,29 @@ import { CreateWatchlistItemDialogParams } from './create-watchlist-item-dialog/
templateUrl : './home-watchlist.html'
} )
export class GfHomeWatchlistComponent implements OnInit {
public deviceType : string ;
public hasImpersonationId : boolean ;
public hasPermissionToCreateWatchlistItem : boolean ;
public hasPermissionToDeleteWatchlistItem : boolean ;
public user : User ;
public watchlist : Benchmark [ ] ;
public constructor (
private changeDetectorRef : ChangeDetectorRef ,
private dataService : DataService ,
private destroyRef : DestroyRef ,
private deviceService : DeviceDetectorService ,
private dialog : MatDialog ,
private impersonationStorageService : ImpersonationStorageService ,
private route : ActivatedRoute ,
private router : Router ,
private userService : UserService
) {
this . deviceType = this . deviceService . getDeviceInfo ( ) . deviceType ;
protected hasImpersonationId : boolean ;
protected hasPermissionToCreateWatchlistItem : boolean ;
protected hasPermissionToDeleteWatchlistItem : boolean ;
protected user : User ;
protected watchlist : Benchmark [ ] ;
protected readonly deviceType = computed (
( ) = > this . deviceDetectorService . deviceInfo ( ) . deviceType
) ;
private readonly changeDetectorRef = inject ( ChangeDetectorRef ) ;
private readonly dataService = inject ( DataService ) ;
private readonly destroyRef = inject ( DestroyRef ) ;
private readonly deviceDetectorService = inject ( DeviceDetectorService ) ;
private readonly dialog = inject ( MatDialog ) ;
private readonly impersonationStorageService = inject (
ImpersonationStorageService
) ;
private readonly route = inject ( ActivatedRoute ) ;
private readonly router = inject ( Router ) ;
private readonly userService = inject ( UserService ) ;
public constructor ( ) {
this . impersonationStorageService
. onChangeHasImpersonation ( )
. pipe ( takeUntilDestroyed ( this . destroyRef ) )
@ -110,7 +116,7 @@ export class GfHomeWatchlistComponent implements OnInit {
this . loadWatchlistData ( ) ;
}
p ublic onWatchlistItemDeleted ( {
p rotected onWatchlistItemDeleted ( {
dataSource ,
symbol
} : AssetProfileIdentifier ) {
@ -148,10 +154,10 @@ export class GfHomeWatchlistComponent implements OnInit {
> ( GfCreateWatchlistItemDialogComponent , {
autoFocus : false ,
data : {
deviceType : this.deviceType ,
locale : this.user?.settings?.locale
deviceType : this.deviceType () ,
locale : this.user?.settings?.locale ? ? defaultLocale
} ,
width : this.deviceType === 'mobile' ? '100vw' : '50rem'
width : this.deviceType ( ) === 'mobile' ? '100vw' : '50rem'
} ) ;
dialogRef