diff --git a/api/advent22_api/config.py b/api/advent22_api/config.py index 53e78c4..605986e 100644 --- a/api/advent22_api/config.py +++ b/api/advent22_api/config.py @@ -13,13 +13,7 @@ class User(BaseModel): password: str -class Puzzle(BaseModel): - background: str - font: str - solution: str - - -class Door(BaseModel): +class DoorSaved(BaseModel): day: int x1: int y1: int @@ -27,13 +21,19 @@ class Door(BaseModel): y2: int -Doors: TypeAlias = list[Door] | None +DoorsSaved: TypeAlias = list[DoorSaved] + + +class Puzzle(BaseModel): + background: str + doors: DoorsSaved = [] + font: str + solution: str class Config(BaseModel): admin: User puzzle: Puzzle - doors: Doors = [] async def get_config() -> Config: diff --git a/api/advent22_api/routers/general.py b/api/advent22_api/routers/general.py index 49ac110..7b2cf3b 100644 --- a/api/advent22_api/routers/general.py +++ b/api/advent22_api/routers/general.py @@ -2,7 +2,7 @@ from fastapi import APIRouter, Depends from fastapi.responses import StreamingResponse from PIL import Image -from ..config import Config, Doors, get_config, set_config +from ..config import Config, DoorsSaved, get_config, set_config from ..dav_common import dav_get_file from ._misc import api_return_image @@ -28,22 +28,22 @@ async def get_image_for_day( @router.get("/doors") async def get_doors( cfg: Config = Depends(get_config), -) -> Doors: +) -> DoorsSaved: """ Türchen lesen """ - return cfg.doors + return cfg.puzzle.doors @router.put("/doors") async def put_doors( - doors: Doors, + doors: DoorsSaved, cfg: Config = Depends(get_config), ) -> None: """ Türchen setzen """ - cfg.doors = doors + cfg.puzzle.doors = doors await set_config(cfg) diff --git a/ui/src/components/DoorMapEditor.vue b/ui/src/components/DoorMapEditor.vue index d557b32..845c394 100644 --- a/ui/src/components/DoorMapEditor.vue +++ b/ui/src/components/DoorMapEditor.vue @@ -28,7 +28,7 @@