domovoy/templates/discovery/index.php

95 lines
4.0 KiB
PHP

<?php ob_start(); ?>
<h2>Сканирование сети</h2>
<!-- Add Range Form -->
<div class="card mb-4">
<div class="card-header">Добавить диапазон</div>
<div class="card-body">
<form method="POST" action="/discovery/ranges/create" class="row g-2">
<div class="col-md-4">
<input type="text" name="name" class="form-control" placeholder="Название (Home LAN)" required>
</div>
<div class="col-md-3">
<input type="text" name="cidr" class="form-control" placeholder="CIDR (192.168.1.0/24)" required>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary w-100">Добавить</button>
</div>
</form>
</div>
</div>
<!-- Network Ranges -->
<div class="card mb-4">
<div class="card-header">Диапазоны</div>
<div class="card-body">
<?php if (empty($ranges)): ?>
<p class="text-muted">Нет диапазонов. Добавьте первый диапазон выше.</p>
<?php else: ?>
<table class="table table-sm">
<thead>
<tr>
<th>Название</th>
<th>CIDR</th>
<th>Статус</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
<?php foreach ($ranges as $range): ?>
<tr>
<td><?= htmlspecialchars($range->name) ?></td>
<td><?= htmlspecialchars($range->cidr) ?></td>
<td>
<?php if ($range->enabled): ?>
<span class="badge bg-success">Включён</span>
<?php else: ?>
<span class="badge bg-secondary">Выключен</span>
<?php endif; ?>
</td>
<td>
<a href="/discoveries?range_id=<?= (int)$range->id ?>&status=all" class="btn btn-sm btn-outline-primary">
Находки
</a>
<form method="POST" action="/discovery/ranges/toggle" class="d-inline">
<input type="hidden" name="id" value="<?= $range->id ?>">
<button type="submit" class="btn btn-sm btn-outline-secondary">
<?= $range->enabled ? 'Выключить' : 'Включить' ?>
</button>
</form>
<form method="POST" action="/discovery/ranges/delete" class="d-inline" onsubmit="return confirm('Удалить?')">
<input type="hidden" name="id" value="<?= $range->id ?>">
<button type="submit" class="btn btn-sm btn-outline-danger">Удалить</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<form method="POST" action="/discovery/scan" class="mt-3">
<button type="submit" class="btn btn-success" <?= empty($ranges) ? 'disabled' : '' ?>>
Запустить скан
</button>
</form>
</div>
</div>
<div id="active-jobs"
hx-get="/discovery/jobs/active"
hx-trigger="load, every 2s"
hx-swap="innerHTML">
<?php require dirname(__DIR__) . '/discovery/_active_jobs.php'; ?>
</div>
<div id="scan-history"
hx-get="/discovery/jobs/history"
hx-trigger="load, every 2s"
hx-swap="innerHTML">
<?php require dirname(__DIR__) . '/discovery/_scan_history.php'; ?>
</div>
<?php $content = ob_get_clean(); ?>
<?php require dirname(__DIR__) . '/layout.php'; ?>