From f90e738f1d9de866fb51e2d8c63f406fef788744 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 18 Oct 2021 18:09:15 +0000 Subject: [PATCH] license lockout handling code for when db has more active users than license allows for --- ayanova/src/api/authutil.js | 1 + ayanova/src/api/initialize.js | 712 ++++++++++++++++++---------------- ayanova/src/store.js | 3 + 3 files changed, 378 insertions(+), 338 deletions(-) diff --git a/ayanova/src/api/authutil.js b/ayanova/src/api/authutil.js index b6c96ca5..cd59786f 100644 --- a/ayanova/src/api/authutil.js +++ b/ayanova/src/api/authutil.js @@ -54,6 +54,7 @@ export function processLogin(authResponse, loggedInWithKnownPassword) { roles: authResponse.roles, userType: authResponse.usertype, dlt: authResponse.dlt, + l: authResponse.l, tfaEnabled: authResponse.tfa, customerRights: authResponse.customerRights }); diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index b2b880ce..9510fb82 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -23,6 +23,7 @@ function initNavPanel() { let sub = []; const licenseState = window.$gz.store.state.globalSettings.licenseStatus; const useInventory = window.$gz.store.state.globalSettings.useInventory; + const licenseLockout = window.$gz.store.state.l; /*Service = 1, NotService = 2, Customer = 3, @@ -174,365 +175,384 @@ function initNavPanel() { } //####### HOME GROUP + if (!licenseLockout) { + //DASHBOARD + sub.push({ + title: "Dashboard", + icon: "$ayiTachometer", + route: "/home-dashboard", + key: key++ + }); - //DASHBOARD - sub.push({ - title: "Dashboard", - icon: "$ayiTachometer", - route: "/home-dashboard", - key: key++ - }); + //SEARCH + sub.push({ + title: "Search", + icon: "$ayiSearch", + route: "/home-search", + key: key++ + }); - //SEARCH - sub.push({ - title: "Search", - icon: "$ayiSearch", - route: "/home-search", - key: key++ - }); + //SCHEDULE (personal) + sub.push({ + title: "Schedule", + icon: "$ayiCalendarDay", + route: "/home-schedule", + key: key++ + }); - //SCHEDULE (personal) - sub.push({ - title: "Schedule", - icon: "$ayiCalendarDay", - route: "/home-schedule", - key: key++ - }); + //MEMOS + sub.push({ + title: "MemoList", + icon: "$ayiInbox", + route: "/home-memos", + key: key++ + }); - //MEMOS - sub.push({ - title: "MemoList", - icon: "$ayiInbox", - route: "/home-memos", - key: key++ - }); + //REMINDERS + sub.push({ + title: "ReminderList", + icon: "$ayiStickyNote", + route: "/home-reminders", + key: key++ + }); - //REMINDERS - sub.push({ - title: "ReminderList", - icon: "$ayiStickyNote", - route: "/home-reminders", - key: key++ - }); + //REVIEWS + sub.push({ + title: "ReviewList", + icon: "$ayiCalendarCheck", + route: "/home-reviews", + key: key++ + }); - //REVIEWS - sub.push({ - title: "ReviewList", - icon: "$ayiCalendarCheck", - route: "/home-reviews", - key: key++ - }); + //USER SETTINGS + sub.push({ + title: "UserSettings", + icon: "$ayiUserCog", + route: "/home-user-settings", + key: key++ + }); - //USER SETTINGS - sub.push({ - title: "UserSettings", - icon: "$ayiUserCog", - route: "/home-user-settings", - key: key++ - }); + //USER NOTIFICATION SUBSCRIPTIONS + sub.push({ + title: "NotifySubscriptionList", + icon: "$ayiBullhorn", + route: "/home-notify-subscriptions", + key: key++ + }); - //USER NOTIFICATION SUBSCRIPTIONS - sub.push({ - title: "NotifySubscriptionList", - icon: "$ayiBullhorn", - route: "/home-notify-subscriptions", - key: key++ - }); + //HISTORY / MRU / ACTIVITY (personal) + sub.push({ + title: "History", + icon: "$ayiHistory", + route: `/history/3/${window.$gz.store.state.userId}/true`, + key: key++ + }); - //HISTORY / MRU / ACTIVITY (personal) - sub.push({ - title: "History", - icon: "$ayiHistory", - route: `/history/3/${window.$gz.store.state.userId}/true`, - key: key++ - }); + //HOME + if (sub.length > 0) { + //Set homePage in store to dashboard + window.$gz.store.commit("setHomePage", "/home-dashboard"); + addNavItem("Home", "$ayiHome", undefined, sub, key++, "home"); + } - //HOME - if (sub.length > 0) { - //Set homePage in store to dashboard - window.$gz.store.commit("setHomePage", "/home-dashboard"); - addNavItem("Home", "$ayiHome", undefined, sub, key++, "home"); - } + //######### CUSTOMER GROUP + if (window.$gz.role.canOpen(window.$gz.type.Customer)) { + //these all require Customer rights so all in the same block - //######### CUSTOMER GROUP - if (window.$gz.role.canOpen(window.$gz.type.Customer)) { - //these all require Customer rights so all in the same block + //clear sublevel array + sub = []; + + //CUSTOMERS subitem + sub.push({ + title: "CustomerList", + icon: "$ayiAddressCard", + route: "/cust-customers", + key: key++ + }); + + //HEAD OFFICES subitem + sub.push({ + title: "HeadOfficeList", + icon: "$ayiSitemap", + route: "/cust-head-offices", + key: key++ + }); + + //Customer / Headoffice Users subitem + sub.push({ + title: "Contacts", + icon: "$ayiUsers", + route: "/cust-users", + key: key++ + }); + + // ** CUSTOMER (TOP) + addNavItem( + "CustomerList", + "$ayiAddressBook", + undefined, + sub, + key++, + "customer" + ); + } + + //####### SERVICE GROUP + + sub = []; + + //SCHEDULE (service) + if ( + window.$gz.role.canOpen(window.$gz.type.WorkOrder) || + window.$gz.role.canOpen(window.$gz.type.Quote) || + window.$gz.role.canOpen(window.$gz.type.PM) + ) { + sub.push({ + title: "Schedule", + icon: "$ayiCalendarAlt", + route: "/svc-schedule", + key: key++ + }); + } + + //WORKORDERS LIST (was service workorders) + if (window.$gz.role.canOpen(window.$gz.type.WorkOrder)) { + sub.push({ + title: "WorkOrderList", + icon: "$ayiTools", + route: "/svc-workorders", + key: key++ + }); + } + + //QUOTE LIST + if (window.$gz.role.canOpen(window.$gz.type.Quote)) { + sub.push({ + title: "QuoteList", + icon: "$ayiPencilAlt", + route: "/svc-quotes", + key: key++ + }); + } + + //PM LIST + if (window.$gz.role.canOpen(window.$gz.type.PM)) { + sub.push({ + title: "PMList", + icon: "$ayiBusinessTime", + route: "/svc-pms", + key: key++ + }); + } + + //UNITS subitem + if (window.$gz.role.canOpen(window.$gz.type.Unit)) { + sub.push({ + title: "UnitList", + icon: "$ayiFan", + route: "/svc-units", + key: key++ + }); + } + + //LOANERS subitem + if (window.$gz.role.canOpen(window.$gz.type.LoanUnit)) { + sub.push({ + title: "LoanUnitList", + icon: "$ayiPlug", + route: "/svc-loaners", + key: key++ + }); + } + + //PROJECTS subitem + if (window.$gz.role.canOpen(window.$gz.type.Project)) { + sub.push({ + title: "ProjectList", + icon: "$ayiProjectDiagram", + route: "/svc-projects", + key: key++ + }); + } + + //CUSTOMER SERVICE REQUESTS subitem + if (window.$gz.role.canOpen(window.$gz.type.CustomerServiceRequest)) { + sub.push({ + title: "CustomerServiceRequestList", + icon: "$ayiConciergeBell", + route: "/svc-csr", + key: key++ + }); + } + + //**** Service (TOP GROUP) + if ( + sub.length > 0 && + !window.$gz.role.hasRole([ + window.$gz.role.AUTHORIZATION_ROLES.TechRestricted + ]) + ) { + addNavItem("Service", "$ayiToolbox", undefined, sub, key++, "service"); + } + + //######### INVENTORY GROUP //clear sublevel array sub = []; - //CUSTOMERS subitem - sub.push({ - title: "CustomerList", - icon: "$ayiAddressCard", - route: "/cust-customers", - key: key++ - }); + //PARTS (part list) + if (window.$gz.role.canOpen(window.$gz.type.Part)) { + sub.push({ + title: "PartList", + icon: "$ayiBoxes", + route: "/inv-parts", + key: key++ + }); + } - //HEAD OFFICES subitem - sub.push({ - title: "HeadOfficeList", - icon: "$ayiSitemap", - route: "/cust-head-offices", - key: key++ - }); + //PURCHASE ORDERS / PART REQUESTS + if ( + useInventory && + window.$gz.role.canOpen(window.$gz.type.PurchaseOrder) + ) { + sub.push({ + title: "InventoryPurchaseOrders", + icon: "$ayiTruckLoading", + route: "/inv-purchase-orders", + key: key++ + }); - //Customer / Headoffice Users subitem - sub.push({ - title: "Contacts", - icon: "$ayiUsers", - route: "/cust-users", - key: key++ - }); + sub.push({ + title: "WorkOrderItemPartRequestList", + icon: "$ayiParachuteBox", + route: "/inv-part-requests", + key: key++ + }); + } - // ** CUSTOMER (TOP) - addNavItem( - "CustomerList", - "$ayiAddressBook", - undefined, - sub, - key++, - "customer" - ); - } + //INVENTORY + if ( + useInventory && + window.$gz.role.canOpen(window.$gz.type.PartInventory) + ) { + sub.push({ + title: "PartInventoryList", + icon: "$ayiPallet", + route: "/inv-part-inventory", + key: key++ + }); + } - //####### SERVICE GROUP + //INVENTORY TRANSACTIONS + if ( + useInventory && + window.$gz.role.canOpen(window.$gz.type.PartInventory) + ) { + sub.push({ + title: "PartInventoryTransactionList", + icon: "$ayiPeopleCarry", + route: "/inv-part-inventory-transactions", + key: key++ + }); + } - sub = []; + //PART ASSEMBLIES + if (window.$gz.role.canOpen(window.$gz.type.PartAssembly)) { + sub.push({ + title: "PartAssemblyList", + icon: "$ayiObjectGroup", + route: "/inv-part-assemblies", + key: key++ + }); + } - //SCHEDULE (service) - if ( - window.$gz.role.canOpen(window.$gz.type.WorkOrder) || - window.$gz.role.canOpen(window.$gz.type.Quote) || - window.$gz.role.canOpen(window.$gz.type.PM) - ) { - sub.push({ - title: "Schedule", - icon: "$ayiCalendarAlt", - route: "/svc-schedule", - key: key++ - }); - } + //WAREHOUSES + if ( + useInventory && + window.$gz.role.canOpen(window.$gz.type.PartWarehouse) + ) { + sub.push({ + title: "PartWarehouseList", + icon: "$ayiWarehouse", + route: "/inv-part-warehouses", + key: key++ + }); + } - //WORKORDERS LIST (was service workorders) - if (window.$gz.role.canOpen(window.$gz.type.WorkOrder)) { - sub.push({ - title: "WorkOrderList", - icon: "$ayiTools", - route: "/svc-workorders", - key: key++ - }); - } + //**** INVENTORY (TOP GROUP) + if (sub.length > 0) { + addNavItem("Inventory", "$ayiDolly", undefined, sub, key++, "inventory"); + } - //QUOTE LIST - if (window.$gz.role.canOpen(window.$gz.type.Quote)) { - sub.push({ - title: "QuoteList", - icon: "$ayiPencilAlt", - route: "/svc-quotes", - key: key++ - }); - } + //######### VENDORS (TOP GROUP) + if (window.$gz.role.canOpen(window.$gz.type.Vendor)) { + addNavItem("VendorList", "$ayiStore", "/vendors", [], key++, "vendor"); + } - //PM LIST - if (window.$gz.role.canOpen(window.$gz.type.PM)) { - sub.push({ - title: "PMList", - icon: "$ayiBusinessTime", - route: "/svc-pms", - key: key++ - }); - } + //****************** ACCOUNTING - //UNITS subitem - if (window.$gz.role.canOpen(window.$gz.type.Unit)) { - sub.push({ - title: "UnitList", - icon: "$ayiFan", - route: "/svc-units", - key: key++ - }); - } + sub = []; - //LOANERS subitem - if (window.$gz.role.canOpen(window.$gz.type.LoanUnit)) { - sub.push({ - title: "LoanUnitList", - icon: "$ayiPlug", - route: "/svc-loaners", - key: key++ - }); - } + //SERVICE CONTRACTS subitem + if (window.$gz.role.canOpen(window.$gz.type.Contract)) { + sub.push({ + title: "ContractList", + icon: "$ayiFileContract", + route: "/svc-contracts", + key: key++ + }); + } + // //SERVICE BANK + // if (window.$gz.role.canOpen(window.$gz.type.ServiceBank)) { + // sub.push({ + // title: "ServiceBankList", + // icon: "$ayiCarBattery", + // route: "/acc-service-banks", + // key: key++ + // }); + // } - //PROJECTS subitem - if (window.$gz.role.canOpen(window.$gz.type.Project)) { - sub.push({ - title: "ProjectList", - icon: "$ayiProjectDiagram", - route: "/svc-projects", - key: key++ - }); - } + //SERVICE RATES + if (window.$gz.role.canOpen(window.$gz.type.ServiceRate)) { + sub.push({ + title: "ServiceRateList", + icon: "$ayiCalculator", + route: "/acc-service-rates", + key: key++ + }); + } - //CUSTOMER SERVICE REQUESTS subitem - if (window.$gz.role.canOpen(window.$gz.type.CustomerServiceRequest)) { - sub.push({ - title: "CustomerServiceRequestList", - icon: "$ayiConciergeBell", - route: "/svc-csr", - key: key++ - }); - } + //TRAVEL RATES + if (window.$gz.role.canOpen(window.$gz.type.TravelRate)) { + sub.push({ + title: "TravelRateList", + icon: "$ayiCalculator", + route: "/acc-travel-rates", + key: key++ + }); + } - //**** Service (TOP GROUP) - if ( - sub.length > 0 && - !window.$gz.role.hasRole([ - window.$gz.role.AUTHORIZATION_ROLES.TechRestricted - ]) - ) { - addNavItem("Service", "$ayiToolbox", undefined, sub, key++, "service"); - } - - //######### INVENTORY GROUP - - //clear sublevel array - sub = []; - - //PARTS (part list) - if (window.$gz.role.canOpen(window.$gz.type.Part)) { - sub.push({ - title: "PartList", - icon: "$ayiBoxes", - route: "/inv-parts", - key: key++ - }); - } - - //PURCHASE ORDERS / PART REQUESTS - if (useInventory && window.$gz.role.canOpen(window.$gz.type.PurchaseOrder)) { - sub.push({ - title: "InventoryPurchaseOrders", - icon: "$ayiTruckLoading", - route: "/inv-purchase-orders", - key: key++ - }); - - sub.push({ - title: "WorkOrderItemPartRequestList", - icon: "$ayiParachuteBox", - route: "/inv-part-requests", - key: key++ - }); - } - - //INVENTORY - if (useInventory && window.$gz.role.canOpen(window.$gz.type.PartInventory)) { - sub.push({ - title: "PartInventoryList", - icon: "$ayiPallet", - route: "/inv-part-inventory", - key: key++ - }); - } - - //INVENTORY TRANSACTIONS - if (useInventory && window.$gz.role.canOpen(window.$gz.type.PartInventory)) { - sub.push({ - title: "PartInventoryTransactionList", - icon: "$ayiPeopleCarry", - route: "/inv-part-inventory-transactions", - key: key++ - }); - } - - //PART ASSEMBLIES - if (window.$gz.role.canOpen(window.$gz.type.PartAssembly)) { - sub.push({ - title: "PartAssemblyList", - icon: "$ayiObjectGroup", - route: "/inv-part-assemblies", - key: key++ - }); - } - - //WAREHOUSES - if (useInventory && window.$gz.role.canOpen(window.$gz.type.PartWarehouse)) { - sub.push({ - title: "PartWarehouseList", - icon: "$ayiWarehouse", - route: "/inv-part-warehouses", - key: key++ - }); - } - - //**** INVENTORY (TOP GROUP) - if (sub.length > 0) { - addNavItem("Inventory", "$ayiDolly", undefined, sub, key++, "inventory"); - } - - //######### VENDORS (TOP GROUP) - if (window.$gz.role.canOpen(window.$gz.type.Vendor)) { - addNavItem("VendorList", "$ayiStore", "/vendors", [], key++, "vendor"); - } - - //****************** ACCOUNTING - - sub = []; - - //SERVICE CONTRACTS subitem - if (window.$gz.role.canOpen(window.$gz.type.Contract)) { - sub.push({ - title: "ContractList", - icon: "$ayiFileContract", - route: "/svc-contracts", - key: key++ - }); - } - // //SERVICE BANK - // if (window.$gz.role.canOpen(window.$gz.type.ServiceBank)) { - // sub.push({ - // title: "ServiceBankList", - // icon: "$ayiCarBattery", - // route: "/acc-service-banks", - // key: key++ - // }); - // } - - //SERVICE RATES - if (window.$gz.role.canOpen(window.$gz.type.ServiceRate)) { - sub.push({ - title: "ServiceRateList", - icon: "$ayiCalculator", - route: "/acc-service-rates", - key: key++ - }); - } - - //TRAVEL RATES - if (window.$gz.role.canOpen(window.$gz.type.TravelRate)) { - sub.push({ - title: "TravelRateList", - icon: "$ayiCalculator", - route: "/acc-travel-rates", - key: key++ - }); - } - - if (window.$gz.role.canOpen(window.$gz.type.TaxCode)) { - sub.push({ - title: "TaxCodeList", - icon: "$ayiPercent", - route: "/acc-tax-codes", - key: key++ - }); - } - - // ** ACCOUNTING (TOP) - if (sub.length > 0) { - addNavItem("Accounting", "$ayiCoins", undefined, sub, key++, "accounting"); - } + if (window.$gz.role.canOpen(window.$gz.type.TaxCode)) { + sub.push({ + title: "TaxCodeList", + icon: "$ayiPercent", + route: "/acc-tax-codes", + key: key++ + }); + } + // ** ACCOUNTING (TOP) + if (sub.length > 0) { + addNavItem( + "Accounting", + "$ayiCoins", + undefined, + sub, + key++, + "accounting" + ); + } + } //end of licenseLockout check group //############# ADMINISTRATION //clear sublevel array @@ -569,7 +589,7 @@ function initNavPanel() { } //TRANSLATION - if (window.$gz.role.canOpen(window.$gz.type.Translation)) { + if (!licenseLockout && window.$gz.role.canOpen(window.$gz.type.Translation)) { sub.push({ title: "TranslationList", icon: "$ayiLanguage", @@ -579,7 +599,7 @@ function initNavPanel() { } //REPORT TEMPLATES - if (window.$gz.role.canChange(window.$gz.type.Report)) { + if (!licenseLockout && window.$gz.role.canChange(window.$gz.type.Report)) { sub.push({ title: "ReportList", icon: "$ayiThList", @@ -589,7 +609,10 @@ function initNavPanel() { } //FILES IN DATABASE - if (window.$gz.role.canOpen(window.$gz.type.FileAttachment)) { + if ( + !licenseLockout && + window.$gz.role.canOpen(window.$gz.type.FileAttachment) + ) { sub.push({ title: "Attachments", icon: "$ayiFolder", @@ -599,7 +622,7 @@ function initNavPanel() { } //EVENT LOG / HISTORY - if (window.$gz.role.canOpen(window.$gz.type.Global)) { + if (!licenseLockout && window.$gz.role.canOpen(window.$gz.type.Global)) { //not really an appropriate object here just guessing sub.push({ title: "History", @@ -610,7 +633,7 @@ function initNavPanel() { } //IMPORT - if (window.$gz.role.canOpen(window.$gz.type.Global)) { + if (!licenseLockout && window.$gz.role.canOpen(window.$gz.type.Global)) { //again, not really an appropriate object type sub.push({ title: "Import", @@ -648,7 +671,10 @@ function initNavPanel() { } // SERVER STATE - if (window.$gz.role.canChange(window.$gz.type.ServerState)) { + if ( + !licenseLockout && + window.$gz.role.canChange(window.$gz.type.ServerState) + ) { sub.push({ title: "ServerState", icon: "$ayiDoorOpen", @@ -658,7 +684,7 @@ function initNavPanel() { } // JOBS - if (window.$gz.role.canOpen(window.$gz.type.ServerJob)) { + if (!licenseLockout && window.$gz.role.canOpen(window.$gz.type.ServerJob)) { sub.push({ title: "ServerJobs", icon: "$ayiRobot", @@ -678,7 +704,10 @@ function initNavPanel() { } //METRICS - if (window.$gz.role.canOpen(window.$gz.type.ServerMetrics)) { + if ( + !licenseLockout && + window.$gz.role.canOpen(window.$gz.type.ServerMetrics) + ) { sub.push({ title: "ServerMetrics", icon: "$ayiFileMedicalAlt", @@ -697,7 +726,10 @@ function initNavPanel() { } //NOTIFICATION CONFIG AND HISTORY - if (window.$gz.role.canOpen(window.$gz.type.OpsNotificationSettings)) { + if ( + !licenseLockout && + window.$gz.role.canOpen(window.$gz.type.OpsNotificationSettings) + ) { sub.push({ title: "NotificationSettings", icon: "$ayiBullhorn", @@ -738,6 +770,10 @@ function initNavPanel() { ); window.$gz.store.commit("setHomePage", "/ay-evaluate"); } + + if (licenseLockout) { + window.$gz.store.commit("setHomePage", "/adm-license"); + } } async function getUserOptions() { diff --git a/ayanova/src/store.js b/ayanova/src/store.js index ae6564bb..7a5d3a78 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -25,6 +25,7 @@ export default new Vuex.Store({ helpUrl: "", apiToken: "-", downloadToken: "-", + l: false, //license lockout flag tfaEnabled: undefined, customerRights: {}, userId: 0, @@ -103,6 +104,7 @@ export default new Vuex.Store({ state.userName = data.userName; state.userType = data.userType; state.downloadToken = data.dlt; + state.l = data.l; state.tfaEnabled = data.tfaEnabled; if (data.customerRights) { state.customerRights = data.customerRights; @@ -112,6 +114,7 @@ export default new Vuex.Store({ //Things that are reset on logout state.apiToken = "-"; state.downloadToken = "-"; + state.l = false; state.tfaEnabled = undefined; state.customerRights = {}; state.authenticated = false;