summaryrefslogtreecommitdiffstats
path: root/server/api
diff options
context:
space:
mode:
authorUdo Walter2020-03-25 13:29:17 +0100
committerUdo Walter2020-03-25 13:29:17 +0100
commit9bffdf4923a20a443f28c74aa4b130a5bbf1bb34 (patch)
tree904f39a8a13782e9cf51d8d5e9ee059d1149bce1 /server/api
parentmerge (diff)
downloadbas-9bffdf4923a20a443f28c74aa4b130a5bbf1bb34.tar.gz
bas-9bffdf4923a20a443f28c74aa4b130a5bbf1bb34.tar.xz
bas-9bffdf4923a20a443f28c74aa4b130a5bbf1bb34.zip
[webapp] show part of the path (full path on hover) in the select boxes for selecting groups and clients
Diffstat (limited to 'server/api')
-rw-r--r--server/api/clients.js8
-rw-r--r--server/api/groups.js5
2 files changed, 10 insertions, 3 deletions
diff --git a/server/api/clients.js b/server/api/clients.js
index 15e3b8d..4222f49 100644
--- a/server/api/clients.js
+++ b/server/api/clients.js
@@ -8,13 +8,17 @@ const { decorateApp } = require('@awaitjs/express')
var router = decorateApp(express.Router())
const HttpResponse = require(path.join(__appdir, 'lib', 'httpresponse'))
const log = require(path.join(__appdir, 'lib', 'log'))
+const groupHelper = require(path.join(__appdir, 'lib', 'grouphelper'))
// ############################################################################
// ########################### GET requests #################################
router.getAsync('', async (req, res) => {
- const clients = await db.client.findAll({ order: [['name', 'ASC']] })
- res.status(200).send(clients)
+ const includePaths = req.query.path !== undefined && req.query.path !== 'false'
+ const include = includePaths ? ['groups'] : []
+ let clients = await db.client.findAll({ order: [['name', 'ASC']], include })
+ if (includePaths) clients = await groupHelper.addPathsToClients(clients, false)
+ res.send(clients)
})
router.getAsync('/:id', async (req, res) => {
diff --git a/server/api/groups.js b/server/api/groups.js
index 88e7da8..64351cf 100644
--- a/server/api/groups.js
+++ b/server/api/groups.js
@@ -14,7 +14,10 @@ const log = require(path.join(__appdir, 'lib', 'log'))
// ########################### GET requests #################################
router.getAsync('', async (req, res) => {
- const groups = await db.group.findAll({ order: [['name', 'ASC']] })
+ const includePaths = req.query.path !== undefined && req.query.path !== 'false'
+ const include = includePaths ? ['parents'] : []
+ let groups = await db.group.findAll({ order: [['name', 'ASC']], include })
+ if (includePaths) groups = await groupHelper.addPathsToGroups(groups, false)
res.send(groups)
})