From 5fcc4f0684d2aaec634dead4a1cba24f549cf56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Thu, 21 Sep 2023 12:25:23 +0000 Subject: [PATCH] various cleanup --- api/advent22_api/core/config.py | 2 +- api/advent22_api/routers/admin.py | 24 ++++++++--------- api/advent22_api/routers/user.py | 24 ++++++++--------- ui/src/components/AdminButton.vue | 4 +-- ui/src/components/admin/ConfigView.vue | 37 ++++++++------------------ ui/src/lib/api.ts | 2 ++ ui/src/plugins/advent22.ts | 25 ++++++++++++----- 7 files changed, 59 insertions(+), 59 deletions(-) diff --git a/api/advent22_api/core/config.py b/api/advent22_api/core/config.py index 0a11472..c51e208 100644 --- a/api/advent22_api/core/config.py +++ b/api/advent22_api/core/config.py @@ -13,7 +13,7 @@ class User(BaseModel): class Puzzle(BaseModel): # Titel - # TODO + # TODO neue Route GET /user/title title: str # Lösungswort diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index 7a8e2b5..e6a77ba 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -80,18 +80,6 @@ async def get_config_model( ) -@router.get("/day_parts") -async def get_day_parts( - _: None = Depends(require_admin), - parts: dict[int, str] = Depends(get_all_parts), -) -> dict[int, str]: - """ - Zuordnung der Lösungsteile zu den Tagen - """ - - return parts - - @router.get("/day_image_names") async def get_day_image_names( _: None = Depends(require_admin), @@ -104,6 +92,18 @@ async def get_day_image_names( return image_names +@router.get("/day_parts") +async def get_day_parts( + _: None = Depends(require_admin), + parts: dict[int, str] = Depends(get_all_parts), +) -> dict[int, str]: + """ + Zuordnung der Lösungsteile zu den Tagen + """ + + return parts + + @router.get("/doors") async def get_doors( _: None = Depends(require_admin), diff --git a/api/advent22_api/routers/user.py b/api/advent22_api/routers/user.py index 9bd099d..b51aed7 100644 --- a/api/advent22_api/routers/user.py +++ b/api/advent22_api/routers/user.py @@ -26,6 +26,18 @@ async def get_background_image( return await api_return_image(await load_image(f"files/{cal_cfg.background}")) +@router.get("/doors") +async def get_doors( + cal_cfg: CalendarConfig = Depends(get_calendar_config), + visible_days: list[int] = Depends(user_visible_days), +) -> DoorsSaved: + """ + User-sichtbare Türchen lesen + """ + + return [door for door in cal_cfg.doors if door.day in visible_days] + + @router.get( "/image_{day}", response_class=StreamingResponse, @@ -50,18 +62,6 @@ async def get_image_for_day( return await api_return_image(image) -@router.get("/doors") -async def get_doors( - cal_cfg: CalendarConfig = Depends(get_calendar_config), - visible_days: list[int] = Depends(user_visible_days), -) -> DoorsSaved: - """ - User-sichtbare Türchen lesen - """ - - return [door for door in cal_cfg.doors if door.day in visible_days] - - @router.get("/next_door") async def get_next_door( event_dates: EventDates = Depends(get_all_event_dates), diff --git a/ui/src/components/AdminButton.vue b/ui/src/components/AdminButton.vue index dde95b9..ede1c33 100644 --- a/ui/src/components/AdminButton.vue +++ b/ui/src/components/AdminButton.vue @@ -38,7 +38,7 @@ export default class extends Vue { public on_click() { if (this.modelValue) { // logout - this.$advent22.clear_api_auth(); + this.$advent22.set_api_auth(); this.$emit("update:modelValue", false); } else { // show login modal @@ -49,7 +49,7 @@ export default class extends Vue { public on_submit(username: string, password: string) { this.modal_visible = false; - this.$advent22.set_api_auth(username, password); + this.$advent22.api_auth = [username, password]; this.$advent22 .api_get("admin/is_admin") diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index 8cb35e3..a0bbbe9 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -90,10 +90,10 @@
user - {{ dav_credentials.username }} + {{ dav_credentials[0] }}
pass - {{ dav_credentials.password }} + {{ dav_credentials[1] }}
@@ -107,10 +107,10 @@
user - {{ ui_credentials.username }} + {{ ui_credentials[0] }}
pass - {{ ui_credentials.password }} + {{ ui_credentials[1] }}
@@ -122,7 +122,7 @@