{{define "build_detail"}}
<!doctype html>
<html lang="en">
<head>
  <title>{{.Title}}</title>
  {{if gt .AutoRefreshSeconds 0}}<meta http-equiv="refresh" content="{{.AutoRefreshSeconds}}">{{end}}
  {{template "head" .}}
</head>
<body>
  {{template "nav" .}}
  {{if .Msg}}<div class="flash flash-ok">{{.Msg}}</div>{{end}}
  {{if .Err}}<div class="flash flash-err">{{.Err}}</div>{{end}}
  <h1>Build Detail</h1>

  <table>
    <tr><th>Build ID</th><td class="mono">{{.Build.ID}}</td></tr>
    <tr><th>Template ID</th><td>{{.Build.TemplateID}}</td></tr>
    <tr><th>Manifest ID</th><td class="mono">{{.Build.ManifestID}}</td></tr>
    <tr><th>Request Name</th><td>{{.Build.RequestName}}</td></tr>
    <tr><th>Status</th><td>{{.Build.QCStatus}}</td></tr>
    <tr><th>QC Job ID</th><td>{{if .Build.QCJobID}}{{.Build.QCJobID}}{{else}}-{{end}}</td></tr>
    <tr><th>QC Site ID</th><td>{{if .Build.QCSiteID}}{{.Build.QCSiteID}}{{else}}-{{end}}</td></tr>
    <tr><th>Preview URL</th><td>{{if .Build.QCPreviewURL}}<a href="{{.Build.QCPreviewURL}}" target="_blank" rel="noopener">open</a>{{else}}-{{end}}</td></tr>
    <tr><th>Editor URL</th><td>{{if .Build.QCEditorURL}}<a href="{{.Build.QCEditorURL}}" target="_blank" rel="noopener">open</a>{{else}}-{{end}}</td></tr>
    <tr><th>Started At</th><td>{{if .Build.StartedAt}}{{.Build.StartedAt}}{{else}}-{{end}}</td></tr>
    <tr><th>Finished At</th><td>{{if .Build.FinishedAt}}{{.Build.FinishedAt}}{{else}}-{{end}}</td></tr>
  </table>

  {{if .CanPoll}}
    <p>Build is active. This page auto-refreshes every {{.AutoRefreshSeconds}} seconds.</p>
    <form class="inline" method="post" action="/builds/{{.Build.ID}}/poll">
      <button type="submit">Poll Once</button>
    </form>
  {{end}}
  {{if .CanFetchEditorURL}}
    <form class="inline" method="post" action="/builds/{{.Build.ID}}/fetch-editor-url">
      <button type="submit">Fetch Editor URL</button>
    </form>
  {{end}}

  <h2>Effective Global Data (sent to /sites)</h2>
  <p class="mono">{{prettyJSON .EffectiveGlobal}}</p>

  <h2>Stored Global Data JSON</h2>
  <p class="mono">{{prettyJSON .Build.GlobalDataJSON}}</p>

  <h2>AI Data JSON</h2>
  <p class="mono">{{prettyJSON .Build.AIDataJSON}}</p>

  <h2>Final /sites Payload</h2>
  <p class="mono">{{prettyJSON .Build.FinalSitesPayload}}</p>

  <h2>QC Result JSON</h2>
  <p class="mono">{{prettyJSON .Build.QCResultJSON}}</p>

  <h2>QC Error JSON</h2>
  <p class="mono">{{prettyJSON .Build.QCErrorJSON}}</p>
</body>
</html>
{{end}}
