ServerManager project files
This commit is contained in:
60
src/Controllers/DashboardController.php
Executable file
60
src/Controllers/DashboardController.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ServerManager\Controllers;
|
||||
|
||||
use ServerManager\Core\App;
|
||||
use ServerManager\Models\Server;
|
||||
use ServerManager\Services\MonitoringService;
|
||||
use ServerManager\Services\AuditService;
|
||||
|
||||
class DashboardController
|
||||
{
|
||||
private \ServerManager\Core\View $view;
|
||||
private MonitoringService $monitoringService;
|
||||
private AuditService $auditService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->view = App::getInstance()->getView();
|
||||
$this->monitoringService = new MonitoringService();
|
||||
$this->auditService = new AuditService();
|
||||
}
|
||||
|
||||
public function index(): void
|
||||
{
|
||||
$stats = $this->monitoringService->getDashboardStats();
|
||||
$recentActivity = $this->auditService->getRecentActivity(10);
|
||||
|
||||
$serverModel = new Server();
|
||||
$servers = $serverModel->findAll(true);
|
||||
|
||||
$this->view->display('dashboard.index', [
|
||||
'title' => 'Dashboard - ServerManager',
|
||||
'stats' => $stats,
|
||||
'servers' => $servers,
|
||||
'recentActivity' => $recentActivity,
|
||||
]);
|
||||
}
|
||||
|
||||
public function stats(): void
|
||||
{
|
||||
$stats = $this->monitoringService->getDashboardStats();
|
||||
|
||||
$this->view->json([
|
||||
'success' => true,
|
||||
'data' => $stats,
|
||||
]);
|
||||
}
|
||||
|
||||
public function refreshMetrics(): void
|
||||
{
|
||||
$this->monitoringService->collectAllMetrics();
|
||||
|
||||
$this->view->json([
|
||||
'success' => true,
|
||||
'message' => 'Metrics refreshed',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user