Started enhancing device list details with prefiltered information.

Moved enhanced data away from device service.
This commit is contained in:
Gunther Brunner
2014-06-18 01:25:22 +09:00
parent b139849b3f
commit 7982e2bcbe
4 changed files with 39 additions and 56 deletions

View File

@@ -15,35 +15,35 @@ module.exports = angular.module('stf.device-status', [])
}
})
// TODO: translate here the rest
.filter('batteryHealth', function (gettext) {
.filter('batteryHealth', function (gettext, $filter) {
return function (text) {
return {
return $filter('translate')({
'cold': gettext('Cold'),
'good': gettext('Good'),
'dead': gettext('Dead'),
'over_voltage': gettext('Over Voltage'),
'overheat': gettext('Overheat'),
'unspecified_failure': gettext('Unspecified Failure')
}[text] || gettext('-')
}[text] || gettext('-'))
}
})
.filter('batterySource', function (gettext) {
.filter('batterySource', function (gettext, $filter) {
return function (text) {
return {
return $filter('translate')({
'ac': gettext('AC'),
'usb': gettext('USB'),
'wireless': gettext('Wireless')
}[text] || gettext('-')
}[text] || gettext('-'))
}
})
.filter('batteryStatus', function (gettext) {
.filter('batteryStatus', function (gettext, $filter) {
return function (text) {
return {
return $filter('translate')({
'charging': gettext('Charging'),
'discharging': gettext('Discharging'),
'full': gettext('Full'),
'not_charging': gettext('Not Charging')
}[text] || gettext('-')
}[text] || gettext('-'))
}
})
.filter('displayDensity', function (gettext) {
@@ -58,9 +58,9 @@ module.exports = angular.module('stf.device-status', [])
}[text] || text
}
})
.filter('networkType', function (gettext) {
.filter('networkType', function (gettext, $filter) {
return function (text) {
return {
return $filter('translate')({
'bluetooth': gettext('Bluetooth'),
'dummy': gettext('Dummy'),
'ethernet': gettext('Ethernet'),
@@ -71,17 +71,17 @@ module.exports = angular.module('stf.device-status', [])
'mobile_supl': gettext('Mobile SUPL'),
'mobile_wifi': gettext('WiFi'),
'wimax': gettext('WiMAX')
}[text] || text
}[text] || text)
}
})
.filter('networkSubType', function (gettext) {
.filter('networkSubType', function (gettext, $filter) {
return function (text) {
return {
'mobile_wifi': gettext('WiFi'),
}[text] || text
return $filter('translate')({
'mobile_wifi': gettext('WiFi')
}[text] || text)
}
})
.filter('humanizedBool', function (gettext) {
.filter('humanizedBool', function (gettext, $filter) {
return function (text) {
switch (text) {
case true:

View File

@@ -94,28 +94,9 @@ module.exports = function DeviceServiceFactory($http, socket, $filter) {
}
}
// NOTE: For overall performance reasons, put all the filters here:
data.stateSorting = getStateSorting(data.state)
// TODO: i18n shortDate
data.releasedAtFormatted = $filter('date')(data.releasedAt, 'yyyy/MM/dd')
$scope.$broadcast('device.synced', data)
}
// For convenience, add the sorting priority to each state
function getStateSorting(state) {
return {
'using': 1,
'available': 2,
'ready': 3,
'present': 4,
'busy': 5,
'unauthorized': 6,
'offline': 7,
'preparing': 8,
'absent': 9
}[state] || 10
}
function get(data) {
return devices[devicesBySerial[data.serial]]