diff options
author | Gábor Somogyi <gabor.g.somogyi@gmail.com> | 2016-04-27 22:22:08 +0200 |
---|---|---|
committer | Gábor Somogyi <gabor.g.somogyi@gmail.com> | 2016-04-27 22:34:17 +0200 |
commit | bf68718e05f811ffeb2b4b57acab56dca3e7de56 (patch) | |
tree | 5853e81ae5d08e996d1600504027c7a870202643 /web/app | |
parent | 44f026f881efa6207ab79fb5bada20ab67f018a0 (diff) | |
download | trackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.tar.gz trackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.tar.bz2 trackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.zip |
Command framework ugly hack version
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Application.js | 5 | ||||
-rw-r--r-- | web/app/model/SupportedCommand.js | 28 | ||||
-rw-r--r-- | web/app/store/SupportedCommands.js (renamed from web/app/store/CommandTypes.js) | 31 | ||||
-rw-r--r-- | web/app/view/CommandDialog.js | 2 | ||||
-rw-r--r-- | web/app/view/DevicesController.js | 7 |
5 files changed, 52 insertions, 21 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index 69ce8f891..da3fdd505 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -30,7 +30,8 @@ Ext.define('Traccar.Application', { 'Device', 'Position', 'Attribute', - 'Command' + 'Command', + 'SupportedCommand' ], stores: [ @@ -45,7 +46,7 @@ Ext.define('Traccar.Application', { 'MapTypes', 'DistanceUnits', 'SpeedUnits', - 'CommandTypes', + 'SupportedCommands', 'TimeUnits', 'Languages' ], diff --git a/web/app/model/SupportedCommand.js b/web/app/model/SupportedCommand.js new file mode 100644 index 000000000..35c34c8cd --- /dev/null +++ b/web/app/model/SupportedCommand.js @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@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.SupportedCommand', { + extend: 'Ext.data.Model', + identifier: 'negative', + + fields: [{ + name: 'key', + type: 'string' + }, { + name: 'name', + type: 'string' + }] +}); diff --git a/web/app/store/CommandTypes.js b/web/app/store/SupportedCommands.js index 3f5094266..2b052b902 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/SupportedCommands.js @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,21 +14,20 @@ * limitations under the License. */ -Ext.define('Traccar.store.CommandTypes', { +Ext.define('Traccar.store.SupportedCommands', { extend: 'Ext.data.Store', - fields: ['key', 'name'], + model: 'Traccar.model.SupportedCommand', - data: [{ - key: 'positionPeriodic', - name: Strings.commandPositionPeriodic - }, { - key: 'positionStop', - name: Strings.commandPositionStop - }, { - key: 'engineStop', - name: Strings.commandEngineStop - }, { - key: 'engineResume', - name: Strings.commandEngineResume - }] + listeners: { + 'beforeload' : function(store, options) { + var proxy; + proxy = store.getProxy(); + proxy.setUrl('/api/devices/' + proxy.extraParams.deviceId + '/supportedcommands'); + } + }, + + proxy: { + type: 'rest', + url: '' + } }); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 66cd190ea..e24105699 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -30,7 +30,7 @@ Ext.define('Traccar.view.CommandDialog', { xtype: 'combobox', name: 'type', fieldLabel: Strings.commandType, - store: 'CommandTypes', + store: 'SupportedCommands', displayField: 'name', valueField: 'key', listeners: { diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 10918c13a..9dee0ff7c 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -80,11 +80,14 @@ Ext.define('Traccar.view.DevicesController', { }, onCommandClick: function () { - var device, command, dialog; + var device, deviceId, command, dialog, comboStore; device = this.getView().getSelectionModel().getSelection()[0]; + deviceId = device.get('id'); command = Ext.create('Traccar.model.Command'); - command.set('deviceId', device.get('id')); + command.set('deviceId', deviceId); dialog = Ext.create('Traccar.view.CommandDialog'); + comboStore = dialog.down('form').down('combobox').getStore(); + comboStore.getProxy().setExtraParam('deviceId', deviceId); dialog.down('form').loadRecord(command); dialog.show(); }, |