aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-20 22:27:29 +1200
committerGitHub <noreply@github.com>2017-09-20 22:27:29 +1200
commitee56eda11f169a8a9157098827b57a79dc7c841a (patch)
tree33158a0fca300aac5013e23a7fce89eb3998e8d4 /web
parentadf79e9bc86bc485ea3fa02c4d25b11d8fffee1f (diff)
parentc16972a1f574189b9b21fc237336440cdba10f0d (diff)
downloadetbsa-traccar-web-ee56eda11f169a8a9157098827b57a79dc7c841a.tar.gz
etbsa-traccar-web-ee56eda11f169a8a9157098827b57a79dc7c841a.tar.bz2
etbsa-traccar-web-ee56eda11f169a8a9157098827b57a79dc7c841a.zip
Merge pull request #589 from Abyss777/move_distance_menu
Move Device Distance to Device Menu
Diffstat (limited to 'web')
-rw-r--r--web/app/store/AllCommandTypes.js2
-rw-r--r--web/app/store/CommandTypes.js2
-rw-r--r--web/app/view/DeviceMenu.js6
-rw-r--r--web/app/view/DeviceMenuController.js12
-rw-r--r--web/app/view/SettingsMenu.js6
-rw-r--r--web/app/view/SettingsMenuController.js6
-rw-r--r--web/app/view/dialog/DeviceDistance.js12
-rw-r--r--web/app/view/dialog/DeviceDistanceController.js22
8 files changed, 26 insertions, 42 deletions
diff --git a/web/app/store/AllCommandTypes.js b/web/app/store/AllCommandTypes.js
index aac9d59..c86d071 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 f14cb59..3b898f2 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 236d5f4..ed4068f 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 4fa00be..9e5ef14 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 9ef12a3..13d5e39 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 2ebb858..e8893e3 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 c6ac9f2..5394588 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 bd9e059..ae14f33 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();
}
});