mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Added basic fatal message functionality.
This commit is contained in:
parent
99ef24f93b
commit
1d44bf5da3
7 changed files with 81 additions and 4 deletions
|
@ -0,0 +1,41 @@
|
|||
module.exports = function FatalMessageServiceFactory($modal, $location, $route) {
|
||||
var FatalMessageService = {}
|
||||
|
||||
|
||||
var ModalInstanceCtrl = function ($scope, $modalInstance, device) {
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close(5)
|
||||
$route.reload()
|
||||
//$location.path('/control/' + device.serial)
|
||||
}
|
||||
|
||||
$scope.second = function () {
|
||||
$location.path('/devices/')
|
||||
}
|
||||
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel')
|
||||
}
|
||||
}
|
||||
|
||||
FatalMessageService.open = function (device) {
|
||||
var modalInstance = $modal.open({
|
||||
template: require('./fatal-message.jade'),
|
||||
controller: ModalInstanceCtrl,
|
||||
resolve: {
|
||||
device: device,
|
||||
items: function () {
|
||||
return 10
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
modalInstance.result.then(function (selectedItem) {
|
||||
console.log(selectedItem)
|
||||
}, function () {
|
||||
console.log('Modal dismissed at: ' + new Date())
|
||||
})
|
||||
}
|
||||
|
||||
return FatalMessageService
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
describe('FatalMessageService', function() {
|
||||
|
||||
beforeEach(module('stf.fatal-message'));
|
||||
|
||||
it('should ...', inject(function(FatalMessageService) {
|
||||
|
||||
//expect(FatalMessageService.doSomething()).toEqual('something');
|
||||
|
||||
}));
|
||||
|
||||
})
|
|
@ -0,0 +1,8 @@
|
|||
.modal-header
|
||||
h3.modal-title(translate) Device was disconnected
|
||||
.modal-body
|
||||
h4 Device is not in use anymore
|
||||
.modal-footer
|
||||
button.btn.btn-primary(translate, ng-click='ok()') Try to reconnect
|
||||
button.btn.btn-success(translate, ng-click='second()') Go to Device List
|
||||
button.btn.btn-warning(translate, ng-click='cancel()') Close
|
4
res/app/components/stf/common-ui/fatal-message/index.js
Normal file
4
res/app/components/stf/common-ui/fatal-message/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = angular.module('stf.fatal-message', [
|
||||
|
||||
])
|
||||
.factory('FatalMessageService', require('./fatal-message-service'))
|
|
@ -7,5 +7,6 @@ module.exports = angular.module('stf/common-ui', [
|
|||
require('./notifications').name,
|
||||
require('./ng-enter').name,
|
||||
require('./tooltips').name,
|
||||
require('./tree').name
|
||||
require('./tree').name,
|
||||
require('./fatal-message').name
|
||||
])
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function ($scope, gettext, $routeParams, $location, DeviceService, GroupService, ControlService) {
|
||||
module.exports = function ($scope, gettext, $routeParams, $location, DeviceService, GroupService, ControlService, FatalMessageService) {
|
||||
|
||||
var sharedTabs = [
|
||||
{
|
||||
|
@ -122,4 +122,15 @@ module.exports = function ($scope, gettext, $routeParams, $location, DeviceServi
|
|||
.catch(function () {
|
||||
$location.path('/')
|
||||
})
|
||||
|
||||
|
||||
$scope.$watch('device.state', function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
if (oldValue === 'using') {
|
||||
FatalMessageService.open(angular.copy($scope.device))
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
module.exports = function LayoutCtrl() {
|
||||
module.exports = function LayoutCtrl(FatalMessageService) {
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue