aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/dialog
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view/dialog')
-rw-r--r--web/app/view/dialog/Command.js69
-rw-r--r--web/app/view/dialog/SavedCommand.js82
-rw-r--r--web/app/view/dialog/SavedCommandController.js (renamed from web/app/view/dialog/CommandController.js)49
-rw-r--r--web/app/view/dialog/SendCommand.js104
-rw-r--r--web/app/view/dialog/SendCommandController.js93
-rw-r--r--web/app/view/dialog/Server.js6
-rw-r--r--web/app/view/dialog/User.js8
-rw-r--r--web/app/view/dialog/UserController.js1
8 files changed, 313 insertions, 99 deletions
diff --git a/web/app/view/dialog/Command.js b/web/app/view/dialog/Command.js
deleted file mode 100644
index ce5b75b8..00000000
--- a/web/app/view/dialog/Command.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
- *
- * 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.dialog.Command', {
- extend: 'Traccar.view.dialog.Base',
-
- requires: [
- 'Traccar.view.dialog.CommandController'
- ],
-
- controller: 'command',
- title: Strings.commandTitle,
-
- items: {
- xtype: 'form',
- listeners: {
- validitychange: 'onValidityChange'
- },
- items: [{
- xtype: 'checkboxfield',
- name: 'textChannel',
- reference: 'textChannelCheckBox',
- inputValue: true,
- uncheckedValue: false,
- fieldLabel: Strings.notificationSms,
- listeners: {
- change: 'onTextChannelChange'
- }
- }, {
- xtype: 'combobox',
- name: 'type',
- reference: 'commandType',
- fieldLabel: Strings.sharedType,
- store: 'CommandTypes',
- displayField: 'name',
- valueField: 'type',
- editable: false,
- listeners: {
- select: 'onSelect'
- }
- }, {
- xtype: 'fieldcontainer',
- reference: 'parameters'
- }]
- },
-
- buttons: [{
- text: Strings.commandSend,
- reference: 'sendButton',
- handler: 'onSendClick'
- }, {
- text: Strings.sharedCancel,
- handler: 'closeView'
- }]
-});
diff --git a/web/app/view/dialog/SavedCommand.js b/web/app/view/dialog/SavedCommand.js
new file mode 100644
index 00000000..4759143a
--- /dev/null
+++ b/web/app/view/dialog/SavedCommand.js
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ *
+ * 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.dialog.SavedCommand', {
+ extend: 'Traccar.view.dialog.BaseEdit',
+
+ requires: [
+ 'Traccar.view.dialog.SavedCommandController'
+ ],
+
+ controller: 'savedCommand',
+ title: Strings.sharedSavedCommand,
+
+ items: [{
+ xtype: 'form',
+ listeners: {
+ validitychange: 'onValidityChange'
+ },
+ items: [{
+ xtype: 'fieldset',
+ title: Strings.sharedRequired,
+ items: [{
+ xtype: 'textfield',
+ name: 'description',
+ fieldLabel: Strings.sharedDescription
+ }, {
+ xtype: 'checkboxfield',
+ name: 'textChannel',
+ inputValue: true,
+ uncheckedValue: false,
+ fieldLabel: Strings.notificationSms
+ }, {
+ xtype: 'combobox',
+ name: 'type',
+ reference: 'commandType',
+ fieldLabel: Strings.sharedType,
+ store: 'AllCommandTypes',
+ queryMode: 'local',
+ displayField: 'name',
+ valueField: 'type',
+ editable: false,
+ allowBlank: false,
+ listeners: {
+ change: 'onTypeChange'
+ }
+ }, {
+ xtype: 'fieldcontainer',
+ reference: 'parameters'
+ }]
+ }]
+ }],
+
+ buttons: [{
+ glyph: 'xf00c@FontAwesome',
+ reference: 'saveButton',
+ tooltip: Strings.sharedSave,
+ tooltipType: 'title',
+ minWidth: 0,
+ disabled: true,
+ handler: 'onSaveClick'
+ }, {
+ glyph: 'xf00d@FontAwesome',
+ tooltip: Strings.sharedCancel,
+ tooltipType: 'title',
+ minWidth: 0,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/dialog/CommandController.js b/web/app/view/dialog/SavedCommandController.js
index 0687f670..37c56603 100644
--- a/web/app/view/dialog/CommandController.js
+++ b/web/app/view/dialog/SavedCommandController.js
@@ -15,18 +15,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-Ext.define('Traccar.view.dialog.CommandController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.command',
+Ext.define('Traccar.view.dialog.SavedCommandController', {
+ extend: 'Traccar.view.dialog.BaseEditController',
+ alias: 'controller.savedCommand',
defaultFieldConfig: {
allowBlank: false
},
- onSelect: function (selected) {
- var i, config, command, parameters, parameter;
+ onTypeChange: function (combo, newValue) {
+ var i, config, command, parameters, parameter, record;
+ record = combo.up('window').down('form').getRecord();
this.lookupReference('parameters').removeAll();
- command = Ext.getStore('KnownCommands').getById(selected.getValue());
+ command = Ext.getStore('KnownCommands').getById(newValue);
if (command && command.get('parameters')) {
parameters = command.get('parameters');
for (i = 0; i < parameters.length; i++) {
@@ -34,6 +35,10 @@ Ext.define('Traccar.view.dialog.CommandController', {
config = Ext.clone(this.defaultFieldConfig);
config.key = parameter.get('key');
config.fieldLabel = parameter.get('name');
+ if (record.get('attributes')) {
+ config.value = record.get('attributes')[parameter.get('key')];
+ }
+ config.disabled = combo.isDisabled();
switch (parameter.get('valueType')) {
case 'number':
config.xtype = 'customNumberField';
@@ -67,8 +72,8 @@ Ext.define('Traccar.view.dialog.CommandController', {
}
},
- onSendClick: function (button) {
- var i, record, form, parameters, attributes = {};
+ fillAttributes: function (button) {
+ var i, form, record, parameters, attributes = {};
form = button.up('window').down('form');
form.updateRecord();
@@ -80,31 +85,15 @@ Ext.define('Traccar.view.dialog.CommandController', {
}
record.set('attributes', attributes);
-
- Ext.Ajax.request({
- scope: this,
- url: 'api/commands',
- jsonData: record.getData(),
- callback: this.onSendResult
- });
- },
-
- onValidityChange: function (form, valid) {
- this.lookupReference('sendButton').setDisabled(!valid);
},
- onTextChannelChange: function (checkbox, newValue) {
- var typesStore = this.lookupReference('commandType').getStore();
- typesStore.getProxy().setExtraParam('textChannel', newValue);
- typesStore.reload();
+ onSaveClick: function (button) {
+ this.fillAttributes(button);
+ this.callParent(arguments);
},
- onSendResult: function (options, success, response) {
- if (success) {
- this.closeView();
- Traccar.app.showToast(Strings.commandSent);
- } else {
- Traccar.app.showError(response);
- }
+ onValidityChange: function (form, valid) {
+ this.lookupReference('saveButton').setDisabled(!valid);
}
+
});
diff --git a/web/app/view/dialog/SendCommand.js b/web/app/view/dialog/SendCommand.js
new file mode 100644
index 00000000..0bb7d610
--- /dev/null
+++ b/web/app/view/dialog/SendCommand.js
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * 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.dialog.SendCommand', {
+ extend: 'Traccar.view.dialog.Base',
+
+ requires: [
+ 'Traccar.view.dialog.SendCommandController'
+ ],
+
+ controller: 'sendCommand',
+ title: Strings.commandTitle,
+
+ items: [{
+ xtype: 'combobox',
+ reference: 'commandsComboBox',
+ fieldLabel: Strings.sharedSavedCommand,
+ displayField: 'description',
+ valueField: 'id',
+ store: 'DeviceCommands',
+ queryMode: 'local',
+ editable: false,
+ allowBlank: false,
+ listeners: {
+ select: 'onCommandSelect'
+ }
+ }, {
+ xtype: 'form',
+ listeners: {
+ validitychange: 'onValidityChange'
+ },
+ items: [{
+ xtype: 'fieldset',
+ reference: 'newCommandFields',
+ disabled: true,
+ items: [{
+ xtype: 'checkboxfield',
+ name: 'textChannel',
+ reference: 'textChannelCheckBox',
+ inputValue: true,
+ uncheckedValue: false,
+ fieldLabel: Strings.notificationSms,
+ listeners: {
+ change: 'onTextChannelChange'
+ }
+ }, {
+ xtype: 'combobox',
+ name: 'type',
+ reference: 'commandType',
+ fieldLabel: Strings.sharedType,
+ store: 'CommandTypes',
+ displayField: 'name',
+ valueField: 'type',
+ editable: false,
+ allowBlank: false,
+ listeners: {
+ change: 'onTypeChange'
+ }
+ }, {
+ xtype: 'fieldcontainer',
+ reference: 'parameters'
+ }]
+ }]
+ }],
+
+ buttons: [{
+ glyph: 'xf093@FontAwesome',
+ text: Strings.sharedSavedCommands,
+ reference: 'linkButton',
+ handler: 'onLinkCommands',
+ hidden: true
+ }, {
+ xtype: 'tbfill'
+ }, {
+ glyph: 'xf093@FontAwesome',
+ tooltip: Strings.sharedSend,
+ tooltipType: 'title',
+ minWidth: 0,
+ disabled: true,
+ reference: 'sendButton',
+ handler: 'onSendClick'
+ }, {
+ glyph: 'xf00d@FontAwesome',
+ tooltip: Strings.sharedCancel,
+ tooltipType: 'title',
+ minWidth: 0,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/dialog/SendCommandController.js b/web/app/view/dialog/SendCommandController.js
new file mode 100644
index 00000000..3bd2ad4a
--- /dev/null
+++ b/web/app/view/dialog/SendCommandController.js
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * 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.dialog.SendCommandController', {
+ extend: 'Traccar.view.dialog.SavedCommandController',
+ alias: 'controller.sendCommand',
+
+ requires: [
+ 'Traccar.view.permissions.SavedCommands'
+ ],
+
+ init: function () {
+ this.lookupReference('linkButton').setHidden(Traccar.app.getPreference('limitCommands', false));
+ },
+
+ onSendClick: function (button) {
+ var record;
+ this.fillAttributes(button);
+ record = button.up('window').down('form').getRecord();
+
+ Ext.Ajax.request({
+ scope: this,
+ url: 'api/commands/send',
+ jsonData: record.getData({
+ persist: true
+ }),
+ callback: this.onSendResult
+ });
+ },
+
+ onValidityChange: function (form, valid) {
+ this.lookupReference('sendButton').setDisabled(!valid ||
+ this.lookupReference('commandsComboBox').getValue() === null);
+ },
+
+ onTextChannelChange: function (checkbox, newValue) {
+ var typesStore = this.lookupReference('commandType').getStore();
+ typesStore.getProxy().setExtraParam('textChannel', newValue);
+ typesStore.reload();
+ },
+
+ onCommandSelect: function (selected) {
+ var record, form, command = selected.getStore().getById(selected.getValue());
+ command.set('deviceId', this.getView().deviceId);
+ form = selected.up('window').down('form');
+ record = form.getRecord();
+ form.loadRecord(command);
+ if (record && command.get('type') === record.get('type')) {
+ this.onTypeChange(this.lookupReference('commandType'), command.get('type'));
+ }
+
+ this.lookupReference('newCommandFields').setDisabled(command.getId() !== 0);
+ this.lookupReference('textChannelCheckBox').setDisabled(command.getId() !== 0 || !this.getView().online);
+ this.lookupReference('sendButton').setDisabled(command.getId() === 0);
+ },
+
+ onLinkCommands: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedSavedCommands,
+ items: {
+ xtype: 'linkSavedCommandsView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'commandId',
+ storeName: 'Commands',
+ baseObject: this.getView().deviceId
+ }
+ }).show();
+ },
+
+ onSendResult: function (options, success, response) {
+ if (success) {
+ this.closeView();
+ Traccar.app.showToast(Strings.commandSent);
+ } else {
+ Traccar.app.showError(response);
+ }
+ }
+});
diff --git a/web/app/view/dialog/Server.js b/web/app/view/dialog/Server.js
index b6343f3c..1fe2184c 100644
--- a/web/app/view/dialog/Server.js
+++ b/web/app/view/dialog/Server.js
@@ -107,6 +107,12 @@ Ext.define('Traccar.view.dialog.Server', {
uncheckedValue: false,
name: 'deviceReadonly',
fieldLabel: Strings.userDeviceReadonly
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'limitCommands',
+ fieldLabel: Strings.userLimitCommands
}]
}]
},
diff --git a/web/app/view/dialog/User.js b/web/app/view/dialog/User.js
index 43990a54..36bccfeb 100644
--- a/web/app/view/dialog/User.js
+++ b/web/app/view/dialog/User.js
@@ -133,6 +133,14 @@ Ext.define('Traccar.view.dialog.User', {
disabled: true,
reference: 'deviceReadonlyField'
}, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'limitCommands',
+ fieldLabel: Strings.userLimitCommands,
+ disabled: true,
+ reference: 'limitCommandsField'
+ }, {
xtype: 'datefield',
name: 'expirationTime',
fieldLabel: Strings.userExpirationTime,
diff --git a/web/app/view/dialog/UserController.js b/web/app/view/dialog/UserController.js
index 89b0bc83..6f2c03a1 100644
--- a/web/app/view/dialog/UserController.js
+++ b/web/app/view/dialog/UserController.js
@@ -30,6 +30,7 @@ Ext.define('Traccar.view.dialog.UserController', {
this.lookupReference('disabledField').setDisabled(false);
this.lookupReference('expirationTimeField').setDisabled(false);
this.lookupReference('deviceReadonlyField').setDisabled(false);
+ this.lookupReference('limitCommandsField').setDisabled(false);
}
},