domovoy/templates/discoveries/index.php

61 lines
2.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php ob_start(); ?>
<div class="d-flex justify-content-between align-items-center mb-3">
<h2 class="mb-0">Находки</h2>
</div>
<form method="GET"
action="/discoveries"
class="row g-2 mb-4"
hx-get="/discoveries/table"
hx-target="#discoveries-table"
hx-trigger="change">
<div class="col-md-4">
<label class="form-label">Диапазон</label>
<select name="range_id" class="form-select">
<option value="">Все диапазоны</option>
<?php foreach ($ranges as $range): ?>
<option value="<?= (int)$range->id ?>" <?= $filters['range_id'] === $range->id ? 'selected' : '' ?>>
<?= htmlspecialchars($range->name) ?> (<?= htmlspecialchars($range->cidr) ?>)
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-3">
<label class="form-label">Статус</label>
<select name="status" class="form-select">
<?php foreach (['new' => 'Новые', 'accepted' => 'Принятые', 'ignored' => 'Игнорированные', 'all' => 'Все'] as $value => $label): ?>
<option value="<?= $value ?>" <?= ($filters['status'] ?? null) === ($value === 'all' ? null : $value) ? 'selected' : '' ?>>
<?= $label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php if ($filters['scan_job_id'] !== null): ?>
<input type="hidden" name="scan_job_id" value="<?= (int)$filters['scan_job_id'] ?>">
<div class="col-md-3">
<label class="form-label">Сканирование</label>
<input type="text" class="form-control" value="#<?= (int)$filters['scan_job_id'] ?>" disabled>
</div>
<?php endif; ?>
<input type="hidden" name="sort" value="<?= htmlspecialchars($filters['sort']) ?>">
<input type="hidden" name="dir" value="<?= htmlspecialchars($filters['dir']) ?>">
<div class="col-md-2 d-flex align-items-end">
<button type="submit" class="btn btn-outline-primary w-100">Применить</button>
</div>
</form>
<div id="discoveries-table"
hx-get="/discoveries/table?<?= htmlspecialchars(http_build_query(array_filter([
'range_id' => $filters['range_id'],
'scan_job_id' => $filters['scan_job_id'],
'status' => $filters['status'] ?? 'all',
'sort' => $filters['sort'],
'dir' => $filters['dir'],
], static fn ($value) => $value !== null && $value !== ''))) ?>"
hx-trigger="every 2s"
hx-swap="innerHTML">
<?php require dirname(__DIR__) . '/discoveries/_table.php'; ?>
</div>
<?php $content = ob_get_clean(); ?>
<?php require dirname(__DIR__) . '/layout.php'; ?>