summaryrefslogtreecommitdiffstats
path: root/server/api/backends.js
diff options
context:
space:
mode:
authorJannik Schönartz2018-07-31 11:35:27 +0200
committerJannik Schönartz2018-07-31 11:35:27 +0200
commita931375c8feeb72fbb121fe762429d5dca6385f3 (patch)
tree1138f0c260603bb7d2f4a3c5412c1b1dafd40903 /server/api/backends.js
parent[webapp/groups] small bugfix (diff)
downloadbas-a931375c8feeb72fbb121fe762429d5dca6385f3.tar.gz
bas-a931375c8feeb72fbb121fe762429d5dca6385f3.tar.xz
bas-a931375c8feeb72fbb121fe762429d5dca6385f3.zip
[server/external-backends] Added iDoIT Api call for getting the locationtree of an object.
Diffstat (limited to 'server/api/backends.js')
-rw-r--r--server/api/backends.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/server/api/backends.js b/server/api/backends.js
index c345aa8..3d7c36e 100644
--- a/server/api/backends.js
+++ b/server/api/backends.js
@@ -48,19 +48,14 @@ module.exports.get = {
})
},
- checkConnectionById: function (req, res) {
- const backendId = req.query.id
- db.backend.findOne({ where: { id: backendId } }).then(backend => {
- const bCredentials = {
- id: backendId,
- name: backend.name,
- type: backend.type,
- credentials: backend.credentials
- }
- const b = new ExternalBackends()
- const instance = b.getInstance(bCredentials.type)
- instance.checkConnection(bCredentials).then(connection => {
- res.status(200).send({ success: connection.success, msg: connection.msg })
+ getObject: function (req, res) {
+ const id = req.query.id
+ const oid = req.query.oid
+ db.backend.findOne({ where: { id: id } }).then(backend => {
+ const ba = new ExternalBackends()
+ const instance = ba.getInstance(backend.type)
+ instance.getRoomdata(backend.credentials, oid).then(result => {
+ res.status(200).send(result)
})
})
}
@@ -103,14 +98,10 @@ module.exports.post = {
else getBackend = new Promise(resolve => resolve(req.body))
getBackend.then(backend => {
- var bCredentials = {
- type: backend.type,
- credentials: backend.credentials
- }
// Creating the backend instance and calling the specific checkConnection.
const b = new ExternalBackends()
- const instance = b.getInstance(bCredentials.type)
- instance.checkConnection(bCredentials).then(connection => {
+ const instance = b.getInstance(backend.type)
+ instance.checkConnection(backend.credentials).then(connection => {
res.status(200).send({ success: connection.success, msg: connection.msg })
})
})