aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-09-06 23:33:09 +1200
committerGitHub <noreply@github.com>2016-09-06 23:33:09 +1200
commit5e6a5e69994aff3c1fe9aca427c746438a22c325 (patch)
treeae00dce3f93e1a1b44de84dc1f38aa0cdc4be43b
parent0d3c05a24992eeeba02032e474d3a9bbb3239f10 (diff)
parentd7afbb815c7d185df9143f886a7494cb73a69ac1 (diff)
downloadtrackermap-server-5e6a5e69994aff3c1fe9aca427c746438a22c325.tar.gz
trackermap-server-5e6a5e69994aff3c1fe9aca427c746438a22c325.tar.bz2
trackermap-server-5e6a5e69994aff3c1fe9aca427c746438a22c325.zip
Merge pull request #2287 from Abyss777/get_center_from_map
Retrieve map state for user and server
-rw-r--r--web/app/view/BaseMap.js2
-rw-r--r--web/app/view/DevicesController.js8
-rw-r--r--web/app/view/GeofenceDialogController.js2
-rw-r--r--web/app/view/GeofenceMapController.js2
-rw-r--r--web/app/view/MapController.js19
-rw-r--r--web/app/view/MapPickerDialogController.js41
-rw-r--r--web/app/view/ReportController.js6
-rw-r--r--web/app/view/ServerDialog.js28
-rw-r--r--web/app/view/UserDialog.js24
-rw-r--r--web/app/view/UserDialogController.js2
-rw-r--r--web/l10n/en.json1
11 files changed, 115 insertions, 20 deletions
diff --git a/web/app/view/BaseMap.js b/web/app/view/BaseMap.js
index 77646cbef..62b2c5735 100644
--- a/web/app/view/BaseMap.js
+++ b/web/app/view/BaseMap.js
@@ -100,7 +100,7 @@ Ext.define('Traccar.view.BaseMap', {
this.map.on('click', function (e) {
this.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
- this.fireEvent('selectFeature', feature);
+ this.fireEvent('selectfeature', feature);
}, this);
}, this);
},
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js
index 6dcc45448..68dd16025 100644
--- a/web/app/view/DevicesController.js
+++ b/web/app/view/DevicesController.js
@@ -31,8 +31,8 @@ Ext.define('Traccar.view.DevicesController', {
listen: {
controller: {
'*': {
- selectDevice: 'selectDevice',
- selectReport: 'selectReport'
+ selectdevice: 'selectDevice',
+ selectreport: 'selectReport'
}
},
store: {
@@ -121,7 +121,7 @@ Ext.define('Traccar.view.DevicesController', {
var device;
if (pressed) {
device = this.getView().getSelectionModel().getSelection()[0];
- this.fireEvent('selectDevice', device, true);
+ this.fireEvent('selectdevice', device, true);
}
},
@@ -136,7 +136,7 @@ Ext.define('Traccar.view.DevicesController', {
onSelectionChange: function (selected) {
this.updateButtons(selected);
if (selected.getCount() > 0) {
- this.fireEvent('selectDevice', selected.getLastSelected(), true);
+ this.fireEvent('selectdevice', selected.getLastSelected(), true);
}
},
diff --git a/web/app/view/GeofenceDialogController.js b/web/app/view/GeofenceDialogController.js
index b04935b9c..5638db362 100644
--- a/web/app/view/GeofenceDialogController.js
+++ b/web/app/view/GeofenceDialogController.js
@@ -26,7 +26,7 @@ Ext.define('Traccar.view.GeofenceDialogController', {
listen: {
controller: {
'*': {
- saveArea: 'saveArea'
+ savearea: 'saveArea'
}
}
}
diff --git a/web/app/view/GeofenceMapController.js b/web/app/view/GeofenceMapController.js
index d643c89e4..c508127d7 100644
--- a/web/app/view/GeofenceMapController.js
+++ b/web/app/view/GeofenceMapController.js
@@ -27,7 +27,7 @@ Ext.define('Traccar.view.GeofenceMapController', {
if (this.getView().getFeatures().getLength() > 0) {
geometry = this.getView().getFeatures().pop().getGeometry();
projection = this.getView().getMapView().getProjection();
- this.fireEvent('saveArea', Traccar.GeofenceConverter.geometryToWkt(projection, geometry));
+ this.fireEvent('savearea', Traccar.GeofenceConverter.geometryToWkt(projection, geometry));
button.up('window').close();
}
},
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index bc6a5d404..3b0db6b07 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -22,8 +22,9 @@ Ext.define('Traccar.view.MapController', {
listen: {
controller: {
'*': {
- selectDevice: 'selectDevice',
- selectReport: 'selectReport'
+ selectdevice: 'selectDevice',
+ selectreport: 'selectReport',
+ mapstaterequest: 'getMapState'
}
},
store: {
@@ -42,7 +43,7 @@ Ext.define('Traccar.view.MapController', {
},
component: {
'#': {
- selectFeature: 'selectFeature'
+ selectfeature: 'selectFeature'
}
}
}
@@ -299,10 +300,18 @@ Ext.define('Traccar.view.MapController', {
var record = feature.get('record');
if (record) {
if (record instanceof Traccar.model.Device) {
- this.fireEvent('selectDevice', record, false);
+ this.fireEvent('selectdevice', record, false);
} else {
- this.fireEvent('selectReport', record, false);
+ this.fireEvent('selectreport', record, false);
}
}
+ },
+
+ 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('mapstate', center[1], center[0], zoom);
}
});
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/ReportController.js b/web/app/view/ReportController.js
index 3a3345d83..a6253952a 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -29,8 +29,8 @@ Ext.define('Traccar.view.ReportController', {
listen: {
controller: {
'*': {
- selectDevice: 'selectDevice',
- selectReport: 'selectReport'
+ selectdevice: 'selectDevice',
+ selectreport: 'selectReport'
}
}
}
@@ -116,7 +116,7 @@ Ext.define('Traccar.view.ReportController', {
onSelectionChange: function (selected) {
if (selected.getCount() > 0) {
- this.fireEvent('selectReport', selected.getLastSelected(), true);
+ this.fireEvent('selectreport', selected.getLastSelected(), true);
}
},
diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js
index dd4579168..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.BaseEditDialogController'
+ 'Traccar.view.MapPickerDialogController'
],
- controller: 'baseEditDialog',
+ controller: 'mapPickerDialog',
title: Strings.serverTitle,
items: {
@@ -67,16 +67,19 @@ Ext.define('Traccar.view.ServerDialog', {
valueField: 'key'
}, {
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
}, {
@@ -85,5 +88,24 @@ Ext.define('Traccar.view.ServerDialog', {
fieldLabel: Strings.settingsTwelveHourFormat,
allowBlank: false
}]
- }
+ },
+
+ buttons: [{
+ text: Strings.sharedAttributes,
+ handler: 'showAttributesView'
+ }, {
+ glyph: 'xf041@FontAwesome',
+ minWidth: 0,
+ handler: 'getMapState',
+ tooltip: Strings.sharedGetMapState,
+ 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 07fc1431f..f9e704ee5 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',
@@ -71,16 +71,19 @@ Ext.define('Traccar.view.UserDialog', {
valueField: 'key'
}, {
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
}, {
@@ -89,5 +92,24 @@ Ext.define('Traccar.view.UserDialog', {
fieldLabel: Strings.settingsTwelveHourFormat,
allowBlank: false
}]
+ },
+
+ buttons: [{
+ text: Strings.sharedAttributes,
+ handler: 'showAttributesView'
+ }, {
+ glyph: 'xf041@FontAwesome',
+ minWidth: 0,
+ handler: 'getMapState',
+ tooltip: Strings.sharedGetMapState,
+ tooltipType: 'title'
+ }, {
+ xtype: 'tbfill'
+ }, {
+ text: Strings.sharedSave,
+ handler: 'onSaveClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
}]
});
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index c3a4ca62d..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.BaseEditDialogController',
+ extend: 'Traccar.view.MapPickerDialogController',
alias: 'controller.userDialog',
init: function () {
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 563a37b18..e61710523 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -28,6 +28,7 @@
"sharedDistance": "Distance",
"sharedHourAbbreviation": "h",
"sharedMinuteAbbreviation": "m",
+ "sharedGetMapState": "Get Map State",
"errorTitle": "Error",
"errorUnknown": "Unknown error",
"errorConnection": "Connection error",