mirror of https://github.com/ghostfolio/ghostfolio
Thomas Kaul
2 years ago
committed by
GitHub
16 changed files with 495 additions and 128 deletions
@ -0,0 +1,7 @@ |
|||
:host { |
|||
display: block; |
|||
|
|||
.mat-dialog-content { |
|||
max-height: unset; |
|||
} |
|||
} |
@ -0,0 +1,73 @@ |
|||
import { |
|||
ChangeDetectionStrategy, |
|||
ChangeDetectorRef, |
|||
Component, |
|||
Inject, |
|||
OnDestroy, |
|||
OnInit |
|||
} from '@angular/core'; |
|||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|||
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|||
import { UniqueAsset } from '@ghostfolio/common/interfaces'; |
|||
import { MarketData } from '@prisma/client'; |
|||
import { Subject } from 'rxjs'; |
|||
import { takeUntil } from 'rxjs/operators'; |
|||
|
|||
import { AssetProfileDialogParams } from './interfaces/interfaces'; |
|||
|
|||
@Component({ |
|||
host: { class: 'd-flex flex-column h-100' }, |
|||
selector: 'gf-asset-profile-dialog', |
|||
changeDetection: ChangeDetectionStrategy.OnPush, |
|||
templateUrl: 'asset-profile-dialog.html', |
|||
styleUrls: ['./asset-profile-dialog.component.scss'] |
|||
}) |
|||
export class AssetProfileDialog implements OnDestroy, OnInit { |
|||
public marketDataDetails: MarketData[] = []; |
|||
|
|||
private unsubscribeSubject = new Subject<void>(); |
|||
|
|||
public constructor( |
|||
private adminService: AdminService, |
|||
private changeDetectorRef: ChangeDetectorRef, |
|||
public dialogRef: MatDialogRef<AssetProfileDialog>, |
|||
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams |
|||
) {} |
|||
|
|||
public ngOnInit(): void { |
|||
this.initialize(); |
|||
} |
|||
|
|||
public onClose(): void { |
|||
this.dialogRef.close(); |
|||
} |
|||
|
|||
public onMarketDataChanged(withRefresh: boolean = false) { |
|||
if (withRefresh) { |
|||
this.initialize(); |
|||
} |
|||
} |
|||
|
|||
public ngOnDestroy() { |
|||
this.unsubscribeSubject.next(); |
|||
this.unsubscribeSubject.complete(); |
|||
} |
|||
|
|||
private fetchAdminMarketDataBySymbol({ dataSource, symbol }: UniqueAsset) { |
|||
this.adminService |
|||
.fetchAdminMarketDataBySymbol({ dataSource, symbol }) |
|||
.pipe(takeUntil(this.unsubscribeSubject)) |
|||
.subscribe(({ marketData }) => { |
|||
this.marketDataDetails = marketData; |
|||
|
|||
this.changeDetectorRef.markForCheck(); |
|||
}); |
|||
} |
|||
|
|||
private initialize() { |
|||
this.fetchAdminMarketDataBySymbol({ |
|||
dataSource: this.data.dataSource, |
|||
symbol: this.data.symbol |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
<gf-dialog-header |
|||
mat-dialog-title |
|||
position="center" |
|||
[deviceType]="data.deviceType" |
|||
[title]="data.symbol" |
|||
(closeButtonClicked)="onClose()" |
|||
></gf-dialog-header> |
|||
|
|||
<div class="flex-grow-1" mat-dialog-content> |
|||
<gf-admin-market-data-detail |
|||
[dataSource]="data.dataSource" |
|||
[dateOfFirstActivity]="data.dateOfFirstActivity" |
|||
[locale]="data.locale" |
|||
[marketData]="marketDataDetails" |
|||
[symbol]="data.symbol" |
|||
(marketDataChanged)="onMarketDataChanged($event)" |
|||
></gf-admin-market-data-detail> |
|||
</div> |
|||
|
|||
<gf-dialog-footer |
|||
mat-dialog-actions |
|||
[deviceType]="data.deviceType" |
|||
(closeButtonClicked)="onClose()" |
|||
></gf-dialog-footer> |
@ -0,0 +1,23 @@ |
|||
import { CommonModule } from '@angular/common'; |
|||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; |
|||
import { MatButtonModule } from '@angular/material/button'; |
|||
import { MatDialogModule } from '@angular/material/dialog'; |
|||
import { GfDialogFooterModule } from '@ghostfolio/client/components/dialog-footer/dialog-footer.module'; |
|||
import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module'; |
|||
import { GfAdminMarketDataDetailModule } from '../../admin-market-data-detail/admin-market-data-detail.module'; |
|||
|
|||
import { AssetProfileDialog } from './asset-profile-dialog.component'; |
|||
|
|||
@NgModule({ |
|||
declarations: [AssetProfileDialog], |
|||
imports: [ |
|||
CommonModule, |
|||
GfAdminMarketDataDetailModule, |
|||
GfDialogFooterModule, |
|||
GfDialogHeaderModule, |
|||
MatButtonModule, |
|||
MatDialogModule |
|||
], |
|||
schemas: [CUSTOM_ELEMENTS_SCHEMA] |
|||
}) |
|||
export class GfAssetProfileDialogModule {} |
@ -0,0 +1,9 @@ |
|||
import { DataSource } from '@prisma/client'; |
|||
|
|||
export interface AssetProfileDialogParams { |
|||
dateOfFirstActivity: string; |
|||
dataSource: DataSource; |
|||
deviceType: string; |
|||
locale: string; |
|||
symbol: string; |
|||
} |
@ -1,12 +1,16 @@ |
|||
import { DataSource } from '@prisma/client'; |
|||
import { AssetClass, AssetSubClass, DataSource } from '@prisma/client'; |
|||
|
|||
export interface AdminMarketData { |
|||
marketData: AdminMarketDataItem[]; |
|||
} |
|||
|
|||
export interface AdminMarketDataItem { |
|||
assetClass?: AssetClass; |
|||
assetSubClass?: AssetSubClass; |
|||
countriesCount: number; |
|||
dataSource: DataSource; |
|||
date?: Date; |
|||
marketDataItemCount?: number; |
|||
marketDataItemCount: number; |
|||
sectorsCount: number; |
|||
symbol: string; |
|||
} |
|||
|
Loading…
Reference in new issue