From 8727beefdc93407c94b971f7edfab0571a136992 Mon Sep 17 00:00:00 2001 From: Edwin Betancourt Date: Fri, 15 May 2020 10:57:53 -0400 Subject: [PATCH] feat: Add grpc core client support. (#495) * feat: Add grpc core client support. * export instances and catching error. --- package.json | 7 +- src/api/ADempiere/browser.js | 15 +--- src/api/ADempiere/dashboard/dashboard.js | 20 +---- src/api/ADempiere/dictionary.js | 13 +-- src/api/ADempiere/enrollment.js | 19 ++-- src/api/ADempiere/field/locator.js | 4 +- src/api/ADempiere/form/price-checking.js | 15 +--- src/api/ADempiere/instances.js | 69 +++++++++++++++ src/api/ADempiere/persistence.js | 19 +--- src/api/ADempiere/private-access.js | 15 +--- src/api/ADempiere/process.js | 15 +--- src/api/ADempiere/report.js | 15 +--- src/api/ADempiere/rule.js | 15 +--- src/api/ADempiere/system-core.js | 15 +--- src/api/ADempiere/values.js | 15 +--- src/api/ADempiere/window.js | 15 +--- src/api/user.js | 32 +++---- .../ADempiere/ContextMenu/contextMenuMixin.js | 6 +- src/components/ADempiere/Dialog/index.vue | 3 + src/components/ADempiere/Panel/index.vue | 3 + src/components/ADempiere/Tab/tabMixin.js | 3 + src/permission.js | 2 +- src/store/modules/ADempiere/dashboard.js | 33 ++----- src/store/modules/ADempiere/data.js | 7 +- .../modules/ADempiere/languageControl.js | 1 - src/store/modules/ADempiere/process.js | 2 +- src/store/modules/ADempiere/processControl.js | 5 +- src/store/modules/ADempiere/windowControl.js | 19 +++- src/store/modules/user.js | 86 +++++++++---------- src/views/dashboard/admin/index.vue | 1 - 30 files changed, 191 insertions(+), 298 deletions(-) create mode 100644 src/api/ADempiere/instances.js diff --git a/package.json b/package.json index adbfed02..525fb398 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,11 @@ "url": "https://github.com/PanJiaChen/vue-element-admin/issues" }, "dependencies": { - "@adempiere/grpc-access-client": "^1.2.0", - "@adempiere/grpc-data-client": "^2.3.2", + "@adempiere/grpc-access-client": "^1.2.1", + "@adempiere/grpc-data-client": "^2.3.4", "@adempiere/grpc-dictionary-client": "^1.4.1", "@adempiere/grpc-enrollment-client": "^1.1.0", - "@adempiere/grpc-pos-client": "^1.1.0", + "@adempiere/grpc-pos-client": "^1.2.0", "axios": "0.19.2", "clipboard": "2.0.6", "codemirror": "5.53.2", @@ -87,6 +87,7 @@ "xlsx": "0.15.6" }, "devDependencies": { + "@adempiere/grpc-core-client": "^1.0.3", "@babel/core": "7.9.0", "@babel/register": "7.9.0", "@vue/cli-plugin-babel": "4.3.1", diff --git a/src/api/ADempiere/browser.js b/src/api/ADempiere/browser.js index b036af28..1dd31861 100644 --- a/src/api/ADempiere/browser.js +++ b/src/api/ADempiere/browser.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Request a browser search diff --git a/src/api/ADempiere/dashboard/dashboard.js b/src/api/ADempiere/dashboard/dashboard.js index 885c4b15..f13b0f9f 100644 --- a/src/api/ADempiere/dashboard/dashboard.js +++ b/src/api/ADempiere/dashboard/dashboard.js @@ -1,26 +1,8 @@ // This file is for get all information for dashboard of ADempiere client, // please if you want to implement a custom dashboard create a new fielwith api definition -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} - -// Request a Process Activity list -export function requestListProcessesLogs({ pageToken, pageSize }) { - // Get Process Activity - return Instance.call(this).requestListProcessesLogs({ pageToken, pageSize }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' // Get Recent Items based on selection option export function getRecentItems({ pageToken, pageSize }) { diff --git a/src/api/ADempiere/dictionary.js b/src/api/ADempiere/dictionary.js index 715348bc..e8166fcd 100644 --- a/src/api/ADempiere/dictionary.js +++ b/src/api/ADempiere/dictionary.js @@ -1,16 +1,5 @@ -import { getLanguage } from '@/lang/index' -import { getToken } from '@/utils/auth' -import Dictionary from '@adempiere/grpc-dictionary-client' -import { DICTIONARY_ADDRESS } from '@/api/ADempiere/constants' - // Get Instance for connection -function Instance() { - return new Dictionary( - DICTIONARY_ADDRESS, - getToken(), - getLanguage() || 'en_US' - ) -} +import { DictionaryInstance as Instance } from '@/api/ADempiere/instances.js' export function getWindow(uuid, isWithTabs = true) { return Instance.call(this).requestWindow({ diff --git a/src/api/ADempiere/enrollment.js b/src/api/ADempiere/enrollment.js index 78247137..be84721e 100644 --- a/src/api/ADempiere/enrollment.js +++ b/src/api/ADempiere/enrollment.js @@ -1,14 +1,5 @@ -import Enrollment from '@adempiere/grpc-enrollment-client' -import { ENROLLMENT_ADDRESS } from '@/api/ADempiere/constants' - // Get Instance for connection -function Instance() { - return new Enrollment( - ENROLLMENT_ADDRESS, - 3.9, - 'ADempiere-Vue' - ) -} +import { EnrollmentInstance as Instance } from '@/api/ADempiere/instances.js' /** * enroll User @@ -18,10 +9,10 @@ function Instance() { */ export function enrollmentUser({ name, userName, password, eMail }) { return Instance.call(this).enrollUser({ - name: name, - userName: userName, - password: password, - eMail: eMail + name, + userName, + password, + eMail }) } diff --git a/src/api/ADempiere/field/locator.js b/src/api/ADempiere/field/locator.js index edf76c2f..08db43d8 100644 --- a/src/api/ADempiere/field/locator.js +++ b/src/api/ADempiere/field/locator.js @@ -1,8 +1,8 @@ -import { getEntitiesList } from '@/api/ADempiere/persistence' - export function getLocatorList({ warehouseId }) { + const { getEntitiesList } = require('@/api/ADempiere/persistence') + return getEntitiesList({ tableName: 'M_Locator', whereClause: `M_Warehouse_ID = ${warehouseId}` diff --git a/src/api/ADempiere/form/price-checking.js b/src/api/ADempiere/form/price-checking.js index c594f43f..08175171 100644 --- a/src/api/ADempiere/form/price-checking.js +++ b/src/api/ADempiere/form/price-checking.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import POS from '@adempiere/grpc-pos-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new POS({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { POSInstance as Instance } from '@/api/ADempiere/instances.js' export function getProductPrice({ searchValue, diff --git a/src/api/ADempiere/instances.js b/src/api/ADempiere/instances.js new file mode 100644 index 00000000..717a08ba --- /dev/null +++ b/src/api/ADempiere/instances.js @@ -0,0 +1,69 @@ +// Instance for connection Access (or Security) +export const AccessInstance = () => { + const Access = require('@adempiere/grpc-access-client') + const { ACCESS_ADDRESS } = require('@/api/ADempiere/constants') + const { getLanguage } = require('@/lang/index') + + return new Access({ + host: ACCESS_ADDRESS, + version: 'Version Epale', + language: getLanguage() || 'en_US' + }) +} + +// Instance for connection Business Data +export const BusinessDataInstance = () => { + const BusinessData = require('@adempiere/grpc-data-client') + const { BUSINESS_DATA_ADDRESS } = require('@/api/ADempiere/constants') + const { getLanguage } = require('@/lang/index') + const { getToken, getCurrentOrganization, getCurrentWarehouse } = require('@/utils/auth') + + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +// Get Instance for connection +export const DictionaryInstance = () => { + const Dictionary = require('@adempiere/grpc-dictionary-client') + const { DICTIONARY_ADDRESS } = require('@/api/ADempiere/constants') + const { getLanguage } = require('@/lang/index') + const { getToken } = require('@/utils/auth') + + return new Dictionary( + DICTIONARY_ADDRESS, + getToken(), + getLanguage() || 'en_US' + ) +} + +// Instance for connection Enrollment +export const EnrollmentInstance = () => { + const Enrollment = require('@adempiere/grpc-enrollment-client') + const { ENROLLMENT_ADDRESS } = require('@/api/ADempiere/constants') + + return new Enrollment( + ENROLLMENT_ADDRESS, + 3.9, + 'ADempiere-Vue' + ) +} + +export const POSInstance = () => { + const POS = require('@adempiere/grpc-pos-client') + const { BUSINESS_DATA_ADDRESS } = require('@/api/ADempiere/constants') + const { getLanguage } = require('@/lang/index') + const { getToken, getCurrentOrganization, getCurrentWarehouse } = require('@/utils/auth') + + return new POS({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} diff --git a/src/api/ADempiere/persistence.js b/src/api/ADempiere/persistence.js index c997dc0f..810cc45e 100644 --- a/src/api/ADempiere/persistence.js +++ b/src/api/ADempiere/persistence.js @@ -1,23 +1,10 @@ -import { getLanguage } from '@/lang/index' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Create entity - * @param {string} parameters.tableName - * @param {array} parameters.attributesList + * @param {string} tableName + * @param {array} attributesList */ export function createEntity({ tableName, attributesList }) { return Instance.call(this).requestCreateEntity({ diff --git a/src/api/ADempiere/private-access.js b/src/api/ADempiere/private-access.js index b7228c93..2622a36c 100644 --- a/src/api/ADempiere/private-access.js +++ b/src/api/ADempiere/private-access.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' // Get private access for a record export function getPrivateAccessFromServer({ tableName, recordId, userUuid }) { diff --git a/src/api/ADempiere/process.js b/src/api/ADempiere/process.js index e4157b83..47eb30a8 100644 --- a/src/api/ADempiere/process.js +++ b/src/api/ADempiere/process.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Request a process diff --git a/src/api/ADempiere/report.js b/src/api/ADempiere/report.js index 17c05de2..4492b7e5 100644 --- a/src/api/ADempiere/report.js +++ b/src/api/ADempiere/report.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Request Pending Documents List diff --git a/src/api/ADempiere/rule.js b/src/api/ADempiere/rule.js index 5bb45d2f..b8fea13a 100644 --- a/src/api/ADempiere/rule.js +++ b/src/api/ADempiere/rule.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Run callout request diff --git a/src/api/ADempiere/system-core.js b/src/api/ADempiere/system-core.js index a68c3807..8c4bad71 100644 --- a/src/api/ADempiere/system-core.js +++ b/src/api/ADempiere/system-core.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' // Get Organization list from role export function getOrganizationsList({ diff --git a/src/api/ADempiere/values.js b/src/api/ADempiere/values.js index d4f69dba..3df5b3dc 100644 --- a/src/api/ADempiere/values.js +++ b/src/api/ADempiere/values.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' /** * Request a Lookup data from Reference diff --git a/src/api/ADempiere/window.js b/src/api/ADempiere/window.js index 5401cc17..fcb45017 100644 --- a/src/api/ADempiere/window.js +++ b/src/api/ADempiere/window.js @@ -1,18 +1,5 @@ -import { getLanguage } from '@/lang/index' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' - // Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} +import { BusinessDataInstance as Instance } from '@/api/ADempiere/instances.js' // Get list of log for a records export function requestListRecordsLogs({ diff --git a/src/api/user.js b/src/api/user.js index fb805fae..a5ba3956 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,30 +1,22 @@ -import { getLanguage } from '@/lang/index' -import Access from '@adempiere/grpc-access-client' -import { ACCESS_ADDRESS } from '@/api/ADempiere/constants' - // Instance for connection -function Instance() { - return new Access( - ACCESS_ADDRESS, - 'Version Epale', - getLanguage() || 'en_US' - ) -} +import { AccessInstance as Instance } from '@/api/ADempiere/instances.js' // Make login by UserName and password, this function can return user data for show -export function login(loginValues) { - if (loginValues.role && loginValues.role.trim() !== '') { +export function login({ + userName, + password: userPass, + role +}) { + if (role && role.trim() !== '') { return Instance.call(this).requestLogin({ - userName: loginValues.userName, - userPass: loginValues.password, - role: loginValues.role, - language: getLanguage() || 'en_US' + userName, + userPass, + role }) } else { return Instance.call(this).requestLoginDefault({ - userName: loginValues.userName, - userPass: loginValues.password, - language: getLanguage() || 'en_US' + userName, + userPass }) } } diff --git a/src/components/ADempiere/ContextMenu/contextMenuMixin.js b/src/components/ADempiere/ContextMenu/contextMenuMixin.js index a89a519c..0df754d8 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuMixin.js +++ b/src/components/ADempiere/ContextMenu/contextMenuMixin.js @@ -262,6 +262,9 @@ export const contextMixin = { isRefreshPanel: true, recordUuid: this.recordUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } else if (this.panelType === 'browser') { const fieldsEmpty = this.$store.getters.getFieldListEmptyMandatory({ containerUuid: this.containerUuid, @@ -297,9 +300,6 @@ export const contextMixin = { .then(() => { this.references = this.getterReferences }) - .catch(error => { - console.warn(`References Load Error ${error.code}: ${error.message}.`) - }) .finally(() => { this.isLoadedReferences = true }) diff --git a/src/components/ADempiere/Dialog/index.vue b/src/components/ADempiere/Dialog/index.vue index 4cd33ccc..74d115ee 100644 --- a/src/components/ADempiere/Dialog/index.vue +++ b/src/components/ADempiere/Dialog/index.vue @@ -112,6 +112,9 @@ export default { containerUuid: this.modalMetadata.containerUuid, isAddRecord: true }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } } } diff --git a/src/components/ADempiere/Panel/index.vue b/src/components/ADempiere/Panel/index.vue index 03e5d301..dd4518f9 100644 --- a/src/components/ADempiere/Panel/index.vue +++ b/src/components/ADempiere/Panel/index.vue @@ -585,6 +585,9 @@ export default { }) } }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } }, /** diff --git a/src/components/ADempiere/Tab/tabMixin.js b/src/components/ADempiere/Tab/tabMixin.js index 7bfa34e1..fee7ec4c 100644 --- a/src/components/ADempiere/Tab/tabMixin.js +++ b/src/components/ADempiere/Tab/tabMixin.js @@ -35,6 +35,9 @@ export const tabMixin = { parentUuid: this.windowUuid, containerUuid: this.tabUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) }, /** * @param {object} tabHTML DOM HTML the tab clicked diff --git a/src/permission.js b/src/permission.js index 80a51c24..655cae36 100644 --- a/src/permission.js +++ b/src/permission.js @@ -35,7 +35,7 @@ router.beforeEach(async(to, from, next) => { try { // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] // get user info from server - await store.dispatch('user/getInfo') + await store.dispatch('user/getSessionInfo') // generate accessible routes map based on roles const accessRoutes = await store.dispatch('permission/generateRoutes') diff --git a/src/store/modules/ADempiere/dashboard.js b/src/store/modules/ADempiere/dashboard.js index 22480a76..ffd3601f 100644 --- a/src/store/modules/ADempiere/dashboard.js +++ b/src/store/modules/ADempiere/dashboard.js @@ -1,6 +1,5 @@ // Default store for handle dashboard refresh and other functionalities -import { requestLisDashboards, getRecentItems } from '@/api/ADempiere/dashboard/dashboard' -import { convertAction } from '@/utils/ADempiere/dictionaryUtils' +import { requestLisDashboards } from '@/api/ADempiere/dashboard/dashboard' import { isEmptyValue } from '@/utils/ADempiere/valueUtils' import { getCurrentRole } from '@/utils/auth' @@ -27,9 +26,11 @@ const dashboard = { listDashboard({ commit, rootGetters }, roleUuid) { if (isEmptyValue(roleUuid)) { roleUuid = rootGetters.getRoleUuid - } else if (isEmptyValue(roleUuid)) { - roleUuid = getCurrentRole() + if (isEmptyValue(roleUuid)) { + roleUuid = getCurrentRole() + } } + return new Promise(resolve => { requestLisDashboards({ roleUuid }) .then(dashboardResponse => { @@ -44,27 +45,6 @@ const dashboard = { console.warn(`Error getting List Dashboards: ${error.message}. Code: ${error.code}.`) }) }) - }, - getRecentItemsFromServer({ commit }) { - return new Promise(resolve => { - getRecentItems({ pageToken: undefined, pageSize: undefined }) - .then(recentItemsResponse => { - const recentItems = recentItemsResponse.recentItemsList.map(item => { - const actionConverted = convertAction(item.action) - return { - ...item, - originalAction: item.action, - action: actionConverted.name, - icon: actionConverted.icon - } - }) - commit('setRecentItems', recentItems) - resolve(recentItems) - }) - .catch(error => { - console.warn(`Error getting recent items: ${error.message}. Code: ${error.code}.`) - }) - }) } }, getters: { @@ -77,9 +57,6 @@ const dashboard = { return state.dashboard.find( item => item.roleUuid === roleUuid ) - }, - getRecentItems: (state) => { - return state.recentItems } } } diff --git a/src/store/modules/ADempiere/data.js b/src/store/modules/ADempiere/data.js index 4e5cf447..aca00384 100644 --- a/src/store/modules/ADempiere/data.js +++ b/src/store/modules/ADempiere/data.js @@ -112,6 +112,9 @@ const data = { isAddRecord, isShowNotification }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } else if (panelType === 'browser') { if (!rootGetters.isNotReadyForSubmit(containerUuid)) { dispatch('getBrowserSearch', { @@ -455,7 +458,7 @@ const data = { recordUuid, recordId }) { - return new Promise((resolve, reject) => { + return new Promise(resolve => { getEntity({ tableName, recordUuid, @@ -465,7 +468,7 @@ const data = { resolve(responseGetEntity.values) }) .catch(error => { - reject(error) + console.warn(`Error Get Entity ${error.message}. Code: ${error.code}.`) }) }) }, diff --git a/src/store/modules/ADempiere/languageControl.js b/src/store/modules/ADempiere/languageControl.js index 13864215..80c1c7a5 100644 --- a/src/store/modules/ADempiere/languageControl.js +++ b/src/store/modules/ADempiere/languageControl.js @@ -181,7 +181,6 @@ const languageControl = { if (translationRecord) { return translationRecord.values } - return {} } return {} } diff --git a/src/store/modules/ADempiere/process.js b/src/store/modules/ADempiere/process.js index 85daa97c..596647bf 100644 --- a/src/store/modules/ADempiere/process.js +++ b/src/store/modules/ADempiere/process.js @@ -75,7 +75,7 @@ const process = { }) { return new Promise(resolve => { const { processDefinition, actions } = generateProcess({ - processToGenerate: processToGenerate + processToGenerate }) dispatch('addPanel', processDefinition) diff --git a/src/store/modules/ADempiere/processControl.js b/src/store/modules/ADempiere/processControl.js index eb5642f4..d8c819d3 100644 --- a/src/store/modules/ADempiere/processControl.js +++ b/src/store/modules/ADempiere/processControl.js @@ -148,8 +148,7 @@ const processControl = { message: `Required selection data record to run this process (${action.name})` }) } - } - if (panelType === 'window') { + } else if (panelType === 'window') { const contextMenu = getters.getRecordUuidMenu tab = rootGetters.getTab(parentUuid, containerUuid) if (isProcessTableSelection) { @@ -322,7 +321,7 @@ const processControl = { processId: processDefinition.id, tableName: output.tableName, printFormatUuid: output.printFormatUuid, - reportViewUuid: output.reportViewUuid + reportViewUuid: output.reportViewUuid // TODO: Change to uuid }) .then(responseReportView => { reportViewList.childs = responseReportView diff --git a/src/store/modules/ADempiere/windowControl.js b/src/store/modules/ADempiere/windowControl.js index 50e476cd..3a18bfd9 100644 --- a/src/store/modules/ADempiere/windowControl.js +++ b/src/store/modules/ADempiere/windowControl.js @@ -260,6 +260,9 @@ const windowControl = { parentUuid, containerUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } commit('deleteInCreate', { containerUuid, @@ -473,6 +476,9 @@ const windowControl = { } } }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) showMessage({ message: language.t('data.deleteRecordSuccessful'), type: 'success' @@ -534,6 +540,9 @@ const windowControl = { parentUuid, containerUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) return } deleteEntity({ @@ -571,6 +580,9 @@ const windowControl = { parentUuid, containerUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) showMessage({ message: language.t('data.deleteRecordSuccessful'), type: 'success' @@ -779,7 +791,7 @@ const windowControl = { if (isEmptyValue(tableName)) { tableName = rootGetters.getTab(windowUuid, containerUuid).tableName } - return new Promise((resolve, reject) => { + return new Promise(resolve => { getReferencesList({ windowUuid, tableName, @@ -803,7 +815,7 @@ const windowControl = { resolve(referenceResponse) }) .catch(error => { - reject(error) + console.warn(`References Load Error ${error.code}: ${error.message}.`) }) }) }, @@ -886,6 +898,9 @@ const windowControl = { parentUuid, containerUuid: tabAssociatedUuid }) + .catch(error => { + console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`) + }) } }) }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index d8f998bc..420e3344 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -123,16 +123,18 @@ const actions = { setToken(token) resolve() - }).catch(error => { + }) + .catch(error => { reject(error) }) }) }, // session info - getInfo({ commit, dispatch }, sessionUuid = null) { + getSessionInfo({ commit, dispatch }, sessionUuid = null) { if (isEmptyValue(sessionUuid)) { sessionUuid = getToken() } + return new Promise((resolve, reject) => { getSessionInfo(sessionUuid) .then(responseGetInfo => { @@ -166,47 +168,11 @@ const actions = { commit('SET_ROLE', role) setCurrentRole(role.uuid) - getOrganizationsList({ roleUuid: role.uuid }) - .then(response => { - commit('SET_ORGANIZATIONS_LIST', response.organizationsList) - let organization = response.organizationsList.find(item => item.uuid === getCurrentOrganization()) - if (isEmptyValue(organization)) { - organization = response.organizationsList[0] - } - if (isEmptyValue(organization)) { - removeCurrentOrganization() - commit('SET_ORGANIZATION', undefined) - } else { - setCurrentOrganization(organization.uuid) - commit('SET_ORGANIZATION', organization) - } - getWarehousesList({ organizationUuid: getCurrentOrganization() }) - .then(response => { - commit('SET_WAREHOUSES_LIST', response.warehousesList) - let warehouse = response.warehousesList.find(item => item.uuid === getCurrentWarehouse()) - if (isEmptyValue(warehouse)) { - warehouse = response.warehousesList[0] - } - if (isEmptyValue(warehouse)) { - removeCurrentWarehouse() - commit('SET_WAREHOUSE', undefined) - } else { - setCurrentWarehouse(warehouse.uuid) - commit('SET_WAREHOUSE', warehouse) - } - }) - .catch(error => { - console.warn(`Error ${error.code} getting user info value: ${error.message}.`) - reject(error) - }) - }) - .catch(error => { - console.warn(`Error ${error.code} getting user info value: ${error.message}.`) - reject(error) - }) - // + resolve(sessionResponse) + dispatch('getOrganizationsList', role.uuid) + dispatch('getUserInfoFromSession', sessionUuid) .catch(error => { console.warn(`Error ${error.code} getting user info value: ${error.message}.`) @@ -303,11 +269,43 @@ const actions = { resolve() }) }, + getOrganizationsList({ commit, dispatch }, roleUuid) { + if (isEmptyValue(roleUuid)) { + roleUuid = getCurrentRole() + } + + return getOrganizationsList({ roleUuid }) + .then(response => { + commit('SET_ORGANIZATIONS_LIST', response.organizationsList) + let organization = response.organizationsList.find(item => item.uuid === getCurrentOrganization()) + if (isEmptyValue(organization)) { + organization = response.organizationsList[0] + } + if (isEmptyValue(organization)) { + removeCurrentOrganization() + organization = undefined + } else { + setCurrentOrganization(organization.uuid) + } + commit('SET_ORGANIZATION', organization) + + dispatch('getWarehousesList', organization.uuid) + }) + .catch(error => { + console.warn(`Error ${error.code} getting Organizations list: ${error.message}.`) + }) + }, changeOrganization({ commit, dispatch }, { organizationUuid }) { setCurrentOrganization(organizationUuid) - getWarehousesList({ organizationUuid: organizationUuid }) + dispatch('getWarehousesList', organizationUuid) + }, + getWarehousesList({ commit }, organizationUuid) { + if (isEmptyValue(organizationUuid)) { + organizationUuid = getCurrentOrganization() + } + return getWarehousesList({ organizationUuid }) .then(response => { commit('SET_WAREHOUSES_LIST', response.warehousesList) let warehouse = response.warehousesList.find(item => item.uuid === getCurrentWarehouse()) @@ -323,7 +321,7 @@ const actions = { } }) .catch(error => { - console.warn(`Error ${error.code} getting user info value: ${error.message}.`) + console.warn(`Error ${error.code} getting Warehouses list: ${error.message}.`) }) }, changeWarehouse({ commit, state }, { @@ -372,7 +370,7 @@ const actions = { setToken(changeRoleResponse.uuid) // Update user info and context associated with session - dispatch('getInfo', changeRoleResponse.uuid) + dispatch('getSessionInfo', changeRoleResponse.uuid) dispatch('resetStateBusinessData', null, { root: true diff --git a/src/views/dashboard/admin/index.vue b/src/views/dashboard/admin/index.vue index 842f3265..16a5a977 100644 --- a/src/views/dashboard/admin/index.vue +++ b/src/views/dashboard/admin/index.vue @@ -11,7 +11,6 @@