Update templates/index.html
Browse files- templates/index.html +30 -25
templates/index.html
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
padding: 0;
|
11 |
box-sizing: border-box;
|
12 |
}
|
13 |
-
|
14 |
body {
|
15 |
min-height: 100vh;
|
16 |
background-color: #111827;
|
@@ -21,7 +20,6 @@
|
|
21 |
align-items: center;
|
22 |
padding: 1.5rem;
|
23 |
}
|
24 |
-
|
25 |
.container {
|
26 |
max-width: 28rem;
|
27 |
width: 100%;
|
@@ -29,17 +27,14 @@
|
|
29 |
flex-direction: column;
|
30 |
gap: 2rem;
|
31 |
}
|
32 |
-
|
33 |
.header {
|
34 |
text-align: center;
|
35 |
}
|
36 |
-
|
37 |
.title {
|
38 |
font-size: 2rem;
|
39 |
font-weight: bold;
|
40 |
margin-bottom: 0.5rem;
|
41 |
}
|
42 |
-
|
43 |
.status {
|
44 |
display: inline-flex;
|
45 |
align-items: center;
|
@@ -51,12 +46,10 @@
|
|
51 |
font-size: 0.875rem;
|
52 |
transition: all 0.3s ease;
|
53 |
}
|
54 |
-
|
55 |
.status.connected {
|
56 |
background-color: rgba(34, 197, 94, 0.2);
|
57 |
color: rgb(74, 222, 128);
|
58 |
}
|
59 |
-
|
60 |
.status::before {
|
61 |
content: '';
|
62 |
width: 0.5rem;
|
@@ -65,13 +58,26 @@
|
|
65 |
border-radius: 50%;
|
66 |
animation: pulse 2s infinite;
|
67 |
}
|
68 |
-
|
69 |
@keyframes pulse {
|
70 |
0% { opacity: 1; }
|
71 |
50% { opacity: 0.4; }
|
72 |
100% { opacity: 1; }
|
73 |
}
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
.control-pad {
|
76 |
display: grid;
|
77 |
grid-template-columns: repeat(3, 1fr);
|
@@ -80,7 +86,6 @@
|
|
80 |
margin: 0 auto;
|
81 |
place-items: center;
|
82 |
}
|
83 |
-
|
84 |
.control-button {
|
85 |
width: 4rem;
|
86 |
height: 4rem;
|
@@ -95,19 +100,16 @@
|
|
95 |
transition: all 0.2s;
|
96 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
97 |
}
|
98 |
-
|
99 |
.control-button:hover {
|
100 |
background-color: #4338ca;
|
101 |
transform: translateY(-2px);
|
102 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
103 |
}
|
104 |
-
|
105 |
.control-button:active {
|
106 |
background-color: #3730a3;
|
107 |
transform: translateY(0);
|
108 |
box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
|
109 |
}
|
110 |
-
|
111 |
.emergency-stop {
|
112 |
grid-column: 2;
|
113 |
grid-row: 2;
|
@@ -116,15 +118,12 @@
|
|
116 |
height: 4.5rem !important;
|
117 |
border: 3px solid #ef4444;
|
118 |
}
|
119 |
-
|
120 |
.emergency-stop:hover {
|
121 |
background-color: #b91c1c !important;
|
122 |
}
|
123 |
-
|
124 |
.emergency-stop:active {
|
125 |
background-color: #991b1b !important;
|
126 |
}
|
127 |
-
|
128 |
.control-button svg {
|
129 |
width: 1.5rem;
|
130 |
height: 1.5rem;
|
@@ -134,19 +133,16 @@
|
|
134 |
stroke-linecap: round;
|
135 |
stroke-linejoin: round;
|
136 |
}
|
137 |
-
|
138 |
.command-log {
|
139 |
background-color: #1f2937;
|
140 |
border-radius: 0.5rem;
|
141 |
padding: 1rem;
|
142 |
}
|
143 |
-
|
144 |
.command-log h2 {
|
145 |
font-size: 1.125rem;
|
146 |
font-weight: 600;
|
147 |
margin-bottom: 0.5rem;
|
148 |
}
|
149 |
-
|
150 |
.log-container {
|
151 |
height: 12rem;
|
152 |
overflow-y: auto;
|
@@ -154,14 +150,12 @@
|
|
154 |
flex-direction: column;
|
155 |
gap: 0.25rem;
|
156 |
}
|
157 |
-
|
158 |
.log-entry {
|
159 |
padding: 0.25rem 0.5rem;
|
160 |
background-color: rgba(55, 65, 81, 0.5);
|
161 |
border-radius: 0.25rem;
|
162 |
font-size: 0.875rem;
|
163 |
}
|
164 |
-
|
165 |
/* Grid positioning */
|
166 |
.btn-up { grid-column: 2; grid-row: 1; }
|
167 |
.btn-left { grid-column: 1; grid-row: 2; }
|
@@ -174,6 +168,7 @@
|
|
174 |
<div class="header">
|
175 |
<h1 class="title">Robot Controller</h1>
|
176 |
<div class="status">Disconnected</div>
|
|
|
177 |
</div>
|
178 |
|
179 |
<div class="control-pad">
|
@@ -192,7 +187,6 @@
|
|
192 |
<rect x="6" y="6" width="12" height="12" fill="white"/>
|
193 |
</svg>
|
194 |
</button>
|
195 |
-
</button>
|
196 |
<button class="control-button btn-right" data-direction="right">
|
197 |
<svg viewBox="0 0 24 24">
|
198 |
<path d="M5 12h14m-7-7 7 7-7 7"/>
|
@@ -217,6 +211,7 @@
|
|
217 |
const buttons = document.querySelectorAll('.control-button');
|
218 |
const status = document.querySelector('.status');
|
219 |
const logContainer = document.getElementById('logContainer');
|
|
|
220 |
let commandInterval = null;
|
221 |
let activeCommand = null;
|
222 |
let isButtonPressed = false;
|
@@ -231,6 +226,17 @@
|
|
231 |
status.classList.remove('connected');
|
232 |
});
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
function logCommand(command) {
|
235 |
const entry = document.createElement('div');
|
236 |
entry.className = 'log-entry';
|
@@ -252,7 +258,6 @@
|
|
252 |
sendCommand('emergency_stop');
|
253 |
return;
|
254 |
}
|
255 |
-
|
256 |
if (commandInterval) {
|
257 |
clearInterval(commandInterval);
|
258 |
}
|
@@ -280,7 +285,7 @@
|
|
280 |
|
281 |
buttons.forEach(button => {
|
282 |
const direction = button.dataset.direction;
|
283 |
-
|
284 |
button.addEventListener('mousedown', () => {
|
285 |
startCommand(direction);
|
286 |
if (direction !== 'emergency_stop') {
|
@@ -320,4 +325,4 @@
|
|
320 |
});
|
321 |
</script>
|
322 |
</body>
|
323 |
-
</html>
|
|
|
10 |
padding: 0;
|
11 |
box-sizing: border-box;
|
12 |
}
|
|
|
13 |
body {
|
14 |
min-height: 100vh;
|
15 |
background-color: #111827;
|
|
|
20 |
align-items: center;
|
21 |
padding: 1.5rem;
|
22 |
}
|
|
|
23 |
.container {
|
24 |
max-width: 28rem;
|
25 |
width: 100%;
|
|
|
27 |
flex-direction: column;
|
28 |
gap: 2rem;
|
29 |
}
|
|
|
30 |
.header {
|
31 |
text-align: center;
|
32 |
}
|
|
|
33 |
.title {
|
34 |
font-size: 2rem;
|
35 |
font-weight: bold;
|
36 |
margin-bottom: 0.5rem;
|
37 |
}
|
|
|
38 |
.status {
|
39 |
display: inline-flex;
|
40 |
align-items: center;
|
|
|
46 |
font-size: 0.875rem;
|
47 |
transition: all 0.3s ease;
|
48 |
}
|
|
|
49 |
.status.connected {
|
50 |
background-color: rgba(34, 197, 94, 0.2);
|
51 |
color: rgb(74, 222, 128);
|
52 |
}
|
|
|
53 |
.status::before {
|
54 |
content: '';
|
55 |
width: 0.5rem;
|
|
|
58 |
border-radius: 50%;
|
59 |
animation: pulse 2s infinite;
|
60 |
}
|
|
|
61 |
@keyframes pulse {
|
62 |
0% { opacity: 1; }
|
63 |
50% { opacity: 0.4; }
|
64 |
100% { opacity: 1; }
|
65 |
}
|
66 |
+
.manual-status {
|
67 |
+
margin-top: 1rem;
|
68 |
+
font-size: 1rem;
|
69 |
+
font-weight: bold;
|
70 |
+
text-align: center;
|
71 |
+
padding: 0.5rem;
|
72 |
+
background-color: rgba(34, 197, 94, 0.2);
|
73 |
+
color: rgb(74, 222, 128);
|
74 |
+
border-radius: 9999px;
|
75 |
+
transition: all 0.3s ease;
|
76 |
+
}
|
77 |
+
.manual-status.deactivated {
|
78 |
+
background-color: rgba(239, 68, 68, 0.2);
|
79 |
+
color: rgb(248, 113, 113);
|
80 |
+
}
|
81 |
.control-pad {
|
82 |
display: grid;
|
83 |
grid-template-columns: repeat(3, 1fr);
|
|
|
86 |
margin: 0 auto;
|
87 |
place-items: center;
|
88 |
}
|
|
|
89 |
.control-button {
|
90 |
width: 4rem;
|
91 |
height: 4rem;
|
|
|
100 |
transition: all 0.2s;
|
101 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
102 |
}
|
|
|
103 |
.control-button:hover {
|
104 |
background-color: #4338ca;
|
105 |
transform: translateY(-2px);
|
106 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
107 |
}
|
|
|
108 |
.control-button:active {
|
109 |
background-color: #3730a3;
|
110 |
transform: translateY(0);
|
111 |
box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
|
112 |
}
|
|
|
113 |
.emergency-stop {
|
114 |
grid-column: 2;
|
115 |
grid-row: 2;
|
|
|
118 |
height: 4.5rem !important;
|
119 |
border: 3px solid #ef4444;
|
120 |
}
|
|
|
121 |
.emergency-stop:hover {
|
122 |
background-color: #b91c1c !important;
|
123 |
}
|
|
|
124 |
.emergency-stop:active {
|
125 |
background-color: #991b1b !important;
|
126 |
}
|
|
|
127 |
.control-button svg {
|
128 |
width: 1.5rem;
|
129 |
height: 1.5rem;
|
|
|
133 |
stroke-linecap: round;
|
134 |
stroke-linejoin: round;
|
135 |
}
|
|
|
136 |
.command-log {
|
137 |
background-color: #1f2937;
|
138 |
border-radius: 0.5rem;
|
139 |
padding: 1rem;
|
140 |
}
|
|
|
141 |
.command-log h2 {
|
142 |
font-size: 1.125rem;
|
143 |
font-weight: 600;
|
144 |
margin-bottom: 0.5rem;
|
145 |
}
|
|
|
146 |
.log-container {
|
147 |
height: 12rem;
|
148 |
overflow-y: auto;
|
|
|
150 |
flex-direction: column;
|
151 |
gap: 0.25rem;
|
152 |
}
|
|
|
153 |
.log-entry {
|
154 |
padding: 0.25rem 0.5rem;
|
155 |
background-color: rgba(55, 65, 81, 0.5);
|
156 |
border-radius: 0.25rem;
|
157 |
font-size: 0.875rem;
|
158 |
}
|
|
|
159 |
/* Grid positioning */
|
160 |
.btn-up { grid-column: 2; grid-row: 1; }
|
161 |
.btn-left { grid-column: 1; grid-row: 2; }
|
|
|
168 |
<div class="header">
|
169 |
<h1 class="title">Robot Controller</h1>
|
170 |
<div class="status">Disconnected</div>
|
171 |
+
<div id="manualModeStatus" class="manual-status deactivated">Manual Mode Deactivated</div>
|
172 |
</div>
|
173 |
|
174 |
<div class="control-pad">
|
|
|
187 |
<rect x="6" y="6" width="12" height="12" fill="white"/>
|
188 |
</svg>
|
189 |
</button>
|
|
|
190 |
<button class="control-button btn-right" data-direction="right">
|
191 |
<svg viewBox="0 0 24 24">
|
192 |
<path d="M5 12h14m-7-7 7 7-7 7"/>
|
|
|
211 |
const buttons = document.querySelectorAll('.control-button');
|
212 |
const status = document.querySelector('.status');
|
213 |
const logContainer = document.getElementById('logContainer');
|
214 |
+
const manualModeStatus = document.getElementById('manualModeStatus');
|
215 |
let commandInterval = null;
|
216 |
let activeCommand = null;
|
217 |
let isButtonPressed = false;
|
|
|
226 |
status.classList.remove('connected');
|
227 |
});
|
228 |
|
229 |
+
// Listen for manual mode status change
|
230 |
+
socket.on('manual_mode_status', (data) => {
|
231 |
+
if (data.status === 'activated') {
|
232 |
+
manualModeStatus.textContent = 'Manual Mode Activated';
|
233 |
+
manualModeStatus.classList.remove('deactivated');
|
234 |
+
} else {
|
235 |
+
manualModeStatus.textContent = 'Manual Mode Deactivated';
|
236 |
+
manualModeStatus.classList.add('deactivated');
|
237 |
+
}
|
238 |
+
});
|
239 |
+
|
240 |
function logCommand(command) {
|
241 |
const entry = document.createElement('div');
|
242 |
entry.className = 'log-entry';
|
|
|
258 |
sendCommand('emergency_stop');
|
259 |
return;
|
260 |
}
|
|
|
261 |
if (commandInterval) {
|
262 |
clearInterval(commandInterval);
|
263 |
}
|
|
|
285 |
|
286 |
buttons.forEach(button => {
|
287 |
const direction = button.dataset.direction;
|
288 |
+
|
289 |
button.addEventListener('mousedown', () => {
|
290 |
startCommand(direction);
|
291 |
if (direction !== 'emergency_stop') {
|
|
|
325 |
});
|
326 |
</script>
|
327 |
</body>
|
328 |
+
</html>
|