mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
Fix service controls, loading overlay, DB engine awareness
- system.php: add sudo to all systemctl/apt-get calls (www-data runs as non-root) - system.php: flush command for postfix uses postqueue -f - system.php: save-option writes web_server to config.ini so VhostManager picks it up - databases.php: list endpoint supports admin (no account_id), defaults db type to active_db_engine setting - nova.js: add Nova.loading() / Nova.loadingDone() spinner overlay - admin.js: adminServiceAction shows loading overlay + optimistic badge update - admin.js: phpInstallVersion, dbEngineAction, docker install, OS/NovaCPX update all show loading overlay - WordPressManager.php: fix Database::getInstance() -> DB::getInstance()->pdo() - DockerManager.php: fix install to write script file and sudo bash (no interactive terminal)
This commit is contained in:
@@ -13,10 +13,18 @@ if ($user['role'] === 'user') {
|
||||
|
||||
match ($action) {
|
||||
|
||||
'list' => (function() use ($db, $accountId) {
|
||||
if (!$accountId) Response::error("account_id required");
|
||||
$rows = $db->fetchAll("SELECT id, db_name, db_user, db_type, size_mb, created_at FROM `databases` WHERE account_id = ?", [$accountId]);
|
||||
foreach ($rows as &$r) { $r['size_mb'] = DatabaseManager::getSize($r['db_name'], $r['db_type']); }
|
||||
'list' => (function() use ($db, $accountId, $user) {
|
||||
if (!$accountId && $user['role'] !== 'admin') Response::error("account_id required");
|
||||
if ($accountId) {
|
||||
$rows = $db->fetchAll(
|
||||
"SELECT d.id, d.db_name, d.db_user, d.db_type, d.size_mb, d.created_at, a.username
|
||||
FROM `databases` d LEFT JOIN accounts a ON a.id=d.account_id WHERE d.account_id = ?", [$accountId]);
|
||||
} else {
|
||||
$rows = $db->fetchAll(
|
||||
"SELECT d.id, d.db_name, d.db_user, d.db_type, d.size_mb, d.created_at, a.username
|
||||
FROM `databases` d LEFT JOIN accounts a ON a.id=d.account_id ORDER BY d.created_at DESC LIMIT 500");
|
||||
}
|
||||
foreach ($rows as &$r) { $r['size_mb'] = DatabaseManager::getSize($r['db_name'], $r['db_type'] ?? 'mysql'); }
|
||||
Response::success($rows);
|
||||
})(),
|
||||
|
||||
@@ -28,7 +36,9 @@ match ($action) {
|
||||
$count = (int)$db->fetchOne("SELECT COUNT(*) c FROM `databases` WHERE account_id=?", [$accountId])['c'];
|
||||
if ($count >= (int)$acctPkg['max_databases']) Response::error("Database limit ({$acctPkg['max_databases']}) reached for this package", 403);
|
||||
}
|
||||
$type = $body['type'] ?? 'mysql';
|
||||
// Default to active DB engine from settings so autoinstallers use whatever the admin has selected
|
||||
$activeEngine = $db->fetchOne("SELECT `value` FROM settings WHERE `key`='active_db_engine'")['value'] ?? 'mysql';
|
||||
$type = $body['type'] ?? ($activeEngine === 'postgresql' ? 'postgresql' : 'mysql');
|
||||
$dbName = trim($body['db_name'] ?? '');
|
||||
$dbUser = trim($body['db_user'] ?? $dbName . '_user');
|
||||
$dbPass = $body['db_pass'] ?? bin2hex(random_bytes(8));
|
||||
|
||||
Reference in New Issue
Block a user