diff --git a/lib/units/api/controllers/devices.js b/lib/units/api/controllers/devices.js index 366ca7d6..559a70c6 100755 --- a/lib/units/api/controllers/devices.js +++ b/lib/units/api/controllers/devices.js @@ -23,7 +23,9 @@ const wirerouter = require('../../../wire/router') function filterGenericDevices(req, res, devices) { apiutil.respond(res, 200, 'Devices Information', { devices: devices.map(function(device) { - return apiutil.filterDevice(req, device) + const filteredDevice = apiutil.filterDevice(req, device) + filteredDevice.name = device.model + return filteredDevice }) }) } @@ -221,6 +223,7 @@ function getDeviceBySerial(req, res) { dbapi.loadDevice(req.user.groups.subscribed, serial) .then(function(cursor) { + const deviceName = cursor._responses[0].r[0].model cursor.next(function(err, device) { if (err) { return res.status(404).json({ @@ -230,6 +233,8 @@ function getDeviceBySerial(req, res) { } let responseDevice = apiutil.publishDevice(device, req.user) + responseDevice.name = deviceName + if (fields) { responseDevice = _.pick(device, fields.split(',')) }