mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Added Restart Device functionality.
Added device status to Fatal Message modal. Added auto-reconnect to Fatal Message modal.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
module.exports = function FatalMessageServiceFactory($modal, $location, $route) {
|
||||
module.exports = function FatalMessageServiceFactory($modal, $location, $route, $interval) {
|
||||
var FatalMessageService = {}
|
||||
|
||||
var intervalDeviceInfo
|
||||
|
||||
var ModalInstanceCtrl = function ($scope, $modalInstance, device) {
|
||||
$scope.ok = function () {
|
||||
@@ -9,6 +10,18 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||
//$location.path('/control/' + device.serial)
|
||||
}
|
||||
|
||||
// TODO: this is ugly, find why its not updated correctly (also on the device list)
|
||||
intervalDeviceInfo = $interval(function () {
|
||||
$scope.device = device
|
||||
|
||||
if (device.usable) {
|
||||
// Try to reconnect
|
||||
$scope.ok()
|
||||
}
|
||||
}, 1000, 500)
|
||||
|
||||
$scope.device = device
|
||||
|
||||
$scope.second = function () {
|
||||
$modalInstance.dismiss()
|
||||
$location.path('/devices/')
|
||||
@@ -17,6 +30,17 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel')
|
||||
}
|
||||
|
||||
var destroyInterval = function () {
|
||||
if (angular.isDefined(intervalDeviceInfo)) {
|
||||
$interval.cancel(intervalDeviceInfo)
|
||||
intervalDeviceInfo = undefined
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
destroyInterval()
|
||||
})
|
||||
}
|
||||
|
||||
FatalMessageService.open = function (device) {
|
||||
@@ -24,11 +48,13 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||
template: require('./fatal-message.jade'),
|
||||
controller: ModalInstanceCtrl,
|
||||
resolve: {
|
||||
device: device
|
||||
device: function () {
|
||||
return device
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
modalInstance.result.then(function (selectedItem) {
|
||||
modalInstance.result.then(function () {
|
||||
}, function () {
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user