fix: test connection reads form values instead of saved config

The "Kapcsolat tesztelése" button sent an empty POST to /settings/test,
which read from the (possibly empty) config file on disk. Now sends the
current form values so testing works before clicking Save.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 07:53:11 +01:00
parent 95fc8a1976
commit 92912c5890
3 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -107,11 +107,11 @@ volumes:
## Building ## Building
On the build server (192.168.0.180): On the build server (kisfenyo@192.168.0.180):
```bash ```bash
cd ~/build/recipe-importer cd ~/build/recipe-importer
./build.sh 0.1.0 --push ./build.sh X.X.X --push
``` ```
## Web UI ## Web UI
+5 -4
View File
@@ -50,12 +50,13 @@ def settings():
@app.route("/settings/test", methods=["POST"]) @app.route("/settings/test", methods=["POST"])
def settings_test(): def settings_test():
"""AJAX endpoint — test Mealie connection.""" """AJAX endpoint — test Mealie connection using form values."""
cfg = config.load() url = (request.form.get("mealie_url") or "").strip().rstrip("/")
if not cfg.get("mealie_url") or not cfg.get("mealie_api_key"): key = (request.form.get("mealie_api_key") or "").strip()
if not url or not key:
return jsonify({"ok": False, "error": "Nincs megadva Mealie URL vagy API kulcs."}) return jsonify({"ok": False, "error": "Nincs megadva Mealie URL vagy API kulcs."})
try: try:
client = MealieClient(cfg["mealie_url"], cfg["mealie_api_key"]) client = MealieClient(url, key)
info = client.test_connection() info = client.test_connection()
return jsonify({"ok": True, "data": info}) return jsonify({"ok": True, "data": info})
except Exception as exc: except Exception as exc:
+2 -1
View File
@@ -39,7 +39,8 @@ async function testConnection() {
result.innerHTML = '<span class="spinner"></span>'; result.innerHTML = '<span class="spinner"></span>';
try { try {
const resp = await fetch('/settings/test', { method: 'POST' }); const form = new FormData(document.querySelector('form'));
const resp = await fetch('/settings/test', { method: 'POST', body: form });
const data = await resp.json(); const data = await resp.json();
if (data.ok) { if (data.ok) {
const v = data.data.version || '?'; const v = data.data.version || '?';