pinkmine/src/dashboards/simple-issues-list.controller.ts

34 lines
1.1 KiB
TypeScript

import { DynamicLoader } from '@app/event-emitter/configs/dynamic-loader';
import { Controller, Get, Param, Render } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { IssuesByTagsWidgetService } from './widgets/issues-by-tags.widget.service';
import { parse } from 'jsonc-parser';
@Controller('simple-issues-list')
export class SimpleIssuesListController {
private path: string;
constructor(
private issuesByTagsWidgetService: IssuesByTagsWidgetService,
private dynamicLoader: DynamicLoader,
private configService: ConfigService,
) {
this.path = this.configService.get<string>('simpleKanbanBoard.path');
}
@Get('/by-tags/:name/raw')
async getByTagsRawData(@Param('name') name: string): Promise<any> {
const cfg = this.dynamicLoader.load(name, {
path: this.path,
ext: 'jsonc',
parser: parse,
});
return await this.issuesByTagsWidgetService.render(cfg);
}
@Get('/by-tags/:name')
@Render('simple-issues-list')
async getByTags(@Param('name') name: string): Promise<any> {
return await this.getByTagsRawData(name);
}
}