58 lines
2.3 KiB
PHP
58 lines
2.3 KiB
PHP
<?php ob_start(); ?>
|
|
<h2>Устройства</h2>
|
|
|
|
<div class="mb-3">
|
|
<a href="/devices/create" class="btn btn-primary">Добавить устройство</a>
|
|
</div>
|
|
|
|
<?php if (empty($devices)): ?>
|
|
<div class="alert alert-info">Нет устройств. Добавьте первое устройство вручную или создайте из найденного хоста.</div>
|
|
<?php else: ?>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Название</th>
|
|
<th>Тип</th>
|
|
<th>IP</th>
|
|
<th>MAC</th>
|
|
<th>Vendor</th>
|
|
<th>Важность</th>
|
|
<th>Статус</th>
|
|
<th>Действия</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($devices as $device): ?>
|
|
<tr>
|
|
<td><a href="/devices/<?= $device->id ?>"><?= htmlspecialchars($device->name) ?></a></td>
|
|
<td><?= htmlspecialchars($device->type) ?></td>
|
|
<td><?= htmlspecialchars($device->primaryIp ?? '-') ?></td>
|
|
<td><?= htmlspecialchars($device->macAddress ?? '-') ?></td>
|
|
<td><?= htmlspecialchars($device->vendor ?? '-') ?></td>
|
|
<td>
|
|
<?php
|
|
$badge = match ($device->importance) {
|
|
'critical' => 'bg-danger',
|
|
'high' => 'bg-warning',
|
|
'low' => 'bg-secondary',
|
|
default => 'bg-light text-dark',
|
|
};
|
|
?>
|
|
<span class="badge <?= $badge ?>"><?= htmlspecialchars($device->importance) ?></span>
|
|
</td>
|
|
<td>
|
|
<span class="badge <?= $device->status === 'active' ? 'bg-success' : 'bg-secondary' ?>">
|
|
<?= htmlspecialchars($device->status) ?>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<a href="/devices/<?= $device->id ?>/edit" class="btn btn-sm btn-outline-primary">Изменить</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
<?php $content = ob_get_clean(); ?>
|
|
<?php require dirname(__DIR__) . '/layout.php'; ?>
|