feat: add/remove cameras in Settings, empty fallback fix
This commit is contained in:
parent
86ce14bc5b
commit
ebc05762b0
1 changed files with 32 additions and 2 deletions
|
|
@ -280,7 +280,16 @@ async function renderCameraCards() {
|
|||
<label>Require login on port 8080 <input type="checkbox" ${config?.auth?.enabled ? 'checked' : ''} data-auth="auth-enabled" style="width:auto"></label>
|
||||
</div>
|
||||
</div>
|
||||
` + cameras.map(c => `
|
||||
<div style="grid-column:1/-1;display:flex;gap:8px;margin-bottom:4px">
|
||||
<button class="btn-primary" onclick="addCamera()">+ Add Camera</button>
|
||||
<span style="color:var(--text-muted);font-size:13px;align-self:center">${cameras.length} camera(s)</span>
|
||||
</div>
|
||||
` + cameras.map((c, i) => `
|
||||
<div class="camera-card" data-id="${c.id}">
|
||||
<h3>📷 ${c.name || 'Unnamed'} <span style="font-size:11px;color:var(--text-muted)">${c.ip}</span>
|
||||
<a href="http://${c.ip}" target="_blank" style="font-size:11px;color:var(--accent);margin-left:8px;text-decoration:none" title="Open camera web interface">⚙️ Config</a>
|
||||
<button onclick="removeCamera(${i})" style="float:right;background:var(--red);color:#fff;border:none;padding:2px 8px;border-radius:4px;cursor:pointer;font-size:11px">✕ Remove</button>
|
||||
</h3>
|
||||
<div class="camera-card" data-id="${c.id}">
|
||||
<h3>📷 ${c.name || 'Unnamed'} <span style="font-size:11px;color:var(--text-muted)">${c.ip}</span>
|
||||
<a href="http://${c.ip}" target="_blank" style="font-size:11px;color:var(--accent);margin-left:8px;text-decoration:none" title="Open camera web interface">⚙️ Config</a>
|
||||
|
|
@ -302,7 +311,28 @@ async function renderCameraCards() {
|
|||
`).join('');
|
||||
}
|
||||
|
||||
// ── Settings: Scan ──
|
||||
// ── Settings: Add / Remove cameras ──
|
||||
function addCamera() {
|
||||
const ip = prompt('Camera IP address:', '192.168.1.');
|
||||
if (!ip) return;
|
||||
const id = 'cam_' + ip.split('.').pop();
|
||||
cameras.push({
|
||||
id, name: 'Camera_' + ip.split('.').pop(),
|
||||
ip, username: 'admin', password: '',
|
||||
onvif_port: 80, rtsp_main: '', rtsp_sub: '',
|
||||
description: '', enabled: true, record: true
|
||||
});
|
||||
renderCameraCards();
|
||||
renderLiveGrid();
|
||||
renderPlaybackCameras();
|
||||
}
|
||||
function removeCamera(idx) {
|
||||
if (!confirm('Remove camera ' + (cameras[idx]?.name || '') + '?')) return;
|
||||
cameras.splice(idx, 1);
|
||||
renderCameraCards();
|
||||
renderLiveGrid();
|
||||
renderPlaybackCameras();
|
||||
}
|
||||
async function runWizard() {
|
||||
const from = document.getElementById('wiz-from')?.value || '192.168.1.200';
|
||||
const to = document.getElementById('wiz-to')?.value || '192.168.1.210';
|
||||
|
|
|
|||
Loading…
Reference in a new issue