aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-05-31 16:55:00 +0500
committerAbyss777 <abyss@fox5.ru>2017-05-31 16:55:08 +0500
commit35e8f4b4974515733737c5cc1dd439ca47860007 (patch)
tree21f5e7cc17e982e2c5b52682dfac29943e39199d /web/app/AttributeFormatter.js
parent0e598a6232e9cd7188916e06077862d6630a255b (diff)
downloadtrackermap-web-35e8f4b4974515733737c5cc1dd439ca47860007.tar.gz
trackermap-web-35e8f4b4974515733737c5cc1dd439ca47860007.tar.bz2
trackermap-web-35e8f4b4974515733737c5cc1dd439ca47860007.zip
Implement Events panel
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 83d310c3..302a8941 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -71,6 +71,26 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('Devices').getById(value).get('name');
},
+ lastUpdateFormatter: function (value) {
+ var seconds, interval;
+
+ if (value) {
+ seconds = Math.floor((new Date() - value) / 1000);
+ if (seconds < 0) {
+ seconds = 0;
+ }
+ 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;
+ }
+ },
+
defaultFormatter: function (value) {
if (typeof value === 'number') {
return Number(value.toFixed(Traccar.Style.numberPrecision));
@@ -104,6 +124,8 @@ Ext.define('Traccar.AttributeFormatter', {
return this.durationFormatter;
} else if (key === 'deviceId') {
return this.deviceIdFormatter;
+ } else if (key === 'lastUpdate') {
+ return this.lastUpdateFormatter;
} else {
return this.defaultFormatter;
}