mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +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:
parent
694d621794
commit
aebeb4d357
5 changed files with 47 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
||||||
module.exports = function FatalMessageServiceFactory($modal, $location, $route) {
|
module.exports = function FatalMessageServiceFactory($modal, $location, $route, $interval) {
|
||||||
var FatalMessageService = {}
|
var FatalMessageService = {}
|
||||||
|
|
||||||
|
var intervalDeviceInfo
|
||||||
|
|
||||||
var ModalInstanceCtrl = function ($scope, $modalInstance, device) {
|
var ModalInstanceCtrl = function ($scope, $modalInstance, device) {
|
||||||
$scope.ok = function () {
|
$scope.ok = function () {
|
||||||
|
@ -9,6 +10,18 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||||
//$location.path('/control/' + device.serial)
|
//$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 () {
|
$scope.second = function () {
|
||||||
$modalInstance.dismiss()
|
$modalInstance.dismiss()
|
||||||
$location.path('/devices/')
|
$location.path('/devices/')
|
||||||
|
@ -17,6 +30,17 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||||
$scope.cancel = function () {
|
$scope.cancel = function () {
|
||||||
$modalInstance.dismiss('cancel')
|
$modalInstance.dismiss('cancel')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var destroyInterval = function () {
|
||||||
|
if (angular.isDefined(intervalDeviceInfo)) {
|
||||||
|
$interval.cancel(intervalDeviceInfo)
|
||||||
|
intervalDeviceInfo = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.$on('$destroy', function () {
|
||||||
|
destroyInterval()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalMessageService.open = function (device) {
|
FatalMessageService.open = function (device) {
|
||||||
|
@ -24,11 +48,13 @@ module.exports = function FatalMessageServiceFactory($modal, $location, $route)
|
||||||
template: require('./fatal-message.jade'),
|
template: require('./fatal-message.jade'),
|
||||||
controller: ModalInstanceCtrl,
|
controller: ModalInstanceCtrl,
|
||||||
resolve: {
|
resolve: {
|
||||||
device: device
|
device: function () {
|
||||||
|
return device
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
modalInstance.result.then(function (selectedItem) {
|
modalInstance.result.then(function () {
|
||||||
}, function () {
|
}, function () {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,8 +4,13 @@
|
||||||
h4.modal-title.text-danger
|
h4.modal-title.text-danger
|
||||||
i.fa.fa-warning
|
i.fa.fa-warning
|
||||||
.button-spacer
|
.button-spacer
|
||||||
span(translate) Device was disconnected
|
span(translate) {{ device.enhancedName }} was disconnected
|
||||||
.modal-body.text-danger(translate) You are no longer controlling the device.
|
.modal-body
|
||||||
|
.text-danger(translate) You are no longer controlling the device.
|
||||||
|
br
|
||||||
|
h4(translate).pull-right {{ device.enhancedName }} current status:
|
||||||
|
//span(ng-class='device.enhancedButtonClass').btn.btn-xs.device-status {{device.enhancedState }}
|
||||||
|
span {{ device.enhancedState }}
|
||||||
.modal-footer
|
.modal-footer
|
||||||
button.btn.btn-primary(type='button', ng-click='ok()')
|
button.btn.btn-primary(type='button', ng-click='ok()')
|
||||||
i.fa.fa-refresh
|
i.fa.fa-refresh
|
||||||
|
@ -13,18 +18,3 @@
|
||||||
button.btn.btn-success(ng-click='second()')
|
button.btn.btn-success(ng-click='second()')
|
||||||
i.fa.fa-sitemap
|
i.fa.fa-sitemap
|
||||||
span(translate) Go to Device List
|
span(translate) Go to Device List
|
||||||
//button.btn.btn-warning(ng-click='cancel()') Close
|
|
||||||
|
|
||||||
//'<div class="modal-header dialog-header-error">
|
|
||||||
// <button type="button" class="close" ng-click="close()">×</button>
|
|
||||||
// <h4 class="modal-title text-danger">
|
|
||||||
// <span class="glyphicon glyphicon-warning-sign"></span>
|
|
||||||
// <span ng-bind-html="header"></span>
|
|
||||||
// </h4>
|
|
||||||
//</div>
|
|
||||||
//
|
|
||||||
//<div class="modal-body text-danger" ng-bind-html="msg"></div>
|
|
||||||
//<div class="modal-footer">
|
|
||||||
// <button type="button" class="btn btn-default" ng-click="close()">
|
|
||||||
//'+startSym+'"DIALOGS_CLOSE" | translate'+endSym+'</button>
|
|
||||||
//</div>'
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = function ($scope, gettext, $filter) {
|
module.exports = function ($scope, gettext, $filter) {
|
||||||
|
|
||||||
$scope.reboot = function (device) {
|
$scope.reboot = function () {
|
||||||
var config = {
|
var config = {
|
||||||
rebootEnabled: true
|
rebootEnabled: true
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ module.exports = function ($scope, gettext, $filter) {
|
||||||
if (config.rebootEnabled) {
|
if (config.rebootEnabled) {
|
||||||
if (confirm($filter('translate')(
|
if (confirm($filter('translate')(
|
||||||
gettext('Are you sure you want to reboot this device? \nThe device will be unavailable for a moment.')))) {
|
gettext('Are you sure you want to reboot this device? \nThe device will be unavailable for a moment.')))) {
|
||||||
console.log('reboot')
|
$scope.control.reboot().then(function (result) {
|
||||||
|
console.error(result)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,8 @@ module.exports = function ControlPanesController($scope, $http, gettext, $routeP
|
||||||
$scope.device = device
|
$scope.device = device
|
||||||
$scope.control = ControlService.create(device, device.channel)
|
$scope.control = ControlService.create(device, device.channel)
|
||||||
|
|
||||||
|
//FatalMessageService.open($scope.device)
|
||||||
|
|
||||||
return device
|
return device
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(function () {
|
||||||
|
@ -159,14 +161,17 @@ module.exports = function ControlPanesController($scope, $http, gettext, $routeP
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: WHAT???
|
||||||
$scope.$watch('device')
|
$scope.$watch('device')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$scope.$watch('device.state', function (newValue, oldValue) {
|
$scope.$watch('device.state', function (newValue, oldValue) {
|
||||||
|
|
||||||
if (newValue !== oldValue) {
|
if (newValue !== oldValue) {
|
||||||
if (oldValue === 'using') {
|
if (oldValue === 'using') {
|
||||||
FatalMessageService.open(angular.copy($scope.device))
|
FatalMessageService.open($scope.device)
|
||||||
}
|
}
|
||||||
} else if (typeof newValue === 'undefined' && typeof oldValue === 'undefined') {
|
} else if (typeof newValue === 'undefined' && typeof oldValue === 'undefined') {
|
||||||
//FatalMessageService.open(angular.copy($scope.device))
|
//FatalMessageService.open(angular.copy($scope.device))
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = function LayoutCtrl(FatalMessageService, LanguageService) {
|
module.exports = function LayoutCtrl(LanguageService) {
|
||||||
LanguageService.init()
|
LanguageService.init()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue