From 9f0ef1a8f5972e9833c7e46e30a1edab9973a6a5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 8 Dec 2020 20:25:55 +0000 Subject: [PATCH] User lists now working properly with datalist. Fixup for many areas where error constructor was being called with object instead of string --- ayanova/devdocs/todo.txt | 22 ------------------- ayanova/src/api/enums.js | 1 - ayanova/src/api/form-custom-template.js | 2 +- ayanova/src/api/gzapi.js | 6 +++-- ayanova/src/api/initialize.js | 3 ++- ayanova/src/api/notifypoll.js | 3 ++- ayanova/src/api/open-object-handler.js | 20 ++++++++++++----- .../src/components/extension-tags-control.vue | 8 +++++-- ayanova/src/components/pick-list.vue | 3 +-- .../components/report-selector-control.vue | 3 ++- ayanova/src/views/adm-attachments.vue | 8 +++++-- ayanova/src/views/adm-license.vue | 19 ++++++++++------ ayanova/src/views/ay-about.vue | 1 - ayanova/src/views/ay-customize.vue | 3 ++- ayanova/src/views/ay-data-list-view.vue | 9 +++++--- ayanova/src/views/ay-evaluate.vue | 9 +++++--- ayanova/src/views/ay-report-edit.vue | 1 - ayanova/src/views/home-notifications.vue | 3 ++- ayanova/src/views/login.vue | 4 ++-- 19 files changed, 68 insertions(+), 60 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 0364b805..1b3a14a3 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -5,28 +5,6 @@ MISC ITEMS THAT CAME UP -todo: customer users and regular users really need to reconsider not using a standard grid, - seeded huge basically dies waiting - However, how real is that scenario in the first place? - Ideally though for many reasons it should be a regular datagrid - Look into it, find out why it isn't and can it be implemented? - Also roles could then show on the customer-user grid which would be handy for some - AT LEAST put a wait spinner on that page -ACTIONS: - XMake a snapshot commit at both ends tagged with the fact about to do mucho fuckery and may need to revert - XMake copies of gz-data-table.js and inv-parts.vue - Xmake a InsideUserDataList.cs at server - XModify inv-parts.vue to show the insideuserdatalist in a gz-data-table - Xwork on gz-data-table and attempt to have roles work, use the code in adm-users rolesDisplayFromRoles method - FieldDataType=17 for roles - XSee if can get it to work adequately without worrying about filtering on roles - XNOPE, doesn't offer to filter, only sort and I'm happy with it for now.If it basically is working well enough regardless of filtering roles then see if its even conceivable that server could filter roles - maybe the client sends a lot of or i.e. roles = (64 or 1234 or 32768) however that shit has to work - if conceivable then need to make a copy of the ay-data-list-view.vue and modify to work with roles as a filter - XMake sure can print, bulk ops etc - If all is well then move it into the regular adm-users and replicate to cust-users and ditch the shitty current half-ass grid - Remove the routes that were being used for inside and outside user lists as they are no longer reqd. - $profit todo: throw new Error() code *MUST* put only a string into the constructor of error. Putting a object is wrong and will result in errors that say "Error: [object Object]" Search for all instances of throw new Error and ensure it's a string not an object, use stringify if necessary when all else fails diff --git a/ayanova/src/api/enums.js b/ayanova/src/api/enums.js index 56a402ae..0d7d7266 100644 --- a/ayanova/src/api/enums.js +++ b/ayanova/src/api/enums.js @@ -95,7 +95,6 @@ export default { let res = await window.$gz.api.get("enum-list/list/" + enumKey); //We never expect there to be no data here if (!res.hasOwnProperty("data")) { - // throw new Error(res); return Promise.reject(res); } return res.data; diff --git a/ayanova/src/api/form-custom-template.js b/ayanova/src/api/form-custom-template.js index 6eaa7ce1..8046d125 100644 --- a/ayanova/src/api/form-custom-template.js +++ b/ayanova/src/api/form-custom-template.js @@ -24,7 +24,7 @@ export default { //fetch and populate the store let res = await window.$gz.api.get("form-custom/" + formKey); if (res.error) { - throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } window.$gz.store.commit("setFormCustomTemplateItem", { formKey: formKey, diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index fc8a1883..f6b762c1 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -503,7 +503,8 @@ export default { handleError("UPSERT", error, route); } else { //specifically this is for the login page - throw new Error(error); + // throw new Error(error); + throw new Error(window.$gz.errorHandler.errorToString(res)); } } }, @@ -694,7 +695,8 @@ export default { let res = await window.$gz.api.upsert("report/render", reportDataOptions); if (res.error) { - throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res)); + //throw new Error(res.error); } else { let reportUrl = window.$gz.api.reportDownloadUrl(res.data); if (redirectNotPopup) { diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index 17adbb5b..4d5f45aa 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -730,7 +730,8 @@ async function getUserOptions() { "logItem", "Initialize::() fetch useroptions -> error" + error ); - throw new Error(error); + // throw new Error(error); + throw new Error(window.$gz.errorHandler.errorToString(res)); } } diff --git a/ayanova/src/api/notifypoll.js b/ayanova/src/api/notifypoll.js index b0e17904..dec08bb5 100644 --- a/ayanova/src/api/notifypoll.js +++ b/ayanova/src/api/notifypoll.js @@ -21,7 +21,8 @@ export default { if (keepChecking && window.$gz.store.state.authenticated) { status = await window.$gz.api.get("notify/new-count"); if (status.error) { - throw new Error(status.error); + throw new Error(window.$gz.errorHandler.errorToString(status)); + // throw new Error(status.error); } else { window.$gz.store.commit("setNewNotificationCount", status.data); //success so go to default in case it was changed by an error diff --git a/ayanova/src/api/open-object-handler.js b/ayanova/src/api/open-object-handler.js index 09b26a9e..a0bb1512 100644 --- a/ayanova/src/api/open-object-handler.js +++ b/ayanova/src/api/open-object-handler.js @@ -62,7 +62,10 @@ export default { "user/inside-type/" + tid.id ); if (res.error) { - throw new Error(res.error); + //throw new Error(res.error); + throw new Error( + window.$gz.errorHandler.errorToString(res, vm) + ); } if (res.data) { tid.inside = res.data; @@ -80,7 +83,8 @@ export default { }); } } catch (e) { - throw new Error(e); + throw new Error(window.$gz.errorHandler.errorToString(e, vm)); + //throw new Error(e); } })(); } @@ -100,14 +104,16 @@ export default { let res = await window.$gz.api.get("attachment/parent/" + tid.id); if (res.error) { - throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); + // throw new Error(res.error); } if (res.data.id && res.data.id != 0) { this.handleOpenObjectClick(vm, res.data); return; } } catch (e) { - throw new Error(e); + //throw new Error(e); + throw new Error(window.$gz.errorHandler.errorToString(e, vm)); } })(); @@ -146,7 +152,8 @@ export default { ); if (res.error) { - throw new Error(res.error); + //throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } if (res && res.data) { vm.$router.push({ @@ -156,7 +163,8 @@ export default { return; } } catch (e) { - throw new Error(e); + //throw new Error(e); + throw new Error(window.$gz.errorHandler.errorToString(e, vm)); } })(); diff --git a/ayanova/src/components/extension-tags-control.vue b/ayanova/src/components/extension-tags-control.vue index 92466f04..ff27c47d 100644 --- a/ayanova/src/components/extension-tags-control.vue +++ b/ayanova/src/components/extension-tags-control.vue @@ -93,7 +93,8 @@ export default { //call api route let jobId = await window.$gz.api.upsert(url, body); if (jobId.error) { - throw new Error(jobId.error); + //throw new Error(jobId.error); + throw new Error(window.$gz.errorHandler.errorToString(jobId, vm)); } jobId = jobId.jobId; //it's in a sub key //indicate loading by setting on button @@ -120,7 +121,10 @@ export default { `job-operations/status/${jobId}` ); if (jobStatus.error) { - throw new Error(jobStatus.error); + //throw new Error(jobStatus.error); + throw new Error( + window.$gz.errorHandler.errorToString(jobStatus, vm) + ); } jobStatus = jobStatus.data; if (jobStatus == 4 || jobStatus == 0) { diff --git a/ayanova/src/components/pick-list.vue b/ayanova/src/components/pick-list.vue index 7eaab472..84c8f7a4 100644 --- a/ayanova/src/components/pick-list.vue +++ b/ayanova/src/components/pick-list.vue @@ -270,8 +270,7 @@ export default { vm.fetching = false; //We never expect there to be no data here - if (!res.hasOwnProperty("data")) { - //throw new Error(res); + if (!res.hasOwnProperty("data")) { return Promise.reject(res); } vm.searchResults = res.data; diff --git a/ayanova/src/components/report-selector-control.vue b/ayanova/src/components/report-selector-control.vue index a39ca59a..9c1a828e 100644 --- a/ayanova/src/components/report-selector-control.vue +++ b/ayanova/src/components/report-selector-control.vue @@ -134,7 +134,8 @@ export default { `report/list/${reportDataOptions.ObjectType}` ); if (res.error) { - throw new Error(res.error); + // throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } else { this.reportList = res.data; } diff --git a/ayanova/src/views/adm-attachments.vue b/ayanova/src/views/adm-attachments.vue index 4b03e73f..f122ce98 100644 --- a/ayanova/src/views/adm-attachments.vue +++ b/ayanova/src/views/adm-attachments.vue @@ -204,7 +204,8 @@ export default { //call seed route let jobId = await window.$gz.api.upsert("attachment/maintenance"); if (jobId.error) { - throw new Error(jobId.error); + //throw new Error(jobId.error); + throw new Error(window.$gz.errorHandler.errorToString(jobId, vm)); } jobId = jobId.jobId; //it's in a sub key vm.jobActive = true; @@ -230,7 +231,10 @@ export default { `job-operations/status/${jobId}` ); if (jobStatus.error) { - throw new Error(jobStatus.error); + // throw new Error(jobStatus.error); + throw new Error( + window.$gz.errorHandler.errorToString(jobStatus, vm) + ); } jobStatus = jobStatus.data; if (jobStatus == 4 || jobStatus == 0) { diff --git a/ayanova/src/views/adm-license.vue b/ayanova/src/views/adm-license.vue index 35595c8e..dee1936d 100644 --- a/ayanova/src/views/adm-license.vue +++ b/ayanova/src/views/adm-license.vue @@ -388,11 +388,13 @@ export default { //send request r = await window.$gz.api.upsert("license/trialRequest", vm.request); if (r.error) { - throw new Error(r); + //throw new Error(r); + throw new Error(window.$gz.errorHandler.errorToString(r, vm)); } //a string is returned and will start with E1 if it's an error if (r.startsWith("E1")) { - throw new Error(r); + throw new Error(window.$gz.errorHandler.errorToString(r, vm)); + //throw new Error(r); } if (r == "ok") { @@ -414,7 +416,10 @@ export default { //It might have been just installed by the server on it's own so check if we are not working with the most current license let currentServerLicenseInfo = await window.$gz.api.get("license"); if (currentServerLicenseInfo.error) { - throw new Error(currentServerLicenseInfo.error); + //throw new Error(currentServerLicenseInfo.error); + throw new Error( + window.$gz.errorHandler.errorToString(currentServerLicenseInfo, vm) + ); } currentServerLicenseInfo = currentServerLicenseInfo.data.license; @@ -433,11 +438,13 @@ export default { let r = await window.$gz.api.upsert("license"); //r should just be a string response unless there is an error in which case it's an object if (r.error) { - throw new Error(r); + // throw new Error(r); + throw new Error(window.$gz.errorHandler.errorToString(r, vm)); } if (r.startsWith("E1")) { - throw new Error(r); + //throw new Error(r); + throw new Error(window.$gz.errorHandler.errorToString(r, vm)); } //If here, there is no technical error //key might not exist or be not found but no error so r contains the deets @@ -590,7 +597,6 @@ async function initForm(vm) { //We never expect there to be no data here if (!res.hasOwnProperty("data")) { return Promise.reject(res); - //throw new Error(res); } vm.currentLicenseInfo = res.data.license; @@ -598,7 +604,6 @@ async function initForm(vm) { //We never expect there to be no data here if (!res.hasOwnProperty("data")) { return Promise.reject(res); - //throw new Error(res); } vm.dbIsEmpty = res.data; } diff --git a/ayanova/src/views/ay-about.vue b/ayanova/src/views/ay-about.vue index 16f2559b..58b023b2 100644 --- a/ayanova/src/views/ay-about.vue +++ b/ayanova/src/views/ay-about.vue @@ -305,7 +305,6 @@ async function getServerInfo(vm) { let res = await window.$gz.api.get("server-info"); //We never expect there to be no data here if (!res.hasOwnProperty("data")) { - //throw new Error(res); return Promise.reject(res); } else { vm.serverInfo = res.data; diff --git a/ayanova/src/views/ay-customize.vue b/ayanova/src/views/ay-customize.vue index 9369353a..9735e16f 100644 --- a/ayanova/src/views/ay-customize.vue +++ b/ayanova/src/views/ay-customize.vue @@ -377,7 +377,8 @@ async function initDataObject(vm) { let url = "form-field-definition/" + vm.$route.params.formCustomTemplateKey; let res = await window.$gz.api.get(url); if (res.error) { - throw new Error(res.error); + //throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } //set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form // - {key, ltdisplay, hideable, custom, required, hide, type} diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 27901eac..42aef78b 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -1203,7 +1203,8 @@ async function populateFieldDefinitions(vm) { "data-list/listfields?DataListKey=" + vm.dataListKey ); if (res.error) { - throw new Error(res.error); + //throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } else { vm.fieldDefinitions = res.data; } @@ -1259,7 +1260,8 @@ async function setEffectiveListView(vm) { ); if (res.error) { - throw new Error(res.error); + // throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } else { vm.effectiveListView = JSON.parse(res.data); vm.obj.name = vm.$ay.t("FilterUnsaved"); @@ -1268,7 +1270,8 @@ async function setEffectiveListView(vm) { //listview has an id value let res = await window.$gz.api.get("data-list-view/" + vm.listViewId); if (res.error) { - throw new Error(res.error); + //throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } else { vm.effectiveListView = JSON.parse(res.data.listView); vm.obj.public = res.data.public; diff --git a/ayanova/src/views/ay-evaluate.vue b/ayanova/src/views/ay-evaluate.vue index 7959daf6..bc128fcd 100644 --- a/ayanova/src/views/ay-evaluate.vue +++ b/ayanova/src/views/ay-evaluate.vue @@ -203,7 +203,6 @@ export default { //We never expect there to be no data here if (!res.hasOwnProperty("data")) { return Promise.reject(res); - //throw new Error(res); } if (res.data != true) { let dialogResult = await window.$gz.dialog.confirmGeneric( @@ -233,7 +232,8 @@ export default { `trial/seed/${vm.obj.seedLevel}/${vm.obj.timeZoneOffset}` ); if (jobId.error) { - throw new Error(jobId.error); + //throw new Error(jobId.error); + throw new Error(window.$gz.errorHandler.errorToString(jobId, vm)); } jobId = jobId.jobId; //it's in a sub key //indicate loading by setting on button @@ -260,7 +260,10 @@ export default { `job-operations/status/${jobId}` ); if (jobStatus.error) { - throw new Error(jobStatus.error); + //throw new Error(jobStatus.error); + throw new Error( + window.$gz.errorHandler.errorToString(jobStatus, vm) + ); } jobStatus = jobStatus.data; if (jobStatus == 4 || jobStatus == 0) { diff --git a/ayanova/src/views/ay-report-edit.vue b/ayanova/src/views/ay-report-edit.vue index f628c4de..3aecc77e 100644 --- a/ayanova/src/views/ay-report-edit.vue +++ b/ayanova/src/views/ay-report-edit.vue @@ -1172,7 +1172,6 @@ async function fetchReportData(vm) { //We never expect there to be no data here if (!res.hasOwnProperty("data")) { return Promise.reject(res); - //throw new Error(res); } else { vm.reportData = res.data; } diff --git a/ayanova/src/views/home-notifications.vue b/ayanova/src/views/home-notifications.vue index 30a2d0f6..c6ddfec3 100644 --- a/ayanova/src/views/home-notifications.vue +++ b/ayanova/src/views/home-notifications.vue @@ -215,7 +215,8 @@ export default { //this is to ensure that when a user is viewing the latest notifications they don't see the NEW count still in the bell icon in menu since they are viewing them live let status = await window.$gz.api.get("notify/new-count"); if (status.error) { - throw new Error(status.error); + //throw new Error(status.error); + throw new Error(window.$gz.errorHandler.errorToString(status, vm)); } window.$gz.store.commit("setNewNotificationCount", status.data); } diff --git a/ayanova/src/views/login.vue b/ayanova/src/views/login.vue index 31c802e7..d99ffb66 100644 --- a/ayanova/src/views/login.vue +++ b/ayanova/src/views/login.vue @@ -383,7 +383,6 @@ export default { //move focus to password document.getElementsByName("password")[0].focus(); }, - async login() { let vm = this; if (vm.input.username != "" && vm.input.password != "") { @@ -403,7 +402,8 @@ export default { if (res.error) { //don't expect this to ever get called but just in case - throw new Error(res.error); + // throw new Error(res.error); + throw new Error(window.$gz.errorHandler.errorToString(res, vm)); } await processLogin(res.data, loggedInWithKnownPassword);