aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-10-24 11:28:33 +1300
committerGitHub <noreply@github.com>2016-10-24 11:28:33 +1300
commitf6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e (patch)
tree5885919549e09fd1433ab283cb03bc339b73c8a1
parentae31f81fc81ed306411b07a5ebbf3d47e12c3243 (diff)
parent7f35b89560276d2ae23fb1164a429283fb64ff45 (diff)
downloadtrackermap-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.tar.gz
trackermap-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.tar.bz2
trackermap-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.zip
Merge pull request #305 from Abyss777/reset_distance
Implement reset device distance dialog
-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 182a9cdd..706c5751 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 ab602b8d..d746fa7e 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 00000000..0ce80a5c
--- /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 00000000..2b643c05
--- /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 c494572f..aa0d18b7 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 9d547c55..12630dd2 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 1b8c9668..ff9a7c47 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",