diff --git a/ayanova/src/api/auth.js b/ayanova/src/api/auth.js index fc63b618..3a512fb0 100644 --- a/ayanova/src/api/auth.js +++ b/ayanova/src/api/auth.js @@ -4,24 +4,61 @@ import { processLogin, processLogout } from "./authutil"; export default { async authenticate(login, password) { - return fetch( - window.$gz.api.APIUrl("auth"), - window.$gz.api.fetchPostNoAuthOptions({ - login: login, - password: password - }) - ) - .then(window.$gz.api.status) - .then(window.$gz.api.extractBody) - .then(processLogin) - .then(() => { - return Promise.resolve(true); - }) //succeeded, nothing to return - .catch(function handleAuthError(error) { - processLogout(); - return Promise.reject(error); - }); + return new Promise(async function doAuth(resolve, reject) { + try { + console.log("AUTH: TOP"); + let fetchData = await fetch( + window.$gz.api.APIUrl("auth"), + window.$gz.api.fetchPostNoAuthOptions({ + login: login, + password: password + }) + ); + console.log("AUTH: status"); + fetchData = await window.$gz.api.status(fetchData); + console.log("AUTH: extractBody"); + fetchData = await window.$gz.api.extractBody(fetchData); + console.log("AUTH: calling processLogin"); + await processLogin(fetchData); + console.log( + "### AUTH:after processlogin completed - resolving done (THIS SHOULD BE LAST)" + ); + resolve(); + } catch (e) { + reject(e); + } + // .catch(function handleAuthError(error) { + // processLogout(); + // return reject(error); + // }); + + // .then(processLogin) + // .then(() => { + + // return resolve(true); + // }) //succeeded, nothing to return + }); }, + // async authenticate(login, password) { + // return fetch( + // window.$gz.api.APIUrl("auth"), + // window.$gz.api.fetchPostNoAuthOptions({ + // login: login, + // password: password + // }) + // ) + // .then(window.$gz.api.status) + // .then(window.$gz.api.extractBody) + // .then(processLogin) + // .then(() => { + // console.log("auth:authenticate returning resolved done"); + // return Promise.resolve(true); + // }) //succeeded, nothing to return + // .catch(function handleAuthError(error) { + // processLogout(); + // return Promise.reject(error); + // }); + // }, logout() { processLogout(); } diff --git a/ayanova/src/api/authutil.js b/ayanova/src/api/authutil.js index 51842381..0893a039 100644 --- a/ayanova/src/api/authutil.js +++ b/ayanova/src/api/authutil.js @@ -3,67 +3,101 @@ import decode from "jwt-decode"; import initialize from "./initialize"; export function processLogin(response) { - return new Promise(function(resolve, reject) { - //check there is a response of some kind - if (!response) { - window.$gz.store.commit("logItem", "auth::processLogin -> no response"); - return reject(); - } + return new Promise(async function(resolve, reject) { + try { + console.log("authutil:process login TOP"); - //is there an error? - if (response.error) { - return reject(response.error); - } + //check there is a response of some kind + if (!response) { + window.$gz.store.commit("logItem", "auth::processLogin -> no response"); + return reject(); + } - //is token present? - if (!response.data || !response.data.token) { - window.$gz.store.commit( - "logItem", - "auth::processLogin -> response contains no data" - ); - return reject(); - } - const token = decode(response.data.token); + //is there an error? + if (response.error) { + return reject(response.error); + } - if (!token || !token.iss) { - window.$gz.store.commit( - "logItem", - "auth::processLogin -> response token empty" - ); - return reject(); - } + //is token present? + if (!response.data || !response.data.token) { + window.$gz.store.commit( + "logItem", + "auth::processLogin -> response contains no data" + ); + return reject(); + } + const token = decode(response.data.token); - if (token.iss != "ayanova.com") { - window.$gz.store.commit( - "logItem", - "auth::processLogin -> token invalid (iss): " + token.iss - ); - return reject(); - } + if (!token || !token.iss) { + window.$gz.store.commit( + "logItem", + "auth::processLogin -> response token empty" + ); + return reject(); + } - //ensure the store is clean first in case we didn't come here from a clean logout - window.$gz.store.commit("logout"); - sessionStorage.clear(); //clear all temporary session storage data + if (token.iss != "ayanova.com") { + window.$gz.store.commit( + "logItem", + "auth::processLogin -> token invalid (iss): " + token.iss + ); + return reject(); + } - //Put app relevant items into vuex store so app can use them - window.$gz.store.commit("login", { - apiToken: response.data.token, - authenticated: true, - userId: Number(token.id), - userName: response.data.name, - roles: response.data.roles, - userType: response.data.usertype, - dlt: response.data.dlt - }); + //ensure the store is clean first in case we didn't come here from a clean logout + window.$gz.store.commit("logout"); + sessionStorage.clear(); //clear all temporary session storage data - //Initialize the application - initialize().then(() => { + //Put app relevant items into vuex store so app can use them + window.$gz.store.commit("login", { + apiToken: response.data.token, + authenticated: true, + userId: Number(token.id), + userName: response.data.name, + roles: response.data.roles, + userType: response.data.usertype, + dlt: response.data.dlt + }); + //log the login window.$gz.store.commit( "logItem", "auth::processLogin -> User " + token.id + " logged in" ); - resolve(true); - }); + + //Get global settings + console.log("authutil:calling get blobal settings"); + let gsets = await window.$gz.api.get("global-biz-setting/client"); + console.log("authutil:got global settings"); + + if (gsets.error) { + //In a form this would trigger a bunch of validation or error display code but for here and now: + //convert error to human readable string for display and popup a notification to user + let msg = window.$gz.api.apiErrorToHumanString(gsets.error); + window.$gz.store.commit( + "logItem", + "Initialize::() fetch global-biz-setting/client -> error" + msg + ); + window.$gz.eventBus.$emit("notify-error", msg); + } else { + //Check if overrides and use them here + //or else use browser defaults + window.$gz.store.commit("setGlobalSettings", gsets.data); + } + + console.log("** authutil calling test delay --->>>>"); + await window.$gz.api.doDelayAsync(); + console.log("** authutil back from delay continuing.."); + + //INITIALIZE + console.log("authutil:calling initialize"); + await initialize(); + } catch (err) { + console.log("authutil:error in async chain global/init"); + reject(err); + } + console.log("authutil:no error resolving async chain global/init"); + resolve(); + //------------------------------------------------- }); } diff --git a/ayanova/src/api/enums.js b/ayanova/src/api/enums.js index fa4e405e..dee8693a 100644 --- a/ayanova/src/api/enums.js +++ b/ayanova/src/api/enums.js @@ -43,7 +43,7 @@ export default { if (!window.$gz._.has(window.$gz.store.state.enums, k)) { let that = this; - await that.fetch(k).then(dat => { + await that.fetchEnumKey(k).then(dat => { //massage the data as necessary let e = { enumKey: k, items: {} }; for (let i = 0; i < dat.length; i++) { @@ -56,7 +56,7 @@ export default { } } }, - fetch(enumKey) { + fetchEnumKey(enumKey) { return window.$gz.api.get("enum-list/list/" + enumKey).then(res => { if (res.error) { throw res.error; diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index 65aef434..09e921e1 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -150,6 +150,63 @@ export default { return Promise.resolve(response); } }, + statusEx(response) { + //Handle expected api errors + if (response.status == 401) { + //must reject if not Authenticated + throw new Error("[ErrorUserNotAuthenticated]"); + } + + if (response.status == 403) { + //must reject if not Authorized + throw new Error("[ErrorUserNotAuthorized]"); + } + + //404 not found is an expected status not worth logging allow to bubble up + //for client code to deal with + if (response.status == 404) { + return; + } + + if (response.status == 405) { + //Probably a development error + + throw new Error("Method Not Allowed (route issue?) " + response.url); + } + + if (response.status >= 200 && response.status < 300) { + return; + } else { + //log unhandled api error + window.$gz.store.commit( + "logItem", + "API error: status=" + + response.status + + ", statusText=" + + response.statusText + + ", url=" + + response.url + ); + } + }, + async extractBodyEx(response) { + if (response.status == 204) { + //no content, nothing to process + return response; + } + let contentType = response.headers.get("content-type"); + if (!contentType) { + return response; + } + //console.log("gzapi::extractBody method, content type is:", contentType); + if (contentType.includes("json")) { + return await response.json(); + } + if (contentType.includes("text/plain")) { + return await response.text(); + } + return response; + }, extractBody(response) { if (response.status == 204) { //no content, nothing to process @@ -372,9 +429,58 @@ export default { }); }); }, + ////////////////////////////////////// + // Test delay for troubleshooting + // + doDelayAsync: () => { + return new Promise((resolve) => { + setTimeout(() => resolve("I did something"), 10000); + }); + }, /////////////////////////////////// // POST / PUT DATA TO API SERVER // + async upsertEx(route, data) { + try { + console.log("gzapi:upsertEx TOP"); + let that = this; + // return new Promise(function upsertDataToServer(resolve, reject) { + //determine if this is a new or existing record + let fetchOptions = undefined; + if (data.concurrency) { + //has concurrency token, so this is a PUT as it's updating an existing record + fetchOptions = that.fetchPutOptions(data); + } else { + //Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token + fetchOptions = that.fetchPostOptions(data); + //ensure the route doesn't end in /0 which will happen if it's a new record since the edit forms just send the url here with the ID regardless + if (window.$gz._.endsWith(route, "/0")) { + route = route.slice(0, -2); + } + } + // console.log("** gzapi:upsertEx calling test delay"); + // await this.doDelayAsync(); + // console.log("** gzapi:upsertEx back from delay continuing.."); + console.log("gzapi:upsertEx calling fetch"); + let r = await fetch(that.APIUrl(route), fetchOptions); + console.log("gzapi:upsertEx calling statusEx"); + that.statusEx(r); + console.log("gzapi:upsertEx calling extractBodyEx"); + r = await that.extractBodyEx(r); + console.log("gzapi:upsertEx done, returning response"); + return r; + // eslint-disable-next-line + // .then((response) => { + // //Note: response.error indicates there is an error, however this is not an unusual condition + // //it could be validation errors or other general error so we need to treat it here like it's normal + // //and let the caller deal with it appropriately + // resolve(response); + // }) + } catch (error) { + handleError("UPSERT", error, route, reject); + } + // }); + }, upsert(route, data) { let that = this; return new Promise(function upsertDataToServer(resolve, reject) { diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index 4d2d2a23..248e471e 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -14,843 +14,1609 @@ function addNavItem(title, icon, route, navItems, key, testid) { }); } +function initNavPanal() { + console.log("INITIALIZE:initNavPanal TOP"); + let key = 0; + let sub = []; + + let t = window.$gz.translation.get; + let role = window.$gz.role.AUTHORIZATION_ROLES; + //****************** HOME + //Most users except ops and client logins + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.InventoryLimited, + role.InventoryFull, + role.AccountingFull, + role.TechLimited, + role.TechFull, + role.SubContractorLimited, + role.SubContractorFull, + role.SalesFull, + role.SalesLimited + ]) + ) { + //DASHBOARD + sub.push({ + title: t("Dashboard"), + icon: "fa-tachometer-alt", + route: "/home-dashboard", + key: key++ + }); + + //Set homePage in store to dashboard + window.$gz.store.commit("setHomePage", "/home-dashboard"); + + //SEARCH + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.InventoryLimited, + role.InventoryFull, + role.AccountingFull, + role.TechLimited, + role.TechFull, + role.SalesFull, + role.SalesLimited + ]) + ) { + sub.push({ + title: t("Search"), + icon: "fa-search", + route: "/home-search", + key: key++ + }); + } + + //SCHEDULE (personal) + sub.push({ + title: t("Schedule"), + icon: "fa-calendar-day", + route: "/home-schedule", + key: key++ + }); + + //MEMOS + sub.push({ + title: t("MemoList"), + icon: "fa-inbox", + route: "/home-memos", + key: key++ + }); + + //REMINDERS (SCHEDULE MARKERS) + sub.push({ + title: t("ReminderList"), + icon: "fa-sticky-note", + route: "/home-reminders", + key: key++ + }); + + //USER SETTINGS + sub.push({ + title: t("UserSettings"), + icon: "fa-user-cog", + route: "/home-user-settings", + key: key++ + }); + + //Moved these two into user settings + // //USER TRANSLATE + // sub.push({ + // title: t("Translation"), + // icon: "fa-language", + // route: "/home-translation", + // key: key++ + // }); + + // //SET LOGIN + // sub.push({ + // title: t("SetLoginPassword"), + // icon: "fa-key", + // route: "/home-password", + // key: key++ + // }); + + //USER NOTIFICATION SUBSCRIPTIONS + if ( + //all but subcontractors (arbitrary decision without any facts ;) + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.InventoryLimited, + role.InventoryFull, + role.AccountingFull, + role.TechLimited, + role.TechFull, + role.SalesFull, + role.SalesLimited + ]) + ) { + sub.push({ + title: t("NotifySubscriptionList"), + icon: "fa-bullhorn", + route: "/home-notify-subscriptions", + key: key++ + }); + } + + //HOME + addNavItem(t("Home"), "fa-home", undefined, sub, key++, "home"); + } + + //****************** CUSTOMERS + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited, + role.AccountingFull, + role.SalesFull, + role.SalesLimited + ]) + ) { + //clear sublevel array + sub = []; + + //CUSTOMERS subitem + sub.push({ + title: t("CustomerList"), + icon: "fa-address-card", + route: "/cust-customers", + key: key++ + }); + + //HEAD OFFICES subitem + sub.push({ + title: t("HeadOfficeList"), + icon: "fa-sitemap", + route: "/cust-headoffices", + key: key++ + }); + + // ** CUSTOMER (TOP) + addNavItem( + t("CustomerList"), + "fa-address-book", + undefined, + sub, + key++, + "customer" + ); + } + + //****************** SERVICE + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited, + role.SalesFull, + role.SalesLimited + ]) + ) { + //clear sublevel array + sub = []; + //SCHEDULE (combined) + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("Schedule"), + icon: "fa-calendar-alt", + route: "/svc-schedule", + key: key++ + }); + } + + //WORKORDERS LIST (was service workorders) + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("WorkOrderList"), + icon: "fa-tools", + route: "/svc-workorders", + key: key++ + }); + } + + // //WORKORDER TEMPLATES LIST + //this will be an item inside the workorders NEW menu or grid or wherever but it's not top level worthy + //there used to be an array for 3rd level shit but that's whack yo! ;) + // subSub.push({ + // title: t("WorkOrderServiceTemplate"), + // icon: "fa-stamp", + // route: "/svc-workorder-templates", + // key: key++ + // }); + + //QUOTE LIST + //NOTE: this is the only item in this service level area that is visible to Sales + //so there is no separate role check here as the service group role check supersedes this + sub.push({ + title: t("QuoteList"), + icon: "fa-pencil-alt", + route: "/svc-quotes", + key: key++ + }); + + //PM LIST + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("PMList"), + icon: "fa-business-time", + route: "/svc-pm-list", + key: key++ + }); + } + + //UNITS subitem + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("UnitList"), + icon: "fa-fan", + route: "/svc-units", + key: key++ + }); + + //UNIT MODELS subitem + sub.push({ + title: t("UnitModels"), + icon: "fa-dice-d20", + route: "/svc-unit-models", + key: key++ + }); + } + //LOANERS subitem + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("LoanUnitList"), + icon: "fa-plug", + route: "/svc-loaners", + key: key++ + }); + } + + //CONTRACTS subitem + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("ContractList"), + icon: "fa-file-contract", + route: "/svc-contracts", + key: key++ + }); + } + + //CUSTOMER SERVICE REQUESTS subitem + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.DispatchFull, + role.DispatchLimited, + role.TechFull, + role.TechLimited + ]) + ) { + sub.push({ + title: t("CustomerServiceRequestList"), + icon: "fa-child", + route: "/svc-csr-list", + key: key++ + }); + } + + //**** Service (TOP GROUP) + addNavItem(t("Service"), "fa-toolbox", undefined, sub, key++, "service"); + } + + //****************** INVENTORY + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.InventoryFull, + role.InventoryLimited + ]) + ) { + //clear sublevel array + sub = []; + + //PARTS (part list) + sub.push({ + title: t("PartList"), + icon: "fa-boxes", + route: "/inv-parts", + key: key++ + }); + + //INVENTORY + sub.push({ + title: t("PartByWarehouseInventoryList"), + icon: "fa-pallet", + route: "/inv-part-inventory", + key: key++ + }); + + //PART REQUESTS + sub.push({ + title: t("WorkOrderItemPartRequestList"), + icon: "fa-paper-plane", + route: "/inv-part-requests", + key: key++ + }); + + //PURCHASE ORDERS + sub.push({ + title: t("InventoryPurchaseOrders"), + icon: "fa-shipping-fast", + route: "/inv-purchase-orders", + key: key++ + }); + + //NOTE: V7 HAD POITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE + + //PURCHASE ORDER RECEIPTS + sub.push({ + title: t("InventoryPurchaseOrderReceipts"), + icon: "fa-dolly-flatbed", + route: "/inv-purchase-order-receipts", + key: key++ + }); + + //NOTE: V7 HAD PORECEIPTITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE + + //NOTE: Warehouses? Shouldn't they be here as well?? + + //ADJUSTMENTS + sub.push({ + title: t("InventoryPartInventoryAdjustments"), + icon: "fa-dolly", + route: "/inv-adjustments", + key: key++ + }); + + //**** INVENTORY (TOP GROUP) + addNavItem(t("Inventory"), "fa-box", undefined, sub, key++, "inventory"); + } + + //**** VENDORS (TOP GROUP) + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.AccountingFull, + role.DispatchFull, + role.DispatchLimited, + role.InventoryFull, + role.InventoryLimited + ]) + ) { + addNavItem(t("VendorList"), "fa-store", "/vendors", [], key++, "vendor"); + } + + //****************** ACCOUNTING + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.AccountingFull, + role.BizAdminLimited + ]) + ) { + sub = []; + + //FAKE subitem as is still TBD + sub.push({ + title: t("Accounting"), + icon: "fa-calculator", + route: "/acc-accounting", + key: key++ + }); + + // ** ACCOUNTING (TOP) + addNavItem( + t("Accounting"), + "fa-calculator", + undefined, + sub, + key++, + "accounting" + ); + } + + //****************** ADMINISTRATION + if (window.$gz.role.hasRole([role.BizAdminFull, role.BizAdminLimited])) { + //clear sublevel array + sub = []; + + // GLOBAL SETTINGS + sub.push({ + title: t("AdministrationGlobalSettings"), + icon: "fa-cogs", + route: "/adm-global-settings", + key: key++ + }); + + // LICENSE + sub.push({ + title: t("HelpLicense"), + icon: "fa-ticket-alt", + route: "/adm-license", + key: key++ + }); + + // USERS + sub.push({ + title: t("UserList"), + icon: "fa-users", + route: "/adm-users", + key: key++ + }); + + // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS + + //TRANSLATION + sub.push({ + title: t("Translation"), + icon: "fa-language", + route: "/adm-translation", + key: key++ + }); + + //REPORT TEMPLATES + sub.push({ + title: t("ReportList"), + icon: "fa-th-list", + route: "/adm-report-templates", + key: key++ + }); + + //FILES IN DATABASE + sub.push({ + title: t("Attachments"), + icon: "fa-folder", + route: "/adm-attachments", + key: key++ + }); + + //EVENT LOG / HISTORY + sub.push({ + title: t("History"), + icon: "fa-history", + route: "/adm-history", + key: key++ + }); + + //KPI / METRICS / CHARTS AND STUFF + sub.push({ + title: t("Statistics"), + icon: "fa-chart-line", + route: "/adm-statistics", + key: key++ + }); + + // ** ADMINISTRATION (TOP) + addNavItem( + t("Administration"), + "fa-user-tie", + undefined, + sub, + key++, + "administration" + ); + } + + //****************** OPERATIONS + if (window.$gz.role.hasRole([role.OpsAdminFull, role.OpsAdminLimited])) { + //clear sublevel array + sub = []; + + // ARCHIVE + sub.push({ + title: t("Backup"), + icon: "fa-file-archive", + route: "/ops-backup", + key: key++ + }); + + //Set home page if they don't already have the dashboard set above + if (!window.$gz.store.state.homePage) { + //Set homePage in store to Backup + window.$gz.store.commit("setHomePage", "/ops-BACKUP"); + } + + // SERVER STATE + sub.push({ + title: t("ServerState"), + icon: "fa-door-open", + route: "/ops-server-state", + key: key++ + }); + + // JOBS + sub.push({ + title: t("ServerJobs"), + icon: "fa-robot", + route: "/ops-jobs", + key: key++ + }); + + // LOGS + sub.push({ + title: t("ServerLog"), + icon: "fa-history", + route: "/ops-log", + key: key++ + }); + + //METRICS + sub.push({ + title: t("ServerMetrics"), + icon: "fa-file-medical-alt", + route: "/ops-metrics", + key: key++ + }); + + //PROFILE + sub.push({ + title: t("ServerProfiler"), + icon: "fa-binoculars", + route: "/ops-profile", + key: key++ + }); + + //NOTIFICATION CONFIG AND HISTORY + sub.push({ + title: t("NotificationSettings"), + icon: "fa-bullhorn", + route: "/ops-notification-settings", + key: key++ + }); + + // ** OPERATIONS (TOP) + addNavItem( + t("Operations"), + "fa-server", + undefined, + sub, + key++, + "operations" + ); + } + + //**** WIDGETS (TOP GROUP) + if ( + window.$gz.role.hasRole([ + role.BizAdminFull, + role.BizAdminLimited, + role.InventoryFull, + role.InventoryLimited + ]) + ) { + addNavItem(t("WidgetList"), "fa-vial", "/widgets", [], key++, "widgets"); + } + + //****************** CUSTOMER USER / HEAD OFFICE USER UI + if ( + window.$gz.role.hasRole([role.CustomerFull, role.CustomerLimited]) && + (window.$gz.store.state.userType == 4 || + window.$gz.store.state.userType == 5) + ) { + //clear sublevel array + sub = []; + + //Set homePage in store to customer csr for this user type + + window.$gz.store.commit("setHomePage", "/customer-csr-list"); + + //CSR LIST subitem + sub.push({ + title: t("CustomerServiceRequestList"), + icon: "fa-child", + route: "/customer-csr-list", + key: key++ + }); + + //WORKORDERS subitem + sub.push({ + title: t("WorkOrderList"), + icon: "fa-tools", + route: "/customer-workorders", + key: key++ + }); + + //** CUSTOMER LOGIN HOME (TOP) + + addNavItem(t("Home"), "fa-home", undefined, sub, key++, "homecustomer"); + } + + //*** LOGOUT - all users + addNavItem(t("Logout"), "fa-sign-out-alt", "/login", [], key++, "logout"); + + console.log("initialize:INitnavpanel BOTTOM / DONE"); +} + +function getUserOptions() { + //GET USER OPTIONS + console.log("INITIALIZE:getUserOptions top"); + return ( + window.$gz.api + .get("user-option/" + window.$gz.store.state.userId) + // eslint-disable-next-line + .then((res) => { + if (res.error) { + //In a form this would trigger a bunch of validation or error display code but for here and now: + //convert error to human readable string for display and popup a notification to user + let msg = window.$gz.api.apiErrorToHumanString(res.error); + window.$gz.store.commit( + "logItem", + "Initialize::() fetch useroptions -> error" + msg + ); + window.$gz.eventBus.$emit("notify-error", msg); + } else { + //Check if overrides and use them here + //or else use browser defaults + + let l = { + languageOverride: null, + timeZoneOverride: null, + currencyName: null, + hour12: true + }; + + //get language to use, try user set override first, if empty then browser set, if empty then default to en-us + l.languageOverride = + res.data.languageOverride || + window.$gz.locale.getBrowserFirstLanguage() || + "en-US"; + + l.timeZoneOverride = + res.data.timeZoneOverride || + window.$gz.locale.getBrowserTimeZoneName() || + "America/New_York"; + + //No browser setting for this so meh + l.currencyName = res.data.currencyName || "USD"; + if (res.data.hour12 != null) { + l.hour12 = res.data.hour12; + } + + window.$gz.store.commit("setLocale", l); + } + }) + .catch(function handleFetchUserOptionsError(error) { + window.$gz.store.commit( + "logItem", + "Initialize::() fetch useroptions -> error" + error + ); + throw error; + }) + ); +} + ///////////////////////////////////// // Initialize the app // on change of authentication status export default function initialize() { - return new Promise(function(resolve) { - if (window.$gz.store.state.authenticated) { - //Fetch the core translated text keys that will always be required by user - window.$gz.translation - .fetch(window.$gz.translation.coreKeys) - .then(function initializeNavPanel() { - let key = 0; - let sub = []; - - let t = window.$gz.translation.get; - let role = window.$gz.role.AUTHORIZATION_ROLES; - //****************** HOME - //Most users except ops and client logins - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SubContractorLimited, - role.SubContractorFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - //DASHBOARD - sub.push({ - title: t("Dashboard"), - icon: "fa-tachometer-alt", - route: "/home-dashboard", - key: key++ - }); - - //Set homePage in store to dashboard - window.$gz.store.commit("setHomePage", "/home-dashboard"); - - //SEARCH - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - sub.push({ - title: t("Search"), - icon: "fa-search", - route: "/home-search", - key: key++ - }); - } - - //SCHEDULE (personal) - sub.push({ - title: t("Schedule"), - icon: "fa-calendar-day", - route: "/home-schedule", - key: key++ - }); - - //MEMOS - sub.push({ - title: t("MemoList"), - icon: "fa-inbox", - route: "/home-memos", - key: key++ - }); - - //REMINDERS (SCHEDULE MARKERS) - sub.push({ - title: t("ReminderList"), - icon: "fa-sticky-note", - route: "/home-reminders", - key: key++ - }); - - //USER SETTINGS - sub.push({ - title: t("UserSettings"), - icon: "fa-user-cog", - route: "/home-user-settings", - key: key++ - }); - - //Moved these two into user settings - // //USER TRANSLATE - // sub.push({ - // title: t("Translation"), - // icon: "fa-language", - // route: "/home-translation", - // key: key++ - // }); - - // //SET LOGIN - // sub.push({ - // title: t("SetLoginPassword"), - // icon: "fa-key", - // route: "/home-password", - // key: key++ - // }); - - //USER NOTIFICATION SUBSCRIPTIONS - if ( - //all but subcontractors (arbitrary decision without any facts ;) - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - sub.push({ - title: t("NotifySubscriptionList"), - icon: "fa-bullhorn", - route: "/home-notify-subscriptions", - key: key++ - }); - } - - //HOME - addNavItem(t("Home"), "fa-home", undefined, sub, key++, "home"); - } - - //****************** CUSTOMERS - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited, - role.AccountingFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - //clear sublevel array - sub = []; - - //CUSTOMERS subitem - sub.push({ - title: t("CustomerList"), - icon: "fa-address-card", - route: "/cust-customers", - key: key++ - }); - - //HEAD OFFICES subitem - sub.push({ - title: t("HeadOfficeList"), - icon: "fa-sitemap", - route: "/cust-headoffices", - key: key++ - }); - - // ** CUSTOMER (TOP) - addNavItem( - t("CustomerList"), - "fa-address-book", - undefined, - sub, - key++, - "customer" - ); - } - - //****************** SERVICE - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited, - role.SalesFull, - role.SalesLimited - ]) - ) { - //clear sublevel array - sub = []; - //SCHEDULE (combined) - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("Schedule"), - icon: "fa-calendar-alt", - route: "/svc-schedule", - key: key++ - }); - } - - //WORKORDERS LIST (was service workorders) - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("WorkOrderList"), - icon: "fa-tools", - route: "/svc-workorders", - key: key++ - }); - } - - // //WORKORDER TEMPLATES LIST - //this will be an item inside the workorders NEW menu or grid or wherever but it's not top level worthy - //there used to be an array for 3rd level shit but that's whack yo! ;) - // subSub.push({ - // title: t("WorkOrderServiceTemplate"), - // icon: "fa-stamp", - // route: "/svc-workorder-templates", - // key: key++ - // }); - - //QUOTE LIST - //NOTE: this is the only item in this service level area that is visible to Sales - //so there is no separate role check here as the service group role check supersedes this - sub.push({ - title: t("QuoteList"), - icon: "fa-pencil-alt", - route: "/svc-quotes", - key: key++ - }); - - //PM LIST - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("PMList"), - icon: "fa-business-time", - route: "/svc-pm-list", - key: key++ - }); - } - - //UNITS subitem - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("UnitList"), - icon: "fa-fan", - route: "/svc-units", - key: key++ - }); - - //UNIT MODELS subitem - sub.push({ - title: t("UnitModels"), - icon: "fa-dice-d20", - route: "/svc-unit-models", - key: key++ - }); - } - //LOANERS subitem - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("LoanUnitList"), - icon: "fa-plug", - route: "/svc-loaners", - key: key++ - }); - } - - //CONTRACTS subitem - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("ContractList"), - icon: "fa-file-contract", - route: "/svc-contracts", - key: key++ - }); - } - - //CUSTOMER SERVICE REQUESTS subitem - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited - ]) - ) { - sub.push({ - title: t("CustomerServiceRequestList"), - icon: "fa-child", - route: "/svc-csr-list", - key: key++ - }); - } - - //**** Service (TOP GROUP) - addNavItem( - t("Service"), - "fa-toolbox", - undefined, - sub, - key++, - "service" - ); - } - - //****************** INVENTORY - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.InventoryFull, - role.InventoryLimited - ]) - ) { - //clear sublevel array - sub = []; - - //PARTS (part list) - sub.push({ - title: t("PartList"), - icon: "fa-boxes", - route: "/inv-parts", - key: key++ - }); - - //INVENTORY - sub.push({ - title: t("PartByWarehouseInventoryList"), - icon: "fa-pallet", - route: "/inv-part-inventory", - key: key++ - }); - - //PART REQUESTS - sub.push({ - title: t("WorkOrderItemPartRequestList"), - icon: "fa-paper-plane", - route: "/inv-part-requests", - key: key++ - }); - - //PURCHASE ORDERS - sub.push({ - title: t("InventoryPurchaseOrders"), - icon: "fa-shipping-fast", - route: "/inv-purchase-orders", - key: key++ - }); - - //NOTE: V7 HAD POITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE - - //PURCHASE ORDER RECEIPTS - sub.push({ - title: t("InventoryPurchaseOrderReceipts"), - icon: "fa-dolly-flatbed", - route: "/inv-purchase-order-receipts", - key: key++ - }); - - //NOTE: V7 HAD PORECEIPTITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE - - //NOTE: Warehouses? Shouldn't they be here as well?? - - //ADJUSTMENTS - sub.push({ - title: t("InventoryPartInventoryAdjustments"), - icon: "fa-dolly", - route: "/inv-adjustments", - key: key++ - }); - - //**** INVENTORY (TOP GROUP) - addNavItem( - t("Inventory"), - "fa-box", - undefined, - sub, - key++, - "inventory" - ); - } - - //**** VENDORS (TOP GROUP) - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.AccountingFull, - role.DispatchFull, - role.DispatchLimited, - role.InventoryFull, - role.InventoryLimited - ]) - ) { - addNavItem( - t("VendorList"), - "fa-store", - "/vendors", - [], - key++, - "vendor" - ); - } - - //****************** ACCOUNTING - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.AccountingFull, - role.BizAdminLimited - ]) - ) { - sub = []; - - //FAKE subitem as is still TBD - sub.push({ - title: t("Accounting"), - icon: "fa-calculator", - route: "/acc-accounting", - key: key++ - }); - - // ** ACCOUNTING (TOP) - addNavItem( - t("Accounting"), - "fa-calculator", - undefined, - sub, - key++, - "accounting" - ); - } - - //****************** ADMINISTRATION - if ( - window.$gz.role.hasRole([role.BizAdminFull, role.BizAdminLimited]) - ) { - //clear sublevel array - sub = []; - - // GLOBAL SETTINGS - sub.push({ - title: t("AdministrationGlobalSettings"), - icon: "fa-cogs", - route: "/adm-global-settings", - key: key++ - }); - - // LICENSE - sub.push({ - title: t("HelpLicense"), - icon: "fa-ticket-alt", - route: "/adm-license", - key: key++ - }); - - // USERS - sub.push({ - title: t("UserList"), - icon: "fa-users", - route: "/adm-users", - key: key++ - }); - - // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS - - //TRANSLATION - sub.push({ - title: t("Translation"), - icon: "fa-language", - route: "/adm-translation", - key: key++ - }); - - //REPORT TEMPLATES - sub.push({ - title: t("ReportList"), - icon: "fa-th-list", - route: "/adm-report-templates", - key: key++ - }); - - //FILES IN DATABASE - sub.push({ - title: t("Attachments"), - icon: "fa-folder", - route: "/adm-attachments", - key: key++ - }); - - //EVENT LOG / HISTORY - sub.push({ - title: t("History"), - icon: "fa-history", - route: "/adm-history", - key: key++ - }); - - //KPI / METRICS / CHARTS AND STUFF - sub.push({ - title: t("Statistics"), - icon: "fa-chart-line", - route: "/adm-statistics", - key: key++ - }); - - // ** ADMINISTRATION (TOP) - addNavItem( - t("Administration"), - "fa-user-tie", - undefined, - sub, - key++, - "administration" - ); - } - - //****************** OPERATIONS - if ( - window.$gz.role.hasRole([role.OpsAdminFull, role.OpsAdminLimited]) - ) { - //clear sublevel array - sub = []; - - // ARCHIVE - sub.push({ - title: t("Backup"), - icon: "fa-file-archive", - route: "/ops-backup", - key: key++ - }); - - //Set home page if they don't already have the dashboard set above - if (!window.$gz.store.state.homePage) { - //Set homePage in store to Backup - window.$gz.store.commit("setHomePage", "/ops-BACKUP"); - } - - // SERVER STATE - sub.push({ - title: t("ServerState"), - icon: "fa-door-open", - route: "/ops-server-state", - key: key++ - }); - - // JOBS - sub.push({ - title: t("ServerJobs"), - icon: "fa-robot", - route: "/ops-jobs", - key: key++ - }); - - // LOGS - sub.push({ - title: t("ServerLog"), - icon: "fa-history", - route: "/ops-log", - key: key++ - }); - - //METRICS - sub.push({ - title: t("ServerMetrics"), - icon: "fa-file-medical-alt", - route: "/ops-metrics", - key: key++ - }); - - //PROFILE - sub.push({ - title: t("ServerProfiler"), - icon: "fa-binoculars", - route: "/ops-profile", - key: key++ - }); - - //NOTIFICATION CONFIG AND HISTORY - sub.push({ - title: t("NotificationSettings"), - icon: "fa-bullhorn", - route: "/ops-notification-settings", - key: key++ - }); - - // ** OPERATIONS (TOP) - addNavItem( - t("Operations"), - "fa-server", - undefined, - sub, - key++, - "operations" - ); - } - - //**** WIDGETS (TOP GROUP) - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.InventoryFull, - role.InventoryLimited - ]) - ) { - addNavItem( - t("WidgetList"), - "fa-vial", - "/widgets", - [], - key++, - "widgets" - ); - } - - //****************** CUSTOMER USER / HEAD OFFICE USER UI - if ( - window.$gz.role.hasRole([ - role.CustomerFull, - role.CustomerLimited - ]) && - (window.$gz.store.state.userType == 4 || - window.$gz.store.state.userType == 5) - ) { - //clear sublevel array - sub = []; - - //Set homePage in store to customer csr for this user type - - window.$gz.store.commit("setHomePage", "/customer-csr-list"); - - //CSR LIST subitem - sub.push({ - title: t("CustomerServiceRequestList"), - icon: "fa-child", - route: "/customer-csr-list", - key: key++ - }); - - //WORKORDERS subitem - sub.push({ - title: t("WorkOrderList"), - icon: "fa-tools", - route: "/customer-workorders", - key: key++ - }); - - //** CUSTOMER LOGIN HOME (TOP) - - addNavItem( - t("Home"), - "fa-home", - undefined, - sub, - key++, - "homecustomer" - ); - } - - //*** LOGOUT - all users - addNavItem( - t("Logout"), - "fa-sign-out-alt", - "/login", - [], - key++, - "logout" - ); - }) - .then(() => { - //GET USER OPTIONS - window.$gz.api - .get("user-option/" + window.$gz.store.state.userId) - // eslint-disable-next-line - .then((res) => { - if (res.error) { - //In a form this would trigger a bunch of validation or error display code but for here and now: - //convert error to human readable string for display and popup a notification to user - let msg = window.$gz.api.apiErrorToHumanString(res.error); - window.$gz.store.commit( - "logItem", - "Initialize::() fetch useroptions -> error" + msg - ); - window.$gz.eventBus.$emit("notify-error", msg); - } else { - //Check if overrides and use them here - //or else use browser defaults - - let l = { - languageOverride: null, - timeZoneOverride: null, - currencyName: null, - hour12: true - }; - - //get language to use, try user set override first, if empty then browser set, if empty then default to en-us - l.languageOverride = - res.data.languageOverride || - window.$gz.locale.getBrowserFirstLanguage() || - "en-US"; - - l.timeZoneOverride = - res.data.timeZoneOverride || - window.$gz.locale.getBrowserTimeZoneName() || - "America/New_York"; - - //No browser setting for this so meh - l.currencyName = res.data.currencyName || "USD"; - if (res.data.hour12 != null) { - l.hour12 = res.data.hour12; - } - - window.$gz.store.commit("setLocale", l); - resolve(); - } - }) - .catch(function handleFetchUserOptionsError(error) { - window.$gz.store.commit( - "logItem", - "Initialize::() fetch useroptions -> error" + error - ); - throw error; - }); - }) - .then(() => { - //GET GLOBAL SETTINGS - window.$gz.api - .get("global-biz-setting/client") - // eslint-disable-next-line - .then((res) => { - if (res.error) { - //In a form this would trigger a bunch of validation or error display code but for here and now: - //convert error to human readable string for display and popup a notification to user - let msg = window.$gz.api.apiErrorToHumanString(res.error); - window.$gz.store.commit( - "logItem", - "Initialize::() fetch global-biz-setting/client -> error" + - msg - ); - window.$gz.eventBus.$emit("notify-error", msg); - } else { - //Check if overrides and use them here - //or else use browser defaults - - window.$gz.store.commit("setGlobalSettings", res.data); - resolve(); - } - }) - .catch(function handleFetchClientGlobalSettingsError(error) { - window.$gz.store.commit( - "logItem", - "Initialize::() fetch global-biz-setting/client -> error" + - error - ); - throw error; - }); - }) - .catch(function handleIntializeError(error) { - window.$gz.store.commit( - "logItem", - "Initialize::() ltfetch -> error" + error - ); - throw error; - }); + return new Promise(async function(resolve) { + console.log("INITIALIZE:TOP"); + // console.log("** authutil calling test delay"); + // await window.$gz.api.doDelayAsync(); + // console.log("** authutil back from delay continuing.."); + if (!window.$gz.store.state.authenticated) { + throw "initialize: Error, called but user not authenticated!"; + } + try { + // (async function() { + console.log("INITIALIZE:calling translation.cacheTranslations..."); + await window.$gz.translation.cacheTranslations( + window.$gz.translation.coreKeys + ); + console.log("INITIALIZE: calling initnavpanel"); + await initNavPanal(); + console.log("INITIALIZE:calling get user options"); + await getUserOptions(); + console.log("INITIALIZE:done inside chain"); + console.log("INITIALIZE: calling resolve"); + resolve(); + // })(); + } catch (err) { + reject(err); } }); } +// //Fetch the core translated text keys that will always be required by user +// window.$gz.translation +// .fetch(window.$gz.translation.coreKeys) +// .then(function initializeNavPanel() { +// let key = 0; +// let sub = []; + +// let t = window.$gz.translation.get; +// let role = window.$gz.role.AUTHORIZATION_ROLES; +// //****************** HOME +// //Most users except ops and client logins +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.InventoryLimited, +// role.InventoryFull, +// role.AccountingFull, +// role.TechLimited, +// role.TechFull, +// role.SubContractorLimited, +// role.SubContractorFull, +// role.SalesFull, +// role.SalesLimited +// ]) +// ) { +// //DASHBOARD +// sub.push({ +// title: t("Dashboard"), +// icon: "fa-tachometer-alt", +// route: "/home-dashboard", +// key: key++ +// }); + +// //Set homePage in store to dashboard +// window.$gz.store.commit("setHomePage", "/home-dashboard"); + +// //SEARCH +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.InventoryLimited, +// role.InventoryFull, +// role.AccountingFull, +// role.TechLimited, +// role.TechFull, +// role.SalesFull, +// role.SalesLimited +// ]) +// ) { +// sub.push({ +// title: t("Search"), +// icon: "fa-search", +// route: "/home-search", +// key: key++ +// }); +// } + +// //SCHEDULE (personal) +// sub.push({ +// title: t("Schedule"), +// icon: "fa-calendar-day", +// route: "/home-schedule", +// key: key++ +// }); + +// //MEMOS +// sub.push({ +// title: t("MemoList"), +// icon: "fa-inbox", +// route: "/home-memos", +// key: key++ +// }); + +// //REMINDERS (SCHEDULE MARKERS) +// sub.push({ +// title: t("ReminderList"), +// icon: "fa-sticky-note", +// route: "/home-reminders", +// key: key++ +// }); + +// //USER SETTINGS +// sub.push({ +// title: t("UserSettings"), +// icon: "fa-user-cog", +// route: "/home-user-settings", +// key: key++ +// }); + +// //Moved these two into user settings +// // //USER TRANSLATE +// // sub.push({ +// // title: t("Translation"), +// // icon: "fa-language", +// // route: "/home-translation", +// // key: key++ +// // }); + +// // //SET LOGIN +// // sub.push({ +// // title: t("SetLoginPassword"), +// // icon: "fa-key", +// // route: "/home-password", +// // key: key++ +// // }); + +// //USER NOTIFICATION SUBSCRIPTIONS +// if ( +// //all but subcontractors (arbitrary decision without any facts ;) +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.InventoryLimited, +// role.InventoryFull, +// role.AccountingFull, +// role.TechLimited, +// role.TechFull, +// role.SalesFull, +// role.SalesLimited +// ]) +// ) { +// sub.push({ +// title: t("NotifySubscriptionList"), +// icon: "fa-bullhorn", +// route: "/home-notify-subscriptions", +// key: key++ +// }); +// } + +// //HOME +// addNavItem(t("Home"), "fa-home", undefined, sub, key++, "home"); +// } + +// //****************** CUSTOMERS +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited, +// role.AccountingFull, +// role.SalesFull, +// role.SalesLimited +// ]) +// ) { +// //clear sublevel array +// sub = []; + +// //CUSTOMERS subitem +// sub.push({ +// title: t("CustomerList"), +// icon: "fa-address-card", +// route: "/cust-customers", +// key: key++ +// }); + +// //HEAD OFFICES subitem +// sub.push({ +// title: t("HeadOfficeList"), +// icon: "fa-sitemap", +// route: "/cust-headoffices", +// key: key++ +// }); + +// // ** CUSTOMER (TOP) +// addNavItem( +// t("CustomerList"), +// "fa-address-book", +// undefined, +// sub, +// key++, +// "customer" +// ); +// } + +// //****************** SERVICE +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited, +// role.SalesFull, +// role.SalesLimited +// ]) +// ) { +// //clear sublevel array +// sub = []; +// //SCHEDULE (combined) +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("Schedule"), +// icon: "fa-calendar-alt", +// route: "/svc-schedule", +// key: key++ +// }); +// } + +// //WORKORDERS LIST (was service workorders) +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("WorkOrderList"), +// icon: "fa-tools", +// route: "/svc-workorders", +// key: key++ +// }); +// } + +// // //WORKORDER TEMPLATES LIST +// //this will be an item inside the workorders NEW menu or grid or wherever but it's not top level worthy +// //there used to be an array for 3rd level shit but that's whack yo! ;) +// // subSub.push({ +// // title: t("WorkOrderServiceTemplate"), +// // icon: "fa-stamp", +// // route: "/svc-workorder-templates", +// // key: key++ +// // }); + +// //QUOTE LIST +// //NOTE: this is the only item in this service level area that is visible to Sales +// //so there is no separate role check here as the service group role check supersedes this +// sub.push({ +// title: t("QuoteList"), +// icon: "fa-pencil-alt", +// route: "/svc-quotes", +// key: key++ +// }); + +// //PM LIST +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("PMList"), +// icon: "fa-business-time", +// route: "/svc-pm-list", +// key: key++ +// }); +// } + +// //UNITS subitem +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("UnitList"), +// icon: "fa-fan", +// route: "/svc-units", +// key: key++ +// }); + +// //UNIT MODELS subitem +// sub.push({ +// title: t("UnitModels"), +// icon: "fa-dice-d20", +// route: "/svc-unit-models", +// key: key++ +// }); +// } +// //LOANERS subitem +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("LoanUnitList"), +// icon: "fa-plug", +// route: "/svc-loaners", +// key: key++ +// }); +// } + +// //CONTRACTS subitem +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("ContractList"), +// icon: "fa-file-contract", +// route: "/svc-contracts", +// key: key++ +// }); +// } + +// //CUSTOMER SERVICE REQUESTS subitem +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.DispatchFull, +// role.DispatchLimited, +// role.TechFull, +// role.TechLimited +// ]) +// ) { +// sub.push({ +// title: t("CustomerServiceRequestList"), +// icon: "fa-child", +// route: "/svc-csr-list", +// key: key++ +// }); +// } + +// //**** Service (TOP GROUP) +// addNavItem( +// t("Service"), +// "fa-toolbox", +// undefined, +// sub, +// key++, +// "service" +// ); +// } + +// //****************** INVENTORY +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.InventoryFull, +// role.InventoryLimited +// ]) +// ) { +// //clear sublevel array +// sub = []; + +// //PARTS (part list) +// sub.push({ +// title: t("PartList"), +// icon: "fa-boxes", +// route: "/inv-parts", +// key: key++ +// }); + +// //INVENTORY +// sub.push({ +// title: t("PartByWarehouseInventoryList"), +// icon: "fa-pallet", +// route: "/inv-part-inventory", +// key: key++ +// }); + +// //PART REQUESTS +// sub.push({ +// title: t("WorkOrderItemPartRequestList"), +// icon: "fa-paper-plane", +// route: "/inv-part-requests", +// key: key++ +// }); + +// //PURCHASE ORDERS +// sub.push({ +// title: t("InventoryPurchaseOrders"), +// icon: "fa-shipping-fast", +// route: "/inv-purchase-orders", +// key: key++ +// }); + +// //NOTE: V7 HAD POITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE + +// //PURCHASE ORDER RECEIPTS +// sub.push({ +// title: t("InventoryPurchaseOrderReceipts"), +// icon: "fa-dolly-flatbed", +// route: "/inv-purchase-order-receipts", +// key: key++ +// }); + +// //NOTE: V7 HAD PORECEIPTITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE + +// //NOTE: Warehouses? Shouldn't they be here as well?? + +// //ADJUSTMENTS +// sub.push({ +// title: t("InventoryPartInventoryAdjustments"), +// icon: "fa-dolly", +// route: "/inv-adjustments", +// key: key++ +// }); + +// //**** INVENTORY (TOP GROUP) +// addNavItem( +// t("Inventory"), +// "fa-box", +// undefined, +// sub, +// key++, +// "inventory" +// ); +// } + +// //**** VENDORS (TOP GROUP) +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.AccountingFull, +// role.DispatchFull, +// role.DispatchLimited, +// role.InventoryFull, +// role.InventoryLimited +// ]) +// ) { +// addNavItem( +// t("VendorList"), +// "fa-store", +// "/vendors", +// [], +// key++, +// "vendor" +// ); +// } + +// //****************** ACCOUNTING +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.AccountingFull, +// role.BizAdminLimited +// ]) +// ) { +// sub = []; + +// //FAKE subitem as is still TBD +// sub.push({ +// title: t("Accounting"), +// icon: "fa-calculator", +// route: "/acc-accounting", +// key: key++ +// }); + +// // ** ACCOUNTING (TOP) +// addNavItem( +// t("Accounting"), +// "fa-calculator", +// undefined, +// sub, +// key++, +// "accounting" +// ); +// } + +// //****************** ADMINISTRATION +// if ( +// window.$gz.role.hasRole([role.BizAdminFull, role.BizAdminLimited]) +// ) { +// //clear sublevel array +// sub = []; + +// // GLOBAL SETTINGS +// sub.push({ +// title: t("AdministrationGlobalSettings"), +// icon: "fa-cogs", +// route: "/adm-global-settings", +// key: key++ +// }); + +// // LICENSE +// sub.push({ +// title: t("HelpLicense"), +// icon: "fa-ticket-alt", +// route: "/adm-license", +// key: key++ +// }); + +// // USERS +// sub.push({ +// title: t("UserList"), +// icon: "fa-users", +// route: "/adm-users", +// key: key++ +// }); + +// // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS + +// //TRANSLATION +// sub.push({ +// title: t("Translation"), +// icon: "fa-language", +// route: "/adm-translation", +// key: key++ +// }); + +// //REPORT TEMPLATES +// sub.push({ +// title: t("ReportList"), +// icon: "fa-th-list", +// route: "/adm-report-templates", +// key: key++ +// }); + +// //FILES IN DATABASE +// sub.push({ +// title: t("Attachments"), +// icon: "fa-folder", +// route: "/adm-attachments", +// key: key++ +// }); + +// //EVENT LOG / HISTORY +// sub.push({ +// title: t("History"), +// icon: "fa-history", +// route: "/adm-history", +// key: key++ +// }); + +// //KPI / METRICS / CHARTS AND STUFF +// sub.push({ +// title: t("Statistics"), +// icon: "fa-chart-line", +// route: "/adm-statistics", +// key: key++ +// }); + +// // ** ADMINISTRATION (TOP) +// addNavItem( +// t("Administration"), +// "fa-user-tie", +// undefined, +// sub, +// key++, +// "administration" +// ); +// } + +// //****************** OPERATIONS +// if ( +// window.$gz.role.hasRole([role.OpsAdminFull, role.OpsAdminLimited]) +// ) { +// //clear sublevel array +// sub = []; + +// // ARCHIVE +// sub.push({ +// title: t("Backup"), +// icon: "fa-file-archive", +// route: "/ops-backup", +// key: key++ +// }); + +// //Set home page if they don't already have the dashboard set above +// if (!window.$gz.store.state.homePage) { +// //Set homePage in store to Backup +// window.$gz.store.commit("setHomePage", "/ops-BACKUP"); +// } + +// // SERVER STATE +// sub.push({ +// title: t("ServerState"), +// icon: "fa-door-open", +// route: "/ops-server-state", +// key: key++ +// }); + +// // JOBS +// sub.push({ +// title: t("ServerJobs"), +// icon: "fa-robot", +// route: "/ops-jobs", +// key: key++ +// }); + +// // LOGS +// sub.push({ +// title: t("ServerLog"), +// icon: "fa-history", +// route: "/ops-log", +// key: key++ +// }); + +// //METRICS +// sub.push({ +// title: t("ServerMetrics"), +// icon: "fa-file-medical-alt", +// route: "/ops-metrics", +// key: key++ +// }); + +// //PROFILE +// sub.push({ +// title: t("ServerProfiler"), +// icon: "fa-binoculars", +// route: "/ops-profile", +// key: key++ +// }); + +// //NOTIFICATION CONFIG AND HISTORY +// sub.push({ +// title: t("NotificationSettings"), +// icon: "fa-bullhorn", +// route: "/ops-notification-settings", +// key: key++ +// }); + +// // ** OPERATIONS (TOP) +// addNavItem( +// t("Operations"), +// "fa-server", +// undefined, +// sub, +// key++, +// "operations" +// ); +// } + +// //**** WIDGETS (TOP GROUP) +// if ( +// window.$gz.role.hasRole([ +// role.BizAdminFull, +// role.BizAdminLimited, +// role.InventoryFull, +// role.InventoryLimited +// ]) +// ) { +// addNavItem( +// t("WidgetList"), +// "fa-vial", +// "/widgets", +// [], +// key++, +// "widgets" +// ); +// } + +// //****************** CUSTOMER USER / HEAD OFFICE USER UI +// if ( +// window.$gz.role.hasRole([role.CustomerFull, role.CustomerLimited]) && +// (window.$gz.store.state.userType == 4 || +// window.$gz.store.state.userType == 5) +// ) { +// //clear sublevel array +// sub = []; + +// //Set homePage in store to customer csr for this user type + +// window.$gz.store.commit("setHomePage", "/customer-csr-list"); + +// //CSR LIST subitem +// sub.push({ +// title: t("CustomerServiceRequestList"), +// icon: "fa-child", +// route: "/customer-csr-list", +// key: key++ +// }); + +// //WORKORDERS subitem +// sub.push({ +// title: t("WorkOrderList"), +// icon: "fa-tools", +// route: "/customer-workorders", +// key: key++ +// }); + +// //** CUSTOMER LOGIN HOME (TOP) + +// addNavItem( +// t("Home"), +// "fa-home", +// undefined, +// sub, +// key++, +// "homecustomer" +// ); +// } + +// //*** LOGOUT - all users +// addNavItem( +// t("Logout"), +// "fa-sign-out-alt", +// "/login", +// [], +// key++, +// "logout" +// ); + +// console.log("INITIALIZE:Done menu init"); +// }) +// .then(() => { +// //GET USER OPTIONS +// window.$gz.api +// .get("user-option/" + window.$gz.store.state.userId) +// // eslint-disable-next-line +// .then((res) => { +// if (res.error) { +// //In a form this would trigger a bunch of validation or error display code but for here and now: +// //convert error to human readable string for display and popup a notification to user +// let msg = window.$gz.api.apiErrorToHumanString(res.error); +// window.$gz.store.commit( +// "logItem", +// "Initialize::() fetch useroptions -> error" + msg +// ); +// window.$gz.eventBus.$emit("notify-error", msg); +// } else { +// //Check if overrides and use them here +// //or else use browser defaults + +// let l = { +// languageOverride: null, +// timeZoneOverride: null, +// currencyName: null, +// hour12: true +// }; + +// //get language to use, try user set override first, if empty then browser set, if empty then default to en-us +// l.languageOverride = +// res.data.languageOverride || +// window.$gz.locale.getBrowserFirstLanguage() || +// "en-US"; + +// l.timeZoneOverride = +// res.data.timeZoneOverride || +// window.$gz.locale.getBrowserTimeZoneName() || +// "America/New_York"; + +// //No browser setting for this so meh +// l.currencyName = res.data.currencyName || "USD"; +// if (res.data.hour12 != null) { +// l.hour12 = res.data.hour12; +// } + +// window.$gz.store.commit("setLocale", l); +// resolve(); +// } +// }) +// .catch(function handleFetchUserOptionsError(error) { +// window.$gz.store.commit( +// "logItem", +// "Initialize::() fetch useroptions -> error" + error +// ); +// throw error; +// }); +// }) +// .then(() => { +// //GET GLOBAL SETTINGS +// window.$gz.api +// .get("global-biz-setting/client") +// // eslint-disable-next-line +// .then((res) => { +// if (res.error) { +// //In a form this would trigger a bunch of validation or error display code but for here and now: +// //convert error to human readable string for display and popup a notification to user +// let msg = window.$gz.api.apiErrorToHumanString(res.error); +// window.$gz.store.commit( +// "logItem", +// "Initialize::() fetch global-biz-setting/client -> error" + msg +// ); +// window.$gz.eventBus.$emit("notify-error", msg); +// } else { +// //Check if overrides and use them here +// //or else use browser defaults + +// window.$gz.store.commit("setGlobalSettings", res.data); +// resolve(); +// } +// }) +// .catch(function handleFetchClientGlobalSettingsError(error) { +// window.$gz.store.commit( +// "logItem", +// "Initialize::() fetch global-biz-setting/client -> error" + error +// ); +// throw error; +// }); +// }) +// .catch(function handleIntializeError(error) { +// window.$gz.store.commit( +// "logItem", +// "Initialize::() ltfetch -> error" + error +// ); +// throw error; +// }); +// }); diff --git a/ayanova/src/api/translation.js b/ayanova/src/api/translation.js index 717902ee..eb611814 100644 --- a/ayanova/src/api/translation.js +++ b/ayanova/src/api/translation.js @@ -11,8 +11,8 @@ export default { } return window.$gz.store.state.translationText[key]; }, - fetch(keys) { - return new Promise(function fetchTranslationKeysFromServer(resolve) { + async cacheTranslations(keys) { + return new Promise(async function fetchTranslationKeysFromServer(resolve) { // //step 1: build an array of keys that we don't have already //Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen @@ -27,29 +27,74 @@ export default { } if (needIt.length == 0) { - resolve(); - return; + return resolve(); } //step 2: get it - fetch( + console.log("translation:cacheTranslations calling fetch via API"); + let testres = await window.$gz.api.upsertEx("translation/subset", needIt); + console.log(testres); + + + console.log("translation:cacheTranslations calling fetch directly"); + let response = await fetch( window.$gz.api.APIUrl("translation/subset"), window.$gz.api.fetchPostOptions(needIt) - ) - .then(window.$gz.api.status) - .then(window.$gz.api.extractBody) - // eslint-disable-next-line - .then((response) => { - window.$gz._.forEach( - response.data, - function commitFetchedLTItemToStore(item) { - window.$gz.store.commit("addTranslationText", item); - } - ); - resolve(); - }); + ); + + console.log("translation:fetch calling STATUS"); + + let data = await window.$gz.api.status(response); + console.log("translation:fetch calling extractBody"); + let data2 = await window.$gz.api.extractBody(data); + console.log("translation:fetch calling processing into store"); + window.$gz._.forEach(data2, function commitFetchedLTItemToStore(item) { + window.$gz.store.commit("addTranslationText", item); + }); + console.log("translation:fetch done calling resolve"); + return resolve(); }); }, + // fetch(keys) { + // return new Promise(async function fetchTranslationKeysFromServer(resolve) { + // // + // //step 1: build an array of keys that we don't have already + // //Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen + // //for example datatables have dynamic column names so they need to fetch on demand + // let needIt = []; + // for (let i = 0; i < keys.length; i++) { + // if ( + // !window.$gz._.has(window.$gz.store.state.translationText, keys[i]) + // ) { + // needIt.push(keys[i]); + // } + // } + + // if (needIt.length == 0) { + // resolve(); + // return; + // } + + // //step 2: get it + // await fetch( + // window.$gz.api.APIUrl("translation/subset"), + // window.$gz.api.fetchPostOptions(needIt) + // ) + // .then(window.$gz.api.status) + // .then(window.$gz.api.extractBody) + // // eslint-disable-next-line + // .then((response) => { + // window.$gz._.forEach( + // response.data, + // function commitFetchedLTItemToStore(item) { + // window.$gz.store.commit("addTranslationText", item); + // } + // ); + // console.log("translation:fetch calling resolve"); + // resolve(); + // }); + // }); + // }, //Keys that will always be required for any AyaNova work for any user coreKeys: [ //main nav options diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 45544e87..84eec89a 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -730,7 +730,7 @@ async function fetchTranslatedHeaderNames(columnData) { headerKeys.push(cm.cm); } //Now fetch all the keys and await the response before returning - await window.$gz.translation.fetch(headerKeys).then(() => { + await window.$gz.translation.cacheTranslations(headerKeys).then(() => { return; }); } diff --git a/ayanova/src/main.js b/ayanova/src/main.js index 417a51ae..3a8d6825 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -112,48 +112,48 @@ Vue.config.productionTip = false; // AJAX LOADER INDICATOR // // Store a copy of the fetch function -let _oldFetch = fetch; +// let _oldFetch = fetch; -// Create our new version of the fetch function -window.fetch = function() { - // Create hooks - let fetchStart = new Event("fetchStart", { - view: document, - bubbles: true, - cancelable: false - }); - let fetchEnd = new Event("fetchEnd", { - view: document, - bubbles: true, - cancelable: false - }); +// // Create our new version of the fetch function +// window.fetch = function() { +// // Create hooks +// let fetchStart = new Event("fetchStart", { +// view: document, +// bubbles: true, +// cancelable: false +// }); +// let fetchEnd = new Event("fetchEnd", { +// view: document, +// bubbles: true, +// cancelable: false +// }); - // Pass the supplied arguments to the real fetch function - let fetchCall = _oldFetch.apply(this, arguments); +// // Pass the supplied arguments to the real fetch function +// let fetchCall = _oldFetch.apply(this, arguments); - // Trigger the fetchStart event - document.dispatchEvent(fetchStart); +// // Trigger the fetchStart event +// document.dispatchEvent(fetchStart); - fetchCall - .then(function() { - // Trigger the fetchEnd event - document.dispatchEvent(fetchEnd); - }) - .catch(function() { - // Trigger the fetchEnd event - document.dispatchEvent(fetchEnd); - }); +// fetchCall +// .then(function() { +// // Trigger the fetchEnd event +// document.dispatchEvent(fetchEnd); +// }) +// .catch(function() { +// // Trigger the fetchEnd event +// document.dispatchEvent(fetchEnd); +// }); - return fetchCall; -}; +// return fetchCall; +// }; -document.addEventListener("fetchStart", function() { - NProgress.start(); -}); +// document.addEventListener("fetchStart", function() { +// NProgress.start(); +// }); -document.addEventListener("fetchEnd", function() { - NProgress.done(); -}); +// document.addEventListener("fetchEnd", function() { +// NProgress.done(); +// }); ///////////////////////////////////////////////////////////////// // FILTERS diff --git a/ayanova/src/views/adm-global-select-templates.vue b/ayanova/src/views/adm-global-select-templates.vue index b3a5d476..57114e6b 100644 --- a/ayanova/src/views/adm-global-select-templates.vue +++ b/ayanova/src/views/adm-global-select-templates.vue @@ -258,7 +258,7 @@ export default { for (let i = 0; i < res.data.length; i++) { vm.fieldKeys.push(res.data[i].tKey); } - return window.$gz.translation.fetch(vm.fieldKeys); + return window.$gz.translation.cacheTranslations(vm.fieldKeys); } }) .then(function() { @@ -460,7 +460,7 @@ function initForm(vm) { function fetchTranslatedText(vm) { let tKeysRequired = ["Include", "ResetToDefault"]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } ////////////////////// diff --git a/ayanova/src/views/adm-global-settings.vue b/ayanova/src/views/adm-global-settings.vue index 156e21fa..2c41d4f8 100644 --- a/ayanova/src/views/adm-global-settings.vue +++ b/ayanova/src/views/adm-global-settings.vue @@ -87,7 +87,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "UserInterfaceSettings", "PickListTemplates" ]); diff --git a/ayanova/src/views/ay-about.vue b/ayanova/src/views/ay-about.vue index 416a701c..181493e3 100644 --- a/ayanova/src/views/ay-about.vue +++ b/ayanova/src/views/ay-about.vue @@ -293,7 +293,7 @@ function fetchTranslatedText(vm) { "CurrencyCode" ]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } //////////////////// diff --git a/ayanova/src/views/ay-customize.vue b/ayanova/src/views/ay-customize.vue index adb681e2..3929f2ce 100644 --- a/ayanova/src/views/ay-customize.vue +++ b/ayanova/src/views/ay-customize.vue @@ -359,7 +359,7 @@ function fetchTranslatedText(vm) { "UiFieldDataTypesTrueFalse" ]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } ///////////////////////////////// diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 2833eae2..ce509613 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -1006,7 +1006,7 @@ function fetchTranslatedText(vm) { "Name" ]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } ///////////////////////////////// @@ -1182,7 +1182,7 @@ function fetchTranslatedFieldNames(vm) { columnKeys.push(cm.tKey); } //Now fetch all the keys and await the response before returning - return window.$gz.translation.fetch(columnKeys).then(() => { + return window.$gz.translation.cacheTranslations(columnKeys).then(() => { return; }); } diff --git a/ayanova/src/views/ay-history.vue b/ayanova/src/views/ay-history.vue index 2c70ee40..a4857ea3 100644 --- a/ayanova/src/views/ay-history.vue +++ b/ayanova/src/views/ay-history.vue @@ -466,7 +466,7 @@ function populateEventTypeList(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "EventDeleted", "EventCreated", "EventRetrieved", diff --git a/ayanova/src/views/home-password.vue b/ayanova/src/views/home-password.vue index eff02246..2970a14a 100644 --- a/ayanova/src/views/home-password.vue +++ b/ayanova/src/views/home-password.vue @@ -296,7 +296,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "UserLogin", "OldPassword", "NewPassword", diff --git a/ayanova/src/views/home-search.vue b/ayanova/src/views/home-search.vue index 4bb0f907..35e9efaa 100644 --- a/ayanova/src/views/home-search.vue +++ b/ayanova/src/views/home-search.vue @@ -379,7 +379,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "TooManyResults", "NoResults", "Object" diff --git a/ayanova/src/views/home-user-settings.vue b/ayanova/src/views/home-user-settings.vue index f3b746c2..a4a0b98a 100644 --- a/ayanova/src/views/home-user-settings.vue +++ b/ayanova/src/views/home-user-settings.vue @@ -431,7 +431,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "CurrencyCode", "LanguageCode", "TimeZone", diff --git a/ayanova/src/views/login.vue b/ayanova/src/views/login.vue index f2713390..fa3f2354 100644 --- a/ayanova/src/views/login.vue +++ b/ayanova/src/views/login.vue @@ -256,14 +256,16 @@ export default { let vm = this; if (vm.input.username != "" && vm.input.password != "") { vm.errorBadCreds = false; - auth .authenticate(vm.input.username, vm.input.password) .then(() => { + console.log("LOGIN:BACKFROMAUTHENTICATE"); if (vm.$store.state.openObject != null) { window.$gz.eventBus.$emit("openobject", null); } else { - vm.$router.push(vm.$store.state.homePage); + if (!vm.$store.state.homePage) { + console.log("####LOGIN END BUT homePage is empty!"); + } else vm.$router.push(vm.$store.state.homePage); } }) .catch(function handleCaughtLoginError(error) { diff --git a/ayanova/src/views/ops-backup.vue b/ayanova/src/views/ops-backup.vue index 8da631eb..4ad157d5 100644 --- a/ayanova/src/views/ops-backup.vue +++ b/ayanova/src/views/ops-backup.vue @@ -428,7 +428,7 @@ function initForm(vm) { // // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "BackupSettings", "BackupTime", "BackupLast", diff --git a/ayanova/src/views/ops-jobs.vue b/ayanova/src/views/ops-jobs.vue index 43041cdf..513b3bd9 100644 --- a/ayanova/src/views/ops-jobs.vue +++ b/ayanova/src/views/ops-jobs.vue @@ -260,6 +260,6 @@ function initForm(vm) { function fetchTranslatedText(vm) { let tKeysRequired = ["OpsTestJob"]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } diff --git a/ayanova/src/views/ops-log.vue b/ayanova/src/views/ops-log.vue index 6fa23083..6fd3d3cc 100644 --- a/ayanova/src/views/ops-log.vue +++ b/ayanova/src/views/ops-log.vue @@ -216,7 +216,7 @@ function initForm(vm) { function fetchTranslatedText(vm) { let tKeysRequired = ["OpsTestJob", "Log"]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } ////////////////////// diff --git a/ayanova/src/views/ops-metrics.vue b/ayanova/src/views/ops-metrics.vue index f179d002..73bcc901 100644 --- a/ayanova/src/views/ops-metrics.vue +++ b/ayanova/src/views/ops-metrics.vue @@ -565,6 +565,6 @@ function fetchTranslatedText(vm) { "MetricPrivateBytes" ]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } diff --git a/ayanova/src/views/ops-profile.vue b/ayanova/src/views/ops-profile.vue index 39cd5289..5c8573e7 100644 --- a/ayanova/src/views/ops-profile.vue +++ b/ayanova/src/views/ops-profile.vue @@ -152,6 +152,6 @@ function initForm(vm) { function fetchTranslatedText(vm) { let tKeysRequired = ["ServerProfiler"]; - return window.$gz.translation.fetch(tKeysRequired); + return window.$gz.translation.cacheTranslations(tKeysRequired); } diff --git a/ayanova/src/views/ops-server-state.vue b/ayanova/src/views/ops-server-state.vue index bf00f887..f8fa8803 100644 --- a/ayanova/src/views/ops-server-state.vue +++ b/ayanova/src/views/ops-server-state.vue @@ -300,7 +300,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "ServerStateOpen", "ServerStateOps", "ServerStateReason" diff --git a/ayanova/src/views/widget.vue b/ayanova/src/views/widget.vue index b89a0903..c28de28b 100644 --- a/ayanova/src/views/widget.vue +++ b/ayanova/src/views/widget.vue @@ -756,7 +756,7 @@ function initForm(vm) { // Ensures UI translated text is available // function fetchTranslatedText(vm) { - return window.$gz.translation.fetch([ + return window.$gz.translation.cacheTranslations([ "Widget", "WidgetName", "WidgetSerial",