diff --git a/res/.jshintrc b/res/.jshintrc index 1f6bdbe9..5180cfae 100644 --- a/res/.jshintrc +++ b/res/.jshintrc @@ -12,7 +12,7 @@ "undef": true, "unused": true, "trailing": true, - "maxlen": 80, + "maxlen": 100, "asi": true, "esnext": true, "laxcomma": true, diff --git a/res/app/components/stf/device/device-service.js b/res/app/components/stf/device/device-service.js index 0157aead..866b5326 100644 --- a/res/app/components/stf/device/device-service.js +++ b/res/app/components/stf/device/device-service.js @@ -1,7 +1,7 @@ var oboe = require('oboe') var _ = require('lodash') -module.exports = function DeviceServiceFactory($http, socket, $filter) { +module.exports = function DeviceServiceFactory($http, socket, EnhanceDeviceService) { var deviceService = {} function Tracker($scope, options) { @@ -62,39 +62,7 @@ module.exports = function DeviceServiceFactory($http, socket, $filter) { data.using = false } - // For convenience, formulate an aggregate state property that covers - // every possible state. - data.state = 'absent' - if (data.present) { - data.state = 'present' - switch (data.status) { - case 1: - data.state = 'offline' - break - case 2: - data.state = 'unauthorized' - break - case 3: - data.state = 'preparing' - if (data.ready) { - data.state = 'ready' - if (data.using) { - data.state = 'using' - } - else { - if (data.owner) { - data.state = 'busy' - } - else { - data.state = 'available' - } - } - } - break - } - } - - $scope.$broadcast('device.synced', data) + EnhanceDeviceService.enhance(data) } diff --git a/res/app/components/stf/device/enhance-device/index.js b/res/app/components/stf/device/enhance-device/index.js new file mode 100644 index 00000000..f1e0e870 --- /dev/null +++ b/res/app/components/stf/device/enhance-device/index.js @@ -0,0 +1,3 @@ +module.exports = angular.module('stf/device/enhance-device', [ +]) + .factory('EnhanceDeviceService', require('./enhance-device-service')) diff --git a/res/app/components/stf/device/index.js b/res/app/components/stf/device/index.js index 316f80cd..83adbbac 100644 --- a/res/app/components/stf/device/index.js +++ b/res/app/components/stf/device/index.js @@ -1,4 +1,5 @@ module.exports = angular.module('stf/device', [ - require('./device-info-filter').name + require('./device-info-filter').name, + require('./enhance-device').name ]) .factory('DeviceService', require('./device-service'))