summaryrefslogtreecommitdiffstats
path: root/server/api/backends.js
diff options
context:
space:
mode:
authorJannik Schönartz2018-08-04 19:37:59 +0200
committerJannik Schönartz2018-08-04 19:37:59 +0200
commit1b61be89953be7bbfef93f2fe40317b498353404 (patch)
tree48de32655bb0c16b9800f28efb86180cf282154d /server/api/backends.js
parent[webapp/router] changed dynamic route namespacing (diff)
downloadbas-1b61be89953be7bbfef93f2fe40317b498353404.tar.gz
bas-1b61be89953be7bbfef93f2fe40317b498353404.tar.xz
bas-1b61be89953be7bbfef93f2fe40317b498353404.zip
[external-backends] Sync types are now defined in the backend classes, so every backend can define their own sync methods.
Diffstat (limited to 'server/api/backends.js')
-rw-r--r--server/api/backends.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/server/api/backends.js b/server/api/backends.js
index 2b82cab..ff165a4 100644
--- a/server/api/backends.js
+++ b/server/api/backends.js
@@ -65,21 +65,30 @@ module.exports.get = {
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) {
+ getSyncSettings: 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)
+ types.sync = backend.sync
res.status(200).send(types)
})
+ },
+
+ getSyncTypes: 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)
+ res.status(200).send(instance.getSyncTypes())
+ })
}
}
@@ -129,13 +138,14 @@ module.exports.post = {
})
},
- // Saves the group / clients assigned object types in the database.
- saveObjectTypes: function (req, res) {
+ // Saves the group / clients assigned object types in the database and sync type.
+ saveSyncSettings: function (req, res) {
const id = req.body.id
const groups = JSON.stringify(req.body.groups)
const clients = JSON.stringify(req.body.clients)
+ const sync = req.body.sync
db.backend.findOne({ where: { id: id } }).then(backend => {
- db.backend.update({ groups: groups, clients: clients }, { where: { id: id } }).then(() => {
+ db.backend.update({ groups: groups, clients: clients, sync: sync }, { where: { id: id } }).then(() => {
res.status(200).send()
})
})