mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Handling of about to be kicked devices improved.
This commit is contained in:
@@ -1,17 +1,39 @@
|
||||
module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService, $location) {
|
||||
module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, GroupService, $location) {
|
||||
|
||||
$scope.groupTracker = DeviceService.trackGroup($scope)
|
||||
|
||||
$scope.groupDevices = $scope.groupTracker.devices
|
||||
|
||||
$scope.kickDevice = function (device) {
|
||||
// if current device
|
||||
// no more: go to devices
|
||||
// more: go to first
|
||||
|
||||
return GroupService.kick(device).then(function () {
|
||||
$scope.$digest()
|
||||
})
|
||||
// If we're trying to kick current device
|
||||
if (device.serial === $rootScope.device.serial) {
|
||||
|
||||
// If there is more than one device left
|
||||
if ($scope.groupDevices.length > 1) {
|
||||
|
||||
// Control first free device first
|
||||
var firstFreeDevice = _.find($scope.groupDevices, function (dev) {
|
||||
return dev.serial !== $rootScope.device.serial
|
||||
})
|
||||
$scope.controlDevice(firstFreeDevice)
|
||||
|
||||
// Then kick the old device
|
||||
GroupService.kick(device).then(function () {
|
||||
$scope.$digest()
|
||||
})
|
||||
} else {
|
||||
// Kick the device
|
||||
GroupService.kick(device).then(function () {
|
||||
$scope.$digest()
|
||||
})
|
||||
$location.path('/devices/')
|
||||
}
|
||||
} else {
|
||||
GroupService.kick(device).then(function () {
|
||||
$scope.$digest()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.controlDevice = function (device) {
|
||||
|
||||
Reference in New Issue
Block a user