fix: 时间同步按钮改为JS控制,勾选后即时显示
This commit is contained in:
parent
158c13642e
commit
40e8b35e6b
@ -47,10 +47,7 @@
|
||||
{{if $allOffline}}
|
||||
<button type="submit" id="cleanup-btn" name="action" value="cleanup_offline" class="danger" style="display:none" onclick="var n=document.querySelectorAll('input[name=device_id]:checked').length;return confirm('确认清理选中的 '+n+' 台离线设备及其全部关联数据?此操作不可恢复。')">清理选中离线设备</button>
|
||||
{{end}}
|
||||
{{$drift := false}}{{range .DeviceRows}}{{if and (gt .TimeDriftSec $.TimeSyncThreshold) (hasString $.SelectedDeviceIDs .Device.DeviceID)}}{{$drift = true}}{{end}}{{end}}
|
||||
{{if $drift}}
|
||||
<button type="submit" name="action" value="time_sync" class="secondary">⏱ 时间同步</button>
|
||||
{{end}}
|
||||
<button type="submit" id="time-sync-btn" name="action" value="time_sync" class="secondary" style="display:none">⏱ 时间同步</button>
|
||||
<a class="btn secondary" href="{{.BatchConfigURL}}">下发设备分配</a>
|
||||
<a class="btn secondary" href="/devices">清空选择</a>
|
||||
</div>
|
||||
@ -178,6 +175,19 @@
|
||||
});
|
||||
cleanupBtn.style.display = allOffline ? '' : 'none';
|
||||
}
|
||||
// Show/hide time sync button if any selected device has time drift
|
||||
const syncBtn = document.getElementById('time-sync-btn');
|
||||
if (syncBtn) {
|
||||
let hasDrift = false;
|
||||
checked.forEach(cb => {
|
||||
const row = cb.closest('tr');
|
||||
if (row) {
|
||||
const driftEl = row.querySelector('.pill.bad');
|
||||
if (driftEl && driftEl.textContent.includes('偏差')) hasDrift = true;
|
||||
}
|
||||
});
|
||||
syncBtn.style.display = hasDrift ? '' : 'none';
|
||||
}
|
||||
};
|
||||
for (const box of selectedBoxes) {
|
||||
box.addEventListener('change', syncSelected);
|
||||
|
||||
@ -8,8 +8,10 @@
|
||||
"data_dir": "data",
|
||||
"db_path": "data/app.db",
|
||||
"log_dir": "data/logs",
|
||||
"alarm_retention_days": 30,
|
||||
"company_name": "金航数码有限公司",
|
||||
"time_sync_threshold_sec": 10,
|
||||
"device_aliases": {
|
||||
"d12a4719c91641df91b76ab271280797": "盒子A"
|
||||
},
|
||||
"alarm_retention_days": 30
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user