aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/AttributeFormatter.js20
-rw-r--r--web/app/controller/Root.js44
-rw-r--r--web/app/view/Devices.js17
-rw-r--r--web/app/view/Report.js5
-rw-r--r--web/beep.wavbin0 -> 3047 bytes
-rw-r--r--web/l10n/en.json11
6 files changed, 93 insertions, 4 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 3432ca1e0..c32849101 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -34,6 +34,24 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
},
+ alarmFormatter: function (attributes) {
+ var value = '';
+ if (attributes instanceof Object) {//for Traccar.view.Attributes
+ if (attributes.hasOwnProperty('alarm')) {
+ value = attributes.alarm;
+ if (typeof value === 'boolean') {
+ value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no);
+ }
+ }
+ } else {//for Traccar.view.Report
+ value = attributes;
+ if (typeof value === 'boolean') {
+ value = (value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no);
+ }
+ }
+ return '<span style="color:red;">' + value + '</span>';
+ },
+
defaultFormatter: function (value) {
if (typeof value === 'number') {
return Number(value.toFixed(Traccar.Style.numberPrecision));
@@ -58,6 +76,8 @@ Ext.define('Traccar.AttributeFormatter', {
return this.courseFormatter;
} else if (key === 'distance' || key === 'odometer') {
return this.distanceFormatter;
+ } else if (key === 'alarm') {
+ return this.alarmFormatter;
} else {
return this.defaultFormatter;
}
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 98ded9c47..2c565747b 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);
}
});
- Ext.get('attribution').remove();
+ var attribution = Ext.get('attribution');
+ if (attribution) {
+ attribution.remove();
+ }
if (this.isPhone) {
Ext.create('widget.mainMobile');
} else {
@@ -89,6 +92,18 @@ Ext.define('Traccar.controller.Root', {
}
},
+ beep: function () {
+ if (!this.beepSound) {
+ this.beepSound = new Audio('beep.wav');
+ }
+ this.beepSound.play();
+ },
+
+ mutePressed: function () {
+ var muteButton = Ext.getCmp('muteButton');
+ return muteButton && !muteButton.pressed;
+ },
+
asyncUpdate: function (first) {
var protocol, socket, self = this;
protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
@@ -99,7 +114,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);
@@ -145,10 +160,28 @@ Ext.define('Traccar.controller.Root', {
}
}
text = Strings.eventCommandResult + ': ' + text;
+ } else if (array[i].type === 'alarm' && data.positions) {
+ alarmKey = 'alarm';
+ text = Strings[alarmKey];
+ if (!text) {
+ 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) {
+ alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1);
+ text = Strings[alarmKey];
+ if (!text) {
+ text = alarmKey;
+ }
+ }
+ break;
+ }
+ }
} 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;
}
}
@@ -160,7 +193,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.mutePressed()) {
+ self.beep();
+ }
+ Ext.toast(text, device.get('name'));
}
}
}
diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js
index 1a70dfef8..c086827f8 100644
--- a/web/app/view/Devices.js
+++ b/web/app/view/Devices.js
@@ -57,6 +57,23 @@ Ext.define('Traccar.view.Devices', {
tooltipType: 'title'
}, {
xtype: 'tbfill'
+ },{
+ id: 'muteButton',
+ glyph: 'xf1f7@FontAwesome',
+ tooltip: Strings.muteButton,
+ tooltipType: 'title',
+ pressed : true,
+ enableToggle: true,
+ listeners: {
+ toggle: function (button, pressed) {
+ if (pressed) {
+ button.setGlyph('xf1f7@FontAwesome');
+ } else {
+ button.setGlyph('xf0a2@FontAwesome');
+ }
+ },
+ scope: this
+ }
}, {
id: 'deviceFollowButton',
glyph: 'xf05b@FontAwesome',
diff --git a/web/app/view/Report.js b/web/app/view/Report.js
index 4261b9040..78ff5d52f 100644
--- a/web/app/view/Report.js
+++ b/web/app/view/Report.js
@@ -115,5 +115,10 @@ Ext.define('Traccar.view.Report', {
dataIndex: 'address',
flex: 1,
renderer: Traccar.AttributeFormatter.getFormatter('address')
+ }, {
+ text: 'Alarm',
+ dataIndex: 'attributes',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('alarm')
}]
});
diff --git a/web/beep.wav b/web/beep.wav
new file mode 100644
index 000000000..c2364f114
--- /dev/null
+++ b/web/beep.wav
Binary files differ
diff --git a/web/l10n/en.json b/web/l10n/en.json
index e97bb45b1..32a2a45a4 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -19,6 +19,7 @@
"sharedSearch": "Search",
"sharedGeofence": "Geofence",
"sharedGeofences": "Geofences",
+ "muteButton": "Mute",
"sharedNotifications": "Notifications",
"sharedAttributes": "Attributes",
"sharedAttribute": "Attribute",
@@ -118,6 +119,16 @@
"eventCommandResult": "Command result",
"eventGeofenceEnter": "Device has entered geofence",
"eventGeofenceExit": "Device has exited geofence",
+ "eventAlarm": "Alarms",
+ "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"