<!-- This template contains just the logs table content for Unpoly updates -->
{{ if isset(., "error") }}
  <div class="alert alert-danger">{{ .error }}</div>
{{ end }}

<div class="log-table">
  <table>
    <thead>
      <tr>
        <th>Timestamp</th>
        <th>Level</th>
        <th>Source</th>
        <th>Message</th>
      </tr>
    </thead>
    <tbody>
      {{range logs}}
      <tr>
        <td>{{.timestamp}}</td>
        <td class="log-{{.type | lower}}">{{.type}}</td>
        <td>{{.category}}</td>
        <td>{{.message}}</td>
      </tr>
      {{else}}
      <tr>
        <td colspan="4" class="text-center">No logs found matching your criteria</td>
      </tr>
      {{end}}
    </tbody>
  </table>
</div>

<div class="pagination">
  <div class="pagination-info">
    {{if len(logs) > 0}}
    <span>Showing {{len(logs)}} of {{total}} logs</span>
    {{else}}
    <span>No logs found</span>
    {{end}}
  </div>
  <div class="pagination-controls">
    {{if page > 1}}
    <a href="/admin/system/logs?page={{page - 1}}{{if isset(., "selectedLogType")}}&log_type={{selectedLogType}}{{end}}{{if isset(., "categoryParam")}}&category={{categoryParam}}{{end}}{{if isset(., "typeParam")}}&type={{typeParam}}{{end}}{{if isset(., "fromParam")}}&from={{fromParam}}{{end}}{{if isset(., "toParam")}}&to={{toParam}}{{end}}" role="button" class="outline secondary" up-target="#logs-table-container">← Previous</a>
    {{end}}
    {{if page < totalPages}}
    <a href="/admin/system/logs?page={{page + 1}}{{if isset(., "selectedLogType")}}&log_type={{selectedLogType}}{{end}}{{if isset(., "categoryParam")}}&category={{categoryParam}}{{end}}{{if isset(., "typeParam")}}&type={{typeParam}}{{end}}{{if isset(., "fromParam")}}&from={{fromParam}}{{end}}{{if isset(., "toParam")}}&to={{toParam}}{{end}}" role="button" class="outline secondary" up-target="#logs-table-container">Next →</a>
    {{end}}
  </div>
</div>
