Standard-Theme sichtbar und Autoload repariert
This commit is contained in:
parent
a69b8e4990
commit
6d58a652db
@ -6,7 +6,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
from flask import Blueprint, render_template, request, jsonify, redirect, url_for, current_app
|
from flask import Blueprint, render_template, request, jsonify, redirect, url_for, current_app
|
||||||
from app.state import current_config
|
from app.state import current_config
|
||||||
from app.utils.helpers import load_configs, load_default_sounds, load_soundboard_configs, write_default_theme
|
from app.utils.helpers import load_configs, load_default_sounds, load_soundboard_configs, write_default_theme, read_default_theme
|
||||||
|
|
||||||
admin_bp = Blueprint('admin', __name__)
|
admin_bp = Blueprint('admin', __name__)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -15,7 +15,11 @@ logger = logging.getLogger(__name__)
|
|||||||
def admin():
|
def admin():
|
||||||
configs = load_configs()
|
configs = load_configs()
|
||||||
sb_configs = load_soundboard_configs(current_app.config['SOUNDBOARD_CONFIG_DIR'])
|
sb_configs = load_soundboard_configs(current_app.config['SOUNDBOARD_CONFIG_DIR'])
|
||||||
return render_template('admin.html', configs=configs, sb_configs=sb_configs)
|
default_theme = read_default_theme(current_app.config['DEFAULT_THEME_FILE'])
|
||||||
|
return render_template('admin.html',
|
||||||
|
configs=configs,
|
||||||
|
sb_configs=sb_configs,
|
||||||
|
default_theme=default_theme)
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/edit/<filename>', methods=['GET', 'POST'])
|
@admin_bp.route('/edit/<filename>', methods=['GET', 'POST'])
|
||||||
|
|||||||
@ -77,7 +77,12 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for sb in sb_configs %}
|
{% for sb in sb_configs %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ sb.name }}</td>
|
<td>
|
||||||
|
{{ sb.name }}
|
||||||
|
{% if default_theme == sb.filename %}
|
||||||
|
<span class="badge bg-success ms-2">Standard</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td><code>{{ sb.filename }}</code></td>
|
<td><code>{{ sb.filename }}</code></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('admin.admin_edit_theme', filename=sb.filename) }}"
|
<a href="{{ url_for('admin.admin_edit_theme', filename=sb.filename) }}"
|
||||||
|
|||||||
@ -289,25 +289,29 @@
|
|||||||
(async () => {
|
(async () => {
|
||||||
await updateAutoStatus();
|
await updateAutoStatus();
|
||||||
// Wenn noch kein Theme aktiv ist, versuche Standard-Theme zu laden
|
// Wenn noch kein Theme aktiv ist, versuche Standard-Theme zu laden
|
||||||
const statusRes = await fetch('/api/soundboard/status');
|
let statusRes = await fetch('/api/soundboard/status');
|
||||||
const statusData = await statusRes.json();
|
let statusData = await statusRes.json();
|
||||||
if (!statusData.active && !statusData.current_theme) {
|
if (!statusData.active && !statusData.current_theme) {
|
||||||
await fetch('/api/soundboard/load_default', { method: 'POST' });
|
await fetch('/api/soundboard/load_default', { method: 'POST' });
|
||||||
|
statusRes = await fetch('/api/soundboard/status');
|
||||||
|
statusData = await statusRes.json();
|
||||||
}
|
}
|
||||||
if (selectEl && selectEl.value) {
|
|
||||||
const statusRes2 = await fetch('/api/soundboard/status');
|
if (statusData.current_theme) {
|
||||||
const statusData2 = await statusRes2.json();
|
const cur = await fetch('/api/soundboard/current');
|
||||||
if (!statusData2.active || statusData2.current_theme !== selectEl.value) {
|
const curData = await cur.json();
|
||||||
loadSoundboard(selectEl.value);
|
if (curData.soundboard) {
|
||||||
} else {
|
currentSB = curData.soundboard;
|
||||||
const cur = await fetch('/api/soundboard/current');
|
renderSoundboard(currentSB);
|
||||||
const curData = await cur.json();
|
content.style.display = 'block';
|
||||||
if (curData.soundboard) {
|
|
||||||
currentSB = curData.soundboard;
|
|
||||||
renderSoundboard(currentSB);
|
|
||||||
content.style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Select auf aktuelles Theme setzen, falls vorhanden
|
||||||
|
if (selectEl) {
|
||||||
|
const opt = Array.from(selectEl.options).find(o => o.value === statusData.current_theme);
|
||||||
|
if (opt) selectEl.value = opt.value;
|
||||||
|
}
|
||||||
|
} else if (selectEl && selectEl.value) {
|
||||||
|
loadSoundboard(selectEl.value);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user