diff options
author | ninioe <ninioe@gmail.com> | 2016-07-12 16:04:40 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-07-12 16:04:40 +0300 |
commit | d045c1e2174146ddc8ad8b2ef4442863f3d84a11 (patch) | |
tree | 458ac9a09ef9df6426a34067072164c44ac18020 /web/app/view | |
parent | 8d5b4ec5ec8e4aaa2c34793e3100a7782551afbd (diff) | |
download | traccar-server-d045c1e2174146ddc8ad8b2ef4442863f3d84a11.tar.gz traccar-server-d045c1e2174146ddc8ad8b2ef4442863f3d84a11.tar.bz2 traccar-server-d045c1e2174146ddc8ad8b2ef4442863f3d84a11.zip |
Added support for Alarm popup & positions history cleaner
1. added support for Alarm and Alarm Type in popup and also in history
records. can be muted with a toggle button in the UI
2. added a timer to clear positions history once a day. the default is
to save positions history for 7 days if not defined in the configuration
file.
3. prevent the lock of the UI files (js, html, css, etc..) for wondows
developers in debug mode. It's easier to do changes to the UI without
stopping the app each time.
4. tools: added support in test-generator.py to simulate Alert, also
added minify.bat file to compile new js files for the UI using sencha
SDK for windows developers
Diffstat (limited to 'web/app/view')
-rw-r--r-- | web/app/view/Devices.js | 20 | ||||
-rw-r--r-- | web/app/view/Report.js | 10 | ||||
-rw-r--r-- | web/app/view/StateController.js | 49 |
3 files changed, 79 insertions, 0 deletions
diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 1a70dfef8..4227fd1fb 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -57,6 +57,26 @@ Ext.define('Traccar.view.Devices', { tooltipType: 'title' }, { xtype: 'tbfill' + },{ + id: 'showAlarmButton',//added by Erez + glyph: 'xf0a2@FontAwesome', + tooltip: 'Show Alarms', + tooltipType: 'title', + pressed : true, + enableToggle: true, + listeners:{ + toggle: function(button, pressed){ + if(pressed){ + button.setGlyph('xf0a2@FontAwesome'); + //Ext.getCmp('useAlarmSoundButton').enable(); + } + else { + button.setGlyph('xf1f7@FontAwesome'); + //Ext.getCmp('useAlarmSoundButton').disable(); + } + }, + scope:this + } }, { id: 'deviceFollowButton', glyph: 'xf05b@FontAwesome', diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 4261b9040..fcbd5c028 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -115,5 +115,15 @@ Ext.define('Traccar.view.Report', { dataIndex: 'address', flex: 1, renderer: Traccar.AttributeFormatter.getFormatter('address') + }, { + text: 'Alarm',//added by Erez + dataIndex: 'attributes', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('alarm') + }, { + text: 'Alarm Type',//added by Erez + dataIndex: 'attributes', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('alarm-type') }] }); diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 01df6645d..20b6145ec 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -62,6 +62,11 @@ Ext.define('Traccar.view.StateController', { if (this.deviceId === data[i].get('deviceId')) { this.updatePosition(data[i]); } + var position = data[i]; //added by Erez + var attributes = position.get('attributes'); + if (attributes instanceof Object){ + if (attributes.hasOwnProperty('alarm') && this.showAlarmSelected()) this.onAlarm(position.get('deviceId'), attributes); + } } }, @@ -104,6 +109,50 @@ Ext.define('Traccar.view.StateController', { } }, + showAlarmSelected: function () {//added by Erez + return Ext.getCmp('showAlarmButton') && Ext.getCmp('showAlarmButton').pressed; + }, + + onAlarm: function(deviceId, attributes){//added by Erez + var alatmType = ''; + for (key in attributes) { + if (attributes.hasOwnProperty(key) && key.toLowerCase()=='alarm-type') { + alatmType = ' of type ' + attributes[key]; + break; + } + } + + var device = Ext.getStore('Devices').findRecord('id', deviceId, 0, false, false, true); + if(device){ + var deviceName = device.get('name'); + var msg = 'Alarm'+alatmType+' on device '+deviceName+'!'; + this.showAlarmMsg(msg); + } + }, + + showAlarmMsg: function(msg){//added by Erez + this.beep(); + var alarmMsg = Ext.Msg.show({ + title:'Alarm', + message: msg, + modal: false, + buttons: Ext.Msg.YES, + icon: Ext.Msg.WARNING + }); + + window.setTimeout(function(){ + alarmMsg.close(); + }, 10000) + + }, + + beep: function() {//added by Erez + if(this.snd == null){ + this.snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABYAAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5mBjFANmRwlVJ3/6jYDAmxaiDG3/6xjQQCCKkR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/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU="); + } + this.snd.play(); + }, + selectDevice: function (device) { var position; this.deviceId = device.get('id'); |