{{define "content"}}
<h1>Domains</h1>

{{if .Flash}}<div class="flash">{{.Flash}}</div>{{end}}

{{if .IsGlobal}}
<div class="card">
  <h2>Add a sending domain</h2>
  <form method="post" action="/domains">
    <label for="name">Domain</label>
    <div class="input-row">
      <input id="name" name="name" type="text" placeholder="example.com"
             autocomplete="off" autocapitalize="none" spellcheck="false"
             value="{{.FormName}}" autofocus required>
      <button type="submit">Add domain</button>
    </div>
    {{if .Error}}<p class="error">{{.Error}}</p>{{end}}
  </form>
</div>
{{end}}

<div class="card">
  <h2>Domains</h2>
  {{if .Domains}}
  <table>
    <thead>
      <tr><th>Domain</th><th>DNS</th><th>Selector</th><th>Apps</th><th></th></tr>
    </thead>
    <tbody>
      {{range .Domains}}
      <tr>
        <td><a href="/domains/{{.ID}}">{{.Name}}</a></td>
        <td><a class="st st-{{.DNS}}" href="/domains/{{.ID}}#dns-status">{{.DNS}}</a></td>
        <td class="muted">{{.DKIMSelector}}</td>
        <td>{{.AppCount}}</td>
        {{if $.IsGlobal}}<td class="actions"><a class="danger" href="/domains/{{.ID}}/delete">Delete</a></td>{{else}}<td></td>{{end}}
      </tr>
      {{end}}
    </tbody>
  </table>
  <p class="muted">The <em>DNS</em> badge is the worst of the domain's DKIM, SPF
  and DMARC checks. Results are cached for a few minutes; open a domain for the
  details and a <em>Re-check</em> button.</p>
  {{else}}
  <p class="muted">No domains yet. Add one above to get started.</p>
  {{end}}
</div>
{{end}}
