fix: wizard camera picker — select from existing video sources dropdown

This commit is contained in:
tian 2026-07-17 17:23:50 +08:00
parent bf0fed23f9
commit 13d22ce848

View File

@ -62,6 +62,16 @@
<div style="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);margin-bottom:16px">
<div style="font-size:12px;font-weight:600;margin-bottom:8px">+ 添加摄像头</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:8px">
<select id="existing-source-select" style="width:200px;font-size:12px">
<option value="">选择已有视频源...</option>
{{range .ConsoleAllVideoSources}}
<option value="{{.Name}}|{{.Config.URL}}">{{.Name}}</option>
{{end}}
</select>
<button class="btn" id="btn-add-existing-source" style="white-space:nowrap">添加此摄像头</button>
</div>
<div style="color:var(--muted);font-size:11px;margin:8px 0">或手动输入新摄像头</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap">
<input type="text" id="new-source-name" placeholder="摄像头名称(如:车间东门)" style="width:160px;font-size:12px">
<input type="text" id="new-source-url" placeholder="RTSP 地址rtsp://..." style="flex:1;min-width:260px;font-size:12px;font-family:monospace">
@ -269,6 +279,21 @@
featDiv.innerHTML = '<span class="muted small" id="feature-placeholder">加载设备能力中...</span>';
}
document.getElementById("btn-add-existing-source").addEventListener("click", function(){
var sel = document.getElementById("existing-source-select");
var val = sel.value;
if (!val) return;
var parts = val.split("|");
var name = parts[0];
var url = parts.slice(1).join("|");
if (step2Assigned.find(function(s){return s.name===name}) || step2Added.find(function(s){return s.name===name})) {
return;
}
step2Added.push({name: name, url: url});
sel.value = "";
renderAssignedSources();
});
document.getElementById("btn-add-source").addEventListener("click", function(){
var nameEl = document.getElementById("new-source-name");
var urlEl = document.getElementById("new-source-url");