/* Xeslint-disable */ function addNavItem(title, icon, route, navItems, key) { window.$gz.store.commit("addNavItem", { title, icon, route, navItems, key: key }); } ///////////////////////////////////// // Initialize the app // on change of authentication status export default function initialize() { var promise = new Promise(function(resolve) { if (window.$gz.store.state.authenticated) { //Fetch the core localized text keys that will always be required by user window.$gz.locale .fetch(window.$gz.locale.coreKeys) .then(function putFetchedNavItemsInStore() { //put nav items into store var key = 0; var sub = []; var subSub = []; //****************** HOME //Everyone has a home //create array of sub items under the home menu item //DASHBOARD sub.push({ title: window.$gz.locale.get("DashboardDashboard"), icon: "tachometer-alt", route: "/dashboard", key: key++ }); //SCHEDULE (personal) sub.push({ title: window.$gz.locale.get("Schedule"), icon: "calendar-alt", route: "/schedule/me", //Note: "me" is code for current user id in schedule form, any single user id can be substituted for me as well key: key++ }); //MEMOS sub.push({ title: window.$gz.locale.get("Memo"), icon: "inbox", route: "/memo", key: key++ }); //REMINDERS (SCHEDULE MARKERS) sub.push({ title: window.$gz.locale.get("ScheduleMarkerList"), icon: "sticky-note", route: "/reminder", key: key++ }); //3rd level items under preferences //LOCALE subSub.push({ title: window.$gz.locale.get("Locale"), icon: "language", route: "/userlocale", key: key++ }); //SET LOGIN subSub.push({ title: window.$gz.locale.get("SetLoginPassword"), icon: "key", route: "/changepw", key: key++ }); //NOTIFICATION SUBSCRIPTIONS subSub.push({ title: window.$gz.locale.get("NotifySubscriptionList"), icon: "bullhorn", route: "/notifysubscriptions", key: key++ }); //USER PREFERENCES (personal) sub.push({ title: window.$gz.locale.get("UserPreferences"), icon: "user-cog", route: undefined, navItems: subSub, key: key++ }); //HOME addNavItem( window.$gz.locale.get("Home"), "home", undefined, sub, key++ ); //****************** CUSTOMERS //clear sublevel arrays subSub = []; sub = []; //CUSTOMERS subitem sub.push({ title: window.$gz.locale.get("ClientList"), icon: "address-card", route: "/customers", key: key++ }); //HEAD OFFICES subitem sub.push({ title: window.$gz.locale.get("HeadOfficeList"), icon: "sitemap", route: "/headoffices", key: key++ }); // ** CUSTOMER (TOP) addNavItem( window.$gz.locale.get("ClientList"), "address-book", undefined, sub, key++ ); //****************** SERVICE //clear sublevel arrays subSub = []; sub = []; //SCHEDULE (combined) sub.push({ title: window.$gz.locale.get("Schedule"), icon: "calendar-alt", route: "/schedule/all", key: key++ }); //WORKORDERS GROUP SUBITEMS //WORKORDERS LIST (was service workorders) subSub.push({ title: window.$gz.locale.get("WorkorderServiceList"), icon: "tools", route: "/workorders", key: key++ }); //WORKORDER TEMPLATES LIST subSub.push({ title: window.$gz.locale.get("WorkorderServiceTemplate"), icon: "stamp", route: "/workordertemplates", key: key++ }); //WORKORDERS GROUP sub.push({ title: window.$gz.locale.get("WorkorderServiceList"), icon: "tools", route: undefined, navItems: subSub, key: key++ }); //QUOTE GROUP SUBITEMS subSub = []; //QUOTE LIST subSub.push({ title: window.$gz.locale.get("WorkorderQuoteList"), icon: "edit", route: "/quotes", key: key++ }); //QUOTE TEMPLATES LIST subSub.push({ title: window.$gz.locale.get("WorkorderQuoteTemplate"), icon: "stamp", route: "/quotetemplates", key: key++ }); //QUOTE GROUP sub.push({ title: window.$gz.locale.get("WorkorderQuoteList"), icon: "edit", route: undefined, navItems: subSub, key: key++ }); //PM GROUP SUBITEMS subSub = []; //PM LIST subSub.push({ title: window.$gz.locale.get("WorkorderPreventiveMaintenanceList"), icon: "business-time", route: "/pmlist", key: key++ }); //PM TEMPLATES LIST subSub.push({ title: window.$gz.locale.get( "WorkorderPreventiveMaintenanceTemplate" ), icon: "stamp", route: "/pmtemplates", key: key++ }); //PM GROUP sub.push({ title: window.$gz.locale.get("WorkorderPreventiveMaintenanceList"), icon: "business-time", route: undefined, navItems: subSub, key: key++ }); //UNITS subitem sub.push({ title: window.$gz.locale.get("UnitList"), icon: "fan", route: "/units", key: key++ }); //UNIT MODELS subitem sub.push({ title: window.$gz.locale.get("UnitModels"), icon: "dice-d20", route: "/unitmodels", key: key++ }); //CONTRACTS subitem sub.push({ title: window.$gz.locale.get("ContractList"), icon: "file-contract", route: "/contracts", key: key++ }); //CUSTOMER SERVICE REQUESTS subitem sub.push({ title: window.$gz.locale.get("ClientServiceRequestList"), icon: "child", route: "/csrs", key: key++ }); //LOANERS subitem sub.push({ title: window.$gz.locale.get("LoanItemList"), icon: "plug", route: "/loaners", key: key++ }); //**** Service (TOP GROUP) addNavItem( window.$gz.locale.get("Service"), "toolbox", undefined, sub, key++ ); //****************** INVENTORY //clear sublevel arrays subSub = []; sub = []; //PARTS (part list) sub.push({ title: window.$gz.locale.get("PartList"), icon: "cubes", route: "/parts", key: key++ }); //INVENTORY sub.push({ title: window.$gz.locale.get("PartByWarehouseInventoryList"), icon: "pallet", route: "/partinventorylist", key: key++ }); //PART REQUESTS sub.push({ title: window.$gz.locale.get("WorkorderItemPartRequestList"), icon: "paper-plane", route: "/partrequests", key: key++ }); //PURCHASE ORDERS sub.push({ title: window.$gz.locale.get("InventoryPurchaseOrders"), icon: "boxes", route: "/polist", key: key++ }); //NOTE: V7 HAD POITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE //PURCHASE ORDER RECEIPTS sub.push({ title: window.$gz.locale.get("InventoryPurchaseOrderReceipts"), icon: "dolly-flatbed", route: "/poreceipts", key: key++ }); //NOTE: V7 HAD PORECEIPTITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE //ADJUSTMENTS sub.push({ title: window.$gz.locale.get("InventoryPartInventoryAdjustments"), icon: "dolly", route: "/adjustments", key: key++ }); //**** INVENTORY (TOP GROUP) addNavItem( window.$gz.locale.get("Inventory"), "box", undefined, sub, key++ ); //**** WIDGETS (TOP GROUP) addNavItem( window.$gz.locale.get("WidgetList"), "splotch", "/testinventory", [], key++ ); //**** VENDORS (TOP GROUP) addNavItem( window.$gz.locale.get("VendorList"), "store", "/vendors", [], key++ ); //****************** ACCOUNTING //clear sublevel arrays subSub = []; sub = []; //FAKE subitem as is still TBD sub.push({ title: window.$gz.locale.get("Accounting"), icon: "file-invoice-dollar", route: "/accounting", key: key++ }); // ** CUSTOMER (TOP) addNavItem( window.$gz.locale.get("Accounting"), "file-invoice-dollar", undefined, sub, key++ ); //****************** ADMINISTRATION //clear sublevel arrays subSub = []; sub = []; // GLOBAL SETTINGS sub.push({ title: window.$gz.locale.get("AdministrationGlobalSettings"), icon: "cogs", route: "/globalsettings", key: key++ }); // LICENSE sub.push({ title: window.$gz.locale.get("HelpLicense"), icon: "ticket-alt", route: "/license", key: key++ }); // USERS sub.push({ title: window.$gz.locale.get("UserList"), icon: "users", route: "/users", key: key++ }); // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS //LOCALIZED TEXT DESIGNER sub.push({ title: window.$gz.locale.get("LocalizedTextDesign"), icon: "language", route: "/locales", key: key++ }); //REPORT TEMPLATES sub.push({ title: window.$gz.locale.get("ReportList"), icon: "th-list", route: "/reports", key: key++ }); //FILES IN DATABASE sub.push({ title: window.$gz.locale.get("FILES MANAGER"), icon: "folder", route: "/files", key: key++ }); //EVENT LOG / HISTORY sub.push({ title: window.$gz.locale.get("HISTORY"), icon: "history", route: "/history", key: key++ }); //KPI / METRICS / CHARTS AND STUFF sub.push({ title: window.$gz.locale.get("KPI CHARTS"), icon: "chart-line", route: "/kpi", key: key++ }); // ** ADMINISTRATION (TOP) addNavItem( window.$gz.locale.get("Administration"), "user-tie", undefined, sub, key++ ); //****************** OPERATIONS //clear sublevel arrays subSub = []; sub = []; // ARCHIVE sub.push({ title: window.$gz.locale.get("ARCHIVE DATA"), icon: "archive", route: "/archives", key: key++ }); // JOBS sub.push({ title: window.$gz.locale.get("SERVER JOBS"), icon: "robot", route: "/jobs", key: key++ }); // LOGS sub.push({ title: window.$gz.locale.get("Log"), icon: "history", route: "/serverlogs", key: key++ }); //METRICS sub.push({ title: window.$gz.locale.get("SERVER METRICS"), icon: "file-medical-alt", route: "/metrics", key: key++ }); //NOTIFICATION CONFIG AND HISTORY sub.push({ title: window.$gz.locale.get("NOTIFY CONFIG"), icon: "bullhorn", route: "/notifysettings", key: key++ }); // ** OPERATIONS (TOP) addNavItem( window.$gz.locale.get("Operations"), "server", undefined, sub, key++ ); //NOTE: If a user has read full record or better then they should have access to that area // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.TechLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.TechFull // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.SubContractorLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.SubContractorFull // ) // ) { // addNavItem( // window.$gz.locale.get("Service"), // "toolbox", // "/service", // undefined, // key++ // ); // } // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.DispatchFull // ) // ) { // addNavItem( // window.$gz.locale.get("Dispatch"), // "shipping-fast", // "/dispatch", // undefined, // key++ // ); // } // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.InventoryFull // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull // ) // ) { // addNavItem( // window.$gz.locale.get("Inventory"), // "dolly", // "/inventory", // undefined, // key++ // ); // } // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.AccountingFull // ) // ) { // addNavItem( // window.$gz.locale.get("Accounting"), // "file-invoice-dollar", // "/accounting", // undefined, // key++ // ); // } // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull // ) // ) { // addNavItem( // window.$gz.locale.get("Administration"), // "user-tie", // "/admin", // undefined, // key++ // ); // } // if ( // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.OpsAdminFull // ) || // window.$gz.role.hasRole( // window.$gz.role.AUTHORIZATION_ROLES.OpsAdminLimited // ) // ) { // addNavItem( // window.$gz.locale.get("Operations"), // "cogs", // "ops", // undefined, // key++ // ); // } // console.log(window.$gz.store.state.navItems); }) .then(() => { //CACHE LOCALE SETTINGS window.$gz.api .get("UserOptions/" + window.$gz.store.state.userId) .then(res => { if (res.error != undefined) { //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 var 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 { //TODO: also need the other locale settings such as number and date formats etc var localOffset = new Date().getTimezoneOffset(); if (localOffset != 0) { localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect } if (res.data.timeZoneOffset != localOffset) { //TODO: localize message and also actually have a fix for it here //so this should be a confirm prompt but for now will just show it //for now just show the message window.$gz.eventBus.$emit( "notify-info", "Time zone offset for your account is set to " + res.data.timeZoneOffset + " which doesn't match the local timezone offset of " + localOffset, window.$gz.store.state.helpUrl + "intro/#searching" ); } // window.$gz.eventBus.$emit("notify-success", "Success"); // window.$gz.eventBus.$emit( // "notify-warning", // "This is a very long warning, it has a lot of text and goes on and on and on. Hard to understand why anyone would do it this way but whatever right?@!" // ); // window.$gz.eventBus.$emit( // "notify-error", // "This is a medium error" // ); //Store offset in locale data //TODO: also need the other locale settings such as number and date formats etc to be added at server window.$gz.store.commit("setLocale", { decimalSeparator: ".", currencySymbol: "$", shortDate: "YYYY-MM-DD", shortTime: "hh:mm:ss A", shortDateAndTime: "YYYY-MM-DD hh:mm:ss A", timeZoneOffset: res.data.timeZoneOffset }); resolve(); } }) .catch(function handleFetchUserOptionsError(error) { window.$gz.store.commit( "logItem", "Initialize::() fetch useroptions -> error" + error ); throw error; }); }) .catch(function handleIntializeError(error) { window.$gz.store.commit( "logItem", "Initialize::() ltfetch -> error" + error ); throw error; }); } }); return promise; }