{{define "device_add"}}
<div class="card">
  <h2>新增设备</h2>
  <form method="post" action="/ui/devices-add" style="margin-top:16px">
    <div class="row" style="gap:16px">
      <div>
        <div class="muted small">节点标识 <span class="muted">*</span></div>
        <input name="device_id" placeholder="rk3588-xxx" required />
        <div class="muted small" style="margin-top:4px">必须唯一，可从设备的 machine-id 获取。</div>
      </div>
      <div>
        <div class="muted small">节点名称</div>
        <input name="device_name" placeholder="cam-01" />
      </div>
    </div>
    <div class="row" style="gap:16px;margin-top:12px">
      <div>
        <div class="muted small">IP 地址 <span class="muted">*</span></div>
        <input name="ip" placeholder="10.0.0.10" required />
      </div>
      <div>
        <div class="muted small">管理端口</div>
        <input name="agent_port" value="9100" />
        <div class="muted small" style="margin-top:4px">默认 9100</div>
      </div>
      <div>
        <div class="muted small">视频服务端口</div>
        <input name="media_port" value="9000" />
        <div class="muted small" style="margin-top:4px">默认 9000</div>
      </div>
    </div>
    <div style="margin-top:16px">
      <button type="submit">新增设备</button>
      <a href="/ui/devices" style="margin-left:12px">返回设备列表</a>
    </div>
  </form>
</div>

<div class="card">
  <h3>提示：克隆设备的节点标识冲突问题</h3>
  <div class="muted small">
    如果多台设备是克隆的镜像，它们的 /etc/machine-id 会相同，导致 UDP 发现只能找到一台。<br/>
    <b>解决方法</b>：在每台克隆设备上执行以下命令重新生成 machine-id（<b>注意：必须同时删除 dbus 的 machine-id，否则可能生成相同的 ID</b>）：<br/>
    <pre style="margin-top:8px">sudo rm -f /etc/machine-id /var/lib/dbus/machine-id
sudo reboot</pre>
  </div>
</div>
{{end}}
