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