devsofttech_hms_ci4/app/Controllers/SystemOps.php
DevSoftTech Server 89b862db31 feat: add admin system operations panel with AJAX refresh and server monitoring
- Added SystemOps controller with index and panel endpoints for dynamic content refresh
- Created system_ops_panel.php fragment for AJAX-based UI updates (no full page reload)
- Implemented 30-second auto-refresh using AJAX instead of location.reload()
- Fixed health badge contrast by adding explicit dark text color (#1f2937)
- Added jQuery availability checks to prevent script errors on page load
- Included server overview, resource usage, services, events, and update history
- Integrated delegated event handlers for action buttons (Update, Restart, Reboot, Shutdown)
- All buttons are protected with confirmation dialogs
- Layout maintains NiceAdmin card styling and responsive design

Routes added:
- GET /admin/system-ops/panel - returns panel fragment for refresh
2026-08-03 16:47:41 +05:30

49 lines
1.1 KiB
PHP

<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Libraries\SystemOperations;
class SystemOps extends BaseController
{
public function index(): string
{
$ops = new SystemOperations();
$data = [
'status' => $ops->collectStatus(),
'history' => $ops->getHistory(),
];
return view('Setting/Admin/system_ops', $data);
}
public function panel(): string
{
$ops = new SystemOperations();
$data = [
'status' => $ops->collectStatus(),
'history' => $ops->getHistory(),
];
return view('Setting/Admin/system_ops_panel', $data);
}
public function update()
{
$ops = new SystemOperations();
$result = $ops->runUpdate();
return $this->response->setJSON($result);
}
public function action()
{
$action = (string) $this->request->getPost('action');
$ops = new SystemOperations();
$result = $ops->runServerAction($action);
return $this->response->setJSON($result);
}
}