{{define "content"}}
<h1>{{.Domain.Name}}</h1>
{{template "back_link" (back "/dmarc" "All DMARC reports")}}
{{template "back_link" (back (printf "/domains/%d" .Domain.ID) (printf "Back to %s" .Domain.Name))}}

<div class="pair">
  <div class="card">
    <h2>Last {{.WindowDays}} days {{if and (gt .Pass7d 0) (eq .Fail7d 0)}}<span class="st st-ok">pass</span>{{else if gt .Fail7d 0}}<span class="st st-warn">review</span>{{end}}</h2>
    <p>{{.PolicyHint}}</p>
    <p class="muted"><a href="/domains/{{.Domain.ID}}#dmarc">Domain DNS and rua=</a></p>
  </div>
  <div class="card">
    <h2>Totals</h2>
    <p>{{.Pass7d}} pass · {{.Fail7d}} fail in aggregate summaries.</p>
  </div>
</div>

<div class="card">
  <h2>Reports</h2>
  {{if .Reports}}
  <table class="desk-only">
    <thead><tr><th>Received</th><th>Reporter</th><th>Window</th><th>Pass</th><th>Fail</th><th></th></tr></thead>
    <tbody>
    {{range .Reports}}
      <tr>
        <td class="time muted">{{.ReceivedLabel}}</td>
        <td class="muted">{{.Reporter}}</td>
        <td>{{.PeriodLabel}}</td>
        <td>{{.PassCount}}</td>
        <td>{{.FailCount}}</td>
        <td class="actions"><a href="/dmarc/reports/{{.ID}}">View</a></td>
      </tr>
    {{end}}
    </tbody>
  </table>
  {{else}}
  <p class="muted">No reports for this domain yet.</p>
  {{end}}
</div>

{{if .Sources}}
<div class="card">
  <h2>Sources · last {{.WindowDays}} days</h2>
  <table class="desk-only">
    <thead><tr><th>Source</th><th>Pass</th><th>Fail</th><th>Disposition</th></tr></thead>
    <tbody>
    {{range .Sources}}
      <tr>
        <td class="muted">{{.SourceIP}}{{if .ThisRelay}} (this relay){{end}}</td>
        <td>{{.PassCount}}</td>
        <td>{{.FailCount}}</td>
        <td><span class="st {{if gt .FailCount 0}}st-warn{{else}}st-ok{{end}}">{{.Disposition}}</span></td>
      </tr>
    {{end}}
    </tbody>
  </table>
</div>
{{end}}
{{end}}
