- Fix Enter key detection: handle multiple Enter key formats (\n, \r, \r\n) - Reduce flickering: lower render frequency from 60 FPS to 30 FPS - Fix menu bar visibility: re-render menu bar after content to prevent overwriting - Fix content positioning: explicit line positioning for categories and commands - Fix line shifting: clear lines before writing, control newlines manually - Limit visible items: prevent overflow with maxVisibleCategories/Commands - Improve CPU usage: increase sleep interval when no events processed This fixes: - Enter key not working for selection - Strong flickering of the application - Menu bar not visible or being overwritten - Top half of selection list not displayed - Lines being shifted/misaligned
81 lines
2.9 KiB
PHP
81 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Application\Admin\Database;
|
|
|
|
use App\Framework\Admin\Attributes\AdminPage;
|
|
use App\Framework\Admin\Attributes\AdminSection;
|
|
use App\Framework\Admin\AdminPageRenderer;
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\Database\Browser\Registry\DatabaseRegistry;
|
|
use App\Framework\Database\Browser\Registry\TableRegistry;
|
|
use App\Framework\Meta\MetaData;
|
|
use App\Framework\Pagination\PaginationService;
|
|
use App\Framework\Pagination\ValueObjects\PaginationRequest;
|
|
use App\Framework\Router\Result\ViewResult;
|
|
use App\Framework\View\Table\Generators\DatabaseTableGenerator;
|
|
|
|
#[AdminSection(name: 'Database', icon: 'database', order: 30)]
|
|
final readonly class DatabaseBrowserController
|
|
{
|
|
public function __construct(
|
|
private DatabaseRegistry $databaseRegistry,
|
|
private TableRegistry $tableRegistry,
|
|
private AdminPageRenderer $pageRenderer,
|
|
private PaginationService $paginationService,
|
|
private DatabaseTableGenerator $tableGenerator,
|
|
) {
|
|
}
|
|
|
|
#[AdminPage(title: 'Database Browser', icon: 'database', section: 'Database', order: 10)]
|
|
#[Route('/admin/database', name: 'admin.database.browser')]
|
|
public function index(): ViewResult
|
|
{
|
|
$database = $this->databaseRegistry->getCurrentDatabase();
|
|
$tables = $this->tableRegistry->getAllTables();
|
|
|
|
// Convert to array for pagination
|
|
$tablesArray = array_map(fn ($table) => $table->toArray(), $tables);
|
|
|
|
// Paginate tables
|
|
$paginationRequest = PaginationRequest::first(limit: 50, sortField: 'name');
|
|
$paginator = $this->paginationService->forArray($tablesArray);
|
|
$paginationResponse = $paginator->paginate($paginationRequest);
|
|
|
|
// Generate table
|
|
$tableData = array_map(
|
|
fn ($table) => [
|
|
'name' => $table['name'],
|
|
'row_count' => $table['row_count'],
|
|
'size_mb' => $table['size_mb'],
|
|
'engine' => $table['engine'],
|
|
'collation' => $table['collation'],
|
|
],
|
|
$paginationResponse->data
|
|
);
|
|
|
|
$table = $this->tableGenerator->generate($tableData);
|
|
|
|
$data = [
|
|
'title' => 'Database Browser',
|
|
'database' => $database->toArray(),
|
|
'table' => $table->render(),
|
|
'table_count' => count($tables),
|
|
'pagination' => [
|
|
'current_page' => $paginationResponse->meta->currentPage,
|
|
'total_pages' => $paginationResponse->meta->totalPages,
|
|
'total_items' => $paginationResponse->meta->totalCount,
|
|
'items_per_page' => $paginationResponse->request->limit,
|
|
],
|
|
];
|
|
|
|
return new ViewResult(
|
|
template: 'database/browser',
|
|
metaData: new MetaData('Database Browser', 'Admin - Database Browser'),
|
|
data: $data
|
|
);
|
|
}
|
|
}
|
|
|