styles and startmenuItems
This commit is contained in:
82
utils.js
82
utils.js
@@ -4,7 +4,7 @@ const { permission } = require('process');
|
||||
const { dirname } = require('path');
|
||||
const { File: HotReload } = require(`@services/hotReload.js`);
|
||||
const { service } = require(`@root/server.js`);
|
||||
let integratedStartmenuItems = require('@models/integratedStartmenuItems');
|
||||
// let integratedStartmenuItems = require('@models/integratedStartmenuItems');
|
||||
|
||||
|
||||
global.path = {
|
||||
@@ -20,17 +20,17 @@ global.json = {
|
||||
configuration: new HotReload(path.join(global.path.source, 'models', 'configuration.json')),
|
||||
stylesheet: new HotReload(path.join(global.path.source, 'models', 'stylesheet.json')),
|
||||
indexRoutes: new HotReload(path.join(global.path.source, 'routes', 'indexRoutes.js'), { historyLimit: 50, fileType: 'js' }),
|
||||
startMenuItems: new HotReload(path.join(global.path.source, 'models', 'integratedStartmenuItems.js'), { historyLimit: 50, fileType: 'js' })
|
||||
startMenuItems: new HotReload(path.join(global.path.source, 'models', 'integratedStartMenuItems.json'))
|
||||
}
|
||||
|
||||
|
||||
module.exports = startMenuItems = async function(app, sAMAccountName) {
|
||||
function safeClone(obj) {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
delete integratedStartmenuItems;
|
||||
module.exports = startMenuItems = async function (app, sAMAccountName) {
|
||||
|
||||
integratedStartmenuItems = safeClone(json.startMenuItems.live);
|
||||
function safeClone(obj) {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
const integratedStartmenuItems = safeClone(global.json.startMenuItems.live);
|
||||
|
||||
const plugins = service
|
||||
.get('pluginManager')
|
||||
@@ -50,13 +50,18 @@ function safeClone(obj) {
|
||||
const authorized =
|
||||
item.label === 'hr' ||
|
||||
item.permissions.includes('Administration')
|
||||
? global.json.configuration.live.administration.some(name => name.toLowerCase() === sAMAccountName.toLowerCase())
|
||||
? global.json.configuration.live.administration.some(
|
||||
name => name.toLowerCase() === sAMAccountName.toLowerCase()
|
||||
)
|
||||
: item.permissions.includes('*') ||
|
||||
(
|
||||
await Promise.all(
|
||||
item.permissions.map(async permission =>
|
||||
(await service.get('activeDirectoryManager').getGroup(permission)) &&
|
||||
(await service.get('activeDirectoryManager').isUserMemberOfRecursive(sAMAccountName, permission))
|
||||
(await service.get('activeDirectoryManager').isUserMemberOfRecursive(
|
||||
sAMAccountName,
|
||||
permission
|
||||
))
|
||||
)
|
||||
)
|
||||
).some(Boolean);
|
||||
@@ -81,6 +86,63 @@ function safeClone(obj) {
|
||||
|
||||
return [...getAllPlugins];
|
||||
};
|
||||
// module.exports = startMenuItems = async function(app, sAMAccountName) {
|
||||
// function safeClone(obj) {
|
||||
// return JSON.parse(JSON.stringify(obj));
|
||||
// }
|
||||
// delete integratedStartmenuItems;
|
||||
|
||||
// integratedStartmenuItems = safeClone(json.startMenuItems.live);
|
||||
|
||||
// const plugins = service
|
||||
// .get('pluginManager')
|
||||
// .getStatus()
|
||||
// .map(({ config, ...plugin }) => ({
|
||||
// ...safeClone(plugin),
|
||||
// section: 'Plugin'
|
||||
// }));
|
||||
|
||||
// let getAllPlugins = [...plugins, ...integratedStartmenuItems];
|
||||
|
||||
// for (const plugin of getAllPlugins) {
|
||||
|
||||
// plugin.menu.items = await Promise.all(
|
||||
// (plugin.menu.items || []).map(async item => {
|
||||
|
||||
// const authorized =
|
||||
// item.label === 'hr' ||
|
||||
// item.permissions.includes('Administration')
|
||||
// ? global.json.configuration.live.administration.some(name => name.toLowerCase() === sAMAccountName.toLowerCase())
|
||||
// : item.permissions.includes('*') ||
|
||||
// (
|
||||
// await Promise.all(
|
||||
// item.permissions.map(async permission =>
|
||||
// (await service.get('activeDirectoryManager').getGroup(permission)) &&
|
||||
// (await service.get('activeDirectoryManager').isUserMemberOfRecursive(sAMAccountName, permission))
|
||||
// )
|
||||
// )
|
||||
// ).some(Boolean);
|
||||
|
||||
// return {
|
||||
// ...safeClone(item),
|
||||
// authorized
|
||||
// };
|
||||
// })
|
||||
// );
|
||||
|
||||
// plugin.onlyAdministration =
|
||||
// plugin.menu.items.every(item => !item.authorized) &&
|
||||
// !global.json.configuration.live.administration.includes(sAMAccountName);
|
||||
// }
|
||||
|
||||
// getAllPlugins = getAllPlugins
|
||||
// .filter(plugin => !plugin.onlyAdministration)
|
||||
// .filter(plugin => plugin.active);
|
||||
|
||||
// app.locals.startMenuItems = getAllPlugins;
|
||||
|
||||
// return [...getAllPlugins];
|
||||
// };
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user