From d93e45e176fc2cbba6525f100ef084d904baa1c1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 8 Nov 2017 15:04:43 +0500 Subject: Implement geocoding retry --- web/app/view/ReportController.js | 34 +++++++++++++++++++++++++++++++++- web/app/view/State.js | 3 +++ web/app/view/StateController.js | 28 +++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) (limited to 'web/app') diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 80e56ba4..5d4d00c2 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -40,6 +40,9 @@ Ext.define('Traccar.view.ReportController', { selectreport: 'selectReport' } }, + global: { + routegeocode: 'onGeocode' + }, store: { '#ReportEvents': { add: 'loadRelatedPositions', @@ -423,6 +426,28 @@ Ext.define('Traccar.view.ReportController', { this.updateButtons(); }, + onGeocode: function (positionId) { + var position = Ext.getStore('ReportRoute').getById(positionId); + if (position && !position.get('address')) { + Ext.Ajax.request({ + scope: this, + method: 'GET', + url: 'api/server/geocode', + params: { + latitude: position.get('latitude'), + longitude: position.get('longitude') + }, + success: function (response) { + position.set('address', response.responseText); + position.commit(); + }, + failure: function (response) { + Traccar.app.showError(response); + } + }); + } + }, + routeColumns: [{ text: Strings.reportDeviceName, dataIndex: 'deviceId', @@ -455,7 +480,14 @@ Ext.define('Traccar.view.ReportController', { }, { text: Strings.positionAddress, dataIndex: 'address', - renderer: Traccar.AttributeFormatter.getFormatter('address') + renderer: function (value, metaData, record) { + if (!value) { + return '' + + Strings.stateShowAddress + ''; + } + return Traccar.AttributeFormatter.getFormatter('address')(value); + } }], eventsColumns: [{ diff --git a/web/app/view/State.js b/web/app/view/State.js index 32f95861..d4c56d79 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -63,6 +63,9 @@ Ext.define('Traccar.view.State', { renderer: function (value, metaData, record) { if (record.get('attribute') === 'alarm') { metaData.tdCls = 'view-color-red'; + } else if (record.get('name') === Strings.positionAddress && !value) { + return '' + + Strings.stateShowAddress + ''; } return value; } diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 70f02281..44b01382 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -36,6 +36,9 @@ Ext.define('Traccar.view.StateController', { deselectfeature: 'deselectFeature' } }, + global: { + stategeocode: 'onGeocode' + }, store: { '#LatestPositions': { add: 'updateLatest', @@ -48,7 +51,6 @@ Ext.define('Traccar.view.StateController', { } }, - init: function () { var i, hideAttributesPreference, attributesList; if (Traccar.app.getUser().get('admin') || @@ -184,5 +186,29 @@ Ext.define('Traccar.view.StateController', { this.position = null; Ext.getStore('Attributes').removeAll(); } + }, + + onGeocode: function () { + var positionId = this.position.getId(); + if (!this.position.get('address')) { + Ext.Ajax.request({ + scope: this, + method: 'GET', + url: 'api/server/geocode', + params: { + latitude: this.position.get('latitude'), + longitude: this.position.get('longitude') + }, + success: function (response) { + if (this.position && this.position.getId() === positionId) { + this.position.set('address', response.responseText); + this.updatePosition(); + } + }, + failure: function (response) { + Traccar.app.showError(response); + } + }); + } } }); -- cgit v1.2.3 From 6c765684b17b62e3be8f47c0d0cfa925bc94c2c8 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 13 Nov 2017 12:43:22 +0500 Subject: Update State panel after address decoding in Route report --- web/app/view/ReportController.js | 1 + 1 file changed, 1 insertion(+) (limited to 'web/app') diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 5d4d00c2..40f3afd7 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -440,6 +440,7 @@ Ext.define('Traccar.view.ReportController', { success: function (response) { position.set('address', response.responseText); position.commit(); + this.fireEvent('selectReport', position); }, failure: function (response) { Traccar.app.showError(response); -- cgit v1.2.3 From be7876d44dd63d9c7fc1b6e61f0caa01b1bb423e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 13 Nov 2017 16:48:52 +0500 Subject: Rename string to "shared" --- web/app/view/ReportController.js | 4 ++-- web/app/view/State.js | 2 +- web/l10n/en.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'web/app') diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 40f3afd7..e266bf47 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -484,8 +484,8 @@ Ext.define('Traccar.view.ReportController', { renderer: function (value, metaData, record) { if (!value) { return '' + - Strings.stateShowAddress + ''; + record.getId() + ')" >' + + Strings.stateShowAddress + ''; } return Traccar.AttributeFormatter.getFormatter('address')(value); } diff --git a/web/app/view/State.js b/web/app/view/State.js index d4c56d79..95529a48 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -65,7 +65,7 @@ Ext.define('Traccar.view.State', { metaData.tdCls = 'view-color-red'; } else if (record.get('name') === Strings.positionAddress && !value) { return '' + - Strings.stateShowAddress + ''; + Strings.sharedShowAddress + ''; } return value; } diff --git a/web/l10n/en.json b/web/l10n/en.json index 93278983..25c8c69a 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -72,6 +72,7 @@ "sharedSavedCommand": "Saved Command", "sharedSavedCommands": "Saved Commands", "sharedNew": "New…", + "sharedShowAddress": "Show Address", "attributeSpeedLimit": "Speed Limit", "attributeReportIgnoreOdometer": "Report: Ignore Odometer", "attributeMaintenanceStart": "Maintenance: Start", @@ -241,7 +242,6 @@ "stateTitle": "State", "stateName": "Attribute", "stateValue": "Value", - "stateShowAddress": "Show Address", "commandTitle": "Command", "commandSend": "Send", "commandSent": "Command has been sent", -- cgit v1.2.3