diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-05-09 14:47:28 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-05-09 14:47:28 +1200 |
commit | 4e44bf1fa20bf6ce41cc7e0eed9b79d079454f82 (patch) | |
tree | e145e20169c61e12bb57f9145bc0c626add5596d /web | |
parent | 7ed27b733d442cb442a8049263fab282b39e5872 (diff) | |
parent | 301f2d314f446410da78615ac76ce0c07571d445 (diff) | |
download | trackermap-server-4e44bf1fa20bf6ce41cc7e0eed9b79d079454f82.tar.gz trackermap-server-4e44bf1fa20bf6ce41cc7e0eed9b79d079454f82.tar.bz2 trackermap-server-4e44bf1fa20bf6ce41cc7e0eed9b79d079454f82.zip |
Merge pull request #1920 from gaborgsomogyi/command_framework
Get supported commands from server
Diffstat (limited to 'web')
-rw-r--r-- | web/app/store/CommandTypes.js | 45 | ||||
-rw-r--r-- | web/app/view/CommandDialog.js | 2 | ||||
-rw-r--r-- | web/app/view/DevicesController.js | 7 |
3 files changed, 36 insertions, 18 deletions
diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js index 3f5094266..2ef190edc 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/CommandTypes.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. @@ -16,19 +16,34 @@ Ext.define('Traccar.store.CommandTypes', { extend: 'Ext.data.Store', - fields: ['key', 'name'], + fields: ['type', 'name'], - 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) { + var proxy; + proxy = store.getProxy(); + proxy.setUrl('/api/commandtypes?deviceId' + proxy.extraParams.deviceId); + } + }, + + proxy: { + type: 'rest', + url: '', + reader: { + type: 'json', + getData: function(data) { + Ext.each(data, function(entry) { + entry.name = entry.type; + if (typeof entry.type !== "undefined") { + var nameKey = 'command' + entry.type.charAt(0).toUpperCase() + entry.type.slice(1); + var name = Strings[nameKey]; + if (typeof name !== "undefined") { + entry.name = name; + } + } + }); + return data; + } + } + } }); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 66cd190ea..d23b50d4c 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -32,7 +32,7 @@ Ext.define('Traccar.view.CommandDialog', { fieldLabel: Strings.commandType, store: 'CommandTypes', displayField: 'name', - valueField: 'key', + valueField: 'type', listeners: { select: 'onSelect' } 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(); }, |