Skip to content

Commit

Permalink
Merge pull request #49 from Thymis-io/feat/settings-order
Browse files Browse the repository at this point in the history
Explicit settings order
  • Loading branch information
elikoga authored Jul 12, 2024
2 parents 4546a56 + b12b3b8 commit 89407cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions controller/thymis_controller/models/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Setting(BaseModel):
default: object
description: str
example: Optional[str] = None
order: int = 0


class Module(BaseModel):
Expand Down
5 changes: 5 additions & 0 deletions controller/thymis_controller/modules/thymis.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ThymisDevice(modules.Module):
default="",
description="The device type of the thymis device.",
example="",
order=10,
)

device_name = models.Setting(
Expand All @@ -37,6 +38,7 @@ class ThymisDevice(modules.Module):
default="",
description="The device name of the thymis device.",
example="",
order=20,
)

password = models.Setting(
Expand All @@ -45,6 +47,7 @@ class ThymisDevice(modules.Module):
default="",
description="The password of the thymis device.",
example="",
order=30,
)

wifi_ssid = models.Setting(
Expand All @@ -53,6 +56,7 @@ class ThymisDevice(modules.Module):
default="",
description="The wifi ssid of the thymis device.",
example="",
order=40,
)

wifi_password = models.Setting(
Expand All @@ -61,6 +65,7 @@ class ThymisDevice(modules.Module):
default="",
description="The wifi password of the thymis device.",
example="",
order=50,
)

def write_nix_settings(self, f, module_settings: ModuleSettings, priority: int):
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Setting = {
default: string;
description: string;
example: string | null;
order: number;
};

export type Module = {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/routes/config/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
$: if (selectedModule) {
console.log(selectedModule);
selectedModulesValidSettingkeys = Object.keys(selectedModule.settings);
selectedModulesValidSettingkeys.sort(
(a, b) => selectedModule.settings[a].order - selectedModule.settings[b].order
);
console.log(selectedModulesValidSettingkeys);
}
Expand Down

0 comments on commit 89407cf

Please sign in to comment.