|
1 |
| -<link rel="import" href="bower_components/polymer/polymer.html"> |
2 |
| -<link rel="import" href="bower_components/iron-ajax/iron-ajax.html"> |
| 1 | +<link rel="import" href="../../bower_components/polymer/polymer.html"> |
| 2 | +<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> |
3 | 3 |
|
4 | 4 | <dom-module id="copter-user-controls">
|
5 | 5 | <template>
|
| 6 | + <iron-ajax auto method="post" url="[[urlCommand]]"></iron-ajax> |
| 7 | + |
| 8 | + <div>All Motors</div> |
| 9 | + <button on-click="motorOnClick">On</button> |
| 10 | + <button on-click="motorOffClick">Off</button> |
| 11 | + <button on-click="motorIncreaseSpeedClick">Speed Up</button> |
| 12 | + <button on-click="motorDecreaseSpeedClick">Speed Down</button> |
| 13 | + <button on-click="motorReverseClick">Reverse</button> |
| 14 | + |
| 15 | + <div>Motor 1</div> |
| 16 | + <button on-click="motorOnClick" data-motor-id="1">On</button> |
| 17 | + <button on-click="motorOffClick" data-motor-id="1">Off</button> |
| 18 | + <button on-click="motorIncreaseSpeedClick" data-motor-id="1">Speed Up</button> |
| 19 | + <button on-click="motorDecreaseSpeedClick" data-motor-id="1">Speed Down</button> |
| 20 | + <button on-click="motorReverseClick" data-motor-id="1">Reverse</button> |
| 21 | + |
| 22 | + <div>Motor 2</div> |
| 23 | + <button on-click="motorOnClick" data-motor-id="2">On</button> |
| 24 | + <button on-click="motorOffClick" data-motor-id="2">Off</button> |
| 25 | + <button on-click="motorIncreaseSpeedClick" data-motor-id="2">Speed Up</button> |
| 26 | + <button on-click="motorDecreaseSpeedClick" data-motor-id="2">Speed Down</button> |
| 27 | + <button on-click="motorReverseClick" data-motor-id="2">Reverse</button> |
| 28 | + |
| 29 | + <div>Motor 3</div> |
| 30 | + <button on-click="motorOnClick" data-motor-id="3">On</button> |
| 31 | + <button on-click="motorOffClick" data-motor-id="3">Off</button> |
| 32 | + <button on-click="motorIncreaseSpeedClick" data-motor-id="3">Speed Up</button> |
| 33 | + <button on-click="motorDecreaseSpeedClick" data-motor-id="3">Speed Down</button> |
| 34 | + <button on-click="motorReverseClick" data-motor-id="3">Reverse</button> |
| 35 | + |
| 36 | + <div>Motor 4</div> |
| 37 | + <button on-click="motorOnClick" data-motor-id="4">On</button> |
| 38 | + <button on-click="motorOffClick" data-motor-id="4">Off</button> |
| 39 | + <button on-click="motorIncreaseSpeedClick" data-motor-id="4">Speed Up</button> |
| 40 | + <button on-click="motorDecreaseSpeedClick" data-motor-id="4">Speed Down</button> |
| 41 | + <button on-click="motorReverseClick" data-motor-id="4">Reverse</button> |
6 | 42 | </template>
|
7 | 43 |
|
8 | 44 | <script>
|
| 45 | + class CopterUserControls { |
| 46 | + beforeRegister() { |
| 47 | + this.is = 'copter-user-controls'; |
| 48 | + } |
| 49 | + |
| 50 | + motorOnClick(e) { |
| 51 | + const motorId = e.target.dataset.motorId; |
| 52 | + this.urlCommand = ''; |
| 53 | + this.urlCommand = `motor-on/${motorId}`; |
| 54 | + } |
| 55 | + |
| 56 | + motorOffClick(e) { |
| 57 | + const motorId = e.target.dataset.motorId; |
| 58 | + this.urlCommand = ''; |
| 59 | + this.urlCommand = `motor-off/${motorId}`; |
| 60 | + } |
| 61 | + |
| 62 | + motorIncreaseSpeedClick(e) { |
| 63 | + const motorId = e.target.dataset.motorId; |
| 64 | + this.urlCommand = ''; |
| 65 | + this.urlCommand = `motor-increase-speed/${motorId}`; |
| 66 | + } |
| 67 | + |
| 68 | + motorDecreaseSpeedClick(e) { |
| 69 | + const motorId = e.target.dataset.motorId; |
| 70 | + this.urlCommand = ''; |
| 71 | + this.urlCommand = `motor-decrease-speed/${motorId}`; |
| 72 | + } |
| 73 | + |
| 74 | + motorReverseClick(e) { |
| 75 | + const motorId = e.target.dataset.motorId; |
| 76 | + this.urlCommand = ''; |
| 77 | + this.urlCommand = `motor-reverse/${motorId}`; |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + Polymer(CopterUserControls); |
9 | 82 | </script>
|
10 | 83 | </dom-module>
|
0 commit comments