Итерация 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
This commit is contained in:
2026-05-26 07:50:37 +08:00
parent 177e44f015
commit 15772bc17e
13 changed files with 760 additions and 28 deletions
+31 -2
View File
@@ -114,8 +114,11 @@ $containerBuilder->addDefinitions([
\Domovoy\Controllers\SetupController::class => function ($c) {
return new \Domovoy\Controllers\SetupController($c->get(\Domovoy\Services\AuthService::class));
},
\Domovoy\Controllers\DashboardController::class => function () {
return new \Domovoy\Controllers\DashboardController();
\Domovoy\Controllers\DashboardController::class => function ($c) {
return new \Domovoy\Controllers\DashboardController(
$c->get(\Domovoy\Repositories\DeviceRepository::class),
$c->get(\Domovoy\Repositories\ScanJobRepository::class)
);
},
\Domovoy\Controllers\DiscoveryController::class => function ($c) {
return new \Domovoy\Controllers\DiscoveryController(
@@ -129,6 +132,22 @@ $containerBuilder->addDefinitions([
$c->get(\Domovoy\Repositories\NetworkRangeRepository::class)
);
},
// Inventory
\Domovoy\Repositories\DeviceRepository::class => function ($c) {
return new \Domovoy\Repositories\DeviceRepository($c->get(PDO::class));
},
\Domovoy\Services\Inventory\DeviceService::class => function ($c) {
return new \Domovoy\Services\Inventory\DeviceService($c->get(\Domovoy\Repositories\DeviceRepository::class));
},
\Domovoy\Services\Inventory\MergeSuggestionService::class => function ($c) {
return new \Domovoy\Services\Inventory\MergeSuggestionService($c->get(\Domovoy\Repositories\DeviceRepository::class));
},
\Domovoy\Controllers\DeviceController::class => function ($c) {
return new \Domovoy\Controllers\DeviceController(
$c->get(\Domovoy\Services\Inventory\DeviceService::class),
$c->get(\Domovoy\Repositories\DiscoveredHostRepository::class)
);
},
]);
$container = $containerBuilder->build();
@@ -161,6 +180,16 @@ $app->group('', function (\Slim\Routing\RouteCollectorProxy $group) {
$group->post('/discovery/ranges/create', [\Domovoy\Controllers\NetworkRangeController::class, 'create'])->setName('discovery.ranges.create');
$group->post('/discovery/ranges/toggle', [\Domovoy\Controllers\NetworkRangeController::class, 'toggle'])->setName('discovery.ranges.toggle');
$group->post('/discovery/ranges/delete', [\Domovoy\Controllers\NetworkRangeController::class, 'delete'])->setName('discovery.ranges.delete');
// Devices CRUD
$group->get('/devices', [\Domovoy\Controllers\DeviceController::class, 'index'])->setName('devices');
$group->get('/devices/create', [\Domovoy\Controllers\DeviceController::class, 'createForm'])->setName('devices.create');
$group->post('/devices/create', [\Domovoy\Controllers\DeviceController::class, 'create'])->setName('devices.create.post');
$group->get('/devices/{id}', [\Domovoy\Controllers\DeviceController::class, 'show'])->setName('devices.show');
$group->get('/devices/{id}/edit', [\Domovoy\Controllers\DeviceController::class, 'editForm'])->setName('devices.edit');
$group->post('/devices/{id}/update', [\Domovoy\Controllers\DeviceController::class, 'update'])->setName('devices.update');
$group->post('/devices/{id}/delete', [\Domovoy\Controllers\DeviceController::class, 'delete'])->setName('devices.delete');
$group->post('/devices/from-host', [\Domovoy\Controllers\DeviceController::class, 'createFromHost'])->setName('devices.from_host');
});
$app->run();