added add and remove foreign server support for Q-Apps
This commit is contained in:
parent
679f84a76f
commit
64d66d961e
@ -2065,6 +2065,110 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case actions.ADD_FOREIGN_SERVER: {
|
||||||
|
const requiredFields = ['coin']
|
||||||
|
const missingFields = []
|
||||||
|
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field]) {
|
||||||
|
missingFields.push(field)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (missingFields.length > 0) {
|
||||||
|
const missingFieldsString = missingFields.join(', ')
|
||||||
|
const errorMsg = `Missing fields: ${missingFieldsString}`
|
||||||
|
let data = {}
|
||||||
|
data['error'] = errorMsg
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let coin = data.coin;
|
||||||
|
let host = data.host;
|
||||||
|
let port = data.port;
|
||||||
|
let type = data.type;
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
hostName: host,
|
||||||
|
port: port,
|
||||||
|
connectionType: type
|
||||||
|
}
|
||||||
|
|
||||||
|
const bodyToString = JSON.stringify(body)
|
||||||
|
|
||||||
|
response = await parentEpml.request('apiCall', {
|
||||||
|
type: 'api',
|
||||||
|
method: 'POST',
|
||||||
|
url: `/crosschain/${coin}/addserver?apiKey=${this.getApiKey()}`,
|
||||||
|
headers: {
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${bodyToString}`
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
const data = {}
|
||||||
|
data['error'] = "Error in add server"
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
} finally {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case actions.REMOVE_FOREIGN_SERVER: {
|
||||||
|
const requiredFields = ['coin']
|
||||||
|
const missingFields = []
|
||||||
|
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field]) {
|
||||||
|
missingFields.push(field)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (missingFields.length > 0) {
|
||||||
|
const missingFieldsString = missingFields.join(', ')
|
||||||
|
const errorMsg = `Missing fields: ${missingFieldsString}`
|
||||||
|
let data = {}
|
||||||
|
data['error'] = errorMsg
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let coin = data.coin;
|
||||||
|
let host = data.host;
|
||||||
|
let port = data.port;
|
||||||
|
let type = data.type;
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
hostName: host,
|
||||||
|
port: port,
|
||||||
|
connectionType: type
|
||||||
|
}
|
||||||
|
|
||||||
|
const bodyToString = JSON.stringify(body)
|
||||||
|
|
||||||
|
response = await parentEpml.request('apiCall', {
|
||||||
|
type: 'api',
|
||||||
|
method: 'POST',
|
||||||
|
url: `/crosschain/${coin}/removeserver?apiKey=${this.getApiKey()}`,
|
||||||
|
headers: {
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${bodyToString}`
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
const data = {}
|
||||||
|
data['error'] = "Error in remove server"
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
} finally {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case actions.GET_DAY_SUMMARY: {
|
case actions.GET_DAY_SUMMARY: {
|
||||||
try {
|
try {
|
||||||
response = await parentEpml.request('apiCall', {
|
response = await parentEpml.request('apiCall', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user