diff --git a/res/app/components/stf/common-ui/modals/common/modals.css b/res/app/components/stf/common-ui/modals/common/modals.css index 3ae2e13e..eb57377a 100644 --- a/res/app/components/stf/common-ui/modals/common/modals.css +++ b/res/app/components/stf/common-ui/modals/common/modals.css @@ -57,3 +57,17 @@ height: 100%; max-height: 800px; } + +.stf-modal .big-thumbnail { + text-align: center; +} + +.stf-modal .device-name { + color: #3FA9F5; + font-size: 16px; + margin: 10px 0; + font-family: 'HelveticaNeue-UltraLight', Helvetica, Arial, sans-serif; +} + +.stf-modal .device-photo-small { +} diff --git a/res/app/components/stf/common-ui/modals/fatal-message/fatal-message-service.js b/res/app/components/stf/common-ui/modals/fatal-message/fatal-message-service.js index ee1ac9d3..4fe9f4a7 100644 --- a/res/app/components/stf/common-ui/modals/fatal-message/fatal-message-service.js +++ b/res/app/components/stf/common-ui/modals/fatal-message/fatal-message-service.js @@ -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 -} diff --git a/res/app/components/stf/common-ui/modals/fatal-message/fatal-message.jade b/res/app/components/stf/common-ui/modals/fatal-message/fatal-message.jade index e7c47d5c..53cd48ea 100644 --- a/res/app/components/stf/common-ui/modals/fatal-message/fatal-message.jade +++ b/res/app/components/stf/common-ui/modals/fatal-message/fatal-message.jade @@ -1,25 +1,24 @@ .stf-fatal-message.stf-modal - .modal-header.dialog-header-error + .modal-header.dialog-header-errorX button(type='button', ng-click='cancel()').close × h4.modal-title.text-danger i.fa.fa-warning .button-spacer - span(translate) {{ device.enhancedName }} was disconnected + span(translate) Device was disconnected .modal-body - .text-danger(translate) You are no longer controlling the device. + h4(translate, ng-bind='device.likelyLeaveReason | likelyLeaveReason') br - h3(translate, ng-bind='device.likelyLeaveReason | likelyLeaveReason') - br - h4(translate).pull-right {{ device.enhancedName }} current status: - br - br - h4(ng-bind='device.enhancedStatePassive | translate').pull-right - + .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') .modal-footer - button.btn.btn-primary(type='button', ng-click='ok()') + button.btn.btn-primary-outline(type='button', ng-click='ok()') i.fa.fa-refresh span(translate) Try to reconnect - button.btn.btn-success(ng-click='second()') + 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/device/index.js b/res/app/components/stf/device/index.js index 83adbbac..01abb6b6 100644 --- a/res/app/components/stf/device/index.js +++ b/res/app/components/stf/device/index.js @@ -3,3 +3,4 @@ module.exports = angular.module('stf/device', [ require('./enhance-device').name ]) .factory('DeviceService', require('./device-service')) + .factory('StateClassesService', require('./state-classes-service')) diff --git a/res/app/components/stf/device/state-classes-service.js b/res/app/components/stf/device/state-classes-service.js new file mode 100644 index 00000000..e96e9b24 --- /dev/null +++ b/res/app/components/stf/device/state-classes-service.js @@ -0,0 +1,40 @@ +module.exports = function StateClassesService() { + var service = {} + + service.stateButton = function (state) { + var stateClasses = { + using: 'state-using btn-primary', + busy: 'state-busy btn-warning', + available: 'state-available btn-primary-outline', + ready: 'state-ready btn-primary-outline', + present: 'state-present btn-primary-outline', + preparing: 'state-preparing btn-primary-outline btn-success-outline', + unauthorized: 'state-unauthorized btn-danger-outline', + offline: 'state-offline btn-warning-outline' + }[state] + if (typeof stateClasses === 'undefined') { + stateClasses = 'btn-default-outline' + } + return stateClasses + } + + service.stateColor = function (state) { + var stateClasses = { + using: 'state-using', + busy: 'state-busy', + available: 'state-available', + ready: 'state-ready', + present: 'state-present', + preparing: 'state-preparing', + unauthorized: 'state-unauthorized', + offline: 'state-offline' + }[state] + if (typeof stateClasses === 'undefined') { + stateClasses = '' + } + return stateClasses + } + + return service +} +