forked from Qortal/qortal-ui
Merge pull request #310 from kennycud/master
Added add and remove foreign server support for Q-Apps
This commit is contained in:
commit
70646f1f3f
@ -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: {
|
||||
try {
|
||||
response = await parentEpml.request('apiCall', {
|
||||
|
Loading…
x
Reference in New Issue
Block a user