Skip to content

Commit

Permalink
feat: Add grpc core client support. (adempiere#495)
Browse files Browse the repository at this point in the history
* feat: Add grpc core client support.

* export instances and catching error.
  • Loading branch information
Edwin Betancourt authored May 15, 2020
1 parent cfc03c6 commit 8727bee
Show file tree
Hide file tree
Showing 30 changed files with 191 additions and 298 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/browser.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 1 addition & 19 deletions src/api/ADempiere/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
13 changes: 1 addition & 12 deletions src/api/ADempiere/dictionary.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
19 changes: 5 additions & 14 deletions src/api/ADempiere/enrollment.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/ADempiere/field/locator.js
Original file line number Diff line number Diff line change
@@ -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}`
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/form/price-checking.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
69 changes: 69 additions & 0 deletions src/api/ADempiere/instances.js
Original file line number Diff line number Diff line change
@@ -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'
})
}
19 changes: 3 additions & 16 deletions src/api/ADempiere/persistence.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/private-access.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/process.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/report.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/rule.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/system-core.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/values.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 1 addition & 14 deletions src/api/ADempiere/window.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Loading

0 comments on commit 8727bee

Please sign in to comment.