67 lines
2.6 KiB
PHP
67 lines
2.6 KiB
PHP
<?= $this->extend('layouts/main') ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
<header class="cb-page-header">
|
|
<div>
|
|
<a href="<?= base_url('alert') ?>" class="text-decoration-none small d-inline-block mb-1" style="color: var(--text-secondary);">← Back to alerts</a>
|
|
<h1 class="cb-page-title">History: <?= esc($alert['name']) ?></h1>
|
|
<p class="cb-page-subtitle mb-0"><?= (int) $total ?> event(s) logged.</p>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="cb-page-body">
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="table-responsive">
|
|
<table class="table align-middle mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Time</th>
|
|
<th>Value</th>
|
|
<th>Status</th>
|
|
<th>Channels</th>
|
|
<th>Error</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($history === []): ?>
|
|
<tr><td colspan="5" class="text-center text-muted py-4">No history yet.</td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($history as $h): ?>
|
|
<?php
|
|
$ch = $h['channels_notified'] ?? null;
|
|
$chList = '';
|
|
if ($ch) {
|
|
$d = json_decode((string) $ch, true);
|
|
$chList = is_array($d) ? implode(', ', $d) : '';
|
|
}
|
|
?>
|
|
<tr>
|
|
<td class="small"><?= esc($h['triggered_at'] ?? '') ?></td>
|
|
<td><code><?= esc((string) ($h['metric_value'] ?? '')) ?></code></td>
|
|
<td><span class="badge bg-<?= ($h['status'] ?? '') === 'sent' ? 'success' : (($h['status'] ?? '') === 'muted' ? 'warning' : 'danger') ?>"><?= esc($h['status'] ?? '') ?></span></td>
|
|
<td class="small"><?= esc($chList) ?></td>
|
|
<td class="small text-danger"><?= esc($h['error_message'] ?? '') ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$pages = (int) ceil($total / max(1, $perPage));
|
|
if ($pages > 1):
|
|
?>
|
|
<nav class="mt-3">
|
|
<ul class="pagination pagination-sm">
|
|
<?php for ($p = 1; $p <= $pages; $p++): ?>
|
|
<li class="page-item <?= $p === $page ? 'active' : '' ?>">
|
|
<a class="page-link" href="<?= base_url('alert/history/' . (int) $alert['id'] . '?page=' . $p) ?>"><?= $p ?></a>
|
|
</li>
|
|
<?php endfor; ?>
|
|
</ul>
|
|
</nav>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?= $this->endSection() ?>
|