v1.9.11: Bouton 'Test Power Supply' (check sous-tension rapide)
Ajoute un bouton à côté de 'Run Self Test' (4 pages) qui lance uniquement le check sous-tension dans un petit modal dédié, sans dérouler tout le Self Test. Réutilise l'endpoint type=throttled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1025,6 +1025,65 @@ function downloadReport() {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// STANDALONE POWER SUPPLY TEST (quick check)
|
||||
// ============================================
|
||||
function runPowerTest() {
|
||||
const modalEl = document.getElementById('powerTestModal');
|
||||
const bodyEl = document.getElementById('powerTest_body');
|
||||
|
||||
bodyEl.innerHTML = `
|
||||
<div class="d-flex align-items-center text-primary">
|
||||
<div class="spinner-border spinner-border-sm me-2" role="status"></div>
|
||||
<span>Lecture de l'alimentation (vcgencmd get_throttled)...</span>
|
||||
</div>`;
|
||||
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(modalEl);
|
||||
modal.show();
|
||||
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=throttled',
|
||||
dataType: 'json',
|
||||
method: 'GET',
|
||||
cache: false,
|
||||
timeout: 10000,
|
||||
success: function(data) { renderPowerTestResult(bodyEl, data); },
|
||||
error: function(xhr, status, error) {
|
||||
bodyEl.innerHTML = `<div class="alert alert-secondary mb-0">Erreur: ${error || status}</div>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderPowerTestResult(bodyEl, data) {
|
||||
if (!data || !data.available) {
|
||||
bodyEl.innerHTML = `<div class="alert alert-secondary mb-0">${(data && data.error) || 'vcgencmd indisponible'}</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
let alertClass, icon;
|
||||
if (data.status === 'critical') { alertClass = 'alert-danger'; icon = '✗'; }
|
||||
else if (data.status === 'warning') { alertClass = 'alert-warning'; icon = '!'; }
|
||||
else { alertClass = 'alert-success'; icon = '✓'; }
|
||||
|
||||
const flag = (b) => b
|
||||
? '<span class="badge bg-danger">oui</span>'
|
||||
: '<span class="badge bg-success">non</span>';
|
||||
|
||||
bodyEl.innerHTML = `
|
||||
<div class="alert ${alertClass}">
|
||||
<strong>${icon} ${data.message}</strong>
|
||||
</div>
|
||||
<table class="table table-sm mb-0">
|
||||
<tbody>
|
||||
<tr><td>Valeur brute</td><td><code>${data.raw}</code></td></tr>
|
||||
<tr><td>Sous-tension maintenant</td><td>${flag(data.under_voltage_now)}</td></tr>
|
||||
<tr><td>Throttling maintenant</td><td>${flag(data.throttled_now)}</td></tr>
|
||||
<tr><td>Sous-tension depuis le boot</td><td>${flag(data.under_voltage_occurred)}</td></tr>
|
||||
<tr><td>Throttling depuis le boot</td><td>${flag(data.throttling_occurred)}</td></tr>
|
||||
</tbody>
|
||||
</table>`;
|
||||
}
|
||||
|
||||
// Load the self-test modal HTML into the page
|
||||
function initSelfTestModal() {
|
||||
fetch('selftest-modal.html')
|
||||
|
||||
Reference in New Issue
Block a user