mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Use automation state for devices used by api
This commit is contained in:
parent
42b55889ae
commit
a62a6094e4
11 changed files with 45 additions and 10 deletions
|
@ -153,6 +153,7 @@ dbapi.saveDeviceInitialState = function(serial, device) {
|
|||
, reverseForwards: []
|
||||
, remoteConnect: false
|
||||
, remoteConnectUrl: null
|
||||
, usage: null
|
||||
}
|
||||
return db.run(r.table('devices').get(serial).update(data))
|
||||
.then(function(stats) {
|
||||
|
@ -212,6 +213,20 @@ dbapi.setDeviceAbsent = function(serial) {
|
|||
}))
|
||||
}
|
||||
|
||||
dbapi.setDeviceUsage = function(serial, usage) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
usage: usage
|
||||
, usageChangedAt: r.now()
|
||||
}))
|
||||
}
|
||||
|
||||
dbapi.unsetDeviceUsage = function(serial) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
usage: null
|
||||
, usageChangedAt: r.now()
|
||||
}))
|
||||
}
|
||||
|
||||
dbapi.setDeviceAirplaneMode = function(serial, enabled) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
airplaneMode: enabled
|
||||
|
|
|
@ -148,6 +148,7 @@ function addUserDevice(req, res) {
|
|||
.handler()
|
||||
|
||||
req.options.channelRouter.on(wireutil.global, messageListener)
|
||||
var usage = 'automation'
|
||||
|
||||
req.options.push.send([
|
||||
device.channel
|
||||
|
@ -165,6 +166,7 @@ function addUserDevice(req, res) {
|
|||
, match: 'exact'
|
||||
}
|
||||
})
|
||||
, usage
|
||||
)
|
||||
)
|
||||
])
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = syrup.serial()
|
|||
return currentGroup
|
||||
})
|
||||
|
||||
plugin.join = function(newGroup, timeout, identifier) {
|
||||
plugin.join = function(newGroup, timeout, usage) {
|
||||
return plugin.get()
|
||||
.then(function() {
|
||||
if (currentGroup.group !== newGroup.group) {
|
||||
|
@ -57,10 +57,11 @@ module.exports = syrup.serial()
|
|||
, wireutil.envelope(new wire.JoinGroupMessage(
|
||||
options.serial
|
||||
, currentGroup
|
||||
, usage
|
||||
))
|
||||
])
|
||||
|
||||
plugin.emit('join', currentGroup, identifier)
|
||||
plugin.emit('join', currentGroup)
|
||||
|
||||
return currentGroup
|
||||
})
|
||||
|
@ -113,7 +114,7 @@ module.exports = syrup.serial()
|
|||
var reply = wireutil.reply(options.serial)
|
||||
grouputil.match(ident, message.requirements)
|
||||
.then(function() {
|
||||
return plugin.join(message.owner, message.timeout)
|
||||
return plugin.join(message.owner, message.timeout, message.usage)
|
||||
})
|
||||
.then(function() {
|
||||
push.send([
|
||||
|
|
|
@ -175,10 +175,14 @@ module.exports = function(options) {
|
|||
})
|
||||
.on(wire.JoinGroupMessage, function(channel, message, data) {
|
||||
dbapi.setDeviceOwner(message.serial, message.owner)
|
||||
if (message.usage) {
|
||||
dbapi.setDeviceUsage(message.serial, message.usage)
|
||||
}
|
||||
appDealer.send([channel, data])
|
||||
})
|
||||
.on(wire.LeaveGroupMessage, function(channel, message, data) {
|
||||
dbapi.unsetDeviceOwner(message.serial, message.owner)
|
||||
dbapi.unsetDeviceUsage(message.serial)
|
||||
appDealer.send([channel, data])
|
||||
})
|
||||
.on(wire.DeviceLogMessage, function(channel, message, data) {
|
||||
|
|
|
@ -174,6 +174,7 @@ module.exports = function(options) {
|
|||
serial: message.serial
|
||||
, owner: message.owner
|
||||
, likelyLeaveReason: 'owner_change'
|
||||
, usage: message.usage
|
||||
}
|
||||
, user
|
||||
)
|
||||
|
|
|
@ -261,6 +261,7 @@ message GroupMessage {
|
|||
required OwnerMessage owner = 1;
|
||||
optional uint32 timeout = 2;
|
||||
repeated DeviceRequirement requirements = 3;
|
||||
optional string usage = 4;
|
||||
}
|
||||
|
||||
message AutoGroupMessage {
|
||||
|
@ -275,6 +276,7 @@ message UngroupMessage {
|
|||
message JoinGroupMessage {
|
||||
required string serial = 1;
|
||||
required OwnerMessage owner = 2;
|
||||
optional string usage = 3;
|
||||
}
|
||||
|
||||
message JoinGroupByAdbFingerprintMessage {
|
||||
|
|
|
@ -10,7 +10,8 @@ module.exports = angular.module('stf.device-status', [])
|
|||
ready: gettext('Ready'),
|
||||
using: gettext('Stop Using'),
|
||||
busy: gettext('Busy'),
|
||||
available: gettext('Use')
|
||||
available: gettext('Use'),
|
||||
automation: gettext('Stop Automation')
|
||||
}[text] || gettext('Unknown')
|
||||
}
|
||||
})
|
||||
|
@ -25,7 +26,8 @@ module.exports = angular.module('stf.device-status', [])
|
|||
ready: gettext('Ready'),
|
||||
using: gettext('Using'),
|
||||
busy: gettext('Busy'),
|
||||
available: gettext('Available')
|
||||
available: gettext('Available'),
|
||||
automation: gettext('Automating'),
|
||||
}[text] || gettext('Unknown')
|
||||
}
|
||||
})
|
||||
|
|
|
@ -19,8 +19,13 @@ module.exports = function EnhanceDeviceServiceFactory($filter, AppState) {
|
|||
if (data.ready) {
|
||||
data.state = 'ready'
|
||||
if (data.using) {
|
||||
if (data.usage === 'automation') {
|
||||
data.state = 'automation'
|
||||
}
|
||||
else {
|
||||
data.state = 'using'
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (data.owner) {
|
||||
data.state = 'busy'
|
||||
|
|
|
@ -10,7 +10,8 @@ module.exports = function StateClassesService() {
|
|||
present: 'state-present btn-primary-outline',
|
||||
preparing: 'state-preparing btn-primary-outline btn-success-outline',
|
||||
unauthorized: 'state-unauthorized btn-danger-outline',
|
||||
offline: 'state-offline btn-warning-outline'
|
||||
offline: 'state-offline btn-warning-outline',
|
||||
automation: 'state-automation btn-info'
|
||||
}[state]
|
||||
if (typeof stateClasses === 'undefined') {
|
||||
stateClasses = 'btn-default-outline'
|
||||
|
@ -27,7 +28,8 @@ module.exports = function StateClassesService() {
|
|||
present: 'state-present',
|
||||
preparing: 'state-preparing',
|
||||
unauthorized: 'state-unauthorized',
|
||||
offline: 'state-offline'
|
||||
offline: 'state-offline',
|
||||
automation: 'state-automation'
|
||||
}[state]
|
||||
if (typeof stateClasses === 'undefined') {
|
||||
stateClasses = ''
|
||||
|
@ -37,4 +39,3 @@ module.exports = function StateClassesService() {
|
|||
|
||||
return service
|
||||
}
|
||||
|
||||
|
|
|
@ -571,6 +571,7 @@ function DeviceStatusCell(options) {
|
|||
, preparing: 'state-preparing btn-primary-outline btn-success-outline'
|
||||
, unauthorized: 'state-unauthorized btn-danger-outline'
|
||||
, offline: 'state-offline btn-warning-outline'
|
||||
, automation: 'state-automation btn-info'
|
||||
}
|
||||
|
||||
return _.defaults(options, {
|
||||
|
|
|
@ -66,7 +66,8 @@ module.exports = function DeviceListIconsDirective(
|
|||
present: 'state-present btn-primary-outline',
|
||||
preparing: 'state-preparing btn-primary-outline btn-success-outline',
|
||||
unauthorized: 'state-unauthorized btn-danger-outline',
|
||||
offline: 'state-offline btn-warning-outline'
|
||||
offline: 'state-offline btn-warning-outline',
|
||||
automation: 'state-automation btn-info'
|
||||
}[state]
|
||||
if (typeof stateClasses === 'undefined') {
|
||||
stateClasses = 'btn-default-outline'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue