aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
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 83d310c..302a894 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;
}