From cfa8225c8298fd933d92f62928edbd1f6f9096fc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Jul 2015 12:28:03 +1200 Subject: Extra parameters for commands --- web/app/Application.js | 3 ++- web/app/store/TimeUnits.js | 25 +++++++++++++++++++++++++ web/app/view/command/CommandDialog.js | 23 ++++++++++++++++++++++- web/app/view/command/CommandDialogController.js | 21 ++++++++++++++++++--- 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 web/app/store/TimeUnits.js (limited to 'web/app') diff --git a/web/app/Application.js b/web/app/Application.js index 7e5a8ff97..b93ef2f28 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -41,7 +41,8 @@ Ext.define('Traccar.Application', { 'MapTypes', 'DistanceUnits', 'SpeedUnits', - 'CommandTypes' + 'CommandTypes', + 'TimeUnits' ], controllers: [ diff --git a/web/app/store/TimeUnits.js b/web/app/store/TimeUnits.js new file mode 100644 index 000000000..e8cda7b26 --- /dev/null +++ b/web/app/store/TimeUnits.js @@ -0,0 +1,25 @@ +/* + * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.define('Traccar.store.TimeUnits', { + extend: 'Ext.data.Store', + fields: ['multiplier', 'name'], + data : [ + {'multiplier': 1, 'name': strings.shared_second}, + {'multiplier': 60, 'name': strings.shared_minute}, + {'multiplier': 3600, 'name': strings.shared_hour} + ] +}); diff --git a/web/app/view/command/CommandDialog.js b/web/app/view/command/CommandDialog.js index ef99c4db6..7f4b3c592 100644 --- a/web/app/view/command/CommandDialog.js +++ b/web/app/view/command/CommandDialog.js @@ -37,7 +37,28 @@ Ext.define('Traccar.view.command.CommandDialog', { fieldLabel: strings.command_type, store: 'CommandTypes', displayField: 'name', - valueField: 'key' + valueField: 'key', + listeners: { + select: 'onSelect' + } + }, { + xtype: 'fieldcontainer', + reference: 'paramPositionFix', + name: 'other', + hidden: true, + + items: [{ + xtype: 'numberfield', + fieldLabel: strings.command_frequency, + name: 'frequency' + }, { + xtype: 'combobox', + fieldLabel: strings.command_unit, + name: 'unit', + store: 'TimeUnits', + displayField: 'name', + valueField: 'multiplier' + }] }] }, diff --git a/web/app/view/command/CommandDialogController.js b/web/app/view/command/CommandDialogController.js index 08624bf73..14d4ba2e0 100644 --- a/web/app/view/command/CommandDialogController.js +++ b/web/app/view/command/CommandDialogController.js @@ -18,10 +18,25 @@ Ext.define('Traccar.view.command.CommandDialogController', { extend: 'Ext.app.ViewController', alias: 'controller.commanddialog', + onSelect: function(selected) { + this.lookupReference('paramPositionFix').setHidden(selected.getValue() !== 'positionFix'); + }, + onSendClick: function(button) { - var dialog = button.up('window').down('form'); - dialog.updateRecord(); - var record = dialog.getRecord(); + var other; + var form = button.up('window').down('form'); + form.updateRecord(); + var record = form.getRecord(); + + if (record.get('type') === 'positionFix') { + other = this.lookupReference('paramPositionFix'); + var value = other.down('numberfield[name="frequency"]').getValue(); + value *= other.down('combobox[name="unit"]').getValue(); + + record.set('other', { + frequency: value + }); + } Ext.Ajax.request({ scope: this, -- cgit v1.2.3