feat: add Data Cards feature with CRUD operations and UI integration

This commit is contained in:
2026-03-01 13:28:40 +01:00
parent b4528920da
commit f4ce115a95
6 changed files with 822 additions and 3 deletions

View File

@@ -13,7 +13,8 @@ DEFAULT_STATE = {
"showing": False,
"image_url": "",
"caption": ""
}
},
"data_cards": []
}
MINIO_CLIENT = Minio(
@@ -73,6 +74,29 @@ def main(args):
current["image_popup"]["showing"] = False
_write_state(current)
return {"status": "success"}
elif route == "push_data_card":
# Upsert a data card by id
card = body.get("card")
if not card or not card.get("id"):
return {"status": "error", "message": "Missing card or card id"}
current = _read_state()
cards = current.get("data_cards", [])
existing = next((i for i, c in enumerate(cards) if c["id"] == card["id"]), None)
if existing is not None:
cards[existing] = card
else:
cards.append(card)
current["data_cards"] = cards
_write_state(current)
return {"status": "success"}
elif route == "push_delete_data_card":
card_id = body.get("id")
if not card_id:
return {"status": "error", "message": "Missing card id"}
current = _read_state()
current["data_cards"] = [c for c in current.get("data_cards", []) if c["id"] != card_id]
_write_state(current)
return {"status": "success"}
else:
return {"status": "error", "message": "Unknown push route"}
elif route.startswith("pull"):
@@ -83,5 +107,7 @@ def main(args):
return {"status": "success", "image_popup": current.get("image_popup", {})}
elif route == "pull_full":
return {"status": "success", "state": current}
elif route == "pull_data_cards":
return {"status": "success", "data_cards": current.get("data_cards", [])}
else:
return {"status": "error", "message": "Unknown pull route"}