@ -1,4 +1,5 @@
import { DataService } from '@ghostfolio/client/services/data.service' ;
import { DataService } from '@ghostfolio/client/services/data.service' ;
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service' ;
import { UserService } from '@ghostfolio/client/services/user/user.service' ;
import { UserService } from '@ghostfolio/client/services/user/user.service' ;
import {
import {
AssetProfileIdentifier ,
AssetProfileIdentifier ,
@ -45,6 +46,7 @@ import { CreateWatchlistItemDialogParams } from './create-watchlist-item-dialog/
} )
} )
export class HomeWatchlistComponent implements OnDestroy , OnInit {
export class HomeWatchlistComponent implements OnDestroy , OnInit {
public deviceType : string ;
public deviceType : string ;
public hasImpersonationId : boolean ;
public hasPermissionToCreateWatchlistItem : boolean ;
public hasPermissionToCreateWatchlistItem : boolean ;
public hasPermissionToDeleteWatchlistItem : boolean ;
public hasPermissionToDeleteWatchlistItem : boolean ;
public user : User ;
public user : User ;
@ -57,12 +59,20 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit {
private dataService : DataService ,
private dataService : DataService ,
private deviceService : DeviceDetectorService ,
private deviceService : DeviceDetectorService ,
private dialog : MatDialog ,
private dialog : MatDialog ,
private impersonationStorageService : ImpersonationStorageService ,
private route : ActivatedRoute ,
private route : ActivatedRoute ,
private router : Router ,
private router : Router ,
private userService : UserService
private userService : UserService
) {
) {
this . deviceType = this . deviceService . getDeviceInfo ( ) . deviceType ;
this . deviceType = this . deviceService . getDeviceInfo ( ) . deviceType ;
this . impersonationStorageService
. onChangeHasImpersonation ( )
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. subscribe ( ( impersonationId ) = > {
this . hasImpersonationId = ! ! impersonationId ;
} ) ;
this . route . queryParams
this . route . queryParams
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. subscribe ( ( params ) = > {
. subscribe ( ( params ) = > {
@ -77,14 +87,18 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit {
if ( state ? . user ) {
if ( state ? . user ) {
this . user = state . user ;
this . user = state . user ;
this . hasPermissionToCreateWatchlistItem = hasPermission (
this . hasPermissionToCreateWatchlistItem =
this . user . permissions ,
! this . hasImpersonationId &&
permissions . createWatchlistItem
hasPermission (
) ;
this . user . permissions ,
this . hasPermissionToDeleteWatchlistItem = hasPermission (
permissions . createWatchlistItem
this . user . permissions ,
) ;
permissions . deleteWatchlistItem
this . hasPermissionToDeleteWatchlistItem =
) ;
! this . hasImpersonationId &&
hasPermission (
this . user . permissions ,
permissions . deleteWatchlistItem
) ;
this . changeDetectorRef . markForCheck ( ) ;
this . changeDetectorRef . markForCheck ( ) ;
}
}