Browse Source

Refactoring

pull/4080/head
Thomas Kaul 9 months ago
parent
commit
6f03a52b55
  1. 2
      apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
  2. 14
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  3. 1
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  4. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.module.ts
  5. 0
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/interfaces/interfaces.ts
  6. 2
      libs/ui/src/lib/market-data-detail/market-data-detail-dialog/market-data-detail-dialog.component.ts
  7. 23
      libs/ui/src/lib/market-data-detail/market-data-detail.component.ts

2
apps/client/src/app/components/admin-market-data/admin-market-data.component.ts

@ -39,9 +39,9 @@ import { distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators';
import { AdminMarketDataService } from './admin-market-data.service';
import { AssetProfileDialog } from './asset-profile-dialog/asset-profile-dialog.component';
import { AssetProfileDialogParams } from './asset-profile-dialog/interfaces/interfaces';
import { CreateAssetProfileDialog } from './create-asset-profile-dialog/create-asset-profile-dialog.component';
import { CreateAssetProfileDialogParams } from './create-asset-profile-dialog/interfaces/interfaces';
import { AssetProfileDialogParams } from './interfaces/interfaces';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,

14
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -10,8 +10,8 @@ import { DATE_FORMAT } from '@ghostfolio/common/helper';
import {
AdminMarketDataDetails,
AssetProfileIdentifier,
User,
LineChartItem
LineChartItem,
User
} from '@ghostfolio/common/interfaces';
import { translate } from '@ghostfolio/ui/i18n';
@ -35,7 +35,7 @@ import { format } from 'date-fns';
import { EMPTY, Subject } from 'rxjs';
import { catchError, takeUntil } from 'rxjs/operators';
import { AssetProfileDialogParams } from '../interfaces/interfaces';
import { AssetProfileDialogParams } from './interfaces/interfaces';
@Component({
host: { class: 'd-flex flex-column h-100' },
@ -118,6 +118,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.user = state.user;
}
});
this.adminService
.fetchAdminMarketDataBySymbol({
dataSource: this.data.dataSource,
@ -130,10 +131,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
this.assetProfileClass = translate(this.assetProfile?.assetClass);
this.assetProfileSubClass = translate(this.assetProfile?.assetSubClass);
this.countries = {};
this.isBenchmark = this.benchmarks.some(({ id }) => {
return id === this.assetProfile.id;
});
this.marketDataDetails = marketData;
this.historicalDataItems = this.marketDataDetails.map(
({ date, marketPrice }) => {
@ -144,6 +145,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}
);
this.marketDataDetails = marketData;
this.sectors = {};
if (this.assetProfile?.countries?.length > 0) {
@ -225,10 +227,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
}
}
public onImportHistoricalDataChanged() {
this.initialize();
}
public onSetBenchmark({ dataSource, symbol }: AssetProfileIdentifier) {
this.dataService
.postBenchmark({ dataSource, symbol })

1
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

@ -87,7 +87,6 @@
[marketData]="marketDataDetails"
[symbol]="data.symbol"
[user]="user"
(historicalDataUpdated)="onImportHistoricalDataChanged()"
(marketDataChanged)="onMarketDataChanged($event)"
/>

2
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.module.ts

@ -23,12 +23,12 @@ import { AssetProfileDialog } from './asset-profile-dialog.component';
@NgModule({
declarations: [AssetProfileDialog],
imports: [
GfMarketDataDetailComponent,
CommonModule,
FormsModule,
GfAssetProfileIconComponent,
GfCurrencySelectorComponent,
GfLineChartComponent,
GfMarketDataDetailComponent,
GfPortfolioProportionChartComponent,
GfValueComponent,
MatButtonModule,

0
apps/client/src/app/components/admin-market-data/interfaces/interfaces.ts → apps/client/src/app/components/admin-market-data/asset-profile-dialog/interfaces/interfaces.ts

2
libs/ui/src/lib/market-data-detail/market-data-detail-dialog/market-data-detail-dialog.component.ts

@ -25,6 +25,7 @@ import { Subject, takeUntil } from 'rxjs';
import { MarketDataDetailDialogParams } from './interfaces/interfaces';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'h-100' },
imports: [
CommonModule,
@ -37,7 +38,6 @@ import { MarketDataDetailDialogParams } from './interfaces/interfaces';
ReactiveFormsModule
],
selector: 'gf-market-data-detail-dialog',
changeDetection: ChangeDetectionStrategy.OnPush,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
standalone: true,
styleUrls: ['./market-data-detail-dialog.scss'],

23
libs/ui/src/lib/market-data-detail/market-data-detail.component.ts

@ -14,6 +14,7 @@ import {
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output
} from '@angular/core';
@ -53,7 +54,9 @@ import { MarketDataDetailDialogComponent } from './market-data-detail-dialog/mar
styleUrls: ['./market-data-detail.component.scss'],
templateUrl: './market-data-detail.component.html'
})
export class GfMarketDataDetailComponent implements OnChanges, OnInit {
export class GfMarketDataDetailComponent
implements OnChanges, OnDestroy, OnInit
{
@Input() currency: string;
@Input() dataSource: DataSource;
@Input() dateOfFirstActivity: string;
@ -63,7 +66,6 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
@Input() user: User;
@Output() marketDataChanged = new EventEmitter<boolean>();
@Output() historicalDataUpdated = new EventEmitter();
public days = Array(31);
public defaultDateFormat: string;
@ -90,8 +92,8 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
public constructor(
private adminService: AdminService,
private deviceService: DeviceDetectorService,
private formBuilder: FormBuilder,
private dialog: MatDialog,
private formBuilder: FormBuilder,
private snackBar: MatSnackBar
) {
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
@ -215,7 +217,7 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
.afterClosed()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ withRefresh } = { withRefresh: false }) => {
this.marketDataChanged.next(withRefresh);
this.marketDataChanged.emit(withRefresh);
});
}
@ -249,8 +251,9 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
takeUntil(this.unsubscribeSubject)
)
.subscribe(() => {
this.historicalDataUpdated.emit();
this.initializeHistoricalDataForm();
this.marketDataChanged.emit(true);
});
} catch {
this.snackBar.open(
@ -261,6 +264,11 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
}
}
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
private initializeHistoricalDataForm() {
this.historicalDataForm.setValue({
historicalData: {
@ -268,9 +276,4 @@ export class GfMarketDataDetailComponent implements OnChanges, OnInit {
}
});
}
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
}

Loading…
Cancel
Save