diff options
author | Abyss777 <abyss@fox5.ru> | 2016-12-21 17:48:08 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-12-21 18:05:28 +0500 |
commit | b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7 (patch) | |
tree | 372b47bd8f30216f9eb369a885e76e67378eb979 | |
parent | 19d6e1c9cc916ed4c1ed72fe168909770a657db2 (diff) | |
download | trackermap-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.tar.gz trackermap-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.tar.bz2 trackermap-web-b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7.zip |
Save toggles state in user/server attributes
-rw-r--r-- | web/app/view/Map.js | 2 | ||||
-rw-r--r-- | web/app/view/MapController.js | 20 | ||||
-rw-r--r-- | web/app/view/MapPickerDialogController.js | 12 | ||||
-rw-r--r-- | web/app/view/ServerDialog.js | 6 | ||||
-rw-r--r-- | web/app/view/UserDialog.js | 6 | ||||
-rw-r--r-- | web/l10n/en.json | 1 |
6 files changed, 43 insertions, 4 deletions
diff --git a/web/app/view/Map.js b/web/app/view/Map.js index be17b889..2cc37ecb 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 c52fdd5f..b8e2657d 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 1dc48ea0..6a3b1a51 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 0a05876e..667bf47f 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 8ee12437..02e7b2fc 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 39376bea..3c7a965b 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", |