From 0a35d3a7c4aa2968e2b8d4b73cfbd486c9fc625b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 29 Mar 2017 21:56:33 +1300 Subject: More devices table improvements --- web/app/view/edit/Devices.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'web/app/view/edit/Devices.js') diff --git a/web/app/view/edit/Devices.js b/web/app/view/edit/Devices.js index 9393b43..42291f0 100644 --- a/web/app/view/edit/Devices.js +++ b/web/app/view/edit/Devices.js @@ -90,7 +90,7 @@ Ext.define('Traccar.view.edit.Devices', { columns: { defaults: { - flex: 2, + flex: 1, minWidth: Traccar.Style.columnWidthNormal }, items: [{ @@ -132,7 +132,6 @@ Ext.define('Traccar.view.edit.Devices', { }, { text: Strings.deviceStatus, dataIndex: 'status', - flex: 1, filter: { type: 'list', labelField: 'name', @@ -151,7 +150,27 @@ Ext.define('Traccar.view.edit.Devices', { }, { text: Strings.deviceLastUpdate, dataIndex: 'lastUpdate', - renderer: Traccar.AttributeFormatter.getFormatter('lastUpdate') + renderer: function (value, metaData, record) { + var status, seconds, interval; + + status = record.get('status'); + if (status) { + metaData.tdCls = Ext.getStore('DeviceStatuses').getById(status).get('color'); + } + + if (value) { + seconds = Math.floor((new Date() - value) / 1000); + interval = Math.floor(seconds / 86400); + if (interval > 1) { + return interval + ' ' + Strings.sharedDays; + } + interval = Math.floor(seconds / 3600); + if (interval > 1) { + return interval + ' ' + Strings.sharedHours; + } + return Math.floor(seconds / 60) + ' ' + Strings.sharedMinutes; + } + } }] } }); -- cgit v1.2.3