mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Started enhancing device list details with prefiltered information.
Moved enhanced data away from device service.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user