From 367fef145d74523715b622bea9d2f505a6d33942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 31 Oct 2023 21:48:27 +0000 Subject: [PATCH] RedisSettings --- api/advent22_api/core/settings.py | 8 -------- api/advent22_api/routers/admin.py | 6 +++--- ui/src/components/admin/ConfigView.vue | 12 ++++++++++-- ui/src/lib/api.ts | 7 ++++++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/api/advent22_api/core/settings.py b/api/advent22_api/core/settings.py index 04c3ea5..c509978 100644 --- a/api/advent22_api/core/settings.py +++ b/api/advent22_api/core/settings.py @@ -41,14 +41,6 @@ class RedisSettings(BaseModel): db: int = 0 protocol: int = 3 - @property - def url(self) -> str: - """ - Combined DAV URL. - """ - - return f"redis_v{self.protocol}://{self.host}:{self.port}/db_{self.db}" - class Settings(BaseSettings): """ diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index 63b523f..e3cc78b 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -8,7 +8,7 @@ from advent22_api.core.helpers import EventDates from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config from ..core.config import Config, Image, get_config from ..core.depends import get_all_event_dates, get_all_image_names, get_all_parts -from ..core.settings import SETTINGS +from ..core.settings import SETTINGS, RedisSettings from ._security import require_admin, user_is_admin router = APIRouter(prefix="/admin", tags=["admin"]) @@ -48,7 +48,7 @@ class ConfigModel(BaseModel): puzzle: __Puzzle calendar: __Calendar image: Image - redis_url: str + redis: RedisSettings webdav: __WebDAV @@ -83,7 +83,7 @@ async def get_config_model( "background": cal_cfg.background, }, "image": cfg.image, - "redis_url": SETTINGS.redis.url, + "redis": SETTINGS.redis, "webdav": { "url": SETTINGS.webdav.url, "cache_ttl": SETTINGS.webdav.cache_ttl, diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index 80c77ae..ba5e44a 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -139,7 +139,10 @@

Sonstige

Redis
-
{{ config_model.redis_url }}
+
Host: {{ config_model.redis.host }}
+
Port: {{ config_model.redis.port }}
+
Datenbank: {{ config_model.redis.db }}
+
Protokoll: {{ config_model.redis.protocol }}
UI-Admin
@@ -199,7 +202,12 @@ export default class extends Vue { border: 0, fonts: [{ file: "consetetur", size: 0 }], }, - redis_url: "sadipscing elitr", + redis: { + host: "0.0.0.0", + port: 6379, + db: 0, + protocol: 3, + }, webdav: { url: "sadipscing elitr", cache_ttl: 0, diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index d8f358a..6f1a3cc 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -21,7 +21,12 @@ export interface ConfigModel { border: number; fonts: { file: string; size: number }[]; }; - redis_url: string; + redis: { + host: string; + port: number; + db: number; + protocol: number; + }; webdav: { url: string; cache_ttl: number;