Stabilize discovery workflow
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">Активные сканирования</div>
|
||||
<div class="card-body">
|
||||
<?php if (empty($activeJobs)): ?>
|
||||
<p class="text-muted mb-0">Нет активных сканирований.</p>
|
||||
<?php else: ?>
|
||||
<table class="table table-sm align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Тип</th>
|
||||
<th>Статус</th>
|
||||
<th>Прогресс</th>
|
||||
<th>Найдено</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($activeJobs as $job): ?>
|
||||
<?php $progress = json_decode($job->resultJson ?? '{}', true) ?: []; ?>
|
||||
<?php
|
||||
$totalIps = (int)($progress['total_ips'] ?? 0);
|
||||
$nextIpIndex = (int)($progress['next_ip_index'] ?? 0);
|
||||
$hostsFound = (int)($progress['hosts_found'] ?? 0);
|
||||
$percent = $totalIps > 0 ? min(100, (int)floor(($nextIpIndex / $totalIps) * 100)) : 0;
|
||||
$badgeClass = match ($job->status) {
|
||||
'pending' => 'bg-warning',
|
||||
'running' => 'bg-info',
|
||||
'paused' => 'bg-secondary',
|
||||
default => 'bg-light text-dark',
|
||||
};
|
||||
?>
|
||||
<tr>
|
||||
<td>#<?= (int)$job->id ?></td>
|
||||
<td><?= htmlspecialchars($job->type) ?></td>
|
||||
<td><span class="badge <?= $badgeClass ?>"><?= htmlspecialchars($job->status) ?></span></td>
|
||||
<td style="min-width: 180px;">
|
||||
<div class="progress" style="height: 8px;">
|
||||
<div class="progress-bar" style="width: <?= $percent ?>%"></div>
|
||||
</div>
|
||||
<small class="text-muted"><?= $nextIpIndex ?> / <?= $totalIps ?: '?' ?> IP</small>
|
||||
</td>
|
||||
<td><?= $hostsFound ?></td>
|
||||
<td>
|
||||
<a href="/discoveries?scan_job_id=<?= (int)$job->id ?>&status=all"
|
||||
class="btn btn-sm btn-outline-primary">
|
||||
Находки
|
||||
</a>
|
||||
<?php if ($job->status === 'running'): ?>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-secondary"
|
||||
hx-post="/discovery/jobs/<?= (int)$job->id ?>/pause"
|
||||
hx-target="#active-jobs"
|
||||
hx-swap="innerHTML">
|
||||
Пауза
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($job->status === 'paused'): ?>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-success"
|
||||
hx-post="/discovery/jobs/<?= (int)$job->id ?>/resume"
|
||||
hx-target="#active-jobs"
|
||||
hx-swap="innerHTML">
|
||||
Продолжить
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (in_array($job->status, ['pending', 'running', 'paused'], true)): ?>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
hx-post="/discovery/jobs/<?= (int)$job->id ?>/cancel"
|
||||
hx-target="#active-jobs"
|
||||
hx-swap="innerHTML">
|
||||
Отменить
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user