Added admin-mode.

For now it shows/hides columns in the Device List and adds kicking behaviour.
Using $rootScope.adminMode for convenience.
This commit is contained in:
Gunther Brunner
2014-07-14 20:20:53 +09:00
parent e33b0f922f
commit fa71aae56a
10 changed files with 91 additions and 24 deletions

View File

@@ -1,5 +1,23 @@
var _ = require('lodash')
var filterOps = {
'<': function(a, filterValue) {
return a < filterValue
}
, '<=': function(a, filterValue) {
return a <= filterValue
}
, '>': function(a, filterValue) {
return a > filterValue
}
, '>=': function(a, filterValue) {
return a >= filterValue
}
, '=': function(a, filterValue) {
return a === filterValue
}
}
module.exports = function DeviceColumnService($filter, gettext) {
// Definitions for all possible values.
return {
@@ -134,24 +152,28 @@ module.exports = function DeviceColumnService($filter, gettext) {
})
, phone: TextCell({
title: gettext('Phone')
, admin: true
, value: function(device) {
return device.phone ? device.phone.phoneNumber : ''
}
})
, imei: TextCell({
title: gettext('Phone IMEI')
, admin: true
, value: function(device) {
return device.phone ? device.phone.imei : ''
}
})
, iccid: TextCell({
title: gettext('Phone ICCID')
, admin: true
, value: function(device) {
return device.phone ? device.phone.iccid : ''
}
})
, batteryHealth: TextCell({
title: gettext('Battery Health')
, admin: true
, value: function(device) {
return device.battery
? $filter('translate')(device.enhancedBatteryHealth)
@@ -160,6 +182,7 @@ module.exports = function DeviceColumnService($filter, gettext) {
})
, batterySource: TextCell({
title: gettext('Battery Source')
, admin: true
, value: function(device) {
return device.battery
? $filter('translate')(device.enhancedBatterySource)
@@ -168,6 +191,7 @@ module.exports = function DeviceColumnService($filter, gettext) {
})
, batteryStatus: TextCell({
title: gettext('Battery Status')
, admin: true
, value: function(device) {
return device.battery
? $filter('translate')(device.enhancedBatteryStatus)
@@ -176,6 +200,7 @@ module.exports = function DeviceColumnService($filter, gettext) {
})
, batteryLevel: TextCell({
title: gettext('Battery Level')
, admin: true
, value: function(device) {
return device.battery
? Math.floor(device.battery.level / device.battery.scale * 100) + '%'
@@ -184,6 +209,7 @@ module.exports = function DeviceColumnService($filter, gettext) {
})
, batteryTemp: TextCell({
title: gettext('Battery Temp')
, admin: true
, value: function(device) {
return device.battery ? device.battery.temp + '°C' : ''
}
@@ -227,27 +253,12 @@ function compareRespectCase(a, b) {
return a === b ? 0 : (a < b ? -1 : 1)
}
var filterOps = {
'<': function(a, filterValue) {
return a < filterValue
}
, '<=': function(a, filterValue) {
return a <= filterValue
}
, '>': function(a, filterValue) {
return a > filterValue
}
, '>=': function(a, filterValue) {
return a >= filterValue
}
, '=': function(a, filterValue) {
return a === filterValue
}
}
function TextCell(options) {
return _.defaults(options, {
title: options.title
, admin: options.admin
, defaultOrder: 'asc'
, build: function () {
var td = document.createElement('td')