diff --git a/api/advent22_api/core/depends.py b/api/advent22_api/core/depends.py index c3fb90a..a164e59 100644 --- a/api/advent22_api/core/depends.py +++ b/api/advent22_api/core/depends.py @@ -71,6 +71,19 @@ async def get_all_auto_image_names( return dict(zip(days, rnd.shuffled(ls))) +async def get_all_image_names( + auto_image_names: dict[int, str] = Depends(get_all_auto_image_names), +) -> dict[int, str]: + """ + Bilder "auto" und "manual" zu Tagen zuordnen + """ + + # TODO penner + # "manual"-Bilder erkennen (hier neue variable anlegen) + + return auto_image_names + + async def gen_day_auto_image( day: int, cfg: Config = Depends(get_config), diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index b88ae72..e46ce7d 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -5,7 +5,7 @@ from pydantic import BaseModel from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config from ..core.config import Config, get_config -from ..core.depends import get_all_parts +from ..core.depends import get_all_image_names, get_all_parts from ..core.settings import SETTINGS from ._security import require_admin, user_is_admin @@ -105,6 +105,20 @@ async def get_day_parts( return [DayStrModel(day=day, value=part) for day, part in sorted(parts.items())] +@router.get("/day_image_names") +async def get_day_image_names( + _: None = Depends(require_admin), + image_names: dict[int, str] = Depends(get_all_image_names), +) -> list[DayStrModel]: + """ + Zuordnung der verwendeten Bilder zu den Tagen + """ + + return [ + DayStrModel(day=day, value=name) for day, name in sorted(image_names.items()) + ] + + @router.get("/doors") async def get_doors( _: None = Depends(require_admin), diff --git a/ui/src/components/CalendarAssistant.vue b/ui/src/components/CalendarAssistant.vue index 2221837..28eb96d 100644 --- a/ui/src/components/CalendarAssistant.vue +++ b/ui/src/components/CalendarAssistant.vue @@ -9,18 +9,6 @@ >
-

Alle Türchen

-
- -
-

Buchstaben-Zuordnung

Bilder-Zuordnung

-
- 1: images_auto/1.jpg - 2: images_manual/1.jpg - 3: images_auto/penelope.png - 4: images_auto/hand.png - 5: images_auto/hand.jpg - 6: images_auto/Zaphod.jpg - 7: images_auto/Zaphod.jpg - + + {{ day_part.day }}: {{ day_part.value }} + +
+ +

Alle Türchen

+
+
@@ -67,6 +65,7 @@ import MultiModal from "./calendar/MultiModal.vue"; export default class extends Vue { public is_loaded = true; public day_parts: DayStrModel[] = []; + public day_image_names: DayStrModel[] = []; declare $refs: { multi_modal: MultiModal; @@ -75,9 +74,13 @@ export default class extends Vue { public on_open(): void { this.is_loaded = false; - Promise.all([this.$advent22.api_get("admin/day_parts")]) - .then(([day_parts]) => { + Promise.all([ + this.$advent22.api_get("admin/day_parts"), + this.$advent22.api_get("admin/day_image_names"), + ]) + .then(([day_parts, day_image_names]) => { this.day_parts = day_parts; + this.day_image_names = day_image_names; this.is_loaded = true; }) .catch(console.log);