fixed error

This commit is contained in:
Dmitri 2026-03-19 07:36:50 +04:00
parent e890ccf2ed
commit ffb3a3819c
2 changed files with 30 additions and 23 deletions

View File

@ -141,28 +141,36 @@ router.get(
); );
const role = await RolesDBApi.findBy({ id: roleId }); const role = await RolesDBApi.findBy({ id: roleId });
if (!role?.role_customization) { if (!role?.role_customization) {
await Promise.all(["pie", "bar"].map(async (e) => { try {
const schema = await sjs.getSequelizeSchema(db.sequelize, {}); await Promise.all(["pie", "bar"].map(async (e) => {
const payload = { const schema = await sjs.getSequelizeSchema(db.sequelize, {});
description: `Create some cool ${e} chart`, const payload = {
modelDefinition: schema.definitions, description: `Create some cool ${e} chart`,
}; modelDefinition: schema.definitions,
const widgetId = await getWidget(payload, currentUser?.id, roleId); };
if (widgetId) { const widgetId = await getWidget(payload, currentUser?.id, roleId);
await RolesService.addRoleInfo( if (widgetId) {
roleId, await RolesService.addRoleInfo(
currentUser?.id, roleId,
'widgets', currentUser?.id,
widgetId, 'widgets',
req.currentUser, widgetId,
); req.currentUser,
);
}
}));
info = await RolesService.getRoleInfoByKey(
key,
roleId,
currentUser,
);
} catch (error) {
console.warn('Widget creation skipped (external API unavailable):', error.message);
// Return empty widgets when external API is unavailable
if (key === 'widgets') {
info = [];
} }
})) }
info = await RolesService.getRoleInfoByKey(
key,
roleId,
currentUser,
);
} }
res.status(200).send(info); res.status(200).send(info);
}), }),

View File

@ -374,12 +374,11 @@ router.get('/', wrapAsync(async (req, res) => {
* description: Some server error * description: Some server error
*/ */
router.get('/count', wrapAsync(async (req, res) => { router.get('/count', wrapAsync(async (req, res) => {
const currentUser = req.currentUser; const currentUser = req.currentUser;
const runtimeContext = req.runtimeContext; const runtimeContext = req.runtimeContext;
const payload = await ProjectsDBApi.findAll( const payload = await ProjectsDBApi.findAll(
req.query, req.query,
null,
{ countOnly: true, currentUser, runtimeContext } { countOnly: true, currentUser, runtimeContext }
); );