mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Handling of about to be kicked devices improved.
This commit is contained in:
parent
0bce25cabf
commit
c6a34713f0
3 changed files with 38 additions and 15 deletions
|
@ -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.groupTracker = DeviceService.trackGroup($scope)
|
||||||
|
|
||||||
$scope.groupDevices = $scope.groupTracker.devices
|
$scope.groupDevices = $scope.groupTracker.devices
|
||||||
|
|
||||||
$scope.kickDevice = function (device) {
|
$scope.kickDevice = function (device) {
|
||||||
// if current device
|
|
||||||
// no more: go to devices
|
|
||||||
// more: go to first
|
|
||||||
|
|
||||||
return GroupService.kick(device).then(function () {
|
// If we're trying to kick current device
|
||||||
$scope.$digest()
|
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) {
|
$scope.controlDevice = function (device) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ device-screen textarea {
|
||||||
min-width: 37px;
|
min-width: 37px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stf-vnc-device-name {
|
.stf-device-control .stf-vnc-device-name {
|
||||||
/*padding: 6px 2px 6px 15px;*/
|
/*padding: 6px 2px 6px 15px;*/
|
||||||
/*float: left;*/
|
/*float: left;*/
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
|
@ -19,16 +19,17 @@
|
||||||
i(ng-show='!showScreen', tooltip-html-unsafe='{{"View device"|translate}}<br /><code>⌘-⇧-O</code>', tooltip-placement='left').fa.fa-eye-slash
|
i(ng-show='!showScreen', tooltip-html-unsafe='{{"View device"|translate}}<br /><code>⌘-⇧-O</code>', tooltip-placement='left').fa.fa-eye-slash
|
||||||
|
|
||||||
div
|
div
|
||||||
|
a.stf-vnc-device-name.pointer.unselectable.dropdown-toggle
|
||||||
|
p
|
||||||
a.stf-vnc-device-name.pointer.unselectable.dropdown-toggle(ng-class='{"pointer": groupDevices.length > 1, "cursor": groupDevices.length <= 1}')
|
.device-small-image
|
||||||
p {{ $root.device.name }}
|
img(ng-src='{{$root.device.image ? "/static/devices/" + $root.device.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
|
||||||
span.caret(ng-show='groupDevices.length > 1')
|
span {{ $root.device.name }}
|
||||||
|
span.caret(ng-show='groupDevices.length > 0')
|
||||||
span(ng-show='$root.device && !$root.device.present', translate) (Absent)
|
span(ng-show='$root.device && !$root.device.present', translate) (Absent)
|
||||||
|
|
||||||
ul.dropdown-menu.pointer.unselectable(ng-show='groupDevices.length > 1')
|
ul.dropdown-menu.pointer.unselectable(ng-show='groupDevices.length > 0')
|
||||||
li(ng-repeat='groupDevice in groupDevices')
|
li(ng-repeat='groupDevice in groupDevices')
|
||||||
a(ng-click='controlDevice(groupDevice); $event.stopPropagation();')
|
a(ng-click='controlDevice(groupDevice); $event.stopPropagation()')
|
||||||
.device-small-image
|
.device-small-image
|
||||||
img(ng-src='{{groupDevice.image ? "/static/devices/" + groupDevice.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
|
img(ng-src='{{groupDevice.image ? "/static/devices/" + groupDevice.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
|
||||||
span {{ groupDevice.name }}
|
span {{ groupDevice.name }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue