summaryrefslogblamecommitdiffstats
path: root/server/api/clients.js
blob: 8daab55a0e43d722f8719b522844924a1a4519c3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                     

                                                         
 





                                                                    
    
 










                                                                                                
      

   
/* global __appdir */
var path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))

// GET Requests
module.exports.get = {
  getList: function (req, res) {
    db.client.findAll({ attributes: ['id', 'name'] }).then(list => {
      res.send(list)
    })
  },

  // get all clients that have no groups
  getTopLevel: function (req, res) {
    db.client.findAll({ where: { '$groups.id$': null }, include: ['groups'] }).then(clients => {
      res.send(clients)
    })
  },

  // get name, description, ip, mac and uuid of a client (by id)
  getClient: function (req, res) {
    db.client.findOne({ where: { id: req.query.id }, include: ['groups'] }).then(client => {
      res.send(client)
    })
  }
}