Files
domovoy/app/Controllers/DashboardController.php
T
mirivlad 15772bc17e Итерация 3: инвентарь устройств
- Миграция devices (name, type, ip, mac, hostname, vendor, os, location, importance, status)
- Device model + DeviceRepository с полным CRUD
- DeviceService для бизнес-логики
- MergeSuggestionService для предложений объединения (MAC→90%, hostname→60%)
- DeviceController: список, создание, редактирование, карточка, удаление, создание из discovered_host
- Шаблоны: devices/index, devices/form, devices/show
- Dashboard с реальными счётчиками (устройства, новые находки)
- Кнопка «Создать устройство» в Discovery для новых хостов
- DeviceRepository + DeviceService + DeviceController в DI
2026-05-26 07:50:37 +08:00

36 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Domovoy\Controllers;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class DashboardController
{
private \Domovoy\Repositories\DeviceRepository $deviceRepository;
private \Domovoy\Repositories\ScanJobRepository $scanJobRepository;
public function __construct(
\Domovoy\Repositories\DeviceRepository $deviceRepository,
\Domovoy\Repositories\ScanJobRepository $scanJobRepository
) {
$this->deviceRepository = $deviceRepository;
$this->scanJobRepository = $scanJobRepository;
}
public function index(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
ob_start();
$username = $_SESSION['username'] ?? 'User';
$deviceCount = $this->deviceRepository->getCount();
$newDiscoveries = $this->deviceRepository->getNewDiscoveriesCount();
$recentScans = $this->scanJobRepository->findRecent(5);
require dirname(__DIR__, 2) . '/templates/dashboard/index.php';
$body = ob_get_clean();
$response->getBody()->write($body);
return $response;
}
}