From 8cc6d8a58edc42edc0b55ae23ab41ca2a25b9e6a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 3 Mar 2020 22:53:43 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 11 +- ayanova/src/views/ay-about.vue | 271 +++++++++++++++++++-------------- 2 files changed, 166 insertions(+), 116 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 2ac99929..a711e2bf 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -44,12 +44,15 @@ CURRENT TODOs @@@@@@@@@@@ ROADMAP STAGE 1 and 2: - -todo: Make functional user settings form with all overrides so can test shit out -todo: Need a browser check on opening the login page that will check to ensure the browser can do the date conversions properly etc and tell user browser is unsuitable if it isn't - todo: Make sure fetching locale text is done properly in forms as in datalistview editor and widget etc - for sure this needs to be fixed in about form + +todo: Make functional user settings form with all overrides so can test shit out + +todo: Need a browser check on opening the login page that will check to ensure the browser can do the date conversions properly etc and +tell user browser is unsuitable if it isn't + + diff --git a/ayanova/src/views/ay-about.vue b/ayanova/src/views/ay-about.vue index 605a1b50..a53920cb 100644 --- a/ayanova/src/views/ay-about.vue +++ b/ayanova/src/views/ay-about.vue @@ -128,6 +128,83 @@ /* xeslint-disable */ import ayaNovaVersion from "../api/ayanova-version"; +export default { + created() { + var vm = this; + + initForm(vm) + .then(() => { + vm.formState.ready = true; + window.$gz.eventBus.$on("menu-click", clickHandler); + generateMenu(vm); + vm.formState.loading = false; + }) + .catch(err => { + vm.formState.ready = true; + window.$gz.errorHandler.handleFormError(err); + }); + }, + beforeDestroy() { + window.$gz.eventBus.$off("menu-click", clickHandler); + }, + mounted() { + this.clientInfo = {}; + this.clientInfo = ayaNovaVersion; + }, + data() { + return { + serverInfo: { license: { license: {} } }, + clientInfo: {}, + browser: {}, + formState: { + ready: false, + loading: true, + errorBoxMessage: null, + appError: null, + serverError: {} + } + }; + }, + methods: { + lt(ltKey) { + return window.$gz.locale.get(ltKey); + }, + locale() { + return window.$gz.locale; + } + } +}; + +////////////////////// +// +// +function generateMenu(vm) { + var menuOptions = { + isMain: false, + icon: "fa-info-circle", + title: window.$gz.locale.get("HelpAboutAyaNova"), + helpUrl: "form-ay-about", + menuItems: [ + { + title: window.$gz.locale.get("Copy"), + icon: "copy", + surface: true, + key: "about:copysupportinfo", + vm: vm + }, + { + title: window.$gz.locale.get("Log"), + icon: "glasses", + surface: true, + key: "app:nav:log", + data: "ay-log" + } + ] + }; + + window.$gz.eventBus.$emit("menu-change", menuOptions); +} + ///////////////////////////// // // @@ -160,118 +237,88 @@ function clickHandler(menuItem) { } } -export default { - beforeCreate() { - var vm = this; - window.$gz.locale - .fetch([ - "HelpAboutAyaNova", - "ClientApp", - "Server", - "Version", - "SchemaVersion", - "ServerTime", - "ServerAddress", - "TimeZone", - "HelpLicense", - "RegisteredUser", - "DatabaseID", - "LicenseSerial", - "LicenseExpiration", - "SupportedUntil", - "LicensedOptions", - "Log", - "User", - "Browser", - "LanguageCode", - "TimeZone", - "CurrencyCode" - ]) - .then(function() { - vm.formState.ready = true; - - window.$gz.eventBus.$emit("menu-change", { - isMain: false, - icon: "fa-info-circle", - title: window.$gz.locale.get("HelpAboutAyaNova"), - helpUrl: "form-ay-about", - menuItems: [ - { - title: window.$gz.locale.get("Copy"), - icon: "copy", - surface: true, - key: "about:copysupportinfo", - vm: vm - }, - { - title: window.$gz.locale.get("Log"), - icon: "glasses", - surface: true, - key: "app:nav:log", - data: "ay-log" - } - ] - }); - window.$gz.eventBus.$on("menu-click", clickHandler); - }) - .catch(err => { - vm.formState.ready = true; - window.$gz.errorHandler.handleFormError(err); - }); - }, - created() { - this.browser = { - platform: window.navigator.platform, - userAgent: window.navigator.userAgent, - languages: window.navigator.languages, - tz: Intl.DateTimeFormat().resolvedOptions().timeZone, - oscpu: window.navigator.oscpu, - maxTouchPoints: window.navigator.maxTouchPoints, - webdriver: window.navigator.webdriver, - vendor: window.navigator.vendor, - availWidth: window.screen.availWidth, - availHeight: window.screen.availHeight, - width: window.screen.width, - height: window.screen.height, - devicePixelRatio: window.devicePixelRatio, - pixelDepth: window.screen.pixelDepth - }; - - window.$gz.api - .get("ServerInfo") - .then(response => { - this.serverInfo = response.data; - }) - .catch(function handleGetServerInfoError(error) { - throw error; - }); - }, - beforeDestroy() {}, - mounted() { - this.clientInfo = {}; - this.clientInfo = ayaNovaVersion; - }, - data() { - return { - serverInfo: { license: { license: {} } }, - clientInfo: {}, - browser: {}, - formState: { - ready: false, - loading: true, - errorBoxMessage: null, - appError: null, - serverError: {} +///////////////////////////////// +// +// +function initForm(vm) { + return new Promise(function(resolve, reject) { + (async function() { + try { + await fetchUILocalizedText(vm); + await getServerInfo(vm); + await getBrowserInfo(vm); + } catch (err) { + reject(err); } - }; - }, - methods: { - lt(ltKey) { - return window.$gz.locale.get(ltKey); - }, - locale() { - return window.$gz.locale; + resolve(); + })(); + }); +} + +////////////////////////////////////////////////////////// +// +// Ensures UI localized text is available +// +function fetchUILocalizedText(vm) { + var ltKeysRequired = [ + "HelpAboutAyaNova", + "ClientApp", + "Server", + "Version", + "SchemaVersion", + "ServerTime", + "ServerAddress", + "TimeZone", + "HelpLicense", + "RegisteredUser", + "DatabaseID", + "LicenseSerial", + "LicenseExpiration", + "SupportedUntil", + "LicensedOptions", + "Log", + "User", + "Browser", + "LanguageCode", + "TimeZone", + "CurrencyCode" + ]; + + return window.$gz.locale.fetch(ltKeysRequired); +} + +//////////////////// +// +function getServerInfo(vm) { + return window.$gz.api.get("ServerInfo").then(res => { + if (res.error != undefined) { + throw res.error; + } else { + vm.serverInfo = res.data; } - } -}; + }); +} + +//////////////////// +// +function getBrowserInfo(vm) { + vm.browser = { + platform: window.navigator.platform, + userAgent: window.navigator.userAgent, + languages: window.navigator.languages, + tz: Intl.DateTimeFormat().resolvedOptions().timeZone, + oscpu: window.navigator.oscpu, + maxTouchPoints: window.navigator.maxTouchPoints, + webdriver: window.navigator.webdriver, + vendor: window.navigator.vendor, + availWidth: window.screen.availWidth, + availHeight: window.screen.availHeight, + width: window.screen.width, + height: window.screen.height, + devicePixelRatio: window.devicePixelRatio, + pixelDepth: window.screen.pixelDepth + }; +} + +//eoc