aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/app/view/AttributeAliases.js1
-rw-r--r--web/app/view/DeviceDialog.js2
-rw-r--r--web/app/view/DeviceDistanceController.js44
-rw-r--r--web/app/view/DeviceDistanceDialog.js55
-rw-r--r--web/app/view/SettingsMenu.js5
-rw-r--r--web/app/view/SettingsMenuController.js7
-rw-r--r--web/l10n/en.json5
7 files changed, 117 insertions, 2 deletions
diff --git a/web/app/view/AttributeAliases.js b/web/app/view/AttributeAliases.js
index 182a9cd..706c575 100644
--- a/web/app/view/AttributeAliases.js
+++ b/web/app/view/AttributeAliases.js
@@ -33,6 +33,7 @@ Ext.define('Traccar.view.AttributeAliases', {
xtype: 'editToolbar',
items: ['-', {
xtype: 'combobox',
+ fieldLabel: Strings.sharedDevice,
reference: 'deviceField',
store: 'Devices',
displayField: 'name',
diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js
index ab602b8..d746fa7 100644
--- a/web/app/view/DeviceDialog.js
+++ b/web/app/view/DeviceDialog.js
@@ -23,7 +23,7 @@ Ext.define('Traccar.view.DeviceDialog', {
],
controller: 'baseEditDialog',
- title: Strings.deviceDialog,
+ title: Strings.sharedDevice,
items: {
xtype: 'form',
diff --git a/web/app/view/DeviceDistanceController.js b/web/app/view/DeviceDistanceController.js
new file mode 100644
index 0000000..0ce80a5
--- /dev/null
+++ b/web/app/view/DeviceDistanceController.js
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru)
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.DeviceDistanceController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.deviceDistanceDialog',
+
+ onDeviceChange: function (combobox, newValue) {
+ this.lookupReference('setButton').setDisabled(newValue === null);
+ },
+
+ onSetClick: function (button) {
+ var data = {};
+ data.deviceId = this.lookupReference('deviceId').getValue();
+ data.totalDistance = this.lookupReference('totalDistance').getValue();
+ Ext.Ajax.request({
+ scope: this,
+ method: 'PUT',
+ url: 'api/devices/' + data.deviceId + '/distance',
+ jsonData: Ext.util.JSON.encode(data),
+ callback: function (options, success, response) {
+ if (!success) {
+ Traccar.app.showError(response);
+ }
+ }
+ });
+ button.up('window').close();
+ }
+});
diff --git a/web/app/view/DeviceDistanceDialog.js b/web/app/view/DeviceDistanceDialog.js
new file mode 100644
index 0000000..2b643c0
--- /dev/null
+++ b/web/app/view/DeviceDistanceDialog.js
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru)
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.DeviceDistanceDialog', {
+ extend: 'Traccar.view.BaseDialog',
+
+ requires: [
+ 'Traccar.view.DeviceDistanceController'
+ ],
+
+ controller: 'deviceDistanceDialog',
+ title: Strings.sharedDeviceDistance,
+
+ items: [{
+ xtype: 'combobox',
+ reference: 'deviceId',
+ fieldLabel: Strings.sharedDevice,
+ store: 'AllDevices',
+ displayField: 'name',
+ valueField: 'id',
+ listeners: {
+ change: 'onDeviceChange'
+ }
+ }, {
+ xtype: 'numberfield',
+ reference: 'totalDistance',
+ fieldLabel: Strings.deviceTotalDistance,
+ value: 0
+ }],
+
+ buttons: [{
+ text: Strings.sharedSet,
+ disabled: true,
+ reference: 'setButton',
+ handler: 'onSetClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js
index c494572..aa0d18b 100644
--- a/web/app/view/SettingsMenu.js
+++ b/web/app/view/SettingsMenu.js
@@ -63,6 +63,11 @@ Ext.define('Traccar.view.SettingsMenu', {
reference: 'settingsAttributeAliasesButton'
}, {
hidden: true,
+ text: Strings.sharedDeviceDistance,
+ handler: 'onDeviceDistanceClick',
+ reference: 'settingsDeviceDistanceButton'
+ }, {
+ hidden: true,
text: Strings.statisticsTitle,
handler: 'onStatisticsClick',
reference: 'settingsStatisticsButton'
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index 9d547c5..12630dd 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -29,6 +29,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
'Traccar.view.Notifications',
'Traccar.view.AttributeAliases',
'Traccar.view.Statistics',
+ 'Traccar.view.DeviceDistanceDialog',
'Traccar.view.BaseWindow'
],
@@ -40,6 +41,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
this.lookupReference('settingsServerButton').setHidden(false);
this.lookupReference('settingsUsersButton').setHidden(false);
this.lookupReference('settingsStatisticsButton').setHidden(false);
+ this.lookupReference('settingsDeviceDistanceButton').setHidden(false);
}
if (admin || !readonly) {
this.lookupReference('settingsGroupsButton').setHidden(false);
@@ -122,6 +124,11 @@ Ext.define('Traccar.view.SettingsMenuController', {
}).show();
},
+ onDeviceDistanceClick: function () {
+ var dialog = Ext.create('Traccar.view.DeviceDistanceDialog');
+ dialog.show();
+ },
+
onLogoutClick: function () {
Ext.create('Traccar.view.LoginController').logout();
}
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 1b8c966..ff9a7c4 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -1,6 +1,7 @@
{
"sharedLoading": "Loading...",
"sharedSave": "Save",
+ "sharedSet": "Set",
"sharedCancel": "Cancel",
"sharedAdd": "Add",
"sharedEdit": "Edit",
@@ -36,6 +37,8 @@
"sharedAttributeAlias": "Attribute Alias",
"sharedAttributeAliases": "Attribute Aliases",
"sharedAlias": "Alias",
+ "sharedDeviceDistance": "Device Distance",
+ "sharedDevice":"Device",
"errorTitle": "Error",
"errorUnknown": "Unknown error",
"errorConnection": "Connection error",
@@ -51,7 +54,6 @@
"loginCreated": "New user has been registered",
"loginLogout": "Logout",
"devicesAndState": "Devices and State",
- "deviceDialog": "Device",
"deviceTitle": "Devices",
"deviceIdentifier": "Identifier",
"devicePhone": "Phone",
@@ -60,6 +62,7 @@
"deviceLastUpdate": "Last Update",
"deviceCommand": "Command",
"deviceFollow": "Follow",
+ "deviceTotalDistance": "Total Distance",
"groupDialog": "Group",
"groupParent": "Group",
"groupNoGroup": "No Group",