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);
|
shell_exec($command);
|
||||||
echo "Started";
|
echo "Started";
|
||||||
} elseif ($action == "stop") {
|
} elseif ($action == "stop") {
|
||||||
$command = 'sudo pkill -f "screen.py"';
|
$command = 'sudo pkill -f "screen.py" 2>&1';
|
||||||
shell_exec($command);
|
$output = shell_exec($command);
|
||||||
echo "Stopped";
|
echo "Stopped. Output: " . $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Actions</h5>
|
<h5 class="card-title">Actions</h5>
|
||||||
<p class="card-text">Démarrer ou arrêter l'application d'affichage sur l'écran HDMI.</p>
|
<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"
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||||
class="bi bi-play-fill" viewBox="0 0 16 16">
|
class="bi bi-play-fill" viewBox="0 0 16 16">
|
||||||
<path
|
<path
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
Démarrer
|
Démarrer
|
||||||
</button>
|
</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"
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||||
class="bi bi-stop-fill" viewBox="0 0 16 16">
|
class="bi bi-stop-fill" viewBox="0 0 16 16">
|
||||||
<path
|
<path
|
||||||
@@ -149,21 +149,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function controlScreen(action) {
|
function controlScreen(action) {
|
||||||
|
console.log("Sending Screen Control Action:", action);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'launcher.php?type=screen_control&action=' + action,
|
url: 'launcher.php?type=screen_control&action=' + action,
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
console.log("Screen control " + action + ": " + response);
|
console.log("Server Response:", response);
|
||||||
if (action == 'start') {
|
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 {
|
} 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) {
|
error: function (xhr, status, error) {
|
||||||
console.error('AJAX request failed:', status, error);
|
console.error("AJAX Error:", 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>');
|
$('#status-message').html('<div class="alert alert-danger">Erreur: ' + error + '</div>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user