aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-25 17:27:25 +1300
committerGitHub <noreply@github.com>2017-03-25 17:27:25 +1300
commitd68f47ef27eb6afc28444f2e7e0a8310ae4f25b5 (patch)
tree40ac870d42f129cd38bd43410cc7080cfdc3711c /web/app
parent49eebb3a0d11e3c4d6f6951312e44bf65ce02906 (diff)
parentd1a21515aec2d8b6c0ecbc4ca10c54f594e4820e (diff)
downloadtrackermap-web-d68f47ef27eb6afc28444f2e7e0a8310ae4f25b5.tar.gz
trackermap-web-d68f47ef27eb6afc28444f2e7e0a8310ae4f25b5.tar.bz2
trackermap-web-d68f47ef27eb6afc28444f2e7e0a8310ae4f25b5.zip
Merge pull request #447 from Abyss777/save_state
Use cookies to save buttons state instead of User/Server attributes
Diffstat (limited to 'web/app')
-rw-r--r--web/app/controller/Root.js8
-rw-r--r--web/app/view/Map.js47
-rw-r--r--web/app/view/MapController.js18
-rw-r--r--web/app/view/MapPickerDialogController.js12
-rw-r--r--web/app/view/ServerDialog.js6
-rw-r--r--web/app/view/UserDialog.js6
6 files changed, 26 insertions, 71 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index e8d4f0ff..673f7fb3 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -114,9 +114,9 @@ Ext.define('Traccar.controller.Root', {
this.beepSound.play();
},
- mutePressed: function () {
- var muteButton = Ext.getCmp('muteButton');
- return muteButton && !muteButton.pressed;
+ soundPressed: function () {
+ var soundButton = Ext.getCmp('soundButton');
+ return soundButton && soundButton.pressed;
},
removeUrlParameter: function (param) {
@@ -231,7 +231,7 @@ Ext.define('Traccar.controller.Root', {
}
device = Ext.getStore('Devices').getById(array[i].deviceId);
if (device) {
- if (this.mutePressed()) {
+ if (this.soundPressed()) {
this.beep();
}
Ext.toast(text, device.get('name'), 'br');
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index ebc6bbb0..a3879ab9 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -29,6 +29,15 @@ Ext.define('Traccar.view.Map', {
title: Strings.mapTitle,
tbar: {
componentCls: 'toolbar-header-style',
+ defaults: {
+ xtype: 'button',
+ tooltipType: 'title',
+ stateEvents: ['toggle'],
+ enableToggle: true,
+ stateful: {
+ pressed: true
+ }
+ },
items: [{
xtype: 'tbtext',
html: Strings.mapTitle,
@@ -36,53 +45,39 @@ Ext.define('Traccar.view.Map', {
}, {
xtype: 'tbfill'
}, {
- xtype: 'button',
- tooltipType: 'title',
handler: 'showReports',
reference: 'showReportsButton',
glyph: 'xf0f6@FontAwesome',
+ stateful: false,
+ enableToggle: false,
tooltip: Strings.reportTitle
}, {
- xtype: 'button',
- tooltipType: 'title',
handler: 'updateGeofences',
reference: 'showGeofencesButton',
glyph: 'xf21d@FontAwesome',
- enableToggle: true,
+ pressed: true,
+ stateId: 'show-geofences-button',
tooltip: Strings.sharedGeofences
}, {
- xtype: 'button',
- tooltipType: 'title',
handler: 'showLiveRoutes',
reference: 'showLiveRoutes',
glyph: 'xf1b0@FontAwesome',
- enableToggle: true,
+ stateId: 'show-live-routes-button',
tooltip: Strings.mapLiveRoutes
}, {
reference: 'deviceFollowButton',
glyph: 'xf05b@FontAwesome',
tooltip: Strings.deviceFollow,
- tooltipType: 'title',
- enableToggle: true,
+ stateId: 'device-follow-button',
toggleHandler: 'onFollowClick'
}, {
- id: 'muteButton',
- glyph: 'xf1f7@FontAwesome',
- tooltip: Strings.sharedMute,
- tooltipType: 'title',
- enableToggle: true,
- listeners: {
- toggle: function (button, pressed) {
- if (pressed) {
- button.setGlyph('xf1f7@FontAwesome');
- } else {
- button.setGlyph('xf0a2@FontAwesome');
- }
- },
- scope: this
- }
+ id: 'soundButton',
+ glyph: 'xf0a2@FontAwesome',
+ tooltip: Strings.sharedSound,
+ stateId: 'sound-button'
}, {
- xtype: 'settingsMenu'
+ xtype: 'settingsMenu',
+ enableToggle: false
}]
},
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index 57727f20..04e8c448 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -28,7 +28,6 @@ Ext.define('Traccar.view.MapController', {
controller: {
'*': {
mapstaterequest: 'getMapState',
- togglestaterequest: 'getToggleState',
zoomtoalldevices: 'zoomToAllDevices'
}
},
@@ -46,14 +45,6 @@ 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 () {
@@ -78,15 +69,6 @@ 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);
- },
-
updateGeofences: function () {
this.getView().getGeofencesSource().clear();
if (this.lookupReference('showGeofencesButton').pressed) {
diff --git a/web/app/view/MapPickerDialogController.js b/web/app/view/MapPickerDialogController.js
index 6a3b1a51..1dc48ea0 100644
--- a/web/app/view/MapPickerDialogController.js
+++ b/web/app/view/MapPickerDialogController.js
@@ -24,8 +24,7 @@ Ext.define('Traccar.view.MapPickerDialogController', {
listen: {
controller: {
'*': {
- mapstate: 'setMapState',
- togglestate: 'setToggleState'
+ mapstate: 'setMapState'
}
}
}
@@ -35,18 +34,9 @@ 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 bba5e729..13ddcb31 100644
--- a/web/app/view/ServerDialog.js
+++ b/web/app/view/ServerDialog.js
@@ -150,12 +150,6 @@ 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 874f9f00..8df7f2ff 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -202,12 +202,6 @@ 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: 'testNotification',