mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Load devices with Oboe.
This commit is contained in:
parent
c119e2c3d2
commit
4c45a7288b
3 changed files with 30 additions and 7 deletions
|
@ -97,12 +97,17 @@ module.exports = function(options) {
|
|||
.then(function(cursor) {
|
||||
return Promise.promisify(cursor.toArray, cursor)()
|
||||
.then(function(list) {
|
||||
res.json(list)
|
||||
res.json({
|
||||
success: true
|
||||
, devices: list
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Failed to load device list: ', err.stack)
|
||||
res.send(500)
|
||||
res.json(500, {
|
||||
success: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -110,15 +115,22 @@ module.exports = function(options) {
|
|||
dbapi.loadDevice(req.params.serial)
|
||||
.then(function(device) {
|
||||
if (device) {
|
||||
res.json(device)
|
||||
res.json({
|
||||
success: true
|
||||
, device: device
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.send(404)
|
||||
res.json(404, {
|
||||
success: false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Failed to load device "%s": ', req.params.serial, err.stack)
|
||||
res.send(500)
|
||||
res.json(500, {
|
||||
success: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
define(['./module'], function(mod) {
|
||||
mod.controller('DeviceListCtrl', ['$scope', '$http', 'devices', function($scope, $http) {
|
||||
define(['./module', 'oboe'], function(mod, oboe) {
|
||||
mod.controller('DeviceListCtrl', ['$scope', function($scope) {
|
||||
$scope.devices = []
|
||||
|
||||
oboe('/api/v1/devices')
|
||||
.node('$devices[*]', function(devicesLoadedSoFar) {
|
||||
$scope.$apply(function() {
|
||||
$scope.devices = devicesLoadedSoFar
|
||||
})
|
||||
})
|
||||
}])
|
||||
})
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
h1 Devices
|
||||
|
||||
ul
|
||||
li(ng-repeat='device in devices track by device.serial')
|
||||
span {{ device.serial }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue