Browse Source

Response to reviews

pull/2409/head
Manushreshta B L 2 years ago
parent
commit
4a2825840d
  1. 8
      apps/api/src/app/benchmark/benchmark.controller.ts
  2. 8
      apps/api/src/app/benchmark/benchmark.service.ts
  3. 20
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  4. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.module.ts
  5. 8
      apps/client/src/app/services/data.service.ts

8
apps/api/src/app/benchmark/benchmark.controller.ts

@ -10,6 +10,7 @@ import type { RequestWithUser } from '@ghostfolio/common/types';
import {
Body,
Controller,
Delete,
Get,
HttpException,
Inject,
@ -95,9 +96,12 @@ export class BenchmarkController {
}
}
@Post('remove')
@Delete(':dataSource/:symbol')
@UseGuards(AuthGuard('jwt'))
public async deleteBenchmark(@Body() { dataSource, symbol }: UniqueAsset) {
public async deleteBenchmark(
@Param('dataSource') dataSource: DataSource,
@Param('symbol') symbol: string
) {
if (
!hasPermission(
this.request.user.permissions,

8
apps/api/src/app/benchmark/benchmark.service.ts

@ -257,7 +257,7 @@ export class BenchmarkService {
});
if (!assetProfile) {
return;
return null;
}
let benchmarks =
@ -265,9 +265,9 @@ export class BenchmarkService {
PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? [];
benchmarks = benchmarks.filter(
(item) => item.symbolProfileId !== assetProfile.id
);
benchmarks = benchmarks.filter(({ symbolProfileId }) => {
return symbolProfileId !== assetProfile.id;
});
benchmarks = uniqBy(benchmarks, 'symbolProfileId');

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

@ -152,17 +152,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
});
}
public onUnsetBenchmark({ dataSource, symbol }: UniqueAsset) {
this.dataService
.deleteBenchmark({ dataSource, symbol })
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
setTimeout(() => {
window.location.reload();
}, 300);
});
}
public onSubmit() {
let scraperConfiguration = {};
let symbolMapping = {};
@ -196,6 +185,15 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
});
}
public onUnsetBenchmark({ dataSource, symbol }: UniqueAsset) {
this.dataService
.deleteBenchmark({ dataSource, symbol })
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
this.isBenchmark = false;
});
}
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();

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

@ -22,8 +22,8 @@ import { AssetProfileDialog } from './asset-profile-dialog.component';
GfPortfolioProportionChartModule,
GfValueModule,
MatButtonModule,
MatDialogModule,
MatCheckboxModule,
MatDialogModule,
MatInputModule,
MatMenuModule,
ReactiveFormsModule,

8
apps/client/src/app/services/data.service.ts

@ -204,6 +204,10 @@ export class DataService {
return this.http.delete<any>(`/api/v1/order/`);
}
public deleteBenchmark({ dataSource, symbol }: UniqueAsset) {
return this.http.delete<any>(`/api/v1/benchmark/${dataSource}/${symbol}`);
}
public deleteOrder(aId: string) {
return this.http.delete<any>(`/api/v1/order/${aId}`);
}
@ -467,10 +471,6 @@ export class DataService {
return this.http.post(`/api/v1/benchmark`, benchmark);
}
public deleteBenchmark(benchmark: UniqueAsset) {
return this.http.post(`/api/v1/benchmark/remove`, benchmark);
}
public postOrder(aOrder: CreateOrderDto) {
return this.http.post<OrderModel>(`/api/v1/order`, aOrder);
}

Loading…
Cancel
Save