fix: 解決載入任務按鈕的行為與時機
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
67a30b5780
commit
7341b0c55c
|
|
@ -163,7 +163,7 @@
|
|||
<!-- 未來可以在這裡新增 modulation-profile, rpd 等選項 -->
|
||||
</select>
|
||||
<!-- 💡 新增的手動觸發按鈕 -->
|
||||
<button onclick="startConfigTask()" style="background-color: #c0392b; color: white; margin-left: 10px;">🚀 載入任務</button>
|
||||
<button id="btn-load-task" onclick="startConfigTask()" style="background-color: #95a5a6; color: white; margin-left: 10px; cursor: not-allowed;" disabled>🚀 載入任務</button>
|
||||
</div>
|
||||
|
||||
<!-- 💡 表單 3:MAC Domain 配置精靈 -->
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,6 +5,7 @@
|
|||
// ==========================================
|
||||
let term, fitAddon, ws;
|
||||
let currentMacDomainData = null;
|
||||
let isConnected = false; // 💡 新增:用來追蹤目前的連線狀態
|
||||
|
||||
window.onload = initTerminal;
|
||||
window.onresize = () => { if (fitAddon) fitAddon.fit(); };
|
||||
|
|
@ -45,6 +46,12 @@ function switchConfigTask() {
|
|||
|
||||
// 💡 新增的函數:由「🚀 載入任務」按鈕手動觸發
|
||||
function startConfigTask() {
|
||||
// 💡 新增防呆:雙重檢查是否已連線
|
||||
if (!isConnected) {
|
||||
alert("請先成功連線至 CMTS 設備後,再執行載入任務!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 先確保對應的表單有顯示出來
|
||||
switchConfigTask();
|
||||
|
||||
|
|
@ -214,6 +221,14 @@ function connectWebSocket() {
|
|||
ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = () => {
|
||||
isConnected = true; // 💡 標記為已連線
|
||||
const btnLoadTask = document.getElementById('btn-load-task');
|
||||
if (btnLoadTask) {
|
||||
btnLoadTask.disabled = false; // 解鎖按鈕功能
|
||||
btnLoadTask.style.backgroundColor = '#c0392b'; // 恢復原本的紅色
|
||||
btnLoadTask.style.cursor = 'pointer'; // 恢復正常滑鼠游標
|
||||
}
|
||||
|
||||
document.getElementById('wsStatus').textContent = `狀態:已連線`;
|
||||
document.getElementById('wsStatus').style.color = '#27ae60';
|
||||
document.getElementById('btnConnect').style.display = 'none';
|
||||
|
|
@ -229,6 +244,14 @@ function connectWebSocket() {
|
|||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
isConnected = false; // 💡 標記為已斷線
|
||||
const btnLoadTask = document.getElementById('btn-load-task');
|
||||
if (btnLoadTask) {
|
||||
btnLoadTask.disabled = true; // 鎖定按鈕功能
|
||||
btnLoadTask.style.backgroundColor = '#95a5a6'; // 變回反灰色
|
||||
btnLoadTask.style.cursor = 'not-allowed'; // 變回禁止游標
|
||||
}
|
||||
|
||||
document.getElementById('wsStatus').textContent = '狀態:已斷線';
|
||||
document.getElementById('wsStatus').style.color = '#c0392b';
|
||||
document.getElementById('btnConnect').style.display = 'inline-block';
|
||||
|
|
|
|||
Loading…
Reference in New Issue