{{define "title"}}审计{{end}}
{{define "content"}}
<h1>审计日志</h1>
<form method="get" action="/audit" class="filters">
  <label>操作者<input type="text" name="actor" value="{{.Data.Filter.Actor}}"></label>
  <label>动作<input type="text" name="action" value="{{.Data.Filter.Action}}"></label>
  <label>目标<input type="text" name="target" value="{{.Data.Filter.Target}}"></label>
  <label>起<input type="text" name="from" value="{{.Data.FromStr}}" placeholder="2006-01-02"></label>
  <label>止<input type="text" name="to" value="{{.Data.ToStr}}" placeholder="2006-01-02"></label>
  <button type="submit">筛选</button>
</form>

<table>
  <thead><tr><th>ID</th><th>时间</th><th>操作者</th><th>动作</th><th>目标</th><th>meta</th></tr></thead>
  <tbody>
  {{range .Data.Entries}}
    <tr><td>{{.ID}}</td><td>{{fmtTime .At}}</td><td>{{.Actor}}</td><td>{{.Action}}</td><td>{{.Target}}</td><td class="meta">{{.Meta}}</td></tr>
  {{else}}
    <tr><td colspan="6" class="muted">无匹配记录</td></tr>
  {{end}}
  </tbody>
</table>
<div class="pager">
  {{if .Data.HasPrev}}<a href="{{.Data.PrevURL}}">上一页</a>{{end}}
  <span class="muted">共 {{.Data.Total}} 条</span>
  {{if .Data.HasNext}}<a href="{{.Data.NextURL}}">下一页</a>{{end}}
</div>

<h2>节点事件</h2>
<form method="get" action="/audit" class="filters">
  <input type="hidden" name="actor" value="{{.Data.Filter.Actor}}">
  <input type="hidden" name="action" value="{{.Data.Filter.Action}}">
  <input type="hidden" name="target" value="{{.Data.Filter.Target}}">
  <label>节点 ID<input type="text" name="node_id" value="{{.Data.NodeIDStr}}"></label>
  <button type="submit">查看节点事件</button>
</form>
<table>
  <thead><tr><th>ID</th><th>时间</th><th>节点</th><th>事件</th><th>detail</th></tr></thead>
  <tbody>
  {{range .Data.NodeEvents}}
    <tr><td>{{.ID}}</td><td>{{fmtTime .At}}</td><td>{{.NodeID}}</td><td>{{.Event}}</td><td class="meta">{{.Detail}}</td></tr>
  {{else}}
    <tr><td colspan="5" class="muted">输入节点 ID 查看其事件</td></tr>
  {{end}}
  </tbody>
</table>
{{end}}
