aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/DeviceDistanceController.js
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 /web/app/view/DeviceDistanceController.js
parentae31f81fc81ed306411b07a5ebbf3d47e12c3243 (diff)
parent7f35b89560276d2ae23fb1164a429283fb64ff45 (diff)
downloadetbsa-traccar-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.tar.gz
etbsa-traccar-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.tar.bz2
etbsa-traccar-web-f6915ca3bf4e8c2d9df5eb4cd5283614d4dd747e.zip
Merge pull request #305 from Abyss777/reset_distance
Implement reset device distance dialog
Diffstat (limited to 'web/app/view/DeviceDistanceController.js')
-rw-r--r--web/app/view/DeviceDistanceController.js44
1 files changed, 44 insertions, 0 deletions
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();
+ }
+});