diff --git a/templates/index_v2.html b/templates/index_v2.html index d0479363..d242a45b 100644 --- a/templates/index_v2.html +++ b/templates/index_v2.html @@ -220,6 +220,17 @@ 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 { display: flex; border-bottom: 2px solid var(--border-color); @@ -690,6 +701,19 @@ + +
+

Quick Controls

+
+ + + + + +
+
Service actions may require sudo privileges on the Pi.
+
+ {% if editor_mode %}
@@ -1969,29 +1993,12 @@ // Display control functions async function startDisplay() { - try { - const response = await fetch('/api/display/start', { - 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'); - } + // Use system service like Web UI v1 for reliability + await runAction('start_display'); } async function stopDisplay() { - try { - 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'); - } + await runAction('stop_display'); } async function toggleEditorMode() { diff --git a/web_interface_v2.py b/web_interface_v2.py index 67e85692..08ebb2e9 100644 --- a/web_interface_v2.py +++ b/web_interface_v2.py @@ -845,10 +845,16 @@ def view_logs(): """View system logs.""" try: result = subprocess.run( - ['sudo', '-n', 'journalctl', '-u', 'ledmatrix.service', '-n', '500', '--no-pager'], - capture_output=True, text=True, check=True + ['journalctl', '-u', 'ledmatrix.service', '-n', '500', '--no-pager'], + 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 f"""