a fancy canvas mcp server!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: update regen button

+56 -21
+56 -21
src/public/dashboard.html
··· 479 479 showNotification('Configuration copied to clipboard'); 480 480 }); 481 481 482 + let regenerateState = 'initial'; // 'initial', 'confirm', 'show-token' 483 + let newToken = null; 484 + 482 485 document.getElementById('regenerateBtn').addEventListener('click', async () => { 483 - if (!confirm('Regenerate API token? This will invalidate your current token and disconnect all MCP clients.')) { 484 - return; 485 - } 486 + const btn = document.getElementById('regenerateBtn'); 487 + 488 + if (regenerateState === 'initial') { 489 + // First click: show confirmation 490 + regenerateState = 'confirm'; 491 + btn.textContent = 'Click again to confirm'; 492 + btn.style.background = '#c33'; 493 + 494 + // Reset after 3 seconds if not confirmed 495 + setTimeout(() => { 496 + if (regenerateState === 'confirm') { 497 + regenerateState = 'initial'; 498 + btn.textContent = 'Regenerate Token'; 499 + btn.style.background = ''; 500 + } 501 + }, 3000); 502 + } else if (regenerateState === 'confirm') { 503 + // Second click: regenerate 504 + btn.disabled = true; 505 + btn.textContent = 'Regenerating...'; 486 506 487 - try { 488 - const response = await fetch('/api/user/regenerate-key', { 489 - method: 'POST', 490 - credentials: 'include' 491 - }); 507 + try { 508 + const response = await fetch('/api/user/regenerate-key', { 509 + method: 'POST', 510 + credentials: 'include' 511 + }); 492 512 493 - const data = await response.json(); 494 - userData.api_key = data.api_key; 513 + const data = await response.json(); 514 + userData.api_key = data.api_key; 515 + newToken = data.api_key; 495 516 496 - // Show the new key 497 - document.getElementById('apiKeyHidden').style.display = 'none'; 498 - document.getElementById('apiKeyDisplay').style.display = 'block'; 499 - document.getElementById('apiKeyValue').textContent = userData.api_key; 500 - apiKeyVisible = true; 501 - updateMCPConfig(); 517 + // Show the new key 518 + document.getElementById('apiKeyHidden').style.display = 'none'; 519 + document.getElementById('apiKeyDisplay').style.display = 'block'; 520 + document.getElementById('apiKeyValue').textContent = userData.api_key; 521 + apiKeyVisible = true; 522 + updateMCPConfig(); 502 523 503 - // Hide test result 504 - document.getElementById('testResult').style.display = 'none'; 524 + regenerateState = 'show-token'; 525 + btn.disabled = false; 526 + btn.textContent = 'Click to copy new token'; 527 + btn.style.background = '#0066cc'; 528 + } catch (error) { 529 + regenerateState = 'initial'; 530 + btn.disabled = false; 531 + btn.textContent = 'Regenerate Token'; 532 + btn.style.background = ''; 533 + showNotification('Failed to regenerate token'); 534 + } 535 + } else if (regenerateState === 'show-token') { 536 + // Third click: copy token 537 + await navigator.clipboard.writeText(newToken); 538 + showNotification('New token copied to clipboard'); 505 539 506 - showNotification('API token regenerated successfully'); 507 - } catch (error) { 508 - alert('Failed to regenerate API token'); 540 + // Reset button 541 + regenerateState = 'initial'; 542 + btn.textContent = 'Regenerate Token'; 543 + btn.style.background = ''; 509 544 } 510 545 }); 511 546