From e7187ea46a8ca8a0e8d93a030a9d360249b998fa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 16 Sep 2015 22:27:23 +1200 Subject: Fix attribute formatter functions --- web/app/Application.js | 2 +- web/app/AttributeFormatter.js | 11 ++++++----- web/app/view/login/Login.js | 2 +- web/app/view/report/Report.js | 6 ++++-- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'web') diff --git a/web/app/Application.js b/web/app/Application.js index 91d2b7835..c488818a4 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -68,7 +68,7 @@ Ext.define('Traccar.Application', { }, getPreference: function(key, defaultValue) { - return this.getUser().get('distanceUnit') | this.getServer().get('distanceUnit') | defaultValue; + return this.getUser().get(key) || this.getServer().get(key) || defaultValue; } }); diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 294fdaaba..ba77c2072 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -18,17 +18,16 @@ Ext.define('Traccar.AttributeFormatter', { singleton: true, coordinateFormatter: function(value) { - return value.toFixed(5); + return value.toFixed(6); }, speedFormatter: function(value) { return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit')); }, - courseValues: ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'], - courseFormatter: function(value) { - return this.courseValues[Math.floor(value / 45)]; + var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']; + return courseValues[Math.floor(value / 45)]; }, distanceFormatter: function(value) { @@ -36,8 +35,10 @@ Ext.define('Traccar.AttributeFormatter', { }, defaultFormatter: function(value) { - if (value instanceof Number) { + if (typeof value === 'number') { return value.toFixed(2); + } else if (typeof value === 'boolean') { + return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no; } else if (value instanceof Date) { return Ext.Date.format(value, styles.dateTimeFormat); } diff --git a/web/app/view/login/Login.js b/web/app/view/login/Login.js index adb04cf0c..fc1e749d1 100644 --- a/web/app/view/login/Login.js +++ b/web/app/view/login/Login.js @@ -35,7 +35,7 @@ Ext.define('Traccar.view.login.Login', { autoEl: { tag: 'form', method: 'POST', - action: 'blank.html', + action: 'blank', target: 'submitTarget' }, diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js index 25f3b244a..720de698f 100644 --- a/web/app/view/report/Report.js +++ b/web/app/view/report/Report.js @@ -81,7 +81,8 @@ Ext.define('Traccar.view.report.Report', { columns: [{ text: strings.positionValid, dataIndex: 'valid', - flex: 1 + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('valid') }, { text: strings.positionTime, dataIndex: 'fixTime', @@ -111,6 +112,7 @@ Ext.define('Traccar.view.report.Report', { }, { text: strings.positionAddress, dataIndex: 'address', - flex: 1 + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('address') }] }); -- cgit v1.2.3