From 4d55b911bd252c90d1d0ec4053d8502154192676 Mon Sep 17 00:00:00 2001 From: ninioe Date: Sun, 17 Jul 2016 09:54:15 +0300 Subject: Added AlertEventHandler & Mute button for all notifications --- web/app/controller/Root.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 98ded9c47..dec3c9158 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -89,6 +89,17 @@ Ext.define('Traccar.controller.Root', { } }, + beep: function() { + 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//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa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325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU="); + } + this.snd.play(); + }, + + showAlarmSelected: function () { + return Ext.getCmp('showAlarmButton') && Ext.getCmp('showAlarmButton').pressed; + }, + asyncUpdate: function (first) { var protocol, socket, self = this; protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; @@ -160,7 +171,10 @@ Ext.define('Traccar.controller.Root', { } device = Ext.getStore('Devices').getById(array[i].deviceId); if (typeof device !== 'undefined') { - Ext.toast(text, device.getData().name); + if(self.showAlarmSelected()){ + self.beep(); + Ext.toast(text, device.getData().name); + } } } } -- cgit v1.2.3 From bfa3fa62305858166d8acdcf6da4a6d33249877d Mon Sep 17 00:00:00 2001 From: ninioe Date: Tue, 19 Jul 2016 10:20:51 +0300 Subject: changed to generic alarm type event --- src/org/traccar/events/AlertEventHandler.java | 10 +--------- src/org/traccar/model/Event.java | 5 +---- src/org/traccar/protocol/H02ProtocolDecoder.java | 2 +- tools/test-generator.py | 2 +- web/app/controller/Root.js | 15 +++++++++++++++ web/l10n/en.json | 13 +++++++++---- 6 files changed, 28 insertions(+), 19 deletions(-) (limited to 'web/app/controller') diff --git a/src/org/traccar/events/AlertEventHandler.java b/src/org/traccar/events/AlertEventHandler.java index 92d1566a7..61c2d7b16 100644 --- a/src/org/traccar/events/AlertEventHandler.java +++ b/src/org/traccar/events/AlertEventHandler.java @@ -29,15 +29,7 @@ public class AlertEventHandler extends BaseEventHandler { Object alarm = position.getAttributes().get(Position.KEY_ALARM); if (alarm != null) { Collection events = new ArrayList<>(); - if(alarm.equals(Event.TYPE_SOS_ALARM)){ - events.add(new Event(Event.TYPE_SOS_ALARM, position.getDeviceId(), position.getId())); - } else if(alarm.equals(Event.TYPE_VIBRATION_ALARM)){ - events.add(new Event(Event.TYPE_VIBRATION_ALARM, position.getDeviceId(), position.getId())); - } else if(alarm.equals(Event.TYPE_MOVEMENT_ALARM)){ - events.add(new Event(Event.TYPE_MOVEMENT_ALARM, position.getDeviceId(), position.getId())); - } else if(alarm.equals(Event.TYPE_OVERSPEED_ALARM)){ - events.add(new Event(Event.TYPE_OVERSPEED_ALARM, position.getDeviceId(), position.getId())); - } + events.add(new Event(Event.TYPE_ALARM, position.getDeviceId(), position.getId())); return events; } return null; diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 3a0056bd6..a2c346688 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -48,10 +48,7 @@ public class Event extends Message { public static final String TYPE_GEOFENCE_ENTER = "geofenceEnter"; public static final String TYPE_GEOFENCE_EXIT = "geofenceExit"; - public static final String TYPE_SOS_ALARM = "sosAlarm"; - public static final String TYPE_VIBRATION_ALARM = "vibrationAlarm"; - public static final String TYPE_MOVEMENT_ALARM = "movementAlarm"; - public static final String TYPE_OVERSPEED_ALARM = "overspeedAlarm"; + public static final String TYPE_ALARM = "alarm"; private Date serverTime; diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 09375958e..51bcfa26c 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -68,7 +68,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { || !BitUtil.check(status, 3) || !BitUtil.check(status, 4) || !BitUtil.check(status, 7)) { if (!BitUtil.check(status, 0)){ - position.set(Position.KEY_ALARM, Event.TYPE_VIBRATION_ALARM);//theft alarm + position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);//theft alarm in protocol } else if (!BitUtil.check(status, 1)){ position.set(Position.KEY_ALARM, "robbery"); } else if (!BitUtil.check(status, 3)){ diff --git a/tools/test-generator.py b/tools/test-generator.py index 54e5feced..cedbe9c69 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -35,7 +35,7 @@ for i in range(0, len(waypoints)): def send(lat, lon, course, alarm): params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course)) if alarm: - params = params + (('alarm', 'sosAlarm'),) + params = params + (('alarm', 'sos'),) urllib2.urlopen(server + '?' + urllib.urlencode(params)).read() def course(lat1, lon1, lat2, lon2): diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index dec3c9158..b508cc5ef 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -156,6 +156,21 @@ Ext.define('Traccar.controller.Root', { } } text = Strings.eventCommandResult + ': ' + text; + } else if (array[i].type === 'alarm' && data.positions) { + text = 'Alarm'; + for (j = 0; j < data.positions.length; j++) { + if (data.positions[j].id === array[i].positionId && data.positions[j].attributes.alarm != null) { + if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2){ + var alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1); + text = Strings[alarmKey]; + if (typeof text === 'undefined') { + text = alarmKey; + } + text = 'Alarm: ' + text; + } + break; + } + } } else { typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1); text = Strings[typeKey]; diff --git a/web/l10n/en.json b/web/l10n/en.json index 2f930a27c..ff432d444 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -118,10 +118,15 @@ "eventCommandResult": "Command result", "eventGeofenceEnter": "Device has entered geofence", "eventGeofenceExit": "Device has exited geofence", - "eventSosAlarm": "SOS alarm", - "eventVibrationAlarm": "Vibration alarm", - "eventMovementAlarm": "Movement alarm", - "eventOverspeedAlarm": "Overspeed alarm", + "eventAlarm": "Alarms", + "alarmSos": "sos", + "alarmVibration": "vibration", + "alarmMovement": "movement", + "alarmOverspeed": "overspeed", + "alarmFallDown": "fallDown", + "alarmLowBattery": "lowBattery", + "alarmMotion": "motion", + "alarmFault": "fault", "notificationType": "Type of Notification", "notificationWeb": "Send via Web", "notificationMail": "Send via Mail" -- cgit v1.2.3 From e954e95547d05a34bbd36e3aa5003f4ddaf2ccd0 Mon Sep 17 00:00:00 2001 From: ninioe Date: Tue, 19 Jul 2016 15:12:38 +0300 Subject: changes Anton asked me --- src/org/traccar/BasePipelineFactory.java | 6 +++++- src/org/traccar/Main.java | 4 +++- src/org/traccar/database/DataManager.java | 4 +--- web/app/controller/Root.js | 13 ++++++++----- web/beep.wav | Bin 0 -> 3047 bytes web/l10n/en.json | 17 +++++++++-------- 6 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 web/beep.wav (limited to 'web/app/controller') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index eb08c7e08..31845290f 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -29,7 +29,11 @@ import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.handler.logging.LoggingHandler; import org.jboss.netty.handler.timeout.IdleStateHandler; -import org.traccar.events.*; +import org.traccar.events.CommandResultEventHandler; +import org.traccar.events.GeofenceEventHandler; +import org.traccar.events.MotionEventHandler; +import org.traccar.events.OverspeedEventHandler; +import org.traccar.events.AlertEventHandler; import org.traccar.helper.Log; import java.net.InetSocketAddress; diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 45374ca15..baad9d040 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -16,6 +16,8 @@ package org.traccar; import org.traccar.helper.Log; + +import java.sql.SQLException; import java.util.Timer; import java.util.TimerTask; import java.util.Locale; @@ -44,7 +46,7 @@ public final class Main { public void run() { try { Context.getDataManager().clearPositionsHistory(); - } catch (Exception error) { + } catch (SQLException error) { Log.warning(error); } } diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index e5a245568..3c8529eff 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -399,7 +399,6 @@ public class DataManager { } public void clearPositionsHistory() throws SQLException { - //SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd"); int histDays = config.getInteger("database.positionsHistoryDays"); if (histDays == 0) { return; @@ -414,8 +413,7 @@ public class DataManager { Date lastUpdate = device.getLastUpdate(); if(lastUpdate != null){ - Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000 ); - //String dt = s.format(dateBefore); + Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000); QueryBuilder.create(dataSource, sql) .setLong("deviceId", device.getId()) diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index b508cc5ef..3a7f24bca 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -91,7 +91,7 @@ Ext.define('Traccar.controller.Root', { beep: function() { 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/4doscwD6neZjuZR4AgAABYAAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5m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UKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU="); + this.snd = new Audio("beep.wav"); } this.snd.play(); }, @@ -110,7 +110,7 @@ Ext.define('Traccar.controller.Root', { }; socket.onmessage = function (event) { - var i, j, store, data, array, entity, device, typeKey, text, geofence; + var i, j, store, data, array, entity, device, typeKey, alarmKey, text, geofence; data = Ext.decode(event.data); @@ -157,16 +157,19 @@ Ext.define('Traccar.controller.Root', { } text = Strings.eventCommandResult + ': ' + text; } else if (array[i].type === 'alarm' && data.positions) { - text = 'Alarm'; + alarmKey = 'alarm'; + text = Strings[alarmKey]; + if (typeof text === 'undefined') { + text = alarmKey; + } for (j = 0; j < data.positions.length; j++) { if (data.positions[j].id === array[i].positionId && data.positions[j].attributes.alarm != null) { if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2){ - var alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1); + alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1); text = Strings[alarmKey]; if (typeof text === 'undefined') { text = alarmKey; } - text = 'Alarm: ' + text; } break; } diff --git a/web/beep.wav b/web/beep.wav new file mode 100644 index 000000000..c2364f114 Binary files /dev/null and b/web/beep.wav differ diff --git a/web/l10n/en.json b/web/l10n/en.json index ff432d444..c5d67e8c1 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -119,14 +119,15 @@ "eventGeofenceEnter": "Device has entered geofence", "eventGeofenceExit": "Device has exited geofence", "eventAlarm": "Alarms", - "alarmSos": "sos", - "alarmVibration": "vibration", - "alarmMovement": "movement", - "alarmOverspeed": "overspeed", - "alarmFallDown": "fallDown", - "alarmLowBattery": "lowBattery", - "alarmMotion": "motion", - "alarmFault": "fault", + "alarm": "Alarm", + "alarmSos": "SOS Alarm", + "alarmVibration": "Vibration Alarm", + "alarmMovement": "Movement Alarm", + "alarmOverspeed": "Overspeed Alarm", + "alarmFallDown": "FallDown Alarm", + "alarmLowBattery": "LowBattery Alarm", + "alarmMotion": "Motion Alarm", + "alarmFault": "Fault Alarm", "notificationType": "Type of Notification", "notificationWeb": "Send via Web", "notificationMail": "Send via Mail" -- cgit v1.2.3 From 19d51272931f92c5c8a139e8aa8f9aa0314f6c61 Mon Sep 17 00:00:00 2001 From: ninioe Date: Wed, 20 Jul 2016 08:23:40 +0300 Subject: jshint & jscs cleanup --- web/app/AttributeFormatter.js | 2 +- web/app/controller/Root.js | 12 ++++++------ web/app/view/Devices.js | 11 +++++------ 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'web/app/controller') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index e14a9539b..c32849101 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -37,7 +37,7 @@ Ext.define('Traccar.AttributeFormatter', { alarmFormatter: function (attributes) { var value = ''; if (attributes instanceof Object) {//for Traccar.view.Attributes - if (attributes.hasOwnProperty('alarm')){ + if (attributes.hasOwnProperty('alarm')) { value = attributes.alarm; if (typeof value === 'boolean') { value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no); diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 3a7f24bca..90923fe53 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -89,9 +89,9 @@ Ext.define('Traccar.controller.Root', { } }, - beep: function() { - if(this.snd == null){ - this.snd = new Audio("beep.wav"); + beep: function () { + if (this.snd === null) { + this.snd = new Audio('beep.wav'); } this.snd.play(); }, @@ -163,8 +163,8 @@ Ext.define('Traccar.controller.Root', { text = alarmKey; } for (j = 0; j < data.positions.length; j++) { - if (data.positions[j].id === array[i].positionId && data.positions[j].attributes.alarm != null) { - if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2){ + if (data.positions[j].id === array[i].positionId && data.positions[j].attributes.alarm !== null) { + if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2) { alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1); text = Strings[alarmKey]; if (typeof text === 'undefined') { @@ -189,7 +189,7 @@ Ext.define('Traccar.controller.Root', { } device = Ext.getStore('Devices').getById(array[i].deviceId); if (typeof device !== 'undefined') { - if(self.showAlarmSelected()){ + if (self.showAlarmSelected()) { self.beep(); Ext.toast(text, device.getData().name); } diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 77d796b1e..31d22ed2a 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -64,16 +64,15 @@ Ext.define('Traccar.view.Devices', { tooltipType: 'title', pressed : true, enableToggle: true, - listeners:{ - toggle: function(button, pressed){ - if(pressed){ + listeners: { + toggle: function (button, pressed) { + if (pressed) { button.setGlyph('xf0a2@FontAwesome'); - } - else { + } else { button.setGlyph('xf1f7@FontAwesome'); } }, - scope:this + scope: this } }, { id: 'deviceFollowButton', -- cgit v1.2.3 From 2e7987b5df7611299aa76bcc9eca3424ce31d204 Mon Sep 17 00:00:00 2001 From: ninioe Date: Thu, 21 Jul 2016 07:58:28 +0300 Subject: protect Device positionId on clear history --- debug.xml | 2 +- src/org/traccar/database/DataManager.java | 1 + web/app/controller/Root.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'web/app/controller') diff --git a/debug.xml b/debug.xml index 19e81db07..346eda292 100644 --- a/debug.xml +++ b/debug.xml @@ -324,7 +324,7 @@ - DELETE FROM positions WHERE deviceid = :deviceId and servertime < :serverTime; + DELETE FROM positions WHERE id != :positionId and deviceid = :deviceId and servertime < :serverTime; diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 691c31643..710eceebb 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -416,6 +416,7 @@ public class DataManager { Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000); QueryBuilder.create(dataSource, sql) + .setLong("positionId", device.getPositionId()) .setLong("deviceId", device.getId()) .setDate("serverTime", dateBefore) .executeUpdate(); diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 90923fe53..fd30fe7c9 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -81,7 +81,7 @@ Ext.define('Traccar.controller.Root', { this.asyncUpdate(true); } }); - Ext.get('attribution').remove(); + if (Ext.get('attribution') !== null) Ext.get('attribution').remove(); if (this.isPhone) { Ext.create('widget.mainMobile'); } else { -- cgit v1.2.3 From 729f34a34c4b3f857823293c8a46661f606cb03b Mon Sep 17 00:00:00 2001 From: ninioe Date: Sun, 24 Jul 2016 08:53:00 +0300 Subject: more fixes --- src/org/traccar/Main.java | 2 +- web/app/controller/Root.js | 20 ++++++++++---------- web/app/view/Devices.js | 4 ++-- web/l10n/en.json | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'web/app/controller') diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 454124fbf..570becc2d 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -23,7 +23,7 @@ import java.util.TimerTask; import java.util.Locale; public final class Main { - static final long CLEAN_DELAY = 10 * 1000; + static final long CLEAN_DELAY = 500; static final long CLEAN_PERIOD = 24 * 60 * 60 * 1000; private Main() { diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index fd30fe7c9..367b98d88 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -90,14 +90,14 @@ Ext.define('Traccar.controller.Root', { }, beep: function () { - if (this.snd === null) { - this.snd = new Audio('beep.wav'); + if (this.beepSound === null) { + this.beepSound = new Audio('beep.wav'); } - this.snd.play(); + this.beepSound.play(); }, - showAlarmSelected: function () { - return Ext.getCmp('showAlarmButton') && Ext.getCmp('showAlarmButton').pressed; + showNotificationsSelected: function () { + return Ext.getCmp('showNotificationsButton') && Ext.getCmp('showNotificationsButton').pressed; }, asyncUpdate: function (first) { @@ -159,7 +159,7 @@ Ext.define('Traccar.controller.Root', { } else if (array[i].type === 'alarm' && data.positions) { alarmKey = 'alarm'; text = Strings[alarmKey]; - if (typeof text === 'undefined') { + if (!text) { text = alarmKey; } for (j = 0; j < data.positions.length; j++) { @@ -167,7 +167,7 @@ Ext.define('Traccar.controller.Root', { if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2) { alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1); text = Strings[alarmKey]; - if (typeof text === 'undefined') { + if (!text) { text = alarmKey; } } @@ -177,7 +177,7 @@ Ext.define('Traccar.controller.Root', { } else { typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1); text = Strings[typeKey]; - if (typeof text === 'undefined') { + if (!text) { text = typeKey; } } @@ -189,9 +189,9 @@ Ext.define('Traccar.controller.Root', { } device = Ext.getStore('Devices').getById(array[i].deviceId); if (typeof device !== 'undefined') { - if (self.showAlarmSelected()) { + if (self.showNotificationsSelected()) { self.beep(); - Ext.toast(text, device.getData().name); + Ext.toast(text, device.get('name')); } } } diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 31d22ed2a..212aa7f96 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -58,9 +58,9 @@ Ext.define('Traccar.view.Devices', { }, { xtype: 'tbfill' },{ - id: 'showAlarmButton', + id: 'showNotificationsButton', glyph: 'xf0a2@FontAwesome', - tooltip: 'Show Alarms', + tooltip: Strings.showNotifications, tooltipType: 'title', pressed : true, enableToggle: true, diff --git a/web/l10n/en.json b/web/l10n/en.json index c5d67e8c1..d8dd016b5 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -19,6 +19,7 @@ "sharedSearch": "Search", "sharedGeofence": "Geofence", "sharedGeofences": "Geofences", + "showNotifications": "Show Notifications", "sharedNotifications": "Notifications", "sharedAttributes": "Attributes", "sharedAttribute": "Attribute", -- cgit v1.2.3 From fd3a695813f511d1b94775bd4e8a4c57053fc66d Mon Sep 17 00:00:00 2001 From: ninioe Date: Sun, 24 Jul 2016 09:34:41 +0300 Subject: more fix --- web/app/controller/Root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 367b98d88..53f3b83df 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -90,7 +90,7 @@ Ext.define('Traccar.controller.Root', { }, beep: function () { - if (this.beepSound === null) { + if (!this.beepSound) { this.beepSound = new Audio('beep.wav'); } this.beepSound.play(); -- cgit v1.2.3 From 3e1e90ef327102f5942884b8ba517971a47b2673 Mon Sep 17 00:00:00 2001 From: ninioe Date: Sun, 24 Jul 2016 11:56:46 +0300 Subject: more fixes --- src/org/traccar/Main.java | 2 +- web/app/controller/Root.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'web/app/controller') diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 570becc2d..e7e8d8ab9 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -23,7 +23,7 @@ import java.util.TimerTask; import java.util.Locale; public final class Main { - static final long CLEAN_DELAY = 500; + static final long CLEAN_DELAY = 0; static final long CLEAN_PERIOD = 24 * 60 * 60 * 1000; private Main() { diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 53f3b83df..c8e708c09 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -81,7 +81,10 @@ Ext.define('Traccar.controller.Root', { this.asyncUpdate(true); } }); - if (Ext.get('attribution') !== null) Ext.get('attribution').remove(); + var attribution = Ext.get('attribution'); + if (attribution) { + attribution.remove(); + } if (this.isPhone) { Ext.create('widget.mainMobile'); } else { -- cgit v1.2.3 From 1e39c3dbf2078dbe9a99bdf25b944fbe05b8a40d Mon Sep 17 00:00:00 2001 From: ninioe Date: Sun, 24 Jul 2016 12:14:40 +0300 Subject: turn the toggle button into mute button default is muted --- web/app/controller/Root.js | 9 +++++---- web/app/view/Devices.js | 10 +++++----- web/l10n/en.json | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index c8e708c09..7070c48b0 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -99,8 +99,9 @@ Ext.define('Traccar.controller.Root', { this.beepSound.play(); }, - showNotificationsSelected: function () { - return Ext.getCmp('showNotificationsButton') && Ext.getCmp('showNotificationsButton').pressed; + mutePressed: function () { + var muteButton = Ext.getCmp('nuteButton'); + return muteButton && !muteButton.pressed; }, asyncUpdate: function (first) { @@ -192,10 +193,10 @@ Ext.define('Traccar.controller.Root', { } device = Ext.getStore('Devices').getById(array[i].deviceId); if (typeof device !== 'undefined') { - if (self.showNotificationsSelected()) { + if (self.mutePressed()) { self.beep(); - Ext.toast(text, device.get('name')); } + Ext.toast(text, device.get('name')); } } } diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 212aa7f96..63569bd95 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -58,18 +58,18 @@ Ext.define('Traccar.view.Devices', { }, { xtype: 'tbfill' },{ - id: 'showNotificationsButton', - glyph: 'xf0a2@FontAwesome', - tooltip: Strings.showNotifications, + id: 'nuteButton', + glyph: 'xf1f7@FontAwesome', + tooltip: Strings.nuteButton, tooltipType: 'title', pressed : true, enableToggle: true, listeners: { toggle: function (button, pressed) { if (pressed) { - button.setGlyph('xf0a2@FontAwesome'); - } else { button.setGlyph('xf1f7@FontAwesome'); + } else { + button.setGlyph('xf0a2@FontAwesome'); } }, scope: this diff --git a/web/l10n/en.json b/web/l10n/en.json index d8dd016b5..4e0f42fe3 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -19,7 +19,7 @@ "sharedSearch": "Search", "sharedGeofence": "Geofence", "sharedGeofences": "Geofences", - "showNotifications": "Show Notifications", + "nuteButton": "Mute", "sharedNotifications": "Notifications", "sharedAttributes": "Attributes", "sharedAttribute": "Attribute", -- cgit v1.2.3