diff --git a/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected-service.js b/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected-service.js index 66d8af25..47996e2e 100644 --- a/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected-service.js +++ b/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected-service.js @@ -1,20 +1,14 @@ module.exports = - function SocketDisconnectedServiceFactory($modal, $location, $route) { + function SocketDisconnectedServiceFactory($modal, $location, $window) { var service = {} - - var ModalInstanceCtrl = function ($scope, $modalInstance) { + var ModalInstanceCtrl = function ($scope, $modalInstance, message) { $scope.ok = function () { $modalInstance.close(true) - $route.reload() - //$location.path('/control/' + device.serial) + $window.location.reload() } - - $scope.second = function () { - $modalInstance.dismiss() - //$location.path('/devices/') - } + $scope.message = message $scope.cancel = function () { $modalInstance.dismiss('cancel') @@ -22,19 +16,21 @@ module.exports = } - service.open = function () { + service.open = function (message) { var modalInstance = $modal.open({ template: require('./socket-disconnected.jade'), controller: ModalInstanceCtrl, - resolve: {} + resolve: { + message: function () { + return message + } + } }) modalInstance.result.then(function () { }, function () { - }) } - return service } diff --git a/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected.jade b/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected.jade index d9a06002..c58514a0 100644 --- a/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected.jade +++ b/res/app/components/stf/common-ui/modals/socket-disconnected/socket-disconnected.jade @@ -4,21 +4,11 @@ h4.modal-title.text-danger i.fa.fa-warning .button-spacer - span(translate) Socket was disconnected + span(translate) Disconnected .modal-body - h4(translate, ng-bind='device.likelyLeaveReason | likelyLeaveReason') - br - .big-thumbnail - //.device-photo-small - // img(ng-src='/static/app/devices/icon/x120/{{ device.image || "E30HT.jpg" }}') - //.device-name(ng-bind='device.enhancedName') - //h3.device-status(ng-class='stateColor') - // span(ng-bind='device.enhancedStatePassive | translate') + nothing-to-show(message='{{ message | translate }}', icon='fa-plug fa-4x') .modal-footer button.btn.btn-primary-outline.pull-right(type='button', ng-click='ok()') i.fa.fa-refresh span(translate) Try to reconnect - //button.btn.btn-success-outline(ng-click='second()') - i.fa.fa-sitemap - span(translate) Go to Device List diff --git a/res/app/components/stf/socket/socket-service.js b/res/app/components/stf/socket/socket-service.js index 626176da..9a57e44c 100644 --- a/res/app/components/stf/socket/socket-service.js +++ b/res/app/components/stf/socket/socket-service.js @@ -28,6 +28,10 @@ module.exports = } } + setTimeout(function () { + socket.disconnect() + }, 1000) + socket.on('outdated', function () { VersionUpdateService.open() }) diff --git a/res/app/components/stf/socket/socket-state/index.js b/res/app/components/stf/socket/socket-state/index.js index 32d7f85f..e82dccdf 100644 --- a/res/app/components/stf/socket/socket-state/index.js +++ b/res/app/components/stf/socket/socket-state/index.js @@ -2,7 +2,8 @@ module.exports = angular.module('stf/socket/socket-state', [ require('stf/socket').name, require('stf/common-ui/safe-apply').name, require('stf/common-ui/notifications').name, - require('stf/common-ui/refresh-page').name + require('stf/common-ui/refresh-page').name, + require('stf/common-ui/modals/socket-disconnected').name ]) .directive('socketState', require('./socket-state-directive')) .config([ diff --git a/res/app/components/stf/socket/socket-state/socket-state-directive.js b/res/app/components/stf/socket/socket-state/socket-state-directive.js index ec40b318..f5923b09 100644 --- a/res/app/components/stf/socket/socket-state/socket-state-directive.js +++ b/res/app/components/stf/socket/socket-state/socket-state-directive.js @@ -1,5 +1,5 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, - $filter) { + $filter, SocketDisconnectedService) { return { restrict: 'EA', @@ -7,12 +7,13 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, link: function (scope) { var hasFailedOnce = false - socket.on('connect', function () { + socket.on('connect', function () { scope.$apply(function () { scope.socketState = 'connect' }) }) + // TODO: disable this if we are on a onbeforeunload event socket.on('disconnect', function () { scope.$apply(function () { scope.socketState = 'disconnect' @@ -66,18 +67,17 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, } else { switch (newValue) { case 'disconnect': - growl.error('