fixed error
This commit is contained in:
parent
e890ccf2ed
commit
ffb3a3819c
@ -141,28 +141,36 @@ router.get(
|
||||
);
|
||||
const role = await RolesDBApi.findBy({ id: roleId });
|
||||
if (!role?.role_customization) {
|
||||
await Promise.all(["pie", "bar"].map(async (e) => {
|
||||
const schema = await sjs.getSequelizeSchema(db.sequelize, {});
|
||||
const payload = {
|
||||
description: `Create some cool ${e} chart`,
|
||||
modelDefinition: schema.definitions,
|
||||
};
|
||||
const widgetId = await getWidget(payload, currentUser?.id, roleId);
|
||||
if (widgetId) {
|
||||
await RolesService.addRoleInfo(
|
||||
roleId,
|
||||
currentUser?.id,
|
||||
'widgets',
|
||||
widgetId,
|
||||
req.currentUser,
|
||||
);
|
||||
try {
|
||||
await Promise.all(["pie", "bar"].map(async (e) => {
|
||||
const schema = await sjs.getSequelizeSchema(db.sequelize, {});
|
||||
const payload = {
|
||||
description: `Create some cool ${e} chart`,
|
||||
modelDefinition: schema.definitions,
|
||||
};
|
||||
const widgetId = await getWidget(payload, currentUser?.id, roleId);
|
||||
if (widgetId) {
|
||||
await RolesService.addRoleInfo(
|
||||
roleId,
|
||||
currentUser?.id,
|
||||
'widgets',
|
||||
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);
|
||||
}),
|
||||
|
||||
@ -374,12 +374,11 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
|
||||
|
||||
const currentUser = req.currentUser;
|
||||
const runtimeContext = req.runtimeContext;
|
||||
const payload = await ProjectsDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser, runtimeContext }
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user