summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJannik Schönartz2019-10-16 21:16:14 +0200
committerJannik Schönartz2019-10-16 21:16:14 +0200
commit4752614c0105b864d00e97179b4b77ccbad89e2d (patch)
tree88f89882295efda36ea71292241e80922694e85e /server
parent[documentation] Add more information about the automatic registration & chang... (diff)
downloadbas-4752614c0105b864d00e97179b4b77ccbad89e2d.tar.gz
bas-4752614c0105b864d00e97179b4b77ccbad89e2d.tar.xz
bas-4752614c0105b864d00e97179b4b77ccbad89e2d.zip
[webapp/clients] Add the choice to select backends when deleting clients
[group/clients] Checkbox list of the clients in the permanently delete dialog [server/backendhelper] Only deletes from the selected backends (array with backendids)
Diffstat (limited to 'server')
-rw-r--r--server/api/clients.js2
-rw-r--r--server/lib/external-backends/backendhelper.js10
2 files changed, 9 insertions, 3 deletions
diff --git a/server/api/clients.js b/server/api/clients.js
index a6d151a..d72207b 100644
--- a/server/api/clients.js
+++ b/server/api/clients.js
@@ -29,7 +29,7 @@ router.getAsync('/:id', async (req, res) => {
router.postAsync(['', '/:id'], async (req, res) => {
if (req.query.delete !== undefined && req.query.delete !== 'false') {
if (!Array.isArray(req.body.ids)) return HttpResponse.invalidBodyValue('ids', 'an array').send(res)
- await backendHelper.deleteClients(req.body.ids)
+ await backendHelper.deleteClients(req.body.ids, req.body.backendIds)
const count = await db.client.destroy({ where: { id: req.body.ids } })
HttpResponse.successBatch('deleted', 'client', count).send(res)
} else {
diff --git a/server/lib/external-backends/backendhelper.js b/server/lib/external-backends/backendhelper.js
index 7e682d1..485b5f6 100644
--- a/server/lib/external-backends/backendhelper.js
+++ b/server/lib/external-backends/backendhelper.js
@@ -116,9 +116,15 @@ async function updateClient (client) {
return result
}
-async function deleteClients (clientids) {
+async function deleteClients (clientids, backendIds) {
// Get all backends and call deleteClient for each instance.
- const backends = await db.backend.findAll({ where: { '$clientMappings.clientid$': clientids }, include: ['clientMappings'] })
+ const backends = await db.backend.findAll({
+ where: {
+ id: { [db.Op.in]: backendIds },
+ '$clientMappings.clientid$': clientids
+ },
+ include: ['clientMappings']
+ })
backends.forEach(backend => {
const ba = new ExternalBackends()