diff options
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Style.js | 1 | ||||
-rw-r--r-- | web/app/view/edit/Devices.js | 25 | ||||
-rw-r--r-- | web/app/view/edit/DevicesController.js | 6 |
3 files changed, 28 insertions, 4 deletions
diff --git a/web/app/Style.js b/web/app/Style.js index c594d92..aa749ce 100644 --- a/web/app/Style.js +++ b/web/app/Style.js @@ -18,6 +18,7 @@ Ext.define('Traccar.Style', { singleton: true, + refreshPeriod: 60 * 1000, reconnectTimeout: 60 * 1000, normalPadding: 10, 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; + } + } }] } }); diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index 895f0fb..0d18c18 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -52,10 +52,14 @@ Ext.define('Traccar.view.edit.DevicesController', { removeTitle: Strings.sharedDevice, init: function () { - var readonly, deviceReadonly; + var self = this, readonly, deviceReadonly; deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); + + setInterval(function () { + self.getView().getView().refresh(); + }, Traccar.Style.refreshPeriod); }, onGeofencesClick: function () { |