update routers

This commit is contained in:
Jörn-Michael Miehe 2022-09-15 22:32:11 +00:00
parent 2865fd0a6d
commit 3a08a9b711
3 changed files with 44 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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