{{define "title"}}节点{{end}}
{{define "content"}}
<h1>节点</h1>
{{if not .Data.ProvisionReady}}<div class="warn">节点替换服务（#14）尚未接入，相关按钮已置灰。</div>{{end}}
{{if not .Data.LifecycleReady}}<div class="warn">节点生命周期服务（#5）尚未接入，上/下线按钮已置灰。</div>{{end}}

<table>
  <thead><tr><th>ID</th><th>名称</th><th>地区</th><th>tier</th><th>权重</th><th>状态</th><th>厂商</th><th>近期事件</th><th>操作</th></tr></thead>
  <tbody>
  {{range .Data.Nodes}}
    <tr>
      <td>{{.ID}}</td>
      <td>{{.NameZH}}<br><span class="muted">{{.UUID}}</span></td>
      <td>{{.Region}}</td>
      <td>{{.Tier}}</td>
      <td>{{.Weight}}</td>
      <td><span class="status status-{{.Status}}">{{.Status}}</span></td>
      <td>{{.Provider}}</td>
      <td>
        {{range .RecentEvents}}<div class="ev">{{.Event}} <span class="muted">{{fmtTime .At}}</span></div>{{else}}<span class="muted">—</span>{{end}}
      </td>
      <td class="ops">
        <form method="post" action="/nodes/op" class="inline confirm" data-confirm="确认替换节点 {{.ID}}（{{.NameZH}}）？将开通新节点并下线旧节点。">
          <input type="hidden" name="csrf_token" value="{{$.CSRF}}">
          <input type="hidden" name="node_id" value="{{.ID}}">
          <input type="hidden" name="op" value="replace">
          <input type="hidden" name="confirm" value="yes">
          <button type="submit" {{if not $.Data.ProvisionReady}}disabled{{end}}>替换</button>
        </form>
        <form method="post" action="/nodes/op" class="inline confirm" data-confirm="确认将节点 {{.ID}} 置为 draining（停止接入新连接）？">
          <input type="hidden" name="csrf_token" value="{{$.CSRF}}">
          <input type="hidden" name="node_id" value="{{.ID}}">
          <input type="hidden" name="op" value="draining">
          <input type="hidden" name="confirm" value="yes">
          <button type="submit" {{if not $.Data.LifecycleReady}}disabled{{end}}>draining</button>
        </form>
        <form method="post" action="/nodes/op" class="inline confirm" data-confirm="确认将节点 {{.ID}} 置为 up（恢复接入）？">
          <input type="hidden" name="csrf_token" value="{{$.CSRF}}">
          <input type="hidden" name="node_id" value="{{.ID}}">
          <input type="hidden" name="op" value="up">
          <input type="hidden" name="confirm" value="yes">
          <button type="submit" {{if not $.Data.LifecycleReady}}disabled{{end}}>up</button>
        </form>
      </td>
    </tr>
  {{else}}
    <tr><td colspan="9" class="muted">暂无节点</td></tr>
  {{end}}
  </tbody>
</table>
<script src="/static/confirm.js"></script>
{{end}}
