diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/app/Application.js | 6 | ||||
-rw-r--r-- | web/app/model/Command.js | 26 | ||||
-rw-r--r-- | web/app/store/CommandTypes.js | 26 | ||||
-rw-r--r-- | web/app/view/command/CommandDialog.js | 52 | ||||
-rw-r--r-- | web/app/view/command/CommandDialogController.js | 45 | ||||
-rw-r--r-- | web/app/view/device/DeviceController.js | 9 | ||||
-rw-r--r-- | web/l10n/en.js | 10 |
7 files changed, 169 insertions, 5 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index 55b8f774c..7e5a8ff97 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -28,7 +28,8 @@ Ext.define('Traccar.Application', { 'User', 'Device', 'Position', - 'Parameter' + 'Parameter', + 'Command' ], stores: [ @@ -39,7 +40,8 @@ Ext.define('Traccar.Application', { 'Parameters', 'MapTypes', 'DistanceUnits', - 'SpeedUnits' + 'SpeedUnits', + 'CommandTypes' ], controllers: [ diff --git a/web/app/model/Command.js b/web/app/model/Command.js new file mode 100644 index 000000000..642e5d13d --- /dev/null +++ b/web/app/model/Command.js @@ -0,0 +1,26 @@ +/* + * 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.model.Command', { + extend: 'Ext.data.Model', + identifier: 'negative', + + fields: [ + { name: 'deviceId', type: 'int' }, + { name: 'type', type: 'string' }, + { name: 'other' } + ] +}); diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js new file mode 100644 index 000000000..3906eb9a1 --- /dev/null +++ b/web/app/store/CommandTypes.js @@ -0,0 +1,26 @@ +/* + * 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.CommandTypes', { + extend: 'Ext.data.Store', + fields: ['key', 'name'], + data : [ + {'key': 'positionStop', 'name': strings.command_position_stop}, + {'key': 'positionFix', 'name': strings.command_position_fix}, + {'key': 'engineStop', 'name': strings.command_engine_stop}, + {'key': 'engineResume', 'name': strings.command_engine_resume} + ] +}); diff --git a/web/app/view/command/CommandDialog.js b/web/app/view/command/CommandDialog.js new file mode 100644 index 000000000..ef99c4db6 --- /dev/null +++ b/web/app/view/command/CommandDialog.js @@ -0,0 +1,52 @@ +/* + * 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.view.command.CommandDialog', { + extend: 'Ext.window.Window', + xtype: 'command-dialog', + + requires: [ + 'Traccar.view.command.CommandDialogController' + ], + + controller: 'commanddialog', + + bodyPadding: styles.panel_padding, + title: strings.command_title, + resizable: false, + modal: true, + + items: { + xtype: 'form', + items: [{ + xtype: 'combobox', + name: 'type', + fieldLabel: strings.command_type, + store: 'CommandTypes', + displayField: 'name', + valueField: 'key' + }] + }, + + buttons: [{ + text: strings.command_send, + handler: 'onSendClick' + }, { + text: strings.shared_cancel, + handler: 'onCancelClick' + }] + +}); diff --git a/web/app/view/command/CommandDialogController.js b/web/app/view/command/CommandDialogController.js new file mode 100644 index 000000000..08624bf73 --- /dev/null +++ b/web/app/view/command/CommandDialogController.js @@ -0,0 +1,45 @@ +/* + * 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.view.command.CommandDialogController', { + extend: 'Ext.app.ViewController', + alias: 'controller.commanddialog', + + onSendClick: function(button) { + var dialog = button.up('window').down('form'); + dialog.updateRecord(); + var record = dialog.getRecord(); + + Ext.Ajax.request({ + scope: this, + url: '/api/command/send', + jsonData: record.getData(), + callback: this.onSendReturn + }); + }, + + onSendReturn: function(options, success, response) { + if (Traccar.ErrorManager.check(success, response)) { + this.closeView(); + Ext.toast(strings.login_created); + } + }, + + onCancelClick: function(button) { + button.up('window').close(); + } + +}); diff --git a/web/app/view/device/DeviceController.js b/web/app/view/device/DeviceController.js index 794e0f03d..f5577f156 100644 --- a/web/app/view/device/DeviceController.js +++ b/web/app/view/device/DeviceController.js @@ -20,6 +20,7 @@ Ext.define('Traccar.view.device.DeviceController', { requires: [ 'Traccar.view.device.DeviceDialog', + 'Traccar.view.command.CommandDialog', 'Traccar.view.user.UserDialog', 'Traccar.view.admin.ServerDialog', 'Traccar.view.user.User' @@ -82,9 +83,13 @@ Ext.define('Traccar.view.device.DeviceController', { onCommandClick: function() { var device = this.getView().getSelectionModel().getSelection()[0]; - console.log('send command here'); + var command = Ext.create('Traccar.model.Command'); + command.set('deviceId', device.get('id')); + var dialog = Ext.create('Traccar.view.command.CommandDialog'); + dialog.down('form').loadRecord(command); + dialog.show(); }, - + onSelectionChange: function(selected) { var empty = selected.getCount() === 0; this.lookupReference('deviceEditButton').setDisabled(empty); diff --git a/web/l10n/en.js b/web/l10n/en.js index 97612e56a..c1f7360a5 100644 --- a/web/l10n/en.js +++ b/web/l10n/en.js @@ -68,5 +68,13 @@ var strings = { state_title: 'State', state_name: 'Parameter', - state_value: 'Value' + state_value: 'Value', + + command_title: 'Command', + command_send: 'Send', + command_type: 'Type', + command_position_stop: 'Position Stop', + command_position_fix: 'Position Fix', + command_engine_stop: 'Engine Stop', + command_engine_resume: 'Engine Resume' }; |