fixes for new config editor
This commit is contained in:
parent
f1f2a14ccd
commit
4340a58450
@ -121,7 +121,8 @@ def _slugify(name: str) -> str:
|
||||
|
||||
@admin_bp.route('/create_config', methods=['POST'])
|
||||
def admin_create_config():
|
||||
data = request.get_json() or {}
|
||||
try:
|
||||
data = request.get_json(force=True, silent=True) or {}
|
||||
name = data.get('name') or 'Neue Lok'
|
||||
hub_id = int(data.get('hub_id', 0))
|
||||
hub_type = data.get('hub_type', '4channel')
|
||||
@ -145,11 +146,15 @@ def admin_create_config():
|
||||
json.dump(template, f, ensure_ascii=False, indent=2)
|
||||
logger.info(f"Neue Config angelegt: {filename}")
|
||||
return jsonify({"success": True, "filename": filename})
|
||||
except Exception as e:
|
||||
logger.exception("create_config fehlgeschlagen")
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@admin_bp.route('/create_theme', methods=['POST'])
|
||||
def admin_create_theme():
|
||||
data = request.get_json() or {}
|
||||
try:
|
||||
data = request.get_json(force=True, silent=True) or {}
|
||||
name = data.get('name') or 'Neues Theme'
|
||||
folder = data.get('folder') or _slugify(name)
|
||||
filename = data.get('filename') or 'theme.json'
|
||||
@ -173,3 +178,6 @@ def admin_create_theme():
|
||||
json.dump(template, f, ensure_ascii=False, indent=2)
|
||||
logger.info(f"Neues Theme angelegt: {os.path.relpath(path, base_dir)}")
|
||||
return jsonify({"success": True, "path": os.path.relpath(path, base_dir)})
|
||||
except Exception as e:
|
||||
logger.exception("create_theme fehlgeschlagen")
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
@ -212,7 +212,9 @@
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
const json = await res.json();
|
||||
const text = await res.text();
|
||||
let json;
|
||||
try { json = JSON.parse(text); } catch (_) { throw new Error('Serverantwort ist kein JSON:\n'+text); }
|
||||
if (!json.success) throw new Error(json.message || 'Fehler');
|
||||
alert('Konfiguration angelegt: ' + json.filename);
|
||||
location.reload();
|
||||
@ -233,7 +235,9 @@
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
const json = await res.json();
|
||||
const text = await res.text();
|
||||
let json;
|
||||
try { json = JSON.parse(text); } catch (_) { throw new Error('Serverantwort ist kein JSON:\n'+text); }
|
||||
if (!json.success) throw new Error(json.message || 'Fehler');
|
||||
alert('Theme angelegt: ' + json.path);
|
||||
location.reload();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user