aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'web/app')
-rw-r--r--web/app/Application.js13
-rw-r--r--web/app/controller/Root.js8
-rw-r--r--web/app/view/DeviceMenu.js8
-rw-r--r--web/app/view/DeviceMenuController.js8
-rw-r--r--web/app/view/Report.js5
-rw-r--r--web/app/view/ReportController.js12
-rw-r--r--web/app/view/SettingsMenu.js2
-rw-r--r--web/app/view/SettingsMenuController.js10
-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.js2
-rw-r--r--web/app/view/edit/Users.js2
12 files changed, 72 insertions, 34 deletions
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'
}, {