-
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.
- Loading branch information
1 parent
3a37ee6
commit 5ccbc78
Showing
7 changed files
with
141 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<script lang="ts"> | ||
import type { SvelteComponent } from 'svelte'; | ||
import { getModalStore } from '@skeletonlabs/skeleton'; | ||
export let parent: SvelteComponent; | ||
const modalStore = getModalStore(); | ||
const formData = { | ||
displayName: '', | ||
hostname: '' | ||
}; | ||
function onFormSubmit(): void { | ||
if ($modalStore[0].response) $modalStore[0].response(formData); | ||
modalStore.close(); | ||
} | ||
</script> | ||
|
||
{#if $modalStore[0]} | ||
<div class="modal-example-form card p-4 w-modal shadow-xl space-y-4"> | ||
<header class="text-2xl font-bold">{$modalStore[0].title ?? '(title missing)'}</header> | ||
<!-- <article>{$modalStore[0].body ?? '(body missing)'}</article> --> | ||
<form class="modal-form space-y-4"> | ||
<label class="label"> | ||
<span>Name</span> | ||
<input | ||
class="input" | ||
type="text" | ||
bind:value={formData.displayName} | ||
placeholder="Enter name..." | ||
/> | ||
</label> | ||
<label class="label"> | ||
<span>Hostname</span> | ||
<input | ||
class="input" | ||
type="text" | ||
bind:value={formData.hostname} | ||
placeholder="Enter hostname..." | ||
/> | ||
</label> | ||
</form> | ||
<footer class="modal-footer {parent.regionFooter}"> | ||
<button class="btn {parent.buttonNeutral}" on:click={parent.onClose} | ||
>{parent.buttonTextCancel}</button | ||
> | ||
<button class="btn {parent.buttonPositive}" on:click={onFormSubmit}>Create</button> | ||
</footer> | ||
</div> | ||
{/if} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { invalidate } from '$app/navigation'; | ||
|
||
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; | ||
}; | ||
|
||
export type Module = { name: string } & Record<string, Setting>; | ||
|
||
export type SettingValue = { value: SettingTypes } | ||
export type ModuleSettings = { type: string, settings: { [key: string]: SettingValue } }; | ||
export type Device = { hostname: string, displayName: string, modules: ModuleSettings[], tags: string[] }; | ||
|
||
export type State = { | ||
modules: Module[]; | ||
devices: Device[]; | ||
tags: string[]; | ||
}; | ||
|
||
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'); | ||
} |
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 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