diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | web/app/Application.js | 13 | ||||
-rw-r--r-- | web/app/controller/Root.js | 8 | ||||
-rw-r--r-- | web/app/view/DeviceMenu.js | 8 | ||||
-rw-r--r-- | web/app/view/DeviceMenuController.js | 8 | ||||
-rw-r--r-- | web/app/view/Report.js | 5 | ||||
-rw-r--r-- | web/app/view/ReportController.js | 12 | ||||
-rw-r--r-- | web/app/view/SettingsMenu.js | 2 | ||||
-rw-r--r-- | web/app/view/SettingsMenuController.js | 10 | ||||
-rw-r--r-- | web/app/view/dialog/DeviceAccumulators.js (renamed from web/app/view/dialog/DeviceDistance.js) | 13 | ||||
-rw-r--r-- | web/app/view/dialog/DeviceAccumulatorsController.js (renamed from web/app/view/dialog/DeviceDistanceController.js) | 23 | ||||
-rw-r--r-- | web/app/view/edit/Groups.js | 2 | ||||
-rw-r--r-- | web/app/view/edit/Users.js | 2 | ||||
-rw-r--r-- | web/l10n/en.json | 98 | ||||
-rw-r--r-- | web/load.js | 6 |
15 files changed, 127 insertions, 85 deletions
@@ -1,5 +1,5 @@ # [Traccar Web Interface](https://www.traccar.org) -[![Build Status](https://travis-ci.org/tananaev/traccar-web.svg?branch=master)](https://travis-ci.org/tananaev/traccar-web) +[![Build Status](https://travis-ci.org/traccar/traccar-web.svg?branch=master)](https://travis-ci.org/traccar/traccar-web) ## Overview diff --git a/web/app/Application.js b/web/app/Application.js index d0b6713c..a4cbbf22 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -148,6 +148,19 @@ Ext.define('Traccar.Application', { } }, + updateNotificationToken: function (token) { + var attributes = Ext.clone(this.user.get('attributes')); + if (!attributes.notificationTokens || attributes.notificationTokens.indexOf(token) < 0) { + if (!attributes.notificationTokens) { + attributes.notificationTokens = token; + } else { + attributes.notificationTokens += ',' + token; + } + this.user.set('attributes', attributes); + this.user.save(); + } + }, + setUser: function (data) { var reader = Ext.create('Ext.data.reader.Json', { model: 'Traccar.model.User' diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 0edc049a..7c0345ad 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -109,6 +109,14 @@ Ext.define('Traccar.controller.Root', { loadApp: function () { var attribution, eventId; + + if (window.webkit && window.webkit.messageHandlers.appInterface) { + window.webkit.messageHandlers.appInterface.postMessage('login'); + } + if (window.appInterface) { + window.appInterface.postMessage('login'); + } + Ext.getStore('Groups').load(); Ext.getStore('Drivers').load(); Ext.getStore('Geofences').load(); diff --git a/web/app/view/DeviceMenu.js b/web/app/view/DeviceMenu.js index a3381cc4..e4623b94 100644 --- a/web/app/view/DeviceMenu.js +++ b/web/app/view/DeviceMenu.js @@ -33,7 +33,7 @@ Ext.define('Traccar.view.DeviceMenu', { items: [{ text: Strings.sharedDrivers, - glyph: 'xf2c2@FontAwesome', + glyph: 'xf084@FontAwesome', handler: 'onDriversClick', reference: 'menuDriversButton' }, { @@ -63,10 +63,10 @@ Ext.define('Traccar.view.DeviceMenu', { reference: 'menuMaintenancesButton' }, { hidden: true, - text: Strings.sharedDeviceDistance, + text: Strings.sharedDeviceAccumulators, glyph: 'xf0e4@FontAwesome', - handler: 'onDeviceDistanceClick', - reference: 'menuDeviceDistanceButton' + handler: 'onDeviceAccumulatorsClick', + reference: 'menuDeviceAccumulatorsButton' }] } }); diff --git a/web/app/view/DeviceMenuController.js b/web/app/view/DeviceMenuController.js index f191756c..9355571c 100644 --- a/web/app/view/DeviceMenuController.js +++ b/web/app/view/DeviceMenuController.js @@ -27,6 +27,7 @@ Ext.define('Traccar.view.DeviceMenuController', { 'Traccar.view.edit.ComputedAttributes', 'Traccar.view.permissions.SavedCommands', 'Traccar.view.permissions.Maintenances', + 'Traccar.view.dialog.DeviceAccumulators', 'Traccar.view.BaseWindow' ], @@ -36,7 +37,7 @@ Ext.define('Traccar.view.DeviceMenuController', { this.lookupReference('menuComputedAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); this.lookupReference('menuCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false)); - this.lookupReference('menuDeviceDistanceButton').setHidden( + this.lookupReference('menuDeviceAccumulatorsButton').setHidden( !Traccar.app.getUser().get('administrator') && Traccar.app.getUser().get('userLimit') === 0 || Traccar.app.getVehicleFeaturesDisabled()); this.lookupReference('menuMaintenancesButton').setHidden( Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableMaintenances')); @@ -120,12 +121,13 @@ Ext.define('Traccar.view.DeviceMenuController', { }).show(); }, - onDeviceDistanceClick: function () { - var position, dialog = Ext.create('Traccar.view.dialog.DeviceDistance'); + onDeviceAccumulatorsClick: function () { + var position, dialog = Ext.create('Traccar.view.dialog.DeviceAccumulators'); dialog.deviceId = this.getView().up('deviceMenu').device.getId(); position = Ext.getStore('LatestPositions').findRecord('deviceId', dialog.deviceId, 0, false, false, true); if (position) { dialog.lookupReference('totalDistance').setValue(position.get('attributes').totalDistance); + dialog.lookupReference('hours').setValue(position.get('attributes').hours); } dialog.show(); } diff --git a/web/app/view/Report.js b/web/app/view/Report.js index f77cfca6..deedb747 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -63,6 +63,11 @@ Ext.define('Traccar.view.Report', { disabled: true, handler: 'onReportClick' }, { + text: Strings.reportEmail, + reference: 'emailButton', + disabled: true, + handler: 'onReportClick' + }, { text: Strings.reportClear, handler: 'onClearClick' }] diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 7ecb15e2..5d43007a 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -145,6 +145,7 @@ Ext.define('Traccar.view.ReportController', { disabled = !reportType || !devices || !time || this.reportProgress; this.lookupReference('showButton').setDisabled(disabled); this.lookupReference('exportButton').setDisabled(reportType === 'chart' || disabled); + this.lookupReference('emailButton').setDisabled(reportType === 'chart' || disabled); }, onReportClick: function (button) { @@ -187,14 +188,15 @@ Ext.define('Traccar.view.ReportController', { to: to.toISOString() } }); - } else if (button.reference === 'exportButton') { + } else { url = this.getGrid().getStore().getProxy().url; - this.downloadFile(url, { + this.excelReport(url, { deviceId: this.deviceId, groupId: this.groupId, type: this.eventType, from: Ext.Date.format(from, 'c'), - to: Ext.Date.format(to, 'c') + to: Ext.Date.format(to, 'c'), + mail: button.reference === 'emailButton' }); } } @@ -371,7 +373,7 @@ Ext.define('Traccar.view.ReportController', { }); }, - downloadFile: function (requestUrl, requestParams) { + excelReport: function (requestUrl, requestParams) { Ext.Ajax.request({ url: requestUrl, method: 'GET', @@ -384,7 +386,7 @@ Ext.define('Traccar.view.ReportController', { scope: this, callback: function (options, success, response) { var disposition, filename, type, blob, url, downloadUrl; - if (success) { + if (success && !requestParams.mail) { disposition = response.getResponseHeader('Content-Disposition'); filename = disposition.slice(disposition.indexOf('=') + 1, disposition.length); type = response.getResponseHeader('Content-Type'); diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js index 01a06aa6..309133c1 100644 --- a/web/app/view/SettingsMenu.js +++ b/web/app/view/SettingsMenu.js @@ -45,7 +45,7 @@ Ext.define('Traccar.view.SettingsMenu', { }, { hidden: true, text: Strings.sharedDrivers, - glyph: 'xf2c2@FontAwesome', + glyph: 'xf084@FontAwesome', handler: 'onDriversClick', reference: 'settingsDriversButton' }, { diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 59f62c2e..b838fb40 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -30,7 +30,6 @@ Ext.define('Traccar.view.SettingsMenuController', { 'Traccar.view.edit.Notifications', 'Traccar.view.edit.ComputedAttributes', 'Traccar.view.Statistics', - 'Traccar.view.dialog.DeviceDistance', 'Traccar.view.edit.Calendars', 'Traccar.view.edit.SavedCommands', 'Traccar.view.edit.Maintenances', @@ -38,14 +37,15 @@ Ext.define('Traccar.view.SettingsMenuController', { ], init: function () { - var admin, manager, readonly, deviceReadonly; + var admin, manager, readonly; admin = Traccar.app.getUser().get('administrator'); manager = Traccar.app.getUser().get('userLimit') !== 0; readonly = Traccar.app.getPreference('readonly', false); - deviceReadonly = Traccar.app.getUser().get('deviceReadonly'); if (admin) { this.lookupReference('settingsServerButton').setHidden(false); this.lookupReference('settingsStatisticsButton').setHidden(false); + this.lookupReference('settingsComputedAttributesButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); } if (admin || manager) { this.lookupReference('settingsUsersButton').setHidden(false); @@ -63,10 +63,6 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsMaintenancesButton').setHidden( Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableMaintenances')); } - if (admin || !deviceReadonly && !readonly) { - this.lookupReference('settingsComputedAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); - } }, onUserClick: function () { diff --git a/web/app/view/dialog/DeviceDistance.js b/web/app/view/dialog/DeviceAccumulators.js index 53945885..eaa4e9f5 100644 --- a/web/app/view/dialog/DeviceDistance.js +++ b/web/app/view/dialog/DeviceAccumulators.js @@ -16,21 +16,26 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -Ext.define('Traccar.view.dialog.DeviceDistance', { +Ext.define('Traccar.view.dialog.DeviceAccumulators', { extend: 'Traccar.view.dialog.Base', requires: [ - 'Traccar.view.dialog.DeviceDistanceController' + 'Traccar.view.dialog.DeviceAccumulatorsController' ], - controller: 'deviceDistance', - title: Strings.sharedDeviceDistance, + controller: 'deviceAccumulators', + title: Strings.sharedDeviceAccumulators, items: [{ xtype: 'customNumberField', dataType: 'distance', reference: 'totalDistance', fieldLabel: Strings.deviceTotalDistance + }, { + xtype: 'customNumberField', + dataType: 'hours', + reference: 'hours', + fieldLabel: Strings.positionHours }], buttons: [{ diff --git a/web/app/view/dialog/DeviceDistanceController.js b/web/app/view/dialog/DeviceAccumulatorsController.js index ae14f33c..2fdae6c5 100644 --- a/web/app/view/dialog/DeviceDistanceController.js +++ b/web/app/view/dialog/DeviceAccumulatorsController.js @@ -1,6 +1,6 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,19 +16,26 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -Ext.define('Traccar.view.dialog.DeviceDistanceController', { +Ext.define('Traccar.view.dialog.DeviceAccumulatorsController', { extend: 'Ext.app.ViewController', - alias: 'controller.deviceDistance', + alias: 'controller.deviceAccumulators', onSetClick: function () { - var data = { - deviceId: this.getView().deviceId, - totalDistance: this.lookupReference('totalDistance').getValue() + var totalDistance, hours, data = { + deviceId: this.getView().deviceId }; + totalDistance = this.lookupReference('totalDistance'); + if (!isNaN(totalDistance.getRawValue())) { + data.totalDistance = totalDistance.getValue(); + } + hours = this.lookupReference('hours'); + if (!isNaN(hours.getRawValue())) { + data.hours = hours.getValue(); + } Ext.Ajax.request({ scope: this, method: 'PUT', - url: 'api/devices/' + data.deviceId + '/distance', + url: 'api/devices/' + data.deviceId + '/accumulators', jsonData: Ext.util.JSON.encode(data), callback: function (options, success, response) { if (!success) { diff --git a/web/app/view/edit/Groups.js b/web/app/view/edit/Groups.js index 1ff4de80..06974201 100644 --- a/web/app/view/edit/Groups.js +++ b/web/app/view/edit/Groups.js @@ -51,7 +51,7 @@ Ext.define('Traccar.view.edit.Groups', { disabled: true, handler: 'onDriversClick', reference: 'toolbarDriversButton', - glyph: 'xf2c2@FontAwesome', + glyph: 'xf084@FontAwesome', tooltip: Strings.sharedDrivers, tooltipType: 'title' }, { diff --git a/web/app/view/edit/Users.js b/web/app/view/edit/Users.js index e2dd9aa6..2bcaefad 100644 --- a/web/app/view/edit/Users.js +++ b/web/app/view/edit/Users.js @@ -84,7 +84,7 @@ Ext.define('Traccar.view.edit.Users', { disabled: true, handler: 'onDriversClick', reference: 'userDriversButton', - glyph: 'xf2c2@FontAwesome', + glyph: 'xf084@FontAwesome', tooltip: Strings.sharedDrivers, tooltipType: 'title' }, { diff --git a/web/l10n/en.json b/web/l10n/en.json index 2d91ae29..541871a7 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -53,7 +53,6 @@ "sharedComputedAttributes": "Computed Attributes", "sharedCheckComputedAttribute": "Check Computed Attribute", "sharedExpression": "Expression", - "sharedDeviceDistance": "Device Distance", "sharedDevice": "Device", "sharedTestNotification": "Send Test Notification", "sharedCalendar": "Calendar", @@ -77,6 +76,7 @@ "sharedDisabled": "Disabled", "sharedMaintenance": "Maintenance", "sharedMaintenances": "Maintenances", + "sharedDeviceAccumulators": "Accumulators", "attributeSpeedLimit": "Speed Limit", "attributePolylineDistance": "Polyline Distance", "attributeReportIgnoreOdometer": "Report: Ignore Odometer", @@ -252,8 +252,8 @@ "stateValue": "Value", "commandTitle": "Command", "commandSend": "Send", - "commandSent": "Command has been sent", - "commandQueued": "Command has been queued", + "commandSent": "Command sent", + "commandQueued": "Command queued", "commandUnit": "Unit", "commandCustom": "Custom command", "commandDeviceIdentification": "Device Identification", @@ -305,61 +305,62 @@ "commandServer": "Server", "commandPort": "Port", "eventAll": "All Events", - "eventDeviceOnline": "Device is online", - "eventDeviceUnknown": "Device status is unknown", - "eventDeviceOffline": "Device is offline", - "eventDeviceMoving": "Device is moving", - "eventDeviceStopped": "Device has stopped", - "eventDeviceOverspeed": "Device exceeds the speed", - "eventDeviceFuelDrop": "Fuel drop event", + "eventDeviceOnline": "Status online", + "eventDeviceUnknown": "Status unknown", + "eventDeviceOffline": "Status offline", + "eventDeviceMoving": "Device moving", + "eventDeviceStopped": "Device stopped", + "eventDeviceOverspeed": "Speed limit exceeded", + "eventDeviceFuelDrop": "Fuel drop", "eventCommandResult": "Command result", - "eventGeofenceEnter": "Device has entered geofence", - "eventGeofenceExit": "Device has exited geofence", - "eventAlarm": "Alarms", - "eventIgnitionOn": "Ignition is ON", - "eventIgnitionOff": "Ignition is OFF", + "eventGeofenceEnter": "Geofence entered", + "eventGeofenceExit": "Geofence exited", + "eventAlarm": "Alarm", + "eventIgnitionOn": "Ignition on", + "eventIgnitionOff": "Ignition off", "eventMaintenance": "Maintenance required", "eventTextMessage": "Text message received", - "eventDriverChanged": "Driver has changed", + "eventDriverChanged": "Driver changed", "eventsScrollToLast": "Scroll To Last", - "alarmSos": "SOS Alarm", - "alarmVibration": "Vibration Alarm", - "alarmMovement": "Movement Alarm", - "alarmOverspeed": "Overspeed Alarm", - "alarmFallDown": "FallDown Alarm", - "alarmLowBattery": "LowBattery Alarm", - "alarmLowPower": "LowPower Alarm", - "alarmFault": "Fault Alarm", - "alarmPowerOff": "Power Off Alarm", - "alarmPowerOn": "Power On Alarm", - "alarmDoor": "Door Alarm", - "alarmGeofence": "Geofence Alarm", - "alarmGeofenceEnter": "Geofence Enter Alarm", - "alarmGeofenceExit": "Geofence Exit Alarm", - "alarmGpsAntennaCut": "GPS Antenna Cut Alarm", - "alarmAccident": "Accident Alarm", - "alarmTow": "Tow Alarm", - "alarmIdle": "Idle Alarm", - "alarmHardAcceleration": "Hard Acceleration Alarm", - "alarmHardBraking": "Hard Braking Alarm", - "alarmFatigueDriving": "Fatigue Driving Alarm", - "alarmPowerCut": "Power Cut Alarm", - "alarmPowerRestored": "Power Restored Alarm", - "alarmJamming": "Jamming Alarm", - "alarmTemperature": "Temperature Alarm", - "alarmParking": "Parking Alarm", - "alarmShock": "Shock Alarm", - "alarmBonnet": "Bonnet Alarm", - "alarmFootBrake": "Foot Brake Alarm", - "alarmFuelLeak": "Fuel Leak Alarm", - "alarmTampering": "Tampering Alarm", - "alarmRemoving": "Removing Alarm", + "alarmSos": "SOS", + "alarmVibration": "Vibration", + "alarmMovement": "Movement", + "alarmOverspeed": "Overspeed", + "alarmFallDown": "FallDown", + "alarmLowBattery": "LowBattery", + "alarmLowPower": "LowPower", + "alarmFault": "Fault", + "alarmPowerOff": "Power Off", + "alarmPowerOn": "Power On", + "alarmDoor": "Door", + "alarmGeofence": "Geofence", + "alarmGeofenceEnter": "Geofence Enter", + "alarmGeofenceExit": "Geofence Exit", + "alarmGpsAntennaCut": "GPS Antenna Cut", + "alarmAccident": "Accident", + "alarmTow": "Tow", + "alarmIdle": "Idle", + "alarmHardAcceleration": "Hard Acceleration", + "alarmHardBraking": "Hard Braking", + "alarmFatigueDriving": "Fatigue Driving", + "alarmPowerCut": "Power Cut", + "alarmPowerRestored": "Power Restored", + "alarmJamming": "Jamming", + "alarmTemperature": "Temperature", + "alarmParking": "Parking", + "alarmShock": "Shock", + "alarmBonnet": "Bonnet", + "alarmFootBrake": "Foot Brake", + "alarmFuelLeak": "Fuel Leak", + "alarmTampering": "Tampering", + "alarmRemoving": "Removing", "notificationType": "Type of Notification", "notificationAlways": "All Devices", "notificationNotificators": "Channels", "notificatorWeb": "Web", "notificatorMail": "Mail", "notificatorSms": "SMS", + "notificatorFirebase": "Mobile", "reportRoute": "Route", "reportEvents": "Events", "reportTrips": "Trips", @@ -371,6 +372,7 @@ "reportChartType": "Chart Type", "reportShowMarkers": "Show Markers", "reportExport": "Export", + "reportEmail": "Email Report", "reportPeriod": "Period", "reportCustom": "Custom", "reportToday": "Today", diff --git a/web/load.js b/web/load.js index 2eef6b6d..552b167a 100644 --- a/web/load.js +++ b/web/load.js @@ -28,6 +28,10 @@ debugMode = document.getElementById('loadScript').getAttribute('mode') === 'debug'; touchMode = 'ontouchstart' in window || navigator.maxTouchPoints; + window.updateNotificationToken = function (token) { + Traccar.app.updateNotificationToken(token); + }; + locale = {}; window.Locale = locale; @@ -162,8 +166,6 @@ addStyleFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/charts/classic/triton/resources/charts-all.css'); - addStyleFile('//use.fontawesome.com/releases/v' + fontAwesomeVersion + '/css/all.css'); - addStyleFile('//cdnjs.cloudflare.com/ajax/libs/ol3/' + olVersion + '/ol.css'); if (debugMode) { addScriptFile('//cdnjs.cloudflare.com/ajax/libs/ol3/' + olVersion + '/ol-debug.js'); |