|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Arch ISO Builder</title> |
| 7 | + <style> |
| 8 | + body { font-family: sans-serif; margin: 2em; } |
| 9 | + #log { white-space: pre-wrap; background-color: #f4f4f4; border: 1px solid #ddd; padding: 1em; height: 400px; overflow-y: scroll; } |
| 10 | + #buildBtn { padding: 0.5em 1em; font-size: 1em; } |
| 11 | + #downloadLinkContainer { margin-top: 1em; } |
| 12 | + </style> |
| 13 | +</head> |
| 14 | +<body> |
| 15 | + <h1>Arch Linux ISO Builder</h1> |
| 16 | + <button id="buildBtn">Build ISO</button> |
| 17 | + <h2>Build Log</h2> |
| 18 | + <pre id="log"></pre> |
| 19 | + <div id="downloadLinkContainer"></div> |
| 20 | + |
| 21 | + <script> |
| 22 | + const buildBtn = document.getElementById('buildBtn'); |
| 23 | + const log = document.getElementById('log'); |
| 24 | + const downloadLinkContainer = document.getElementById('downloadLinkContainer'); |
| 25 | + |
| 26 | + buildBtn.addEventListener('click', () => { |
| 27 | + buildBtn.disabled = true; |
| 28 | + log.textContent = 'Starting build...\n'; |
| 29 | + downloadLinkContainer.innerHTML = ''; |
| 30 | + |
| 31 | + const eventSource = new EventSource('/build'); |
| 32 | + |
| 33 | + eventSource.onmessage = function(event) { |
| 34 | + if (event.data === 'BUILD_SUCCESS') { |
| 35 | + log.textContent += '\nBuild finished successfully!\n'; |
| 36 | + const downloadLink = document.createElement('a'); |
| 37 | + downloadLink.href = '/download'; |
| 38 | + downloadLink.textContent = 'Download ISO'; |
| 39 | + downloadLinkContainer.appendChild(downloadLink); |
| 40 | + eventSource.close(); |
| 41 | + buildBtn.disabled = false; |
| 42 | + } else if (event.data === 'BUILD_FAILED') { |
| 43 | + log.textContent += '\nBuild failed!\n'; |
| 44 | + eventSource.close(); |
| 45 | + buildBtn.disabled = false; |
| 46 | + } else { |
| 47 | + log.textContent += event.data + '\n'; |
| 48 | + log.scrollTop = log.scrollHeight; |
| 49 | + } |
| 50 | + }; |
| 51 | + |
| 52 | + eventSource.onerror = function() { |
| 53 | + log.textContent += '\nError connecting to the server.\n'; |
| 54 | + eventSource.close(); |
| 55 | + buildBtn.disabled = false; |
| 56 | + }; |
| 57 | + }); |
| 58 | + </script> |
| 59 | +</body> |
| 60 | +</html> |
0 commit comments