Skip to content

Commit 11a8398

Browse files
committed
web app does not look good but seems to be working
1 parent 3bc2f72 commit 11a8398

File tree

3 files changed

+80
-4
lines changed

3 files changed

+80
-4
lines changed

.bowerrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"directory": "src/bower_components"
2+
"directory": "src/client/bower_components"
33
}

bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"tests"
1616
],
1717
"dependencies": {
18-
"polymer": "^1.8.0"
18+
"polymer": "^1.8.0",
19+
"express-web-components": "^0.4.2",
20+
"jfive-web-components": "^0.0.7",
21+
"iron-ajax": "^1.4.3"
1922
}
2023
}
Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,83 @@
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">
33

44
<dom-module id="copter-user-controls">
55
<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>
642
</template>
743

844
<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);
982
</script>
1083
</dom-module>

0 commit comments

Comments
 (0)