aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-09-05 14:27:30 +0500
committerAbyss777 <abyss@fox5.ru>2016-09-05 14:27:30 +0500
commitb7403aaadd130bf1496b97c07667842813d99550 (patch)
tree4a334be60e150b729fd8115e8227afb98cd8f8ff /web
parent6aca189651d8587b9178a38c1830a8cbd8ae0d46 (diff)
downloadtrackermap-server-b7403aaadd130bf1496b97c07667842813d99550.tar.gz
trackermap-server-b7403aaadd130bf1496b97c07667842813d99550.tar.bz2
trackermap-server-b7403aaadd130bf1496b97c07667842813d99550.zip
Implement retrieving map center from current map
Diffstat (limited to 'web')
-rw-r--r--web/app/Style.js4
-rw-r--r--web/app/view/MapController.js11
-rw-r--r--web/app/view/ServerDialog.js39
-rw-r--r--web/app/view/ServerDialogController.js42
-rw-r--r--web/app/view/UserDialog.js35
-rw-r--r--web/app/view/UserDialogController.js2
-rw-r--r--web/l10n/en.json2
7 files changed, 104 insertions, 31 deletions
diff --git a/web/app/Style.js b/web/app/Style.js
index b3b296b75..034d2fb0b 100644
--- a/web/app/Style.js
+++ b/web/app/Style.js
@@ -75,5 +75,7 @@ Ext.define('Traccar.Style', {
coordinatePrecision: 6,
numberPrecision: 2,
- reportTagfieldWidth: 375
+ reportTagfieldWidth: 375,
+
+ inFormButtonMargin: '0 0 9 0'
});
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index bc6a5d404..288593dab 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -23,7 +23,8 @@ Ext.define('Traccar.view.MapController', {
controller: {
'*': {
selectDevice: 'selectDevice',
- selectReport: 'selectReport'
+ selectReport: 'selectReport',
+ getMapCenter: 'getMapCenter'
}
},
store: {
@@ -304,5 +305,13 @@ Ext.define('Traccar.view.MapController', {
this.fireEvent('selectReport', record, false);
}
}
+ },
+
+ getMapCenter: 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);
}
});
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',
diff --git a/web/app/view/ServerDialogController.js b/web/app/view/ServerDialogController.js
new file mode 100644
index 000000000..42760ca58
--- /dev/null
+++ b/web/app/view/ServerDialogController.js
@@ -0,0 +1,42 @@
+/*
+ * 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: {
+ '*': {
+ setCenterFromMap: 'setCenterFromMap'
+ }
+ }
+ }
+ },
+
+ getFromMap: function (button) {
+ this.fireEvent('getMapCenter');
+ },
+
+ 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);
+ }
+});
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index 07fc1431f..c6b732513 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -70,19 +70,28 @@ Ext.define('Traccar.view.UserDialog', {
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',
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index c3a4ca62d..5e541c870 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.BaseEditDialogController',
+ extend: 'Traccar.view.ServerDialogController',
alias: 'controller.userDialog',
init: function () {
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 563a37b18..e06daad93 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -28,6 +28,8 @@
"sharedDistance": "Distance",
"sharedHourAbbreviation": "h",
"sharedMinuteAbbreviation": "m",
+ "sharedMapCenter": "Map Center",
+ "sharedGetFromMap": "Get from Map",
"errorTitle": "Error",
"errorUnknown": "Unknown error",
"errorConnection": "Connection error",