2023-11-17 00:05:35 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { PUBLIC_BASE_URL } from '$env/static/public';
|
|
|
|
import { _ } from 'svelte-i18n';
|
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
ButtonGroup,
|
|
|
|
Card,
|
2023-11-17 02:15:23 +00:00
|
|
|
CardTitle,
|
2023-11-17 00:05:35 +00:00
|
|
|
CardBody,
|
|
|
|
CardHeader,
|
|
|
|
Col,
|
|
|
|
Container,
|
|
|
|
Form,
|
|
|
|
Input,
|
|
|
|
Label,
|
|
|
|
Row
|
|
|
|
} from 'sveltestrap';
|
|
|
|
|
|
|
|
export let settings = {};
|
|
|
|
export let customText:String;
|
2023-11-17 02:15:23 +00:00
|
|
|
export let ledColor:String = "#FFCC00";
|
|
|
|
|
2023-11-17 00:05:35 +00:00
|
|
|
|
|
|
|
const setCustomText = () => {
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/show/text/${customText}`).catch(err => { });
|
|
|
|
};
|
|
|
|
|
|
|
|
const setLEDcolor = () => {
|
2023-11-17 02:15:23 +00:00
|
|
|
console.log(`${PUBLIC_BASE_URL}/api/lights/${ledColor}`);
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/lights/${encodeURIComponent(ledColor.replace(/^#/, ''))}`).catch(err => { });
|
|
|
|
};
|
2023-11-17 00:05:35 +00:00
|
|
|
|
2023-11-17 02:15:23 +00:00
|
|
|
const turnOffLeds = () => {
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/lights/off`).catch(err => { });
|
2023-11-17 00:05:35 +00:00
|
|
|
};
|
2023-11-17 02:15:23 +00:00
|
|
|
|
|
|
|
const restartClock = () => {
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/restart`).catch(err => { });
|
|
|
|
}
|
|
|
|
|
|
|
|
const forceFullRefresh = () => {
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/full_refresh`).catch(err => { });
|
|
|
|
}
|
|
|
|
|
2023-11-17 00:05:35 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<Col>
|
|
|
|
<Card>
|
|
|
|
<CardHeader>
|
2023-11-17 02:15:23 +00:00
|
|
|
<CardTitle>{$_('section.control.title', { default: 'Control' })}</CardTitle>
|
2023-11-17 00:05:35 +00:00
|
|
|
</CardHeader>
|
|
|
|
<CardBody>
|
|
|
|
<Form>
|
|
|
|
<Row>
|
2023-11-17 12:12:22 +00:00
|
|
|
<Label md={6} for="customText">{ $_('section.control.text') }</Label>
|
2023-11-17 00:05:35 +00:00
|
|
|
<Col md="6">
|
2023-11-17 02:15:23 +00:00
|
|
|
<Input type="text" id="customText" bind:value={customText} bsSize="sm" maxLength="{$settings.numScreens}"/>
|
2023-11-17 00:05:35 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-11-17 12:12:22 +00:00
|
|
|
<Button color="primary" on:click={setCustomText}>{ $_('section.control.showText') }</Button>
|
2023-11-17 00:05:35 +00:00
|
|
|
|
|
|
|
</Form>
|
|
|
|
<hr />
|
|
|
|
<h3>LEDs</h3>
|
|
|
|
<Form>
|
|
|
|
<Row>
|
2023-11-17 12:12:22 +00:00
|
|
|
<Label md={6} for="ledColorPicker" size="sm">{ $_('section.control.ledColor') }</Label>
|
2023-11-17 00:05:35 +00:00
|
|
|
<Col md="6">
|
2023-11-17 02:15:23 +00:00
|
|
|
<Input type="color" id="ledColorPicker" bind:value="{ledColor}" />
|
2023-11-17 00:05:35 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-11-17 12:12:22 +00:00
|
|
|
<Button color="secondary" id="turnOffLedsBtn" on:click={turnOffLeds}>{ $_('section.control.turnOff') }</Button>
|
|
|
|
<Button color="primary" on:click={setLEDcolor}>{ $_('section.control.setColor') }</Button>
|
2023-11-17 00:05:35 +00:00
|
|
|
</Form>
|
|
|
|
|
|
|
|
<hr />
|
2023-11-17 12:12:22 +00:00
|
|
|
<h3>{ $_('section.control.systemInfo') }</h3>
|
2023-11-17 00:05:35 +00:00
|
|
|
<ul class="small system_info">
|
2023-11-17 12:12:22 +00:00
|
|
|
<li>{ $_('section.control.version') }: {$settings.gitRev}</li>
|
|
|
|
<li>{ $_('section.control.buildTime') }: {new Date(($settings.lastBuildTime * 1000)).toLocaleString()}</li>
|
2023-11-17 00:05:35 +00:00
|
|
|
<li>IP: {$settings.ip}</li>
|
|
|
|
<li>Hostname: {$settings.hostname}</li>
|
|
|
|
</ul>
|
2023-11-17 12:12:22 +00:00
|
|
|
<Button color="danger" id="restartBtn" on:click="{restartClock}">{ $_('button.restart') }</Button>
|
|
|
|
<Button color="warning" id="forceFullRefresh" on:click="{forceFullRefresh}">{ $_('button.forceFullRefresh') }</Button>
|
2023-11-17 00:05:35 +00:00
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
</Col>
|