Fix dashboard token UX: token required for public space, preserve existing token on save
Browse files
src/reachy_mini_remote_control_app/templates/dashboard.html
CHANGED
|
@@ -226,11 +226,12 @@
|
|
| 226 |
</div>
|
| 227 |
|
| 228 |
<div class="form-group">
|
| 229 |
-
<label for="hf-token">HuggingFace Token
|
| 230 |
<input type="password" id="hf-token" placeholder="hf_...">
|
| 231 |
<p style="font-size: 12px; color: #666; margin-top: 5px;">
|
| 232 |
-
Required
|
| 233 |
-
<a href="https://huggingface.co/settings/tokens" target="_blank" style="color: #667eea;">huggingface.co/settings/tokens</a>
|
|
|
|
| 234 |
</p>
|
| 235 |
</div>
|
| 236 |
|
|
@@ -287,7 +288,7 @@
|
|
| 287 |
|
| 288 |
<div style="margin-top: 20px; padding: 15px; background: rgba(16, 185, 129, 0.1); border-radius: 8px; border-left: 4px solid #10b981;">
|
| 289 |
<p style="margin: 0; color: #065f46; font-size: 14px;">
|
| 290 |
-
<strong>Quick Start:</strong> Use the public shared space
|
| 291 |
<code style="background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; margin-left: 8px;">wss://huggingfacem4-reachy-mini-remote-control.hf.space</code>
|
| 292 |
</p>
|
| 293 |
<button onclick="usePublicSpace()" style="background: #10b981; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 12px; margin-top: 10px; font-weight: 600;">
|
|
@@ -367,6 +368,7 @@
|
|
| 367 |
// Load HF token if present (don't display full token for security)
|
| 368 |
if (data.hf_token && data.hf_token.length > 0) {
|
| 369 |
document.getElementById('hf-token').placeholder = '••••••••' + data.hf_token.slice(-4);
|
|
|
|
| 370 |
}
|
| 371 |
|
| 372 |
// Set the dropdown to match current URI if it's one of the presets
|
|
@@ -405,9 +407,10 @@
|
|
| 405 |
METRICS_LOG_INTERVAL_SEC: '5'
|
| 406 |
};
|
| 407 |
|
| 408 |
-
//
|
| 409 |
-
|
| 410 |
-
|
|
|
|
| 411 |
}
|
| 412 |
|
| 413 |
const response = await fetch('/profile/default/config', {
|
|
|
|
| 226 |
</div>
|
| 227 |
|
| 228 |
<div class="form-group">
|
| 229 |
+
<label for="hf-token">HuggingFace Token</label>
|
| 230 |
<input type="password" id="hf-token" placeholder="hf_...">
|
| 231 |
<p style="font-size: 12px; color: #666; margin-top: 5px;">
|
| 232 |
+
Required to authenticate your robot with the public or private space. Create a token with 'read' permissions at
|
| 233 |
+
<a href="https://huggingface.co/settings/tokens" target="_blank" style="color: #667eea;">huggingface.co/settings/tokens</a>.
|
| 234 |
+
Leave blank to keep the existing token.
|
| 235 |
</p>
|
| 236 |
</div>
|
| 237 |
|
|
|
|
| 288 |
|
| 289 |
<div style="margin-top: 20px; padding: 15px; background: rgba(16, 185, 129, 0.1); border-radius: 8px; border-left: 4px solid #10b981;">
|
| 290 |
<p style="margin: 0; color: #065f46; font-size: 14px;">
|
| 291 |
+
<strong>Quick Start:</strong> Use the public shared space:
|
| 292 |
<code style="background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; margin-left: 8px;">wss://huggingfacem4-reachy-mini-remote-control.hf.space</code>
|
| 293 |
</p>
|
| 294 |
<button onclick="usePublicSpace()" style="background: #10b981; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 12px; margin-top: 10px; font-weight: 600;">
|
|
|
|
| 368 |
// Load HF token if present (don't display full token for security)
|
| 369 |
if (data.hf_token && data.hf_token.length > 0) {
|
| 370 |
document.getElementById('hf-token').placeholder = '••••••••' + data.hf_token.slice(-4);
|
| 371 |
+
currentConfig.hf_token = data.hf_token;
|
| 372 |
}
|
| 373 |
|
| 374 |
// Set the dropdown to match current URI if it's one of the presets
|
|
|
|
| 407 |
METRICS_LOG_INTERVAL_SEC: '5'
|
| 408 |
};
|
| 409 |
|
| 410 |
+
// Use the provided token, or fall back to the existing token to avoid losing it
|
| 411 |
+
const tokenToSave = (hfToken && hfToken.trim().length > 0) ? hfToken.trim() : currentConfig.hf_token;
|
| 412 |
+
if (tokenToSave) {
|
| 413 |
+
configData.HF_TOKEN = tokenToSave;
|
| 414 |
}
|
| 415 |
|
| 416 |
const response = await fetch('/profile/default/config', {
|