Update device status accordingly.

This commit is contained in:
Gunther Brunner
2014-10-03 15:44:16 +09:00
parent 989ca53a91
commit 5d190db1b7
3 changed files with 31 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
module.exports =
function FatalMessageServiceFactory($modal, $location, $route, $interval,
StateClassesService) {
StateClassesService, $timeout) {
var FatalMessageService = {}
var intervalDeviceInfo
@@ -13,12 +13,20 @@ module.exports =
//$location.path('/control/' + device.serial)
}
function update() {
$scope.device = device
$scope.stateColor = StateClassesService.stateButton(device.state)
}
update()
// TODO: remove this please
intervalDeviceInfo = $interval(update, 750)
if (tryToReconnect) {
// TODO: this is ugly, find why its not updated correctly (also on the device list)
intervalDeviceInfo = $interval(function () {
$scope.device = device
$scope.stateColor = StateClassesService.stateColor(device.state)
update()
if (device.usable) {
// Try to reconnect
@@ -27,8 +35,6 @@ module.exports =
}, 1000, 500)
}
$scope.device = device
$scope.second = function () {
$modalInstance.dismiss()
$location.path('/devices/')