Feature/improve usability to delete asset profile (#3208)
* Disable delete button for benchmarks * Update changelog
This commit is contained in:
parent
a668a66e84
commit
5ffc39c32f
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## 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
|
||||
|
||||
- Added missing dates to edit historical market data in the asset profile details dialog of the admin control panel
|
||||
|
@ -212,6 +212,7 @@ export class AdminService {
|
||||
countries: true,
|
||||
currency: true,
|
||||
dataSource: true,
|
||||
id: true,
|
||||
name: true,
|
||||
Order: {
|
||||
orderBy: [{ date: 'asc' }],
|
||||
@ -235,6 +236,7 @@ export class AdminService {
|
||||
countries,
|
||||
currency,
|
||||
dataSource,
|
||||
id,
|
||||
name,
|
||||
Order,
|
||||
sectors,
|
||||
@ -257,6 +259,7 @@ export class AdminService {
|
||||
currency,
|
||||
countriesCount,
|
||||
dataSource,
|
||||
id,
|
||||
name,
|
||||
symbol,
|
||||
marketDataItemCount,
|
||||
@ -413,6 +416,7 @@ export class AdminService {
|
||||
assetClass: 'CASH',
|
||||
countriesCount: 0,
|
||||
currency: symbol.replace(DEFAULT_CURRENCY, ''),
|
||||
id: undefined,
|
||||
name: symbol,
|
||||
sectorsCount: 0
|
||||
};
|
||||
|
@ -1,6 +1,10 @@
|
||||
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 { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config';
|
||||
import {
|
||||
DEFAULT_PAGE_SIZE,
|
||||
ghostfolioScraperApiSymbolPrefix
|
||||
} from '@ghostfolio/common/config';
|
||||
import { getDateFormatString } from '@ghostfolio/common/helper';
|
||||
import { Filter, UniqueAsset, User } from '@ghostfolio/common/interfaces';
|
||||
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 { MatTableDataSource } from '@angular/material/table';
|
||||
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 { DeviceDetectorService } from 'ngx-device-detector';
|
||||
import { Subject } from 'rxjs';
|
||||
@ -79,6 +83,7 @@ export class AdminMarketDataComponent
|
||||
type: <Filter['type']>'PRESET_ID'
|
||||
}
|
||||
]);
|
||||
public benchmarks: Partial<SymbolProfile>[];
|
||||
public currentDataSource: DataSource;
|
||||
public currentSymbol: string;
|
||||
public dataSource: MatTableDataSource<AdminMarketDataItem> =
|
||||
@ -99,6 +104,7 @@ export class AdminMarketDataComponent
|
||||
'actions'
|
||||
];
|
||||
public filters$ = new Subject<Filter[]>();
|
||||
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
|
||||
public isLoading = false;
|
||||
public isUUID = isUUID;
|
||||
public placeholder = '';
|
||||
@ -112,6 +118,7 @@ export class AdminMarketDataComponent
|
||||
private adminMarketDataService: AdminMarketDataService,
|
||||
private adminService: AdminService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private dataService: DataService,
|
||||
private deviceService: DeviceDetectorService,
|
||||
private dialog: MatDialog,
|
||||
private route: ActivatedRoute,
|
||||
@ -171,6 +178,9 @@ export class AdminMarketDataComponent
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
const { benchmarks } = this.dataService.fetchInfo();
|
||||
|
||||
this.benchmarks = benchmarks;
|
||||
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||
}
|
||||
|
||||
@ -282,7 +292,16 @@ export class AdminMarketDataComponent
|
||||
.subscribe(({ count, marketData }) => {
|
||||
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.isLoading = false;
|
||||
|
@ -177,7 +177,11 @@
|
||||
</a>
|
||||
<button
|
||||
mat-menu-item
|
||||
[disabled]="element.activitiesCount !== 0"
|
||||
[disabled]="
|
||||
element.activitiesCount !== 0 ||
|
||||
element.isBenchmark ||
|
||||
element.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
|
||||
"
|
||||
(click)="
|
||||
onDeleteProfileData({
|
||||
dataSource: element.dataSource,
|
||||
|
@ -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 { AdminService } from '@ghostfolio/client/services/admin.service';
|
||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||
import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config';
|
||||
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
||||
import {
|
||||
AdminMarketDataDetails,
|
||||
@ -71,6 +72,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
|
||||
[code: string]: { name: string; value: number };
|
||||
};
|
||||
public currencies: Currency[] = [];
|
||||
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
|
||||
public isBenchmark = false;
|
||||
public marketDataDetails: MarketData[] = [];
|
||||
public sectors: {
|
||||
|
@ -47,7 +47,11 @@
|
||||
<button
|
||||
mat-menu-item
|
||||
type="button"
|
||||
[disabled]="assetProfile?.activitiesCount !== 0"
|
||||
[disabled]="
|
||||
assetProfile?.activitiesCount !== 0 ||
|
||||
isBenchmark ||
|
||||
data.symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
|
||||
"
|
||||
(click)="
|
||||
onDeleteProfileData({
|
||||
dataSource: data.dataSource,
|
||||
|
@ -13,6 +13,8 @@ export interface AdminMarketDataItem {
|
||||
currency: string;
|
||||
dataSource: DataSource;
|
||||
date?: Date;
|
||||
id: string;
|
||||
isBenchmark?: boolean;
|
||||
marketDataItemCount: number;
|
||||
name: string;
|
||||
sectorsCount: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user