From b7403aaadd130bf1496b97c07667842813d99550 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 5 Sep 2016 14:27:30 +0500 Subject: Implement retrieving map center from current map --- web/app/view/ServerDialog.js | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'web/app/view/ServerDialog.js') diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index dd4579168..0f8dbd2eb 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -18,10 +18,10 @@ Ext.define('Traccar.view.ServerDialog', { extend: 'Traccar.view.BaseEditDialog', requires: [ - 'Traccar.view.BaseEditDialogController' + 'Traccar.view.ServerDialogController' ], - controller: 'baseEditDialog', + controller: 'serverEditDialog', title: Strings.serverTitle, items: { @@ -66,19 +66,28 @@ Ext.define('Traccar.view.ServerDialog', { displayField: 'name', valueField: 'key' }, { - xtype: 'numberfield', - name: 'latitude', - fieldLabel: Strings.positionLatitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - name: 'longitude', - fieldLabel: Strings.positionLongitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - name: 'zoom', - fieldLabel: Strings.serverZoom + xtype: 'fieldset', + reference: 'mapCenter', + title: Strings.sharedMapCenter, + defaultType: 'numberfield', + items: [{ + name: 'latitude', + fieldLabel: Strings.positionLatitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + name: 'longitude', + fieldLabel: Strings.positionLongitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + name: 'zoom', + fieldLabel: Strings.serverZoom + }, { + xtype: 'button', + margin: Traccar.Style.inFormButtonMargin, + enableToggle: false, + text: Strings.sharedGetFromMap, + handler: 'getFromMap' + }] }, { xtype: 'checkboxfield', name: 'twelveHourFormat', -- cgit v1.2.3 From 0affb8110de3c53942c85a220babc859e2a7727d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 6 Sep 2016 09:24:33 +0500 Subject: Move button to bottom bar --- web/app/Style.js | 4 +--- web/app/view/ServerDialog.js | 30 +++++++++++++++++++++--------- web/app/view/UserDialog.js | 30 +++++++++++++++++++++--------- web/l10n/en.json | 1 - 4 files changed, 43 insertions(+), 22 deletions(-) (limited to 'web/app/view/ServerDialog.js') diff --git a/web/app/Style.js b/web/app/Style.js index 034d2fb0b..b3b296b75 100644 --- a/web/app/Style.js +++ b/web/app/Style.js @@ -75,7 +75,5 @@ Ext.define('Traccar.Style', { coordinatePrecision: 6, numberPrecision: 2, - reportTagfieldWidth: 375, - - inFormButtonMargin: '0 0 9 0' + reportTagfieldWidth: 375 }); diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index 0f8dbd2eb..83f9c47f2 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -66,9 +66,8 @@ Ext.define('Traccar.view.ServerDialog', { displayField: 'name', valueField: 'key' }, { - xtype: 'fieldset', + xtype: 'fieldcontainer', reference: 'mapCenter', - title: Strings.sharedMapCenter, defaultType: 'numberfield', items: [{ name: 'latitude', @@ -81,12 +80,6 @@ Ext.define('Traccar.view.ServerDialog', { }, { name: 'zoom', fieldLabel: Strings.serverZoom - }, { - xtype: 'button', - margin: Traccar.Style.inFormButtonMargin, - enableToggle: false, - text: Strings.sharedGetFromMap, - handler: 'getFromMap' }] }, { xtype: 'checkboxfield', @@ -94,5 +87,24 @@ Ext.define('Traccar.view.ServerDialog', { fieldLabel: Strings.settingsTwelveHourFormat, allowBlank: false }] - } + }, + + buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + glyph: 'xf276@FontAwesome', + minWidth: 0, + handler: 'getFromMap', + tooltip: Strings.sharedGetFromMap, + tooltipType: 'title' + }, { + xtype: 'tbfill' + }, { + text: Strings.sharedSave, + handler: 'onSaveClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' + }] }); diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index c6b732513..46b86dd5d 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -24,7 +24,7 @@ Ext.define('Traccar.view.UserDialog', { controller: 'userDialog', title: Strings.settingsUser, - items: [{ + items: { xtype: 'form', items: [{ xtype: 'textfield', @@ -70,9 +70,8 @@ Ext.define('Traccar.view.UserDialog', { displayField: 'name', valueField: 'key' }, { - xtype: 'fieldset', + xtype: 'fieldcontainer', reference: 'mapCenter', - title: Strings.sharedMapCenter, defaultType: 'numberfield', items: [{ name: 'latitude', @@ -85,12 +84,6 @@ Ext.define('Traccar.view.UserDialog', { }, { name: 'zoom', fieldLabel: Strings.serverZoom - }, { - xtype: 'button', - margin: Traccar.Style.inFormButtonMargin, - enableToggle: false, - text: Strings.sharedGetFromMap, - handler: 'getFromMap' }] }, { xtype: 'checkboxfield', @@ -98,5 +91,24 @@ Ext.define('Traccar.view.UserDialog', { fieldLabel: Strings.settingsTwelveHourFormat, allowBlank: false }] + }, + + buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + glyph: 'xf276@FontAwesome', + minWidth: 0, + handler: 'getFromMap', + tooltip: Strings.sharedGetFromMap, + tooltipType: 'title' + }, { + xtype: 'tbfill' + }, { + text: Strings.sharedSave, + handler: 'onSaveClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' }] }); diff --git a/web/l10n/en.json b/web/l10n/en.json index e06daad93..88f572e33 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -28,7 +28,6 @@ "sharedDistance": "Distance", "sharedHourAbbreviation": "h", "sharedMinuteAbbreviation": "m", - "sharedMapCenter": "Map Center", "sharedGetFromMap": "Get from Map", "errorTitle": "Error", "errorUnknown": "Unknown error", -- cgit v1.2.3 From 97e80ec49fddec3d56880bae47bd070474fa8fa3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 6 Sep 2016 15:58:03 +0500 Subject: - Remove field container - Renamed functions and strings --- web/app/view/MapController.js | 6 +++--- web/app/view/ServerDialog.js | 37 +++++++++++++++++----------------- web/app/view/ServerDialogController.js | 15 +++++++------- web/app/view/UserDialog.js | 37 +++++++++++++++++----------------- web/l10n/en.json | 2 +- 5 files changed, 49 insertions(+), 48 deletions(-) (limited to 'web/app/view/ServerDialog.js') diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index 288593dab..c0ac2c534 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -24,7 +24,7 @@ Ext.define('Traccar.view.MapController', { '*': { selectDevice: 'selectDevice', selectReport: 'selectReport', - getMapCenter: 'getMapCenter' + mapstaterequest: 'getMapState' } }, store: { @@ -307,11 +307,11 @@ Ext.define('Traccar.view.MapController', { } }, - getMapCenter: function () { + getMapState: function () { var zoom, center, projection; projection = this.getView().getMapView().getProjection(); center = ol.proj.transform(this.getView().getMapView().getCenter(), projection, 'EPSG:4326'); zoom = this.getView().getMapView().getZoom(); - this.fireEvent('setCenterFromMap', center[1], center[0], zoom); + this.fireEvent('mapstate', center[1], center[0], zoom); } }); diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index 83f9c47f2..40afa4ec3 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -66,21 +66,22 @@ Ext.define('Traccar.view.ServerDialog', { displayField: 'name', valueField: 'key' }, { - xtype: 'fieldcontainer', - reference: 'mapCenter', - defaultType: 'numberfield', - items: [{ - name: 'latitude', - fieldLabel: Strings.positionLatitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - name: 'longitude', - fieldLabel: Strings.positionLongitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - name: 'zoom', - fieldLabel: Strings.serverZoom - }] + xtype: 'numberfield', + reference: 'latitude', + name: 'latitude', + fieldLabel: Strings.positionLatitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'longitude', + name: 'longitude', + fieldLabel: Strings.positionLongitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'zoom', + name: 'zoom', + fieldLabel: Strings.serverZoom }, { xtype: 'checkboxfield', name: 'twelveHourFormat', @@ -93,10 +94,10 @@ Ext.define('Traccar.view.ServerDialog', { text: Strings.sharedAttributes, handler: 'showAttributesView' }, { - glyph: 'xf276@FontAwesome', + glyph: 'xf041@FontAwesome', minWidth: 0, - handler: 'getFromMap', - tooltip: Strings.sharedGetFromMap, + handler: 'getMapState', + tooltip: Strings.sharedGetMapState, tooltipType: 'title' }, { xtype: 'tbfill' diff --git a/web/app/view/ServerDialogController.js b/web/app/view/ServerDialogController.js index 42760ca58..55f49f676 100644 --- a/web/app/view/ServerDialogController.js +++ b/web/app/view/ServerDialogController.js @@ -23,20 +23,19 @@ Ext.define('Traccar.view.ServerDialogController', { listen: { controller: { '*': { - setCenterFromMap: 'setCenterFromMap' + mapstate: 'setMapState' } } } }, - getFromMap: function (button) { - this.fireEvent('getMapCenter'); + getMapState: function (button) { + this.fireEvent('mapstaterequest'); }, - setCenterFromMap: function (lat, lon, zoom) { - var mapCenter = this.lookupReference('mapCenter'); - mapCenter.down('numberfield[name="latitude"]').setValue(lat); - mapCenter.down('numberfield[name="longitude"]').setValue(lon); - mapCenter.down('numberfield[name="zoom"]').setValue(zoom); + setMapState: function (lat, lon, zoom) { + this.getView().lookupReference('latitude').setValue(lat); + this.getView().lookupReference('longitude').setValue(lon); + this.getView().lookupReference('zoom').setValue(zoom); } }); diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index 46b86dd5d..f9e704ee5 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -70,21 +70,22 @@ Ext.define('Traccar.view.UserDialog', { displayField: 'name', valueField: 'key' }, { - xtype: 'fieldcontainer', - reference: 'mapCenter', - defaultType: 'numberfield', - items: [{ - name: 'latitude', - fieldLabel: Strings.positionLatitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - name: 'longitude', - fieldLabel: Strings.positionLongitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - name: 'zoom', - fieldLabel: Strings.serverZoom - }] + xtype: 'numberfield', + reference: 'latitude', + name: 'latitude', + fieldLabel: Strings.positionLatitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'longitude', + name: 'longitude', + fieldLabel: Strings.positionLongitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'zoom', + name: 'zoom', + fieldLabel: Strings.serverZoom }, { xtype: 'checkboxfield', name: 'twelveHourFormat', @@ -97,10 +98,10 @@ Ext.define('Traccar.view.UserDialog', { text: Strings.sharedAttributes, handler: 'showAttributesView' }, { - glyph: 'xf276@FontAwesome', + glyph: 'xf041@FontAwesome', minWidth: 0, - handler: 'getFromMap', - tooltip: Strings.sharedGetFromMap, + handler: 'getMapState', + tooltip: Strings.sharedGetMapState, tooltipType: 'title' }, { xtype: 'tbfill' diff --git a/web/l10n/en.json b/web/l10n/en.json index 88f572e33..e61710523 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -28,7 +28,7 @@ "sharedDistance": "Distance", "sharedHourAbbreviation": "h", "sharedMinuteAbbreviation": "m", - "sharedGetFromMap": "Get from Map", + "sharedGetMapState": "Get Map State", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", -- cgit v1.2.3 From d7afbb815c7d185df9143f886a7494cb73a69ac1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 6 Sep 2016 16:31:13 +0500 Subject: - Rename ServerDialogController to MapPickerDialogController - removed getView() --- web/app/view/MapPickerDialogController.js | 41 +++++++++++++++++++++++++++++++ web/app/view/ServerDialog.js | 4 +-- web/app/view/ServerDialogController.js | 41 ------------------------------- web/app/view/UserDialogController.js | 2 +- 4 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 web/app/view/MapPickerDialogController.js delete mode 100644 web/app/view/ServerDialogController.js (limited to 'web/app/view/ServerDialog.js') diff --git a/web/app/view/MapPickerDialogController.js b/web/app/view/MapPickerDialogController.js new file mode 100644 index 000000000..4f202d195 --- /dev/null +++ b/web/app/view/MapPickerDialogController.js @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.define('Traccar.view.MapPickerDialogController', { + extend: 'Traccar.view.BaseEditDialogController', + alias: 'controller.mapPickerDialog', + + config: { + listen: { + controller: { + '*': { + mapstate: 'setMapState' + } + } + } + }, + + getMapState: function (button) { + this.fireEvent('mapstaterequest'); + }, + + setMapState: function (lat, lon, zoom) { + this.lookupReference('latitude').setValue(lat); + this.lookupReference('longitude').setValue(lon); + this.lookupReference('zoom').setValue(zoom); + } +}); diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js index 40afa4ec3..46c76ffa8 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -18,10 +18,10 @@ Ext.define('Traccar.view.ServerDialog', { extend: 'Traccar.view.BaseEditDialog', requires: [ - 'Traccar.view.ServerDialogController' + 'Traccar.view.MapPickerDialogController' ], - controller: 'serverEditDialog', + controller: 'mapPickerDialog', title: Strings.serverTitle, items: { diff --git a/web/app/view/ServerDialogController.js b/web/app/view/ServerDialogController.js deleted file mode 100644 index 55f49f676..000000000 --- a/web/app/view/ServerDialogController.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) - * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.define('Traccar.view.ServerDialogController', { - extend: 'Traccar.view.BaseEditDialogController', - alias: 'controller.serverEditDialog', - - config: { - listen: { - controller: { - '*': { - mapstate: 'setMapState' - } - } - } - }, - - getMapState: function (button) { - this.fireEvent('mapstaterequest'); - }, - - setMapState: function (lat, lon, zoom) { - this.getView().lookupReference('latitude').setValue(lat); - this.getView().lookupReference('longitude').setValue(lon); - this.getView().lookupReference('zoom').setValue(zoom); - } -}); diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js index 5e541c870..52d649b9c 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -15,7 +15,7 @@ */ Ext.define('Traccar.view.UserDialogController', { - extend: 'Traccar.view.ServerDialogController', + extend: 'Traccar.view.MapPickerDialogController', alias: 'controller.userDialog', init: function () { -- cgit v1.2.3