<a href="<%= channel.relative_url %>">channel</a>
<h2><a href="<%= channel.relative_url %>/feed/inbound/endpoints">Channel Feed Inbound Endpoints</a></h2>

<a href="<%= channel.relative_url %>/feed/inbound/endpoints">all endpoints</a>
<a href="<%= channel.relative_url %>/feed/inbound/payloads">payloads</a>

<div class="btn-group float-right">
  <a href="<%= channel.relative_url %>/feed/inbound/endpoints/create" class="btn btn-success">Create</a>
  <%- if ctx.env.params.query.falsey?("active") -%>
  <a href="<%= channel.relative_url %>/feed/inbound/endpoints" class="btn btn-success">Active</a>
  <%- else -%>
  <a href="<%= channel.relative_url %>/feed/inbound/endpoints?active=0" class="btn btn-success">Decommissioned</a>
  <%- end -%>
</div>

<%-= page.render_controls -%>

<br>

<table class="table table-sm">
  <thead>
    <tr>
      <th>ID</th>
      <th>Description</th>
      <th>URL</th>
      <th>Last Active</th>
      <th>Frequency<br><small class="text-muted">last 90 days</small></th>
      <th>Next Poll</th>
      <th>Last Posted</th>
      <th>Next Post</th>
      <th>Created</th>
      <th>Mask</th>
    </tr>
  </thead>
  <tbody>
  <%- page.collection.each do |endpoint| -%>
    <tr>
      <td>
        <a href="<%= channel.relative_url %>/feed/inbound/endpoints/<%= endpoint.id.to_b62 %>">
          <%= endpoint.id.to_b62 -%>
        </a>
      </td>
      <td><%= endpoint.bio.e %></td>
      <td><%= endpoint.url.e %></td>
      <td>
        <%- if at = endpoint.lastpolled_at -%>
          <%-= component "timeago" -%>
        <%- else -%>
          never
        <%- end -%>
      </td>
      <td><%= (endpoint.lastpolled_at ? endpoint.frequency : "unknown") %></td>
      <td><%= (endpoint.nextpoll_at || "na") %></td>
      <td>
        <%- if at = endpoint.created_at -%>
          <%-= component "timeago" -%>
        <%- else -%>
          unknown
        <%- end -%>
      </td>
      <td>
        <%- if at = endpoint.lastposted_at -%>
          <%-= component "timeago" -%>
        <%- else -%>
          never
        <%- end -%>
      </td>
      <td>
        <%- if at = endpoint.nextpost_at -%>
          <%-= component "timeago" -%>
        <%- else -%>
          never
        <%- end -%>
      </td>
      <td><%-= endpoint.mask %></td>
    </tr>
  <%- end -%>
  </tbody>
</table>

<%-= page.render_controls if page.show_bottom_controls -%>
