|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard';
|
|
|
|
|
import { ApiService } from '@ghostfolio/api/services/api/api.service';
|
|
|
|
|
import { Export } from '@ghostfolio/common/interfaces';
|
|
|
|
|
import type { RequestWithUser } from '@ghostfolio/common/types';
|
|
|
|
|
import { Controller, Get, Inject, Query, UseGuards } from '@nestjs/common';
|
|
|
|
@ -10,6 +11,7 @@ import { ExportService } from './export.service';
|
|
|
|
|
@Controller('export')
|
|
|
|
|
export class ExportController {
|
|
|
|
|
public constructor(
|
|
|
|
|
private readonly apiService: ApiService,
|
|
|
|
|
private readonly exportService: ExportService,
|
|
|
|
|
@Inject(REQUEST) private readonly request: RequestWithUser
|
|
|
|
|
) {}
|
|
|
|
@ -17,10 +19,20 @@ export class ExportController {
|
|
|
|
|
@Get()
|
|
|
|
|
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
|
|
|
|
public async export(
|
|
|
|
|
@Query('activityIds') activityIds?: string[]
|
|
|
|
|
@Query('accounts') filterByAccounts?: string,
|
|
|
|
|
@Query('activityIds') activityIds?: string[],
|
|
|
|
|
@Query('assetClasses') filterByAssetClasses?: string,
|
|
|
|
|
@Query('tags') filterByTags?: string
|
|
|
|
|
): Promise<Export> {
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({
|
|
|
|
|
filterByAccounts,
|
|
|
|
|
filterByAssetClasses,
|
|
|
|
|
filterByTags
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return this.exportService.export({
|
|
|
|
|
activityIds,
|
|
|
|
|
filters,
|
|
|
|
|
userCurrency: this.request.user.Settings.settings.baseCurrency,
|
|
|
|
|
userId: this.request.user.id
|
|
|
|
|
});
|
|
|
|
|