diff --git a/ayanova/src/api/authorizationroles.js b/ayanova/src/api/authorizationroles.js index 4afcd533..409c7346 100644 --- a/ayanova/src/api/authorizationroles.js +++ b/ayanova/src/api/authorizationroles.js @@ -42,11 +42,26 @@ export default { ///SalesLimited SalesLimited: 65536 }, + ////////////////////////////////////////////////////////// + // Does current logged in user have role? + // (Can be an array of roles or a single role, if array returns true if any of the array roles are present for this user) + // hasRole(desiredRole) { if (!window.$gz.store.state.roles || window.$gz.store.state.roles === 0) { return false; } - return (window.$gz.store.state.roles & desiredRole) != 0; + //array form? + if (window.$gz._.isArray(desiredRole)) { + //it's an array of roles, iterate and if any are present then return true + for (var i = 0; i < desiredRole.length; i++) { + if ((window.$gz.store.state.roles & desiredRole[i]) != 0) { + return true; + } + } + return false; + } else { + return (window.$gz.store.state.roles & desiredRole) != 0; + } }, /////////////////////////////////////////////////////////////////////// // Get a default empty rights object so that it can be present when a diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index 490f61f8..0a4bfce2 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -402,57 +402,64 @@ export default function initialize() { ); //****************** OPERATIONS - //clear sublevel array - sub = []; + if ( + window.$gz.role.hasRole([ + window.$gz.role.AUTHORIZATION_ROLES.OpsAdminFull, + window.$gz.role.AUTHORIZATION_ROLES.OpsAdminLimited + ]) + ) { + //clear sublevel array + sub = []; - // ARCHIVE - sub.push({ - title: window.$gz.locale.get("Backup"), - icon: "file-archive", - route: "/ops-backup", - key: key++ - }); + // ARCHIVE + sub.push({ + title: window.$gz.locale.get("Backup"), + icon: "file-archive", + route: "/ops-backup", + key: key++ + }); - // JOBS - sub.push({ - title: window.$gz.locale.get("ServerJobs"), - icon: "robot", - route: "/ops-jobs", - key: key++ - }); + // JOBS + sub.push({ + title: window.$gz.locale.get("ServerJobs"), + icon: "robot", + route: "/ops-jobs", + key: key++ + }); - // LOGS - sub.push({ - title: window.$gz.locale.get("ServerLog"), - icon: "history", - route: "/ops-log", - key: key++ - }); + // LOGS + sub.push({ + title: window.$gz.locale.get("ServerLog"), + icon: "history", + route: "/ops-log", + key: key++ + }); - //METRICS - sub.push({ - title: window.$gz.locale.get("ServerMetrics"), - icon: "file-medical-alt", - route: "/ops-metrics", - key: key++ - }); + //METRICS + sub.push({ + title: window.$gz.locale.get("ServerMetrics"), + icon: "file-medical-alt", + route: "/ops-metrics", + key: key++ + }); - //NOTIFICATION CONFIG AND HISTORY - sub.push({ - title: window.$gz.locale.get("NotificationSettings"), - icon: "bullhorn", - route: "/ops-notification-settings", - key: key++ - }); + //NOTIFICATION CONFIG AND HISTORY + sub.push({ + title: window.$gz.locale.get("NotificationSettings"), + icon: "bullhorn", + route: "/ops-notification-settings", + key: key++ + }); - // ** OPERATIONS (TOP) - addNavItem( - window.$gz.locale.get("Operations"), - "server", - undefined, - sub, - key++ - ); + // ** OPERATIONS (TOP) + addNavItem( + window.$gz.locale.get("Operations"), + "server", + undefined, + sub, + key++ + ); + } //**** WIDGETS (TOP GROUP) addNavItem(