diff --git a/app/routes/main.py b/app/routes/main.py index fcb2e4e..871fb70 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -78,9 +78,13 @@ def control_page(): @main_bp.route('/soundboard') def soundboard(): - if state.current_config is None or 'sounds' not in state.current_config: + if state.current_config is None: return redirect(url_for('main.index')) - sounds = state.current_config.get('sounds', []) - return render_template('soundboard.html', sounds=sounds, config=state.current_config) + sounds_local = state.current_config.get('sounds', []) + sounds_global = load_default_sounds(current_app.config['CONFIG_DIR']) + return render_template('soundboard.html', + sounds_local=sounds_local, + sounds_global=sounds_global, + config=state.current_config) pass diff --git a/templates/soundboard.html b/templates/soundboard.html index 76d12ee..ab96e94 100644 --- a/templates/soundboard.html +++ b/templates/soundboard.html @@ -7,9 +7,13 @@

Soundboard – {{ config.name }}

Wähle einen Sound aus – wird direkt über den Raspberry Pi ausgegeben.

- {% if sounds %} + {% set has_local = sounds_local and sounds_local|length > 0 %} + {% set has_global = sounds_global and sounds_global|length > 0 %} + + {% if has_local %} +

Lok-spezifische Sounds

- {% for sound in sounds %} + {% for sound in sounds_local %}
@@ -18,7 +22,9 @@

{{ sound.description }}

{% endif %}
@@ -26,9 +32,35 @@
{% endfor %}
- {% else %} + {% endif %} + + {% if has_global %} +

Standard-Sounds

+
+ {% for sound in sounds_global %} +
+
+
+
{{ sound.name }}
+ {% if sound.description %} +

{{ sound.description }}

+ {% endif %} + +
+
+
+ {% endfor %} +
+ {% endif %} + + {% if not has_local and not has_global %}
- In dieser Konfiguration sind noch keine Sounds definiert. + In dieser Konfiguration sind keine Sounds definiert und keine Default-Sounds vorhanden.
{% endif %} @@ -44,6 +76,8 @@ document.querySelectorAll('.play-sound-btn').forEach(btn => { btn.addEventListener('click', async () => { const soundId = btn.dataset.soundId; + const channel = btn.dataset.channel || null; + const loopFlag = btn.dataset.loop === '1' || btn.dataset.loop === 'true'; btn.disabled = true; btn.innerHTML = ' Spielt...'; @@ -51,7 +85,7 @@ const res = await fetch('/api/play_sound', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ sound_id: soundId }) + body: JSON.stringify({ sound_id: soundId, channel, loop: loopFlag }) }); const data = await res.json(); @@ -80,4 +114,4 @@ }); }); -{% endblock %} \ No newline at end of file +{% endblock %}