Add federation settings
This commit is contained in:
parent
60acf77acd
commit
3a6187d791
@ -6,6 +6,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type FederationSettings struct {
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// Settings represents the settings panel.
|
||||
type Settings struct {
|
||||
Language string `json:"language"`
|
||||
@ -14,6 +18,7 @@ type Settings struct {
|
||||
WeatherAction string `json:"weather_action"`
|
||||
MaxRunTime time.Duration `json:"max_run_time"`
|
||||
MaxVolume uint16 `json:"max_volume"`
|
||||
Federation map[string]FederationSettings `json:"federation"`
|
||||
}
|
||||
|
||||
// ExistsSettings checks if the settings file can by found at the given path.
|
||||
|
68
ui/src/lib/components/FederationSettings.svelte
Normal file
68
ui/src/lib/components/FederationSettings.svelte
Normal file
@ -0,0 +1,68 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
import {
|
||||
Col,
|
||||
Input,
|
||||
Row,
|
||||
} from '@sveltestrap/sveltestrap';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let id = "";
|
||||
export let value = { };
|
||||
|
||||
function changeKey(bak, to) {
|
||||
if (bak === null && to.target.value) {
|
||||
if (!value) value = { };
|
||||
value[to.target.value] = { url:"" };
|
||||
to.target.value = "";
|
||||
value = value;
|
||||
} else {
|
||||
value[to.target.value] = value[bak];
|
||||
delete value[bak];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
{#each Object.keys(value) as key}
|
||||
<Row>
|
||||
<Col>
|
||||
<Input
|
||||
type="string"
|
||||
value={key}
|
||||
on:change={() => dispatch("input")}
|
||||
on:input={(e) => changeKey(key, e)}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<Input
|
||||
type="string"
|
||||
placeholder="https://reveil.fr/"
|
||||
bind:value={value[key].url}
|
||||
on:change={() => dispatch("input")}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
{/each}
|
||||
{/if}
|
||||
<Row>
|
||||
<Col>
|
||||
<Input
|
||||
type="string"
|
||||
{id}
|
||||
placeholder="name"
|
||||
value=""
|
||||
on:input={(e) => changeKey(null, e)}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<Input
|
||||
type="string"
|
||||
placeholder="https://reveil.fr/"
|
||||
disabled
|
||||
value=""
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
@ -5,13 +5,14 @@ export class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
update({ language, gong_interval, weather_delay, weather_action, max_run_time, max_volume }) {
|
||||
update({ language, gong_interval, weather_delay, weather_action, max_run_time, max_volume, federation }) {
|
||||
this.language = language;
|
||||
this.gong_interval = gong_interval;
|
||||
this.weather_delay = weather_delay;
|
||||
this.weather_action = weather_action;
|
||||
this.max_run_time = max_run_time;
|
||||
this.max_volume = max_volume;
|
||||
this.federation = federation;
|
||||
}
|
||||
|
||||
async save() {
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import { actions } from '$lib/stores/actions';
|
||||
import { getSettings } from '$lib/settings';
|
||||
import FederationSettings from '$lib/components/FederationSettings.svelte';
|
||||
|
||||
let settingsP = getSettings();
|
||||
|
||||
@ -130,6 +131,15 @@
|
||||
/>
|
||||
</InputGroup>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<Label for="federation">Federation</Label>
|
||||
<FederationSettings
|
||||
id="federation"
|
||||
bind:value={settings.federation}
|
||||
on:input={submitSettings}
|
||||
/>
|
||||
</FormGroup>
|
||||
{/await}
|
||||
</Form>
|
||||
</Container>
|
||||
|
Loading…
Reference in New Issue
Block a user