Исправлена обработка ошибки для пустых дашбордов или полностью свёрнутых изначально

This commit is contained in:
Pavel Gnedov 2024-02-02 07:59:16 +07:00
parent 50f7aeaf2f
commit fd121d5db1

View file

@ -22,6 +22,7 @@ export class DashboardsDataService {
const cfg = await this.dashboardsService.load(id);
const results: WidgetWithData[] = [];
let isSuccess = false;
let counter = 0;
if (!cfg?.widgets || cfg?.widgets?.length <= 0) {
return results;
}
@ -35,12 +36,13 @@ export class DashboardsDataService {
cfg,
);
if (loadRes.result) {
counter++;
isSuccess = true;
loadRes.result.widgetId = widget.id;
results.push({ data: loadRes.result, widgetId: widget.id });
}
}
if (!isSuccess) throw createAppError('CANNOT_LOAD_DATA');
if (!isSuccess && counter > 0) throw createAppError('CANNOT_LOAD_DATA');
return results;
}