Исправлены адреса ендпоинтов и формат возвращаемых данных из виджетов
This commit is contained in:
parent
10b04bdb0f
commit
14e0108f02
3 changed files with 12 additions and 14 deletions
|
|
@ -3,7 +3,7 @@ import { DashboardsService } from './dashboards.service';
|
|||
import { BadRequestErrorHandler, getOrAppErrorOrThrow } from '../utils/result';
|
||||
import { DashboardsDataService } from './dashboards-data.service';
|
||||
|
||||
@Controller('dashboard')
|
||||
@Controller('api/dashboard')
|
||||
export class DashboardController {
|
||||
constructor(
|
||||
private dashboardsService: DashboardsService,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,7 @@
|
|||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DashboardsService } from './dashboards.service';
|
||||
import * as DashboardModel from '../models/dashboard';
|
||||
import {
|
||||
AppError,
|
||||
Result,
|
||||
createAppError,
|
||||
fail,
|
||||
success,
|
||||
} from '../utils/result';
|
||||
import { AppError, Result, createAppError, fail } from '../utils/result';
|
||||
import { WidgetsCollectionService } from './widgets-collection.service';
|
||||
|
||||
export type WidgetWithData = {
|
||||
|
|
@ -38,10 +32,8 @@ export class DashboardsDataService {
|
|||
);
|
||||
if (loadRes.result) {
|
||||
isSuccess = true;
|
||||
results.push({
|
||||
widget: widget,
|
||||
data: loadRes.result,
|
||||
});
|
||||
loadRes.result.widgetId = widget.id;
|
||||
results.push(loadRes.result);
|
||||
}
|
||||
}
|
||||
if (!isSuccess) throw createAppError('CANNOT_LOAD_DATA');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Result, AppError } from '../utils/result';
|
||||
import { Result, AppError, fail, success } from '../utils/result';
|
||||
import { WidgetDataLoaderInterface } from './widget-data-loader-interface';
|
||||
import { WidgetInterface } from './widget-interface';
|
||||
|
||||
|
|
@ -16,7 +16,13 @@ export class InteractiveWidget
|
|||
dashboardParams: any,
|
||||
): Promise<Result<any, AppError>> {
|
||||
const data = await this.dataLoader.load(dataLoaderParams, dashboardParams);
|
||||
return data;
|
||||
return data.error
|
||||
? fail(data.error)
|
||||
: success({
|
||||
data: data.result,
|
||||
widgetParams: widgetParams,
|
||||
dashboardParams: dashboardParams,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue