diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/app/store/AllCommandTypes.js | 2 | ||||
-rw-r--r-- | web/app/store/CommandTypes.js | 2 | ||||
-rw-r--r-- | web/app/view/DeviceMenu.js | 6 | ||||
-rw-r--r-- | web/app/view/DeviceMenuController.js | 12 | ||||
-rw-r--r-- | web/app/view/SettingsMenu.js | 6 | ||||
-rw-r--r-- | web/app/view/SettingsMenuController.js | 6 | ||||
-rw-r--r-- | web/app/view/dialog/DeviceDistance.js | 12 | ||||
-rw-r--r-- | web/app/view/dialog/DeviceDistanceController.js | 22 |
8 files changed, 26 insertions, 42 deletions
diff --git a/web/app/store/AllCommandTypes.js b/web/app/store/AllCommandTypes.js index aac9d599..c86d0714 100644 --- a/web/app/store/AllCommandTypes.js +++ b/web/app/store/AllCommandTypes.js @@ -22,7 +22,7 @@ Ext.define('Traccar.store.AllCommandTypes', { proxy: { type: 'rest', - url: 'api/commandtypes', + url: 'api/commands/types', listeners: { 'exception': function (proxy, response) { Traccar.app.showError(response); diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js index f14cb596..3b898f2e 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/CommandTypes.js @@ -22,7 +22,7 @@ Ext.define('Traccar.store.CommandTypes', { proxy: { type: 'rest', - url: 'api/commandtypes', + url: 'api/commands/types', listeners: { 'exception': function (proxy, response) { Traccar.app.showError(response); diff --git a/web/app/view/DeviceMenu.js b/web/app/view/DeviceMenu.js index 236d5f4a..ed4068f1 100644 --- a/web/app/view/DeviceMenu.js +++ b/web/app/view/DeviceMenu.js @@ -56,6 +56,12 @@ Ext.define('Traccar.view.DeviceMenu', { glyph: 'xf093@FontAwesome', handler: 'onCommandsClick', reference: 'menuCommandsButton' + }, { + hidden: true, + text: Strings.sharedDeviceDistance, + glyph: 'xf0e4@FontAwesome', + handler: 'onDeviceDistanceClick', + reference: 'menuDeviceDistanceButton' }] } }); diff --git a/web/app/view/DeviceMenuController.js b/web/app/view/DeviceMenuController.js index 4fa00bee..9e5ef14a 100644 --- a/web/app/view/DeviceMenuController.js +++ b/web/app/view/DeviceMenuController.js @@ -35,6 +35,8 @@ 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( + !Traccar.app.getUser().get('admin') || Traccar.app.getVehicleFeaturesDisabled()); }, onGeofencesClick: function () { @@ -100,5 +102,15 @@ Ext.define('Traccar.view.DeviceMenuController', { baseObject: this.getView().up('deviceMenu').device.getId() } }).show(); + }, + + onDeviceDistanceClick: function () { + var position, dialog = Ext.create('Traccar.view.dialog.DeviceDistance'); + 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.show(); } }); diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js index 9ef12a3c..13d5e398 100644 --- a/web/app/view/SettingsMenu.js +++ b/web/app/view/SettingsMenu.js @@ -80,12 +80,6 @@ Ext.define('Traccar.view.SettingsMenu', { reference: 'settingsComputedAttributesButton' }, { hidden: true, - text: Strings.sharedDeviceDistance, - glyph: 'xf0e4@FontAwesome', - handler: 'onDeviceDistanceClick', - reference: 'settingsDeviceDistanceButton' - }, { - hidden: true, text: Strings.statisticsTitle, glyph: 'xf080@FontAwesome', handler: 'onStatisticsClick', diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 2ebb8589..e8893e3f 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -45,7 +45,6 @@ Ext.define('Traccar.view.SettingsMenuController', { if (admin) { this.lookupReference('settingsServerButton').setHidden(false); this.lookupReference('settingsStatisticsButton').setHidden(false); - this.lookupReference('settingsDeviceDistanceButton').setHidden(Traccar.app.getVehicleFeaturesDisabled()); } if (admin || manager) { this.lookupReference('settingsUsersButton').setHidden(false); @@ -136,11 +135,6 @@ Ext.define('Traccar.view.SettingsMenuController', { }).show(); }, - onDeviceDistanceClick: function () { - var dialog = Ext.create('Traccar.view.dialog.DeviceDistance'); - dialog.show(); - }, - onCalendarsClick: function () { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedCalendars, diff --git a/web/app/view/dialog/DeviceDistance.js b/web/app/view/dialog/DeviceDistance.js index c6ac9f20..53945885 100644 --- a/web/app/view/dialog/DeviceDistance.js +++ b/web/app/view/dialog/DeviceDistance.js @@ -27,17 +27,6 @@ Ext.define('Traccar.view.dialog.DeviceDistance', { title: Strings.sharedDeviceDistance, items: [{ - xtype: 'combobox', - reference: 'deviceId', - fieldLabel: Strings.sharedDevice, - store: 'AllDevices', - displayField: 'name', - valueField: 'id', - editable: false, - listeners: { - change: 'onDeviceChange' - } - }, { xtype: 'customNumberField', dataType: 'distance', reference: 'totalDistance', @@ -45,7 +34,6 @@ Ext.define('Traccar.view.dialog.DeviceDistance', { }], buttons: [{ - disabled: true, reference: 'setButton', glyph: 'xf00c@FontAwesome', tooltip: Strings.sharedSet, diff --git a/web/app/view/dialog/DeviceDistanceController.js b/web/app/view/dialog/DeviceDistanceController.js index bd9e059d..ae14f33c 100644 --- a/web/app/view/dialog/DeviceDistanceController.js +++ b/web/app/view/dialog/DeviceDistanceController.js @@ -20,21 +20,11 @@ Ext.define('Traccar.view.dialog.DeviceDistanceController', { extend: 'Ext.app.ViewController', alias: 'controller.deviceDistance', - onDeviceChange: function (combobox, newValue) { - var position; - this.lookupReference('setButton').setDisabled(newValue === null); - if (newValue) { - position = Ext.getStore('LatestPositions').findRecord('deviceId', newValue, 0, false, false, true); - if (position) { - this.lookupReference('totalDistance').setValue(position.get('attributes').totalDistance); - } - } - }, - - onSetClick: function (button) { - var data = {}; - data.deviceId = this.lookupReference('deviceId').getValue(); - data.totalDistance = this.lookupReference('totalDistance').getValue(); + onSetClick: function () { + var data = { + deviceId: this.getView().deviceId, + totalDistance: this.lookupReference('totalDistance').getValue() + }; Ext.Ajax.request({ scope: this, method: 'PUT', @@ -46,6 +36,6 @@ Ext.define('Traccar.view.dialog.DeviceDistanceController', { } } }); - button.up('window').close(); + this.closeView(); } }); |