aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/edit/DevicesController.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-14 22:59:54 +1200
committerGitHub <noreply@github.com>2017-09-14 22:59:54 +1200
commitca960df40e15d7bfb88d2e0e41a269d4b069058c (patch)
tree0b41508a3f856700c353e5a5082c6ea829f13d43 /web/app/view/edit/DevicesController.js
parent4193ac77fd9f0da264284a6f73601963995554c8 (diff)
parentbe47d612285d484e2d0a2aa43174fb8e36acd816 (diff)
downloadtrackermap-web-ca960df40e15d7bfb88d2e0e41a269d4b069058c.tar.gz
trackermap-web-ca960df40e15d7bfb88d2e0e41a269d4b069058c.tar.bz2
trackermap-web-ca960df40e15d7bfb88d2e0e41a269d4b069058c.zip
Merge pull request #585 from Abyss777/saved_commands
Implement Saved Commands
Diffstat (limited to 'web/app/view/edit/DevicesController.js')
-rw-r--r--web/app/view/edit/DevicesController.js45
1 files changed, 27 insertions, 18 deletions
diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js
index df75b1d4..915f724a 100644
--- a/web/app/view/edit/DevicesController.js
+++ b/web/app/view/edit/DevicesController.js
@@ -20,11 +20,12 @@ Ext.define('Traccar.view.edit.DevicesController', {
alias: 'controller.devices',
requires: [
- 'Traccar.view.dialog.Command',
+ 'Traccar.view.dialog.SendCommand',
'Traccar.view.dialog.Device',
- 'Traccar.view.permissions.DeviceGeofences',
- 'Traccar.view.permissions.DeviceAttributes',
- 'Traccar.view.permissions.DeviceDrivers',
+ 'Traccar.view.permissions.Geofences',
+ 'Traccar.view.permissions.ComputedAttributes',
+ 'Traccar.view.permissions.Drivers',
+ 'Traccar.view.permissions.SavedCommands',
'Traccar.view.BaseWindow',
'Traccar.model.Device',
'Traccar.model.Command'
@@ -76,7 +77,7 @@ Ext.define('Traccar.view.edit.DevicesController', {
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedGeofences,
items: {
- xtype: 'deviceGeofencesView',
+ xtype: 'linkGeofencesView',
baseObjectName: 'deviceId',
linkObjectName: 'geofenceId',
storeName: 'Geofences',
@@ -90,7 +91,7 @@ Ext.define('Traccar.view.edit.DevicesController', {
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedComputedAttributes,
items: {
- xtype: 'deviceAttributesView',
+ xtype: 'linkComputedAttributesView',
baseObjectName: 'deviceId',
linkObjectName: 'attributeId',
storeName: 'ComputedAttributes',
@@ -104,7 +105,7 @@ Ext.define('Traccar.view.edit.DevicesController', {
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedDrivers,
items: {
- xtype: 'deviceDriversView',
+ xtype: 'linkDriversView',
baseObjectName: 'deviceId',
linkObjectName: 'driverId',
storeName: 'Drivers',
@@ -114,22 +115,30 @@ Ext.define('Traccar.view.edit.DevicesController', {
},
onCommandClick: function () {
- var device, deviceId, command, dialog, typesStore, online;
+ var device, deviceId, dialog, typesStore, online, commandsStore;
device = this.getView().getSelectionModel().getSelection()[0];
online = device.get('status') === 'online';
deviceId = device.get('id');
- command = Ext.create('Traccar.model.Command');
- command.set('deviceId', deviceId);
- command.set('textChannel', !online);
-
- dialog = Ext.create('Traccar.view.dialog.Command');
-
- typesStore = dialog.lookupReference('commandType').getStore();
- typesStore.getProxy().setExtraParam('deviceId', deviceId);
+ dialog = Ext.create('Traccar.view.dialog.SendCommand');
+ dialog.deviceId = deviceId;
+ dialog.online = online;
+
+ commandsStore = dialog.lookupReference('commandsComboBox').getStore();
+ commandsStore.getProxy().setExtraParam('deviceId', deviceId);
+ if (!Traccar.app.getPreference('limitCommands', false)) {
+ commandsStore.add({
+ id: 0,
+ description: Strings.sharedNew,
+ textChannel: !online
+ });
+ typesStore = dialog.lookupReference('commandType').getStore();
+ typesStore.getProxy().setExtraParam('deviceId', deviceId);
+ }
+ commandsStore.load({
+ addRecords: true
+ });
- dialog.down('form').loadRecord(command);
- dialog.lookupReference('textChannelCheckBox').setDisabled(!online);
dialog.show();
},