diff options
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/view/AttributeAliases.js | 1 | ||||
-rw-r--r-- | web/app/view/DeviceDialog.js | 2 | ||||
-rw-r--r-- | web/app/view/DeviceDistanceController.js | 44 | ||||
-rw-r--r-- | web/app/view/DeviceDistanceDialog.js | 55 | ||||
-rw-r--r-- | web/app/view/SettingsMenu.js | 5 | ||||
-rw-r--r-- | web/app/view/SettingsMenuController.js | 7 |
6 files changed, 113 insertions, 1 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(); } |