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 { import {
Body, Body,
Controller, Controller,
Delete,
Get, Get,
HttpException, HttpException,
Inject, Inject,
@ -95,9 +96,12 @@ export class BenchmarkController {
} }
} }
@Post('remove') @Delete(':dataSource/:symbol')
@UseGuards(AuthGuard('jwt')) @UseGuards(AuthGuard('jwt'))
public async deleteBenchmark(@Body() { dataSource, symbol }: UniqueAsset) { public async deleteBenchmark(
@Param('dataSource') dataSource: DataSource,
@Param('symbol') symbol: string
) {
if ( if (
!hasPermission( !hasPermission(
this.request.user.permissions, this.request.user.permissions,

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

@ -257,7 +257,7 @@ export class BenchmarkService {
}); });
if (!assetProfile) { if (!assetProfile) {
return; return null;
} }
let benchmarks = let benchmarks =
@ -265,9 +265,9 @@ export class BenchmarkService {
PROPERTY_BENCHMARKS PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? []; )) as BenchmarkProperty[]) ?? [];
benchmarks = benchmarks.filter( benchmarks = benchmarks.filter(({ symbolProfileId }) => {
(item) => item.symbolProfileId !== assetProfile.id return symbolProfileId !== assetProfile.id;
); });
benchmarks = uniqBy(benchmarks, 'symbolProfileId'); 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() { public onSubmit() {
let scraperConfiguration = {}; let scraperConfiguration = {};
let symbolMapping = {}; 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() { public ngOnDestroy() {
this.unsubscribeSubject.next(); this.unsubscribeSubject.next();
this.unsubscribeSubject.complete(); 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, GfPortfolioProportionChartModule,
GfValueModule, GfValueModule,
MatButtonModule, MatButtonModule,
MatDialogModule,
MatCheckboxModule, MatCheckboxModule,
MatDialogModule,
MatInputModule, MatInputModule,
MatMenuModule, MatMenuModule,
ReactiveFormsModule, 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/`); 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) { public deleteOrder(aId: string) {
return this.http.delete<any>(`/api/v1/order/${aId}`); return this.http.delete<any>(`/api/v1/order/${aId}`);
} }
@ -467,10 +471,6 @@ export class DataService {
return this.http.post(`/api/v1/benchmark`, benchmark); 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) { public postOrder(aOrder: CreateOrderDto) {
return this.http.post<OrderModel>(`/api/v1/order`, aOrder); return this.http.post<OrderModel>(`/api/v1/order`, aOrder);
} }

Loading…
Cancel
Save