-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Thymis module and device configurations: Make it build with nix
- Loading branch information
Showing
13 changed files
with
161 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,58 @@ | ||
import { invalidate } from '$app/navigation'; | ||
|
||
export type SettingTypes = { | ||
type: 'bool'; | ||
value: boolean; | ||
} | { | ||
type: 'string'; | ||
value: string; | ||
} | { | ||
type: 'path'; | ||
value: string; | ||
}; | ||
export type SettingTypes = | ||
| { | ||
type: 'bool'; | ||
value: boolean; | ||
} | ||
| { | ||
type: 'string'; | ||
value: string; | ||
} | ||
| { | ||
type: 'path'; | ||
value: string; | ||
}; | ||
|
||
export type Setting = SettingTypes & { | ||
name: string; | ||
// value: unknown; | ||
default: string; | ||
description: string; | ||
example: string | null; | ||
// type: string; | ||
name: string; | ||
// value: unknown; | ||
default: string; | ||
description: string; | ||
example: string | null; | ||
// type: string; | ||
}; | ||
|
||
export type Module = { type: string, name: string } & Record<string, Setting>; | ||
export type Module = { type: string; name: string } & Record<string, Setting>; | ||
|
||
export type SettingValue = { value: SettingTypes } | ||
export type ModuleSettings = { type: string, settings: { [key: string]: SettingValue } }; | ||
export type Tag = { name: string, priority: number, modules: (ModuleSettings & { priority: number })[] }; | ||
export type Device = { hostname: string, displayName: string, modules: ModuleSettings[], tags: string[] }; | ||
export type SettingValue = { value: SettingTypes }; | ||
export type ModuleSettings = { type: string; settings: { [key: string]: SettingValue } }; | ||
export type Tag = { | ||
name: string; | ||
priority: number; | ||
modules: (ModuleSettings & { priority: number })[]; | ||
}; | ||
export type Device = { | ||
hostname: string; | ||
displayName: string; | ||
modules: ModuleSettings[]; | ||
tags: string[]; | ||
}; | ||
|
||
export type State = { | ||
modules: Module[]; | ||
devices: Device[]; | ||
tags: Tag[]; | ||
modules: Module[]; | ||
devices: Device[]; | ||
tags: Tag[]; | ||
}; | ||
|
||
export async function saveState(state: State) { | ||
await fetch('http://localhost:8000/state', { | ||
method: 'PATCH', | ||
headers: { | ||
'content-type': 'application/json' | ||
}, | ||
body: JSON.stringify(state) | ||
}); | ||
await invalidate('http://localhost:8000/state'); | ||
await invalidate('http://localhost:8000/available_modules'); | ||
await fetch('http://localhost:8000/state', { | ||
method: 'PATCH', | ||
headers: { | ||
'content-type': 'application/json' | ||
}, | ||
body: JSON.stringify(state) | ||
}); | ||
await invalidate('http://localhost:8000/state'); | ||
await invalidate('http://localhost:8000/available_modules'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import type { PageLoad } from './$types'; | ||
import type { State, Device } from '$lib/state'; | ||
import type { State } from '$lib/state'; | ||
|
||
export const load = (async ({ fetch }) => { | ||
const stateResponse = await fetch('http://localhost:8000/state', { | ||
method: 'GET', | ||
headers: { | ||
'content-type': 'application/json' | ||
} | ||
}); | ||
const stateResponse = await fetch('http://localhost:8000/state', { | ||
method: 'GET', | ||
headers: { | ||
'content-type': 'application/json' | ||
} | ||
}); | ||
|
||
const state = (await stateResponse.json()) as State; | ||
const state = (await stateResponse.json()) as State; | ||
|
||
return { | ||
state: state, | ||
}; | ||
return { | ||
state: state | ||
}; | ||
}) satisfies PageLoad; |
Oops, something went wrong.