{{define "logs"}}
<div class="card">
  <div class="section-title">
    <div>
      <h2>日志分析</h2>
      <div class="muted small">按设备查看诊断日志、运行指标，并进入高级调试。</div>
    </div>
    <a class="btn ghost" href="/ui/api">高级调试</a>
  </div>
  <div class="model-summary">
    <div class="summary-item"><div class="summary-label">日志筛选</div><div class="summary-value">设备/数量</div><div class="summary-hint">首版按设备和 limit 查看</div></div>
    <div class="summary-item"><div class="summary-label">诊断日志</div><div class="summary-value">Recent</div><div class="summary-hint">查看设备最近日志</div></div>
    <div class="summary-item"><div class="summary-label">运行指标</div><div class="summary-value">Graphs</div><div class="summary-hint">查看设备指标 JSON</div></div>
    <div class="summary-item"><div class="summary-label">高级调试</div><div class="summary-value">API</div><div class="summary-hint">保留原始接口排查入口</div></div>
  </div>
</div>

<div class="card">
  <h2>设备诊断入口</h2>
  <div class="table-wrap" style="margin-top:10px">
    <table>
      <thead><tr><th>设备</th><th>状态</th><th>管理地址</th><th>日志分析</th></tr></thead>
      <tbody>
        {{range .Devices}}
        <tr>
          <td><a class="mono" href="/ui/devices/{{.DeviceID}}">{{if .DeviceName}}{{.DeviceName}}{{else}}{{.DeviceID}}{{end}}</a><div class="muted small mono">{{.DeviceID}}</div></td>
          <td>{{if .Online}}<span class="pill ok">在线</span>{{else}}<span class="pill bad">离线</span>{{end}}</td>
          <td class="mono">{{.IP}}:{{.AgentPort}}</td>
          <td>
            <div class="actions">
              <a class="btn ghost" href="/ui/devices/{{.DeviceID}}/logs?limit=200">诊断日志</a>
              <a class="btn ghost" href="/ui/devices/{{.DeviceID}}/graphs">运行指标</a>
            </div>
          </td>
        </tr>
        {{else}}
        <tr><td colspan="4" class="muted">暂无设备。请先在“新增设备”页扫描或手动添加。</td></tr>
        {{end}}
      </tbody>
    </table>
  </div>
</div>
{{end}}
