Browse Source

Used npm run format:write to update formatting since the formatting check in the CI pipeline failed

pull/6225/head
Karel De Smet 2 weeks ago
parent
commit
d6cc978e56
  1. 67
      apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
  2. 14
      apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts
  3. 2
      libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

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

@ -10,7 +10,7 @@ import {
InfoItem, InfoItem,
User User
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { AdminMarketData, AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface'; import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { GfSymbolPipe } from '@ghostfolio/common/pipes'; import { GfSymbolPipe } from '@ghostfolio/common/pipes';
import { GfActivitiesFilterComponent } from '@ghostfolio/ui/activities-filter'; import { GfActivitiesFilterComponent } from '@ghostfolio/ui/activities-filter';
@ -62,8 +62,8 @@ import {
} from 'ionicons/icons'; } from 'ionicons/icons';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { Observable, Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators'; import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
import { AdminMarketDataService } from './admin-market-data.service'; import { AdminMarketDataService } from './admin-market-data.service';
import { GfAssetProfileDialogComponent } from './asset-profile-dialog/asset-profile-dialog.component'; import { GfAssetProfileDialogComponent } from './asset-profile-dialog/asset-profile-dialog.component';
@ -416,6 +416,26 @@ export class GfAdminMarketDataComponent
}); });
} }
private refreshTable() {
this.isLoading = true;
this.changeDetectorRef.markForCheck();
this.adminService
.fetchAdminMarketData({
filters: this.activeFilters,
take: this.pageSize
})
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ marketData }) => {
this.dataSource = new MatTableDataSource(marketData);
this.dataSource.sort = this.sort;
this.isLoading = false;
this.changeDetectorRef.markForCheck();
});
}
private openAssetProfileDialog({ private openAssetProfileDialog({
dataSource, dataSource,
symbol symbol
@ -482,43 +502,24 @@ export class GfAdminMarketDataComponent
dialogRef dialogRef
.afterClosed() .afterClosed()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ addAssetProfile, dataSource, symbol } = {}) => { .subscribe((result) => {
this.isLoading = true; if (!result) {
this.changeDetectorRef.markForCheck(); return;
let observable: Observable<AdminMarketData>;
if (!addAssetProfile) {
this.openAssetProfileDialog({ dataSource, symbol });
observable = this.adminService.fetchAdminMarketData({
filters: this.activeFilters,
take: this.pageSize
});
} }
const { addAssetProfile, dataSource, symbol } = result;
if (addAssetProfile && dataSource && symbol) { if (addAssetProfile && dataSource && symbol) {
observable = this.adminService this.adminService
.addAssetProfile({ dataSource, symbol }) .addAssetProfile({ dataSource, symbol })
.pipe( .pipe(takeUntil(this.unsubscribeSubject))
switchMap(() => { .subscribe(() => {
return this.adminService.fetchAdminMarketData({ this.refreshTable();
filters: this.activeFilters,
take: this.pageSize
}); });
}) } else {
); this.refreshTable();
} }
observable.pipe(
takeUntil(this.unsubscribeSubject)
).subscribe(({ marketData }) => {
this.dataSource = new MatTableDataSource(marketData);
this.dataSource.sort = this.sort;
this.isLoading = false;
this.changeDetectorRef.markForCheck();
});
this.router.navigate(['.'], { relativeTo: this.route }); this.router.navigate(['.'], { relativeTo: this.route });
}); });
}); });

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

@ -101,10 +101,10 @@ export class GfCreateAssetProfileDialogComponent implements OnDestroy, OnInit {
public onSubmit() { public onSubmit() {
if (this.mode === 'auto') { if (this.mode === 'auto') {
this.dialogRef.close({ this.dialogRef.close({
addAssetProfile: true,
dataSource: dataSource:
this.createAssetProfileForm.get('searchSymbol').value.dataSource, this.createAssetProfileForm.get('searchSymbol').value.dataSource,
symbol: this.createAssetProfileForm.get('searchSymbol').value.symbol, symbol: this.createAssetProfileForm.get('searchSymbol').value.symbol
addAssetProfile: true
}); });
} else if (this.mode === 'currency') { } else if (this.mode === 'currency') {
const currency = this.createAssetProfileForm.get('addCurrency') const currency = this.createAssetProfileForm.get('addCurrency')
@ -122,23 +122,23 @@ export class GfCreateAssetProfileDialogComponent implements OnDestroy, OnInit {
switchMap(() => { switchMap(() => {
return this.adminService.gatherSymbol({ return this.adminService.gatherSymbol({
dataSource: this.dataSourceForExchangeRates, dataSource: this.dataSourceForExchangeRates,
symbol: `${DEFAULT_CURRENCY}${currency}`, symbol: `${DEFAULT_CURRENCY}${currency}`
}); });
}), }),
takeUntil(this.unsubscribeSubject) takeUntil(this.unsubscribeSubject)
) )
.subscribe(() => { .subscribe(() => {
this.dialogRef.close({ this.dialogRef.close({
addAssetProfile: false,
dataSource: this.dataSourceForExchangeRates, dataSource: this.dataSourceForExchangeRates,
symbol: `${DEFAULT_CURRENCY}${currency}`, symbol: `${DEFAULT_CURRENCY}${currency}`
addAssetProfile: false
}); });
}); });
} else if (this.mode === 'manual') { } else if (this.mode === 'manual') {
this.dialogRef.close({ this.dialogRef.close({
addAssetProfile: true,
dataSource: 'MANUAL', dataSource: 'MANUAL',
symbol: `${this.ghostfolioPrefix}${this.createAssetProfileForm.get('addSymbol').value}`, symbol: `${this.ghostfolioPrefix}${this.createAssetProfileForm.get('addSymbol').value}`
addAssetProfile: true
}); });
} }
} }

2
libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

@ -121,7 +121,7 @@ export class GfSymbolAutocompleteComponent
this.control.valueChanges this.control.valueChanges
.pipe( .pipe(
filter((query) => { filter((query) => {
if (query && query.length === 0) { if (query?.length === 0) {
this.showDefaultOptions(); this.showDefaultOptions();
return false; return false;

Loading…
Cancel
Save