aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-12-21 17:48:08 +0500
committerAbyss777 <abyss@fox5.ru>2016-12-21 18:05:28 +0500
commitb9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7 (patch)
tree372b47bd8f30216f9eb369a885e76e67378eb979
parent19d6e1c9cc916ed4c1ed72fe168909770a657db2 (diff)
downloadetbsa-traccar-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.tar.gz
etbsa-traccar-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.tar.bz2
etbsa-traccar-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.zip
Save toggles state in user/server attributes
-rw-r--r--web/app/view/Map.js2
-rw-r--r--web/app/view/MapController.js20
-rw-r--r--web/app/view/MapPickerDialogController.js12
-rw-r--r--web/app/view/ServerDialog.js6
-rw-r--r--web/app/view/UserDialog.js6
-rw-r--r--web/l10n/en.json1
6 files changed, 43 insertions, 4 deletions
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index be17b88..2cc37ec 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -48,7 +48,6 @@ Ext.define('Traccar.view.Map', {
reference: 'showGeofencesButton',
glyph: 'xf21d@FontAwesome',
enableToggle: true,
- pressed: true,
tooltip: Strings.sharedGeofences
}, {
xtype: 'button',
@@ -70,7 +69,6 @@ Ext.define('Traccar.view.Map', {
glyph: 'xf1f7@FontAwesome',
tooltip: Strings.sharedMute,
tooltipType: 'title',
- pressed : true,
enableToggle: true,
listeners: {
toggle: function (button, pressed) {
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index c52fdd5..b8e2657 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -27,7 +27,8 @@ Ext.define('Traccar.view.MapController', {
listen: {
controller: {
'*': {
- mapstaterequest: 'getMapState'
+ mapstaterequest: 'getMapState',
+ togglestaterequest: 'getToggleState'
}
},
store: {
@@ -44,6 +45,14 @@ Ext.define('Traccar.view.MapController', {
init: function () {
this.callParent();
this.lookupReference('showReportsButton').setVisible(Traccar.app.isMobile());
+ this.lookupReference('deviceFollowButton').setPressed(
+ Traccar.app.getAttributePreference('web.followToggle', 'false') === 'true');
+ this.lookupReference('showGeofencesButton').setPressed(
+ Traccar.app.getAttributePreference('web.geofenceToggle', 'true') === 'true');
+ this.lookupReference('showLiveRoutes').setPressed(
+ Traccar.app.getAttributePreference('web.liveRouteToggle', 'false') === 'true');
+ Ext.getCmp('muteButton').setPressed(
+ Traccar.app.getAttributePreference('web.muteToggle', 'true') === 'true');
},
showReports: function () {
@@ -68,6 +77,15 @@ Ext.define('Traccar.view.MapController', {
this.fireEvent('mapstate', center[1], center[0], zoom);
},
+ getToggleState: function () {
+ var state = {};
+ state['web.followToggle'] = this.lookupReference('deviceFollowButton').pressed.toString();
+ state['web.geofenceToggle'] = this.lookupReference('showGeofencesButton').pressed.toString();
+ state['web.liveRouteToggle'] = this.lookupReference('showLiveRoutes').pressed.toString();
+ state['web.muteToggle'] = Ext.getCmp('muteButton').pressed.toString();
+ this.fireEvent('togglestate', state);
+ },
+
getGeofenceStyle: function (label) {
return new ol.style.Style({
fill: new ol.style.Fill({
diff --git a/web/app/view/MapPickerDialogController.js b/web/app/view/MapPickerDialogController.js
index 1dc48ea..6a3b1a5 100644
--- a/web/app/view/MapPickerDialogController.js
+++ b/web/app/view/MapPickerDialogController.js
@@ -24,7 +24,8 @@ Ext.define('Traccar.view.MapPickerDialogController', {
listen: {
controller: {
'*': {
- mapstate: 'setMapState'
+ mapstate: 'setMapState',
+ togglestate: 'setToggleState'
}
}
}
@@ -34,9 +35,18 @@ Ext.define('Traccar.view.MapPickerDialogController', {
this.fireEvent('mapstaterequest');
},
+ getToggleState: function (button) {
+ this.fireEvent('togglestaterequest');
+ },
+
setMapState: function (lat, lon, zoom) {
this.lookupReference('latitude').setValue(lat);
this.lookupReference('longitude').setValue(lon);
this.lookupReference('zoom').setValue(zoom);
+ },
+
+ setToggleState: function (state) {
+ var record = this.getView().down('form').getRecord();
+ record.set('attributes', Ext.merge(record.get('attributes'), state));
}
});
diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js
index 0a05876..667bf47 100644
--- a/web/app/view/ServerDialog.js
+++ b/web/app/view/ServerDialog.js
@@ -125,6 +125,12 @@ Ext.define('Traccar.view.ServerDialog', {
tooltip: Strings.sharedGetMapState,
tooltipType: 'title'
}, {
+ glyph: 'xf205@FontAwesome',
+ minWidth: 0,
+ handler: 'getToggleState',
+ tooltip: Strings.sharedGetToggleState,
+ tooltipType: 'title'
+ }, {
xtype: 'tbfill'
}, {
glyph: 'xf00c@FontAwesome',
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index 8ee1243..02e7b2f 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -163,6 +163,12 @@ Ext.define('Traccar.view.UserDialog', {
tooltip: Strings.sharedGetMapState,
tooltipType: 'title'
}, {
+ glyph: 'xf205@FontAwesome',
+ minWidth: 0,
+ handler: 'getToggleState',
+ tooltip: Strings.sharedGetToggleState,
+ tooltipType: 'title'
+ }, {
glyph: 'xf003@FontAwesome',
minWidth: 0,
handler: 'testMail',
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 39376be..3c7a965 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -35,6 +35,7 @@
"sharedHourAbbreviation": "h",
"sharedMinuteAbbreviation": "m",
"sharedGetMapState": "Get Map State",
+ "sharedGetToggleState": "Get Toggle State",
"sharedAttributeAlias": "Attribute Alias",
"sharedAttributeAliases": "Attribute Aliases",
"sharedAlias": "Alias",