summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorUdo Walter2019-04-13 15:33:51 +0200
committerUdo Walter2019-04-13 15:33:51 +0200
commit53028fd8498c7b7ea997c1af51162d26d972ba05 (patch)
treefcf8dbedb382f95aee4f00fc2ea8fc3b64f1c5f5 /server
parent[datatable] fix values with comma in csv copy (diff)
downloadbas-53028fd8498c7b7ea997c1af51162d26d972ba05.tar.gz
bas-53028fd8498c7b7ea997c1af51162d26d972ba05.tar.xz
bas-53028fd8498c7b7ea997c1af51162d26d972ba05.zip
[groups,clients] include config as association
Diffstat (limited to 'server')
-rw-r--r--server/api/clients.js2
-rw-r--r--server/api/groups.js2
-rw-r--r--server/models/client.js2
-rw-r--r--server/models/group.js2
4 files changed, 4 insertions, 4 deletions
diff --git a/server/api/clients.js b/server/api/clients.js
index 3152e10..a6d151a 100644
--- a/server/api/clients.js
+++ b/server/api/clients.js
@@ -18,7 +18,7 @@ router.getAsync('', async (req, res) => {
router.getAsync('/:id', async (req, res) => {
if (!(req.params.id > 0)) return HttpResponse.invalidId().send(res)
- const client = await db.client.findOne({ where: { id: req.params.id }, include: ['groups'] })
+ const client = await db.client.findOne({ where: { id: req.params.id }, include: ['groups', 'config'] })
if (client) res.status(200).send(client)
else HttpResponse.notFound(req.params.id).send(res)
})
diff --git a/server/api/groups.js b/server/api/groups.js
index 7cab3d8..a19c231 100644
--- a/server/api/groups.js
+++ b/server/api/groups.js
@@ -20,7 +20,7 @@ router.getAsync('', async (req, res) => {
router.getAsync('/:id', async (req, res) => {
const all = req.query.all !== undefined && req.query.all !== 'false'
if (req.params.id > 0) {
- let group = await db.group.findOne({ where: { id: req.params.id }, include: ['parents', 'ipranges', 'subgroups', 'clients'] })
+ let group = await db.group.findOne({ where: { id: req.params.id }, include: ['parents', 'ipranges', 'subgroups', 'clients', 'config'] })
if (group) {
// Convert ipranges in readable strings.
group.ipranges.forEach(iprange => {
diff --git a/server/models/client.js b/server/models/client.js
index 502f668..a7c9d4b 100644
--- a/server/models/client.js
+++ b/server/models/client.js
@@ -19,7 +19,7 @@ module.exports = (sequelize, DataTypes) => {
client.associate = function (models) {
var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true })
client.belongsToMany(models.group, { as: 'groups', through: GroupXClient, foreignKey: 'clientId', otherKey: 'groupId' })
- client.belongsTo(models.config)
+ client.belongsTo(models.config, { as: 'config' })
var ClientXEvent = sequelize.define('client_x_event', { blacklist: DataTypes.BOOLEAN }, { timestamps: false, freezeTableName: true })
client.belongsToMany(models.event, { as: 'events', through: ClientXEvent, foreignKey: 'clientId', otherKey: 'eventId' })
}
diff --git a/server/models/group.js b/server/models/group.js
index 0582970..16fd2f1 100644
--- a/server/models/group.js
+++ b/server/models/group.js
@@ -20,7 +20,7 @@ module.exports = (sequelize, DataTypes) => {
group.belongsToMany(group, { as: 'subgroups', through: GroupXGroup, foreignKey: 'parentId', otherKey: 'childId' })
group.belongsToMany(models.client, { as: 'clients', through: GroupXClient, foreignKey: 'groupId', otherKey: 'clientId' })
group.belongsToMany(models.event, { as: 'events', through: GroupXEvent, foreignKey: 'groupId', otherKey: 'eventId' })
- group.belongsTo(models.config)
+ group.belongsTo(models.config, { as: 'config' })
group.hasMany(models.iprange, { as: 'ipranges' })
}
return group