Skip to content

Commit c2085f3

Browse files
authored
Fixes
1 parent d70f002 commit c2085f3

4 files changed

Lines changed: 128 additions & 18 deletions

File tree

config/var/www/admin/control-panel/api.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,26 @@ function getPhpServiceStatus() {
172172
}
173173

174174
function findActivePhpFpmService() {
175-
// Use a safer approach: get list of active services first, then filter in PHP
175+
// Common PHP-FPM service name patterns to check (ordered by likelihood)
176+
$php_patterns = [
177+
'php8.4-fpm',
178+
'php8.3-fpm',
179+
'php8.2-fpm',
180+
'php8.1-fpm',
181+
'php-fpm',
182+
'php-fpm8.4',
183+
'php84-fpm',
184+
];
185+
186+
// Try each pattern
187+
foreach ($php_patterns as $service_name) {
188+
$status = getSystemServiceStatus($service_name);
189+
if ($status === 'active') {
190+
return $service_name;
191+
}
192+
}
193+
194+
// Fallback: Use systemctl to find any active PHP-FPM service
176195
$services_output = SystemCommand::getSystemdServices(); // codacy:ignore - Static utility class pattern
177196

178197
if ($services_output === false || empty($services_output)) {
@@ -202,7 +221,7 @@ function findActivePhpFpmService() {
202221
// Remove .service suffix if present
203222
$service_name = preg_replace('/\.service$/', '', $service_name);
204223

205-
// Check if it contains both "php" and "fpm" (case insensitive) - FIXED TYPO
224+
// Check if it contains both "php" and "fpm" (case insensitive)
206225
if (stripos($service_name, 'php') !== false && stripos($service_name, 'fpm') !== false) {
207226
// Validate the service name matches our flexible pattern for PHP-FPM services
208227
// Pattern: php + optional version/text + fpm + optional version/text

config/var/www/admin/control-panel/dashboard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// EngineScript Admin Dashboard - Modern JavaScript
22
// Security-hardened version with input validation and XSS prevention
33

4-
import { DashboardAPI } from './modules/api.js?v=2025.11.21.08';
5-
import { DashboardState } from './modules/state.js?v=2025.11.21.08';
6-
import { DashboardCharts } from './modules/charts.js?v=2025.11.21.08';
7-
import { DashboardUtils } from './modules/utils.js?v=2025.11.21.08';
4+
import { DashboardAPI } from './modules/api.js?v=2025.11.21.09';
5+
import { DashboardState } from './modules/state.js?v=2025.11.21.09';
6+
import { DashboardCharts } from './modules/charts.js?v=2025.11.21.09';
7+
import { DashboardUtils } from './modules/utils.js?v=2025.11.21.09';
88
// External services loaded dynamically when needed (lazy loading)
99

1010
class EngineScriptDashboard {
@@ -180,7 +180,7 @@ class EngineScriptDashboard {
180180

181181
console.log('[Dashboard] Importing external services module...');
182182
// Dynamic import - only loads when needed
183-
const { ExternalServicesManager } = await import('./external-services/external-services.js?v=2025.11.21.08');
183+
const { ExternalServicesManager } = await import('./external-services/external-services.js?v=2025.11.21.09');
184184

185185
console.log('[Dashboard] Creating ExternalServicesManager instance...');
186186
// Create instance and initialize

config/var/www/admin/control-panel/external-services/external-services.js

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// EngineScript External Services Manager - ES6 Module
22
// Handles external service status monitoring with drag-drop ordering and preferences
33

4-
import { DashboardUtils } from '../modules/utils.js?v=2025.11.21.08';
5-
import { SERVICE_DEFINITIONS } from './services-config.js?v=2025.11.21.08';
4+
import { DashboardUtils } from '../modules/utils.js?v=2025.11.21.09';
5+
import { SERVICE_DEFINITIONS } from './services-config.js?v=2025.11.21.09';
66

77
export class ExternalServicesManager {
88
constructor(containerSelector, settingsContainerSelector) {
@@ -138,6 +138,9 @@ export class ExternalServicesManager {
138138

139139
this.container.appendChild(categoryContainer);
140140
}
141+
142+
// Enable drag and drop for service cards
143+
this.enableServiceDragDrop(this.container);
141144
} catch (error) {
142145
console.error('Failed to load external services:', error);
143146
this.container.innerHTML = "";
@@ -267,7 +270,7 @@ export class ExternalServicesManager {
267270
categoryHeader.className = "category-header";
268271
categoryHeader.innerHTML = `
269272
<span>${category}</span>
270-
<button class="category-toggle-btn" data-category="${category}">
273+
<button class="category-toggle-all-btn" data-category="${category}">
271274
<span class="toggle-all-text">Toggle All</span>
272275
<i class="fas fa-toggle-on"></i>
273276
</button>
@@ -307,7 +310,7 @@ export class ExternalServicesManager {
307310
});
308311

309312
// Add toggle all button functionality
310-
const toggleBtn = categoryHeader.querySelector(".category-toggle-btn");
313+
const toggleBtn = categoryHeader.querySelector(".category-toggle-all-btn");
311314
toggleBtn.addEventListener("click", () => {
312315
const allEnabled = categoryCheckboxes.every(cb => cb.checked);
313316
categoryCheckboxes.forEach(cb => {
@@ -322,7 +325,7 @@ export class ExternalServicesManager {
322325

323326
// Save button
324327
const saveButton = document.createElement("button");
325-
saveButton.className = "save-settings-btn";
328+
saveButton.className = "settings-save-btn";
326329
saveButton.innerHTML = '<i class="fas fa-save"></i> Save Changes';
327330
saveButton.disabled = true;
328331

@@ -762,6 +765,94 @@ export class ExternalServicesManager {
762765
this.setCookie('serviceOrder', encodeURIComponent(JSON.stringify(orderArray)), 365);
763766
}
764767

768+
// ============ Drag and Drop ============
769+
770+
/**
771+
* Enable drag-and-drop for service cards
772+
*/
773+
enableServiceDragDrop(container) {
774+
const serviceCards = container.querySelectorAll('.external-service-card');
775+
let draggedElement = null;
776+
let draggedServiceKey = null;
777+
778+
serviceCards.forEach(card => {
779+
card.draggable = true;
780+
781+
card.addEventListener('dragstart', (e) => {
782+
draggedElement = card;
783+
draggedServiceKey = card.dataset.serviceKey;
784+
card.classList.add('dragging');
785+
e.dataTransfer.effectAllowed = 'move';
786+
e.dataTransfer.setData('text/html', card.innerHTML);
787+
});
788+
789+
card.addEventListener('dragover', (e) => {
790+
e.preventDefault();
791+
e.dataTransfer.dropEffect = 'move';
792+
793+
const targetCard = e.target.closest('.external-service-card');
794+
if (targetCard && targetCard !== draggedElement) {
795+
targetCard.classList.add('drag-over');
796+
}
797+
});
798+
799+
card.addEventListener('dragenter', (e) => {
800+
const targetCard = e.target.closest('.external-service-card');
801+
if (targetCard && targetCard !== draggedElement) {
802+
targetCard.classList.add('drag-over');
803+
}
804+
});
805+
806+
card.addEventListener('dragleave', (e) => {
807+
const targetCard = e.target.closest('.external-service-card');
808+
if (targetCard) {
809+
targetCard.classList.remove('drag-over');
810+
}
811+
});
812+
813+
card.addEventListener('drop', (e) => {
814+
e.preventDefault();
815+
816+
const targetCard = e.target.closest('.external-service-card');
817+
if (targetCard && targetCard !== draggedElement) {
818+
targetCard.classList.remove('drag-over');
819+
820+
// Swap positions
821+
const targetServiceKey = targetCard.dataset.serviceKey;
822+
const allCards = Array.from(container.querySelectorAll('.external-service-card'));
823+
const draggedIndex = allCards.indexOf(draggedElement);
824+
const targetIndex = allCards.indexOf(targetCard);
825+
826+
if (draggedIndex < targetIndex) {
827+
targetCard.parentNode.insertBefore(draggedElement, targetCard.nextSibling);
828+
} else {
829+
targetCard.parentNode.insertBefore(draggedElement, targetCard);
830+
}
831+
832+
// Save new order
833+
this.saveCardOrder();
834+
}
835+
});
836+
837+
card.addEventListener('dragend', () => {
838+
card.classList.remove('dragging');
839+
// Remove drag-over from all cards
840+
container.querySelectorAll('.external-service-card').forEach(c => {
841+
c.classList.remove('drag-over');
842+
});
843+
});
844+
});
845+
}
846+
847+
/**
848+
* Save current card order to cookie
849+
*/
850+
saveCardOrder() {
851+
const cards = document.querySelectorAll('.external-service-card');
852+
const orderArray = Array.from(cards).map(card => card.dataset.serviceKey);
853+
this.saveServiceOrder(orderArray);
854+
}
855+
765856
// ============ Notifications ============
766857

767858
/**

config/var/www/admin/control-panel/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{FONTAWESOME_VER}/css/all.min.css" rel="stylesheet" crossorigin="anonymous">
1313

1414
<!-- Custom Styles -->
15-
<link rel="stylesheet" href="dashboard.css?v=2025.11.21.08">
16-
<link rel="stylesheet" href="external-services/external-services.css?v=2025.11.21.08">
15+
<link rel="stylesheet" href="dashboard.css?v=2025.11.21.09">
16+
<link rel="stylesheet" href="external-services/external-services.css?v=2025.11.21.09">
1717

1818
<!-- Preload Critical Resources -->
19-
<link rel="modulepreload" href="dashboard.js?v=2025.11.21.08" crossorigin="use-credentials">
20-
<link rel="modulepreload" href="modules/api.js?v=2025.11.21.08" crossorigin="use-credentials">
19+
<link rel="modulepreload" href="dashboard.js?v=2025.11.21.09" crossorigin="use-credentials">
20+
<link rel="modulepreload" href="modules/api.js?v=2025.11.21.09" crossorigin="use-credentials">
2121
</head>
2222
<body>
2323
<!-- Loading Screen -->
@@ -370,10 +370,10 @@ <h3>Uptime Robot</h3>
370370

371371
<!-- Dashboard Version -->
372372
<div style="text-align: center; padding: 20px; color: #666; font-size: 0.85rem; border-top: 1px solid #444;">
373-
EngineScript Dashboard v2025.11.21.08
373+
EngineScript Dashboard v2025.11.21.09
374374
</div>
375375

376376
<!-- Scripts -->
377-
<script type="module" src="dashboard.js?v=2025.11.21.08" data-cfasync="false"></script>
377+
<script type="module" src="dashboard.js?v=2025.11.21.09" data-cfasync="false"></script>
378378
</body>
379379
</html>

0 commit comments

Comments
 (0)