diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-22 16:57:16 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 16:57:16 +1300 |
commit | 5bccab1d99586777b346d474b34b764e3b595a92 (patch) | |
tree | 3a937a480a288a4aa38d796a00fb5cb764af80eb | |
parent | 0c7ff9b0366abe63f9c690fa4507b8f28af4bd7b (diff) | |
parent | b9fda5b5d6630fec90b263a0dbcdcdaf24ed43e7 (diff) | |
download | trackermap-web-5bccab1d99586777b346d474b34b764e3b595a92.tar.gz trackermap-web-5bccab1d99586777b346d474b34b764e3b595a92.tar.bz2 trackermap-web-5bccab1d99586777b346d474b34b764e3b595a92.zip |
Merge pull request #365 from Abyss777/save_toggles
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", |