From b8df4605b42d9a61bb4ae4731efabbdc38166063 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 16 Jun 2025 21:50:38 -0500 Subject: add config and add application thread manager --- settings.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 settings.py (limited to 'settings.py') diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..43cb024 --- /dev/null +++ b/settings.py @@ -0,0 +1,39 @@ +from dataclasses import dataclass, asdict, field +import json + + +@dataclass +class AlbumList: + name: str + album_keys: list[str] + + +@dataclass +class Config: + # Immich server + immich_url: str = "" + immich_api_key: str = "" + # Display + image_duration: float = 10.0 + transition_duration: float = 0.5 + max_framerate: float = 30.0 + auto_transition: bool = True + display_size: str = "preview" # 'fullsize', 'preview', 'thumbnail' + # Cache + max_cache_assets: int = 100 + # Albums data + album_lists: list[AlbumList] = field(default_factory=list) + album_list_selected: int = None + + def __post_init__(self): + self.album_lists = [ AlbumList(*a) for a in self.album_lists ] + + @classmethod + def load(cls, filepath): + with open(filepath, "r") as fp: + return cls(**json.load(fp)) + + def save(self, filepath): + data = asdict(self) + with open(filepath, "w") as fp: + json.dump(data, fp, indent=2) -- cgit v1.2.3 From c5465f7ceed37f1ba6575248e1035e1430e78921 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 16 Jun 2025 21:58:13 -0500 Subject: config route and fix config saving/creation --- settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index 43cb024..f11e930 100644 --- a/settings.py +++ b/settings.py @@ -28,12 +28,14 @@ class Config: def __post_init__(self): self.album_lists = [ AlbumList(*a) for a in self.album_lists ] + def __dict__(self): + return asdict(self) + @classmethod def load(cls, filepath): with open(filepath, "r") as fp: return cls(**json.load(fp)) def save(self, filepath): - data = asdict(self) with open(filepath, "w") as fp: - json.dump(data, fp, indent=2) + json.dump(asdict(self), fp, indent=2) -- cgit v1.2.3 From ce64f1a42c9570efa75cc2f568e59d683f499bdd Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 20 Jun 2025 22:32:28 -0500 Subject: config update and more endpoints for api fromtend --- settings.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index f11e930..e6b3df8 100644 --- a/settings.py +++ b/settings.py @@ -2,12 +2,6 @@ from dataclasses import dataclass, asdict, field import json -@dataclass -class AlbumList: - name: str - album_keys: list[str] - - @dataclass class Config: # Immich server @@ -22,11 +16,7 @@ class Config: # Cache max_cache_assets: int = 100 # Albums data - album_lists: list[AlbumList] = field(default_factory=list) - album_list_selected: int = None - - def __post_init__(self): - self.album_lists = [ AlbumList(*a) for a in self.album_lists ] + album_list: list[str] = field(default_factory=list) def __dict__(self): return asdict(self) @@ -39,3 +29,7 @@ class Config: def save(self, filepath): with open(filepath, "w") as fp: json.dump(asdict(self), fp, indent=2) + + def update(self, **config): + for key, value in config.items(): + setattr(self, key, value) -- cgit v1.2.3 From 2f03f39e24053377dce108e45fde13ccd1e0ae22 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Tue, 24 Jun 2025 18:56:53 -0500 Subject: window can now handle no selected albums --- settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index e6b3df8..69e40ca 100644 --- a/settings.py +++ b/settings.py @@ -18,8 +18,8 @@ class Config: # Albums data album_list: list[str] = field(default_factory=list) - def __dict__(self): - return asdict(self) + #def __dict__(self): + # return asdict(self) @classmethod def load(cls, filepath): -- cgit v1.2.3