Fix UI: Add button IDs and fix status message selector in screen.html; Capture stderr in launcher.php
This commit is contained in:
@@ -1760,8 +1760,8 @@ if ($type == "screen_control") {
|
||||
shell_exec($command);
|
||||
echo "Started";
|
||||
} elseif ($action == "stop") {
|
||||
$command = 'sudo pkill -f "screen.py"';
|
||||
shell_exec($command);
|
||||
echo "Stopped";
|
||||
$command = 'sudo pkill -f "screen.py" 2>&1';
|
||||
$output = shell_exec($command);
|
||||
echo "Stopped. Output: " . $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Actions</h5>
|
||||
<p class="card-text">Démarrer ou arrêter l'application d'affichage sur l'écran HDMI.</p>
|
||||
<button class="btn btn-success m-2" onclick="controlScreen('start')">
|
||||
<button id="startBtn" class="btn btn-success m-2" onclick="controlScreen('start')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||
class="bi bi-play-fill" viewBox="0 0 16 16">
|
||||
<path
|
||||
@@ -77,7 +77,7 @@
|
||||
</svg>
|
||||
Démarrer
|
||||
</button>
|
||||
<button class="btn btn-danger m-2" onclick="controlScreen('stop')">
|
||||
<button id="stopBtn" class="btn btn-danger m-2" onclick="controlScreen('stop')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||
class="bi bi-stop-fill" viewBox="0 0 16 16">
|
||||
<path
|
||||
@@ -149,21 +149,26 @@
|
||||
});
|
||||
|
||||
function controlScreen(action) {
|
||||
console.log("Sending Screen Control Action:", action);
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=screen_control&action=' + action,
|
||||
dataType: 'text',
|
||||
method: 'GET',
|
||||
success: function (response) {
|
||||
console.log("Screen control " + action + ": " + response);
|
||||
console.log("Server Response:", response);
|
||||
if (action == 'start') {
|
||||
$('#status-message').html('<div class="alert alert-success alert-dismissible fade show" role="alert">L\'écran a été démarré.<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>');
|
||||
$('#startBtn').removeClass('btn-success').addClass('btn-secondary').prop('disabled', true);
|
||||
$('#stopBtn').removeClass('btn-secondary').addClass('btn-danger').prop('disabled', false);
|
||||
$('#status-message').html('<div class="alert alert-success">L\'écran a été démarré. Réponse: ' + response + '</div>');
|
||||
} else {
|
||||
$('#status-message').html('<div class="alert alert-warning alert-dismissible fade show" role="alert">L\'écran a été arrêté.<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>');
|
||||
$('#startBtn').removeClass('btn-secondary').addClass('btn-success').prop('disabled', false);
|
||||
$('#stopBtn').removeClass('btn-danger').addClass('btn-secondary').prop('disabled', true);
|
||||
$('#status-message').html('<div class="alert alert-warning">L\'écran a été arrêté. Réponse: ' + response + '</div>');
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
$('#status-message').html('<div class="alert alert-danger alert-dismissible fade show" role="alert">Erreur: ' + error + '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>');
|
||||
console.error("AJAX Error:", status, error);
|
||||
$('#status-message').html('<div class="alert alert-danger">Erreur: ' + error + '</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user