|  | @ -1,4 +1,4 @@ | 
			
		
	
		
		
			
				
					
					|  |  | import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; |  |  | import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | import { MatDialog } from '@angular/material/dialog'; |  |  | import { MatDialog } from '@angular/material/dialog'; | 
			
		
	
		
		
			
				
					|  |  | import { ActivatedRoute, Router } from '@angular/router'; |  |  | import { ActivatedRoute, Router } from '@angular/router'; | 
			
		
	
		
		
			
				
					|  |  | import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto'; |  |  | import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto'; | 
			
		
	
	
		
		
			
				
					|  | @ -20,7 +20,7 @@ import { CreateOrUpdateTransactionDialog } from './create-or-update-transaction- | 
			
		
	
		
		
			
				
					|  |  |   templateUrl: './transactions-page.html', |  |  |   templateUrl: './transactions-page.html', | 
			
		
	
		
		
			
				
					|  |  |   styleUrls: ['./transactions-page.scss'] |  |  |   styleUrls: ['./transactions-page.scss'] | 
			
		
	
		
		
			
				
					|  |  | }) |  |  | }) | 
			
		
	
		
		
			
				
					
					|  |  | export class TransactionsPageComponent implements OnInit { |  |  | export class TransactionsPageComponent implements OnDestroy, OnInit { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |   public deviceType: string; |  |  |   public deviceType: string; | 
			
		
	
		
		
			
				
					|  |  |   public hasImpersonationId: boolean; |  |  |   public hasImpersonationId: boolean; | 
			
		
	
		
		
			
				
					|  |  |   public hasPermissionToCreateOrder: boolean; |  |  |   public hasPermissionToCreateOrder: boolean; | 
			
		
	
	
		
		
			
				
					|  | @ -71,6 +71,7 @@ export class TransactionsPageComponent implements OnInit { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     this.impersonationStorageService |  |  |     this.impersonationStorageService | 
			
		
	
		
		
			
				
					|  |  |       .onChangeHasImpersonation() |  |  |       .onChangeHasImpersonation() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       .pipe(takeUntil(this.unsubscribeSubject)) | 
			
		
	
		
		
			
				
					|  |  |       .subscribe((aId) => { |  |  |       .subscribe((aId) => { | 
			
		
	
		
		
			
				
					|  |  |         this.hasImpersonationId = !!aId; |  |  |         this.hasImpersonationId = !!aId; | 
			
		
	
		
		
			
				
					|  |  |       }); |  |  |       }); | 
			
		
	
	
		
		
			
				
					|  | @ -98,15 +99,18 @@ export class TransactionsPageComponent implements OnInit { | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   public fetchOrders() { |  |  |   public fetchOrders() { | 
			
		
	
		
		
			
				
					
					|  |  |     this.dataService.fetchOrders().subscribe((response) => { |  |  |     this.dataService | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       this.transactions = response; |  |  |       .fetchOrders() | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |       .pipe(takeUntil(this.unsubscribeSubject)) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       .subscribe((response) => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.transactions = response; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |       if (this.transactions?.length <= 0) { |  |  |         if (this.transactions?.length <= 0) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         this.router.navigate([], { queryParams: { createDialog: true } }); |  |  |           this.router.navigate([], { queryParams: { createDialog: true } }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       } |  |  |         } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |       this.changeDetectorRef.markForCheck(); |  |  |         this.changeDetectorRef.markForCheck(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     }); |  |  |       }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   public onCloneTransaction(aTransaction: OrderModel) { |  |  |   public onCloneTransaction(aTransaction: OrderModel) { | 
			
		
	
	
		
		
			
				
					|  | @ -114,11 +118,14 @@ export class TransactionsPageComponent implements OnInit { | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   public onDeleteTransaction(aId: string) { |  |  |   public onDeleteTransaction(aId: string) { | 
			
		
	
		
		
			
				
					
					|  |  |     this.dataService.deleteOrder(aId).subscribe({ |  |  |     this.dataService | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       next: () => { |  |  |       .deleteOrder(aId) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         this.fetchOrders(); |  |  |       .pipe(takeUntil(this.unsubscribeSubject)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       } |  |  |       .subscribe({ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     }); |  |  |         next: () => { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |           this.fetchOrders(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       }); | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   public onUpdateTransaction(aTransaction: OrderModel) { |  |  |   public onUpdateTransaction(aTransaction: OrderModel) { | 
			
		
	
	
		
		
			
				
					|  | @ -159,19 +166,25 @@ export class TransactionsPageComponent implements OnInit { | 
			
		
	
		
		
			
				
					|  |  |       width: this.deviceType === 'mobile' ? '100vw' : '50rem' |  |  |       width: this.deviceType === 'mobile' ? '100vw' : '50rem' | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     dialogRef.afterClosed().subscribe((data: any) => { |  |  |     dialogRef | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       const transaction: UpdateOrderDto = data?.transaction; |  |  |       .afterClosed() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |       .pipe(takeUntil(this.unsubscribeSubject)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       if (transaction) { |  |  |       .subscribe((data: any) => { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         this.dataService.putOrder(transaction).subscribe({ |  |  |         const transaction: UpdateOrderDto = data?.transaction; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           next: () => { |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             this.fetchOrders(); |  |  |         if (transaction) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           } |  |  |           this.dataService | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         }); |  |  |             .putOrder(transaction) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       } |  |  |             .pipe(takeUntil(this.unsubscribeSubject)) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             .subscribe({ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |               next: () => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 this.fetchOrders(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |               } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |       this.router.navigate(['.'], { relativeTo: this.route }); |  |  |         this.router.navigate(['.'], { relativeTo: this.route }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     }); |  |  |       }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   public ngOnDestroy() { |  |  |   public ngOnDestroy() { | 
			
		
	
	
		
		
			
				
					|  | @ -203,18 +216,21 @@ export class TransactionsPageComponent implements OnInit { | 
			
		
	
		
		
			
				
					|  |  |       width: this.deviceType === 'mobile' ? '100vw' : '50rem' |  |  |       width: this.deviceType === 'mobile' ? '100vw' : '50rem' | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     dialogRef.afterClosed().subscribe((data: any) => { |  |  |     dialogRef | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       const transaction: CreateOrderDto = data?.transaction; |  |  |       .afterClosed() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |       .pipe(takeUntil(this.unsubscribeSubject)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       if (transaction) { |  |  |       .subscribe((data: any) => { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         this.dataService.postOrder(transaction).subscribe({ |  |  |         const transaction: CreateOrderDto = data?.transaction; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           next: () => { |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             this.fetchOrders(); |  |  |         if (transaction) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           } |  |  |           this.dataService.postOrder(transaction).subscribe({ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         }); |  |  |             next: () => { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       } |  |  |               this.fetchOrders(); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |       this.router.navigate(['.'], { relativeTo: this.route }); |  |  |         this.router.navigate(['.'], { relativeTo: this.route }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     }); |  |  |       }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |