summaryrefslogtreecommitdiffstats
path: root/server/api/backends.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/api/backends.js')
-rw-r--r--server/api/backends.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/api/backends.js b/server/api/backends.js
index 3d7c36e..2b82cab 100644
--- a/server/api/backends.js
+++ b/server/api/backends.js
@@ -58,6 +58,28 @@ module.exports.get = {
res.status(200).send(result)
})
})
+ },
+
+ getObjectTypes: function (req, res) {
+ const id = req.query.id
+ db.backend.findOne({ where: { id: id } }).then(backend => {
+ const ba = new ExternalBackends()
+ const instance = ba.getInstance(backend.type)
+ console.log(backend.type)
+ instance.getObjectTypes(backend.credentials).then(result => {
+ res.status(200).send(result)
+ })
+ })
+ },
+
+ getObjectTypesById: function (req, res) {
+ const id = req.query.id
+ var types = {}
+ db.backend.findOne({ where: { id: id } }).then(backend => {
+ types.groups = JSON.parse(backend.groups)
+ types.clients = JSON.parse(backend.clients)
+ res.status(200).send(types)
+ })
}
}
@@ -105,5 +127,17 @@ module.exports.post = {
res.status(200).send({ success: connection.success, msg: connection.msg })
})
})
+ },
+
+ // Saves the group / clients assigned object types in the database.
+ saveObjectTypes: function (req, res) {
+ const id = req.body.id
+ const groups = JSON.stringify(req.body.groups)
+ const clients = JSON.stringify(req.body.clients)
+ db.backend.findOne({ where: { id: id } }).then(backend => {
+ db.backend.update({ groups: groups, clients: clients }, { where: { id: id } }).then(() => {
+ res.status(200).send()
+ })
+ })
}
}