From 3a08a9b711fc1caf075fe1e3f1b761ded305e22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 15 Sep 2022 22:32:11 +0000 Subject: [PATCH] update routers --- api/ovdashboard_api/routers/calendar.py | 11 +++++++++++ api/ovdashboard_api/routers/image.py | 12 +++++++++++- api/ovdashboard_api/routers/misc.py | 23 ++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/api/ovdashboard_api/routers/calendar.py b/api/ovdashboard_api/routers/calendar.py index 84d6e9b..06a8fe5 100644 --- a/api/ovdashboard_api/routers/calendar.py +++ b/api/ovdashboard_api/routers/calendar.py @@ -11,6 +11,7 @@ from typing import Iterator from fastapi import APIRouter, Depends +from ..config import CalendarUIConfig, Config from ..dav_calendar import CalEvent, DavCalendar from ._common import CalendarNameLister, PrefixFinder, PrefixUnique @@ -47,3 +48,13 @@ async def get_calendar( name: str = Depends(calendar_unique), ) -> list[CalEvent]: return list(await DavCalendar(name).events) + + +@router.get( + "/config", + response_model=CalendarUIConfig, +) +async def get_ui_config( + cfg: Config = Depends(Config.get), +) -> CalendarUIConfig: + return cfg.calendar diff --git a/api/ovdashboard_api/routers/image.py b/api/ovdashboard_api/routers/image.py index 0633375..6714544 100644 --- a/api/ovdashboard_api/routers/image.py +++ b/api/ovdashboard_api/routers/image.py @@ -15,7 +15,7 @@ from fastapi import APIRouter, Depends from fastapi.responses import StreamingResponse from PIL import Image -from ..config import Config +from ..config import Config, ImageUIConfig from ..dav_common import webdav_ensure_path from ..dav_file import DavFile from ._common import FileNameLister, PrefixFinder, PrefixUnique @@ -94,3 +94,13 @@ async def get_image( "Content-Disposition": f"filename={prefix}.jpg" }, ) + + +@router.get( + "/config", + response_model=ImageUIConfig, +) +async def get_ui_config( + cfg: Config = Depends(Config.get), +) -> ImageUIConfig: + return cfg.image diff --git a/api/ovdashboard_api/routers/misc.py b/api/ovdashboard_api/routers/misc.py index e858d54..a9f2376 100644 --- a/api/ovdashboard_api/routers/misc.py +++ b/api/ovdashboard_api/routers/misc.py @@ -9,8 +9,9 @@ from importlib.metadata import version from logging import getLogger from socket import AF_INET, SOCK_DGRAM, socket -from fastapi import APIRouter +from fastapi import APIRouter, Depends +from ..config import Config, LogoUIConfig, ServerUIConfig from ..settings import SETTINGS _logger = getLogger(__name__) @@ -43,3 +44,23 @@ async def get_ip() -> str: @router.get("/version") async def get_version() -> str: return version("ovdashboard-api") + + +@router.get( + "/config/server", + response_model=ServerUIConfig, +) +async def get_server_ui_config( + cfg: Config = Depends(Config.get), +) -> ServerUIConfig: + return cfg.server + + +@router.get( + "/config/logo", + response_model=LogoUIConfig, +) +async def get_logo_ui_config( + cfg: Config = Depends(Config.get), +) -> LogoUIConfig: + return cfg.logo