122 lines
6.2 KiB
PHP
122 lines
6.2 KiB
PHP
<?php ob_start(); ?>
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h2><?= htmlspecialchars($device->name) ?></h2>
|
|
<div>
|
|
<a href="/devices/<?= $device->id ?>/edit" class="btn btn-sm btn-outline-primary">Изменить</a>
|
|
<form method="POST" action="/devices/<?= $device->id ?>/delete" class="d-inline" onsubmit="return confirm('Удалить устройство?')">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger">Удалить</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless">
|
|
<tr><th>Тип</th><td><?= htmlspecialchars($device->type) ?></td></tr>
|
|
<tr><th>IP</th><td><?= htmlspecialchars($device->primaryIp ?? '-') ?></td></tr>
|
|
<tr><th>MAC</th><td><?= htmlspecialchars($device->macAddress ?? '-') ?></td></tr>
|
|
<tr><th>Hostname</th><td><?= htmlspecialchars($device->hostname ?? '-') ?></td></tr>
|
|
<tr><th>Vendor</th><td><?= htmlspecialchars($device->vendor ?? '-') ?></td></tr>
|
|
<tr><th>OS</th><td><?= htmlspecialchars(($device->osName ?? '') . ' ' . ($device->osVersion ?? '')) ?></td></tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless">
|
|
<tr><th>Важность</th><td><?= htmlspecialchars($device->importance) ?></td></tr>
|
|
<tr><th>Статус</th><td><?= htmlspecialchars($device->status) ?></td></tr>
|
|
<tr><th>Location</th><td><?= htmlspecialchars($device->location ?? '-') ?></td></tr>
|
|
<tr><th>Описание</th><td><?= htmlspecialchars($device->description ?? '-') ?></td></tr>
|
|
<tr><th>Создано</th><td><?= $device->createdAt->format('Y-m-d H:i') ?></td></tr>
|
|
<tr><th>Обновлено</th><td><?= $device->updatedAt->format('Y-m-d H:i') ?></td></tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
<h3 class="h5 mb-0">SSH-доступы</h3>
|
|
</div>
|
|
|
|
<div class="table-responsive mb-4">
|
|
<table class="table table-sm align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th>Название</th>
|
|
<th>Пользователь</th>
|
|
<th>Порт</th>
|
|
<th>Метод</th>
|
|
<th>Последний тест</th>
|
|
<th class="text-end">Действия</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($credentials)): ?>
|
|
<tr><td colspan="6" class="text-muted">Доступы пока не добавлены</td></tr>
|
|
<?php else: ?>
|
|
<?php foreach ($credentials as $credential): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($credential->name) ?></td>
|
|
<td><?= htmlspecialchars($credential->username) ?></td>
|
|
<td><?= (int)$credential->port ?></td>
|
|
<td><?= $credential->authMethod === 'private_key' ? 'ключ' : 'пароль' ?></td>
|
|
<td>
|
|
<?php if ($credential->lastTestStatus === null): ?>
|
|
<span class="text-muted">не проверялся</span>
|
|
<?php else: ?>
|
|
<span class="badge <?= $credential->lastTestStatus === 'ok' ? 'text-bg-success' : 'text-bg-danger' ?>">
|
|
<?= htmlspecialchars($credential->lastTestStatus) ?>
|
|
</span>
|
|
<?php if ($credential->lastTestAt !== null): ?>
|
|
<span class="text-muted small"><?= $credential->lastTestAt->format('Y-m-d H:i') ?></span>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td class="text-end">
|
|
<form method="POST" action="/devices/<?= $device->id ?>/credentials/<?= $credential->id ?>/test" class="d-inline">
|
|
<button type="submit" class="btn btn-sm btn-outline-primary">Тест</button>
|
|
</form>
|
|
<form method="POST" action="/devices/<?= $device->id ?>/credentials/<?= $credential->id ?>/delete" class="d-inline" onsubmit="return confirm('Удалить доступ?')">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger">Удалить</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<form method="POST" action="/devices/<?= $device->id ?>/credentials" class="row g-3">
|
|
<div class="col-md-3">
|
|
<label class="form-label">Название</label>
|
|
<input type="text" name="name" class="form-control" value="SSH">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label">Пользователь</label>
|
|
<input type="text" name="username" class="form-control" required>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label">Порт</label>
|
|
<input type="number" name="port" class="form-control" min="1" max="65535" value="22">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label">Метод</label>
|
|
<select name="auth_method" class="form-select">
|
|
<option value="password">Пароль</option>
|
|
<option value="private_key">Ключ</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">Пароль</label>
|
|
<input type="password" name="secret" class="form-control" autocomplete="new-password">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">Private key</label>
|
|
<textarea name="private_key" class="form-control" rows="4"></textarea>
|
|
</div>
|
|
<div class="col-12">
|
|
<button type="submit" class="btn btn-primary">Добавить доступ</button>
|
|
</div>
|
|
</form>
|
|
<?php $content = ob_get_clean(); ?>
|
|
<?php require dirname(__DIR__) . '/layout.php'; ?>
|