From 92c3085546df5f3160c18c536c6183d15ef4b781 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 17 May 2016 15:53:04 +0500 Subject: Custom command support for web-interface --- src/org/traccar/BaseProtocol.java | 1 + web/app/view/CommandDialog.js | 7 +++++++ web/app/view/CommandDialogController.js | 9 +++++++++ web/l10n/en.json | 3 ++- web/l10n/ru.json | 3 ++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index 446f57d65..d1791d673 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -42,6 +42,7 @@ public abstract class BaseProtocol implements Protocol { public void setSupportedCommands(String... commands) { supportedCommands.addAll(Arrays.asList(commands)); + supportedCommands.add(Command.TYPE_CUSTOM); } @Override diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index d23b50d4c..031815273 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -54,6 +54,13 @@ Ext.define('Traccar.view.CommandDialog', { displayField: 'name', valueField: 'factor' }] + }, { + xtype: 'textfield', + reference: 'paramCustom', + fieldLabel: Strings.commandCustom, + name: 'customCommand', + hidden: true, + allowBlank: false }] }, diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js index 93109a2d6..1b5ca0ce0 100644 --- a/web/app/view/CommandDialogController.js +++ b/web/app/view/CommandDialogController.js @@ -21,6 +21,8 @@ Ext.define('Traccar.view.CommandDialogController', { onSelect: function (selected) { this.lookupReference('paramPositionPeriodic').setHidden( selected.getValue() !== 'positionPeriodic'); + this.lookupReference('paramCustom').setHidden( + selected.getValue() !== 'custom'); }, onSendClick: function (button) { @@ -40,6 +42,13 @@ Ext.define('Traccar.view.CommandDialogController', { }); } + if (record.get('type') === 'custom') { + value = this.lookupReference('paramCustom').getValue(); + record.set('attributes', { + data: value + }); + } + Ext.Ajax.request({ scope: this, url: '/api/commands', diff --git a/web/l10n/en.json b/web/l10n/en.json index 1c8cc2bd0..8ce017b52 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -85,5 +85,6 @@ "commandEngineStop": "Engine Stop", "commandEngineResume": "Engine Resume", "commandFrequency": "Frequency", - "commandUnit": "Unit" + "commandUnit": "Unit", + "commandCustom": "Custom command" } \ No newline at end of file diff --git a/web/l10n/ru.json b/web/l10n/ru.json index 4ec4a606c..52279a9e2 100644 --- a/web/l10n/ru.json +++ b/web/l10n/ru.json @@ -85,5 +85,6 @@ "commandEngineStop": "Заблокировать Двигатель", "commandEngineResume": "Разблокировать Двигатель", "commandFrequency": "Частота", - "commandUnit": "Единицы" + "commandUnit": "Единицы", + "commandCustom": "Пользовательская команда" } \ No newline at end of file -- cgit v1.2.3 From 5c1226a4557a894ad690aecd197da3d1a4ec5c79 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 18 May 2016 09:33:20 +0500 Subject: Removed ru string, it is need to be translated via Transifex --- web/l10n/ru.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/l10n/ru.json b/web/l10n/ru.json index 52279a9e2..4ec4a606c 100644 --- a/web/l10n/ru.json +++ b/web/l10n/ru.json @@ -85,6 +85,5 @@ "commandEngineStop": "Заблокировать Двигатель", "commandEngineResume": "Разблокировать Двигатель", "commandFrequency": "Частота", - "commandUnit": "Единицы", - "commandCustom": "Пользовательская команда" + "commandUnit": "Единицы" } \ No newline at end of file -- cgit v1.2.3 From 252530b36e2b7e09bfe16d301d1106f86ebf178d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 18 May 2016 09:55:19 +0500 Subject: Added more strings for commands --- web/l10n/en.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/l10n/en.json b/web/l10n/en.json index 8ce017b52..932cbfa78 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -86,5 +86,16 @@ "commandEngineResume": "Engine Resume", "commandFrequency": "Frequency", "commandUnit": "Unit", - "commandCustom": "Custom command" + "commandCustom": "Custom command", + "commandPositionSingle": "Single Reporting", + "commandAlarmArm": "Arm Alarm", + "commandAlarmDisarm": "Disarm Alarm", + "commandSetTimezone": "Set Timezone", + "commandRequestPhoto": "Request Photo", + "commandRebootDevice": "Reboot Device", + "commandSendSms": "Send SMS", + "commandSosNumber": "Set SOS Number", + "commandSilenceTime": "Set Silence Time", + "commandSetPhonebook": "Set Phonebook", + "commandVoiceMessage": "Voice Message" } \ No newline at end of file -- cgit v1.2.3