mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 08:33:24 +02:00
Improve Device Disconnected UI.
This commit is contained in:
@@ -1,70 +1,75 @@
|
||||
module.exports = function FatalMessageServiceFactory($modal, $location, $route, $interval) {
|
||||
var FatalMessageService = {}
|
||||
module.exports =
|
||||
function FatalMessageServiceFactory($modal, $location, $route, $interval,
|
||||
StateClassesService) {
|
||||
var FatalMessageService = {}
|
||||
|
||||
var intervalDeviceInfo
|
||||
var intervalDeviceInfo
|
||||
|
||||
var ModalInstanceCtrl = function ($scope, $modalInstance, device, tryToReconnect) {
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close(true)
|
||||
$route.reload()
|
||||
//$location.path('/control/' + device.serial)
|
||||
}
|
||||
|
||||
if (tryToReconnect) {
|
||||
// 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/')
|
||||
}
|
||||
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel')
|
||||
}
|
||||
|
||||
var destroyInterval = function () {
|
||||
if (angular.isDefined(intervalDeviceInfo)) {
|
||||
$interval.cancel(intervalDeviceInfo)
|
||||
intervalDeviceInfo = undefined
|
||||
var ModalInstanceCtrl = function ($scope, $modalInstance, device,
|
||||
tryToReconnect) {
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close(true)
|
||||
$route.reload()
|
||||
//$location.path('/control/' + device.serial)
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
destroyInterval()
|
||||
})
|
||||
}
|
||||
if (tryToReconnect) {
|
||||
// TODO: this is ugly, find why its not updated correctly (also on the device list)
|
||||
intervalDeviceInfo = $interval(function () {
|
||||
$scope.device = device
|
||||
|
||||
FatalMessageService.open = function (device, tryToReconnect) {
|
||||
var modalInstance = $modal.open({
|
||||
template: require('./fatal-message.jade'),
|
||||
controller: ModalInstanceCtrl,
|
||||
resolve: {
|
||||
device: function () {
|
||||
return device
|
||||
},
|
||||
tryToReconnect: function () {
|
||||
return tryToReconnect
|
||||
$scope.stateColor = StateClassesService.stateColor(device.state)
|
||||
|
||||
if (device.usable) {
|
||||
// Try to reconnect
|
||||
$scope.ok()
|
||||
}
|
||||
}, 1000, 500)
|
||||
}
|
||||
|
||||
$scope.device = device
|
||||
|
||||
$scope.second = function () {
|
||||
$modalInstance.dismiss()
|
||||
$location.path('/devices/')
|
||||
}
|
||||
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel')
|
||||
}
|
||||
|
||||
var destroyInterval = function () {
|
||||
if (angular.isDefined(intervalDeviceInfo)) {
|
||||
$interval.cancel(intervalDeviceInfo)
|
||||
intervalDeviceInfo = undefined
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
}, function () {
|
||||
$scope.$on('$destroy', function () {
|
||||
destroyInterval()
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
FatalMessageService.open = function (device, tryToReconnect) {
|
||||
var modalInstance = $modal.open({
|
||||
template: require('./fatal-message.jade'),
|
||||
controller: ModalInstanceCtrl,
|
||||
resolve: {
|
||||
device: function () {
|
||||
return device
|
||||
},
|
||||
tryToReconnect: function () {
|
||||
return tryToReconnect
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
}, function () {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return FatalMessageService
|
||||
}
|
||||
|
||||
|
||||
return FatalMessageService
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user