diff --git a/api/ovdashboard_api/config.py b/api/ovdashboard_api/config.py index 55f1fd0..6345dfe 100644 --- a/api/ovdashboard_api/config.py +++ b/api/ovdashboard_api/config.py @@ -18,18 +18,35 @@ from .settings import SETTINGS _logger = getLogger(__name__) -class TickerConfig(BaseModel): +class TickerAPIConfig(BaseModel): """ - Section "[ticker]" in "config.txt". + Section "[ticker.api]" in "config.txt". """ file_name: str = "ticker" separator: str = " +++ " comment_marker: str = "#" + + +class TickerUIConfig(BaseModel): + """ + Section "[ticker.ui]" in "config.txt". + """ + + display: bool = True color: str = "primary" speed: int = 30 +class TickerConfig(BaseModel): + """ + Section "[ticker]" in "config.txt". + """ + + api: TickerAPIConfig = TickerAPIConfig() + ui: TickerUIConfig = TickerUIConfig() + + class ImageConfig(BaseModel): """ Sections "[image*]" in "config.txt". @@ -72,7 +89,7 @@ class Config(BaseModel): dav_file = DavFile(SETTINGS.config_path) try: - return cls.parse_obj( + cfg = cls.parse_obj( toml_loads(await dav_file.as_string) ) @@ -89,4 +106,4 @@ class Config(BaseModel): buffer.seek(0) await dav_file.write(buffer.read()) - return cfg + return cfg diff --git a/api/ovdashboard_api/routers/ticker.py b/api/ovdashboard_api/routers/ticker.py index 1fabf55..d42e934 100644 --- a/api/ovdashboard_api/routers/ticker.py +++ b/api/ovdashboard_api/routers/ticker.py @@ -34,7 +34,7 @@ async def start_router() -> None: async def get_ticker_lines() -> Iterator[str]: cfg = await Config.get() - file_name = await text_unique(cfg.ticker.file_name) + file_name = await text_unique(cfg.ticker.api.file_name) ticker = await DavFile( f"{await text_lister.remote_path}/{file_name}", @@ -55,7 +55,7 @@ async def get_ticker_content_lines( return ( line for line in ticker_lines - if not line.startswith(cfg.ticker.comment_marker) + if not line.startswith(cfg.ticker.api.comment_marker) ) @@ -63,7 +63,7 @@ async def get_ticker_content( ticker_content_lines: Iterator[str] = Depends(get_ticker_content_lines), ) -> str: cfg = await Config.get() - ticker_content = cfg.ticker.separator.join( + ticker_content = cfg.ticker.api.separator.join( ["", *ticker_content_lines, ""], )