mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 13:23:00 +00:00
web action simplification
This commit is contained in:
@@ -220,6 +220,17 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-controls {
|
||||||
|
background: var(--card-background);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
padding: 20px;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
margin-bottom: 20px;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
border-bottom: 2px solid var(--border-color);
|
border-bottom: 2px solid var(--border-color);
|
||||||
@@ -690,6 +701,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Quick Controls -->
|
||||||
|
<div class="quick-controls">
|
||||||
|
<h2 style="margin-bottom:12px;"><i class="fas fa-bolt"></i> Quick Controls</h2>
|
||||||
|
<div class="display-controls">
|
||||||
|
<button class="btn btn-success" onclick="runAction('start_display')"><i class="fas fa-play"></i> Start Display</button>
|
||||||
|
<button class="btn btn-danger" onclick="runAction('stop_display')"><i class="fas fa-stop"></i> Stop Display</button>
|
||||||
|
<button class="btn btn-primary" onclick="systemAction('restart_service')"><i class="fas fa-redo"></i> Restart Service</button>
|
||||||
|
<button class="btn btn-warning" onclick="systemAction('git_pull')"><i class="fas fa-download"></i> Update Code</button>
|
||||||
|
<button class="btn btn-danger" onclick="systemAction('reboot_system')"><i class="fas fa-power-off"></i> Reboot</button>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top:12px; color:#666; font-size:12px;">Service actions may require sudo privileges on the Pi.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Editor Mode Banner -->
|
<!-- Editor Mode Banner -->
|
||||||
{% if editor_mode %}
|
{% if editor_mode %}
|
||||||
<div class="editor-mode">
|
<div class="editor-mode">
|
||||||
@@ -1969,29 +1993,12 @@
|
|||||||
|
|
||||||
// Display control functions
|
// Display control functions
|
||||||
async function startDisplay() {
|
async function startDisplay() {
|
||||||
try {
|
// Use system service like Web UI v1 for reliability
|
||||||
const response = await fetch('/api/display/start', {
|
await runAction('start_display');
|
||||||
method: 'POST',
|
|
||||||
headers: {'Content-Type': 'application/json'}
|
|
||||||
});
|
|
||||||
const result = await response.json();
|
|
||||||
showNotification(result.message, result.status);
|
|
||||||
} catch (error) {
|
|
||||||
showNotification('Error starting display: ' + error.message, 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopDisplay() {
|
async function stopDisplay() {
|
||||||
try {
|
await runAction('stop_display');
|
||||||
const response = await fetch('/api/display/stop', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {'Content-Type': 'application/json'}
|
|
||||||
});
|
|
||||||
const result = await response.json();
|
|
||||||
showNotification(result.message, result.status);
|
|
||||||
} catch (error) {
|
|
||||||
showNotification('Error stopping display: ' + error.message, 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleEditorMode() {
|
async function toggleEditorMode() {
|
||||||
|
|||||||
@@ -845,10 +845,16 @@ def view_logs():
|
|||||||
"""View system logs."""
|
"""View system logs."""
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['sudo', '-n', 'journalctl', '-u', 'ledmatrix.service', '-n', '500', '--no-pager'],
|
['journalctl', '-u', 'ledmatrix.service', '-n', '500', '--no-pager'],
|
||||||
capture_output=True, text=True, check=True
|
capture_output=True, text=True, check=False
|
||||||
)
|
)
|
||||||
logs = result.stdout
|
logs = result.stdout if result.returncode == 0 else ''
|
||||||
|
if result.returncode != 0:
|
||||||
|
try:
|
||||||
|
with open('/tmp/web_interface_v2.log', 'r') as f:
|
||||||
|
logs = f.read()
|
||||||
|
except Exception:
|
||||||
|
logs = 'Insufficient permissions to read journal. Add user to systemd-journal or configure sudoers for journalctl.'
|
||||||
|
|
||||||
# Return logs as HTML page
|
# Return logs as HTML page
|
||||||
return f"""
|
return f"""
|
||||||
|
|||||||
Reference in New Issue
Block a user