{{define "title"}}Inbucket Status{{end}}

{{define "script"}}
<script src="/public/bower_components/jquery-color/jquery.color.js"></script>
<script src="/public/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<script src="/public/metrics.js" type="text/javascript" charset="utf-8"></script>
<script>
$(document).ready(
    function() {
      $('#nav-status').addClass('active');
      loadMetrics();
      setInterval(loadMetrics, 10000);
    });
</script>
{{end}}

{{define "menu"}}
<div id="logo">
  <h1><a href="/">inbucket</a></h1>
  <h2>email testing service</h2>
</div>
{{end}}

{{define "content"}}
<h2>Inbucket Status</h2>

<p class="small">Metrics are polled every 10 seconds.  Inbucket does not keep history for the
10 minute graphs, but your web browser will accumulate the data over time.</p>

<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">
      <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
      Configuration</h3>
  </div>
  <div class="panel-body">
    <table class="metrics">
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Version:</b></div>
        <div class="col-sm-8 col-xs-5"><span>{{.version}}, built on {{.buildDate}}</span></div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>SMTP Listener:</b></div>
        <div class="col-sm-8 col-xs-5"><span>{{.smtpListener}}</span></div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>POP3 Listener:</b></div>
        <div class="col-sm-8 col-xs-5"><span>{{.pop3Listener}}</span></div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>HTTP Listener:</b></div>
        <div class="col-sm-8 col-xs-5"><span>{{.webListener}}</span></div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>No-Store Domain:</b></div>
        <div class="col-sm-8 col-xs-5">
          {{with .smtpConfig}}
          <span>{{or .DomainNoStore .DomainNoStore "Not Configured"}}</span>
          {{end}}
        </div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Message Cap:</b></div>
        <div class="col-sm-8 col-xs-5">
          {{with .dataStoreConfig}}
          <span>{{.MailboxMsgCap}} messages per mailbox</span>
          {{end}}
        </div>
      </div>
    </table>
  </div>
</div>

<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">
      <span class="glyphicon glyphicon-scale" aria-hidden="true"></span>
      General Metrics</h3>
  </div>
  <div class="panel-body">
    <table class="metrics">
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Uptime:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-uptime">.</span></div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>System Memory:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-memstatsSys">.</span></div>
        <div class="col-sm-4"><span id="s-memstatsSys">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Heap Size:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-memstatsHeapSys">.</span></div>
        <div class="col-sm-4"><span id="s-memstatsHeapSys">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Heap In-Use:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-memstatsHeapAlloc">.</span></div>
        <div class="col-sm-4"><span id="s-memstatsHeapAlloc">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Heap # Objects:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-memstatsHeapObjects">.</span></div>
        <div class="col-sm-4"><span id="s-memstatsHeapObjects">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Goroutines:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-goroutinesCurrent">.</span></div>
        <div class="col-sm-4"><span id="s-goroutinesCurrent">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Open WebSockets:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-httpWebSocketConnectsCurrent">.</span></div>
        <div class="col-sm-4"><span id="s-httpWebSocketConnectsCurrent">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
    </table>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">
      <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
      SMTP Metrics</h3>
  </div>
  <div class="panel-body">
    <table class="metrics">
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Current Connections:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-smtpConnectsCurrent">.</span></div>
        <div class="col-sm-4"><span id="s-smtpConnectsCurrent">.</span></div>
        <div class="col-sm-2 hidden-xs">(10min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Total Connections:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-smtpConnectsTotal">.</span></div>
        <div class="col-sm-4"><span id="s-smtpConnectsTotal">.</span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Messages Received:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-smtpReceivedTotal">.</span></div>
        <div class="col-sm-4"><span id="s-smtpReceivedTotal">.</span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Errors Logged:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-smtpErrorsTotal">.</span></div>
        <div class="col-sm-4"><span id="s-smtpErrorsTotal"></span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Warnings Logged:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-smtpWarnsTotal">.</span></div>
        <div class="col-sm-4"><span id="s-smtpWarnsTotal"></span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
    </table>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">
      <span class="glyphicon glyphicon-hdd" aria-hidden="true"></span>
      Data Store Metrics</h3>
  </div>
  <div class="panel-body">
    <table class="metrics">
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Retention Period:</b></div>
        <div class="col-sm-8 col-xs-5">
          {{if .dataStoreConfig.RetentionMinutes}}
          <span id="m-retentionPeriod">.</span>
          {{else}}
          Disabled
          {{end}}
        </div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Retention Scan:</b></div>
        <div class="col-sm-8 col-xs-5">
          {{if .dataStoreConfig.RetentionMinutes}}
          Completed <span id="m-retentionScanCompleted">.</span> ago
          {{else}}
          Disabled
          {{end}}
        </div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Retention Deletes:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-retentionDeletesTotal">.</span></div>
        <div class="col-sm-4"><span id="s-retentionDeletesTotal"></span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
      <div class="row">
        <div class="col-sm-3 col-xs-7"><b>Currently Retained:</b></div>
        <div class="col-sm-3 col-xs-5"><span id="m-retainedCurrent">.</span></div>
        <div class="col-sm-4"><span id="s-retainedCurrent"></span></div>
        <div class="col-sm-2 hidden-xs">(60min)</div>
      </div>
    </table>
  </div>
</div>
{{end}}

