Browse Source

Feature/improve usability to delete asset profile (#3208)

* Disable delete button for benchmarks

* Update changelog
pull/3212/head
Thomas Kaul 10 months ago
committed by GitHub
parent
commit
5ffc39c32f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      CHANGELOG.md
  2. 4
      apps/api/src/app/admin/admin.service.ts
  3. 25
      apps/client/src/app/components/admin-market-data/admin-market-data.component.ts
  4. 6
      apps/client/src/app/components/admin-market-data/admin-market-data.html
  5. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  6. 6
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  7. 2
      libs/common/src/lib/interfaces/admin-market-data.interface.ts

4
CHANGELOG.md

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Changed
- Improved the usability to delete an asset profile in the historical market data table and the asset profile details dialog of the admin control
### Fixed ### Fixed
- Added missing dates to edit historical market data in the asset profile details dialog of the admin control panel - Added missing dates to edit historical market data in the asset profile details dialog of the admin control panel

4
apps/api/src/app/admin/admin.service.ts

@ -212,6 +212,7 @@ export class AdminService {
countries: true, countries: true,
currency: true, currency: true,
dataSource: true, dataSource: true,
id: true,
name: true, name: true,
Order: { Order: {
orderBy: [{ date: 'asc' }], orderBy: [{ date: 'asc' }],
@ -235,6 +236,7 @@ export class AdminService {
countries, countries,
currency, currency,
dataSource, dataSource,
id,
name, name,
Order, Order,
sectors, sectors,
@ -257,6 +259,7 @@ export class AdminService {
currency, currency,
countriesCount, countriesCount,
dataSource, dataSource,
id,
name, name,
symbol, symbol,
marketDataItemCount, marketDataItemCount,
@ -413,6 +416,7 @@ export class AdminService {
assetClass: 'CASH', assetClass: 'CASH',
countriesCount: 0, countriesCount: 0,
currency: symbol.replace(DEFAULT_CURRENCY, ''), currency: symbol.replace(DEFAULT_CURRENCY, ''),
id: undefined,
name: symbol, name: symbol,
sectorsCount: 0 sectorsCount: 0
}; };

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

@ -1,6 +1,10 @@
import { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; import {
DEFAULT_PAGE_SIZE,
ghostfolioScraperApiSymbolPrefix
} from '@ghostfolio/common/config';
import { getDateFormatString } from '@ghostfolio/common/helper'; import { getDateFormatString } from '@ghostfolio/common/helper';
import { Filter, UniqueAsset, User } from '@ghostfolio/common/interfaces'; import { Filter, UniqueAsset, User } from '@ghostfolio/common/interfaces';
import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface'; import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
@ -20,7 +24,7 @@ import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatSort, Sort, SortDirection } from '@angular/material/sort'; import { MatSort, Sort, SortDirection } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { AssetSubClass, DataSource } from '@prisma/client'; import { AssetSubClass, DataSource, SymbolProfile } from '@prisma/client';
import { isUUID } from 'class-validator'; import { isUUID } from 'class-validator';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@ -79,6 +83,7 @@ export class AdminMarketDataComponent
type: <Filter['type']>'PRESET_ID' type: <Filter['type']>'PRESET_ID'
} }
]); ]);
public benchmarks: Partial<SymbolProfile>[];
public currentDataSource: DataSource; public currentDataSource: DataSource;
public currentSymbol: string; public currentSymbol: string;
public dataSource: MatTableDataSource<AdminMarketDataItem> = public dataSource: MatTableDataSource<AdminMarketDataItem> =
@ -99,6 +104,7 @@ export class AdminMarketDataComponent
'actions' 'actions'
]; ];
public filters$ = new Subject<Filter[]>(); public filters$ = new Subject<Filter[]>();
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
public isLoading = false; public isLoading = false;
public isUUID = isUUID; public isUUID = isUUID;
public placeholder = ''; public placeholder = '';
@ -112,6 +118,7 @@ export class AdminMarketDataComponent
private adminMarketDataService: AdminMarketDataService, private adminMarketDataService: AdminMarketDataService,
private adminService: AdminService, private adminService: AdminService,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
private deviceService: DeviceDetectorService, private deviceService: DeviceDetectorService,
private dialog: MatDialog, private dialog: MatDialog,
private route: ActivatedRoute, private route: ActivatedRoute,
@ -171,6 +178,9 @@ export class AdminMarketDataComponent
} }
public ngOnInit() { public ngOnInit() {
const { benchmarks } = this.dataService.fetchInfo();
this.benchmarks = benchmarks;
this.deviceType = this.deviceService.getDeviceInfo().deviceType; this.deviceType = this.deviceService.getDeviceInfo().deviceType;
} }
@ -282,7 +292,16 @@ export class AdminMarketDataComponent
.subscribe(({ count, marketData }) => { .subscribe(({ count, marketData }) => {
this.totalItems = count; this.totalItems = count;
this.dataSource = new MatTableDataSource(marketData); this.dataSource = new MatTableDataSource(
marketData.map((marketDataItem) => {
return {
...marketDataItem,
isBenchmark: this.benchmarks.some(({ id }) => {
return id === marketDataItem.id;
})
};
})
);
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
this.isLoading = false; this.isLoading = false;

6
apps/client/src/app/components/admin-market-data/admin-market-data.html

@ -177,7 +177,11 @@
</a> </a>
<button <button
mat-menu-item mat-menu-item
[disabled]="element.activitiesCount !== 0" [disabled]="
element.activitiesCount !== 0 ||
element.isBenchmark ||
element.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
"
(click)=" (click)="
onDeleteProfileData({ onDeleteProfileData({
dataSource: element.dataSource, dataSource: element.dataSource,

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

@ -3,6 +3,7 @@ import { UpdateMarketDataDto } from '@ghostfolio/api/app/admin/update-market-dat
import { AdminMarketDataService } from '@ghostfolio/client/components/admin-market-data/admin-market-data.service'; import { AdminMarketDataService } from '@ghostfolio/client/components/admin-market-data/admin-market-data.service';
import { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config';
import { DATE_FORMAT } from '@ghostfolio/common/helper'; import { DATE_FORMAT } from '@ghostfolio/common/helper';
import { import {
AdminMarketDataDetails, AdminMarketDataDetails,
@ -71,6 +72,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
[code: string]: { name: string; value: number }; [code: string]: { name: string; value: number };
}; };
public currencies: Currency[] = []; public currencies: Currency[] = [];
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
public isBenchmark = false; public isBenchmark = false;
public marketDataDetails: MarketData[] = []; public marketDataDetails: MarketData[] = [];
public sectors: { public sectors: {

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

@ -47,7 +47,11 @@
<button <button
mat-menu-item mat-menu-item
type="button" type="button"
[disabled]="assetProfile?.activitiesCount !== 0" [disabled]="
assetProfile?.activitiesCount !== 0 ||
isBenchmark ||
data.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
"
(click)=" (click)="
onDeleteProfileData({ onDeleteProfileData({
dataSource: data.dataSource, dataSource: data.dataSource,

2
libs/common/src/lib/interfaces/admin-market-data.interface.ts

@ -13,6 +13,8 @@ export interface AdminMarketDataItem {
currency: string; currency: string;
dataSource: DataSource; dataSource: DataSource;
date?: Date; date?: Date;
id: string;
isBenchmark?: boolean;
marketDataItemCount: number; marketDataItemCount: number;
name: string; name: string;
sectorsCount: number; sectorsCount: number;

Loading…
Cancel
Save