2023-11-17 00:05:35 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { PUBLIC_BASE_URL } from '$env/static/public';
|
|
|
|
|
|
|
|
import { _ } from 'svelte-i18n';
|
|
|
|
import { Col, Container, Row } from 'sveltestrap';
|
|
|
|
|
|
|
|
import Control from './Control.svelte';
|
|
|
|
import Status from './Status.svelte';
|
|
|
|
import Settings from './Settings.svelte';
|
|
|
|
import { writable } from 'svelte/store';
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
2023-11-17 02:15:23 +00:00
|
|
|
let settings = writable({
|
|
|
|
fgColor: "0"
|
|
|
|
});
|
2023-11-17 00:05:35 +00:00
|
|
|
|
2023-11-18 12:55:55 +00:00
|
|
|
let status = writable({
|
|
|
|
data: ["L", "O", "A", "D", "I", "N", "G"],
|
|
|
|
espFreeHeap: 0,
|
|
|
|
espHeapSize: 0,
|
|
|
|
connectionStatus: {
|
|
|
|
"price": false,
|
|
|
|
"blocks": false
|
|
|
|
},
|
|
|
|
leds: []
|
|
|
|
});
|
|
|
|
|
2023-11-17 00:05:35 +00:00
|
|
|
onMount(() => {
|
|
|
|
fetch( PUBLIC_BASE_URL + `/api/settings`)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
|
|
|
data.fgColor = String(data.fgColor);
|
|
|
|
data.bgColor = String(data.bgColor);
|
2023-11-17 02:15:23 +00:00
|
|
|
data.timePerScreen = data.timerSeconds / 60;
|
|
|
|
|
|
|
|
if (data.fgColor> 65535) {
|
|
|
|
data.fgColor = "65535";
|
|
|
|
}
|
2023-11-17 12:12:22 +00:00
|
|
|
|
|
|
|
if (data.bgColor> 65535) {
|
|
|
|
data.bgColor = "65535";
|
|
|
|
}
|
2023-11-17 00:05:35 +00:00
|
|
|
settings.set(data);
|
|
|
|
});
|
2023-11-18 12:55:55 +00:00
|
|
|
|
|
|
|
fetch(`${PUBLIC_BASE_URL}/api/status`)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
|
|
|
status.set(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
const evtSource = new EventSource(`${PUBLIC_BASE_URL}/events`);
|
|
|
|
|
|
|
|
evtSource.addEventListener('status', (e) => {
|
|
|
|
let dataObj = (JSON.parse(e.data));
|
|
|
|
status.set(dataObj);
|
|
|
|
});
|
2023-11-17 00:05:35 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-11-17 18:10:46 +00:00
|
|
|
<svelte:head>
|
|
|
|
<title>₿TClock</title>
|
|
|
|
</svelte:head>
|
|
|
|
|
2023-11-17 00:05:35 +00:00
|
|
|
<Container fluid>
|
|
|
|
<Row>
|
2023-11-18 12:55:55 +00:00
|
|
|
<Control bind:settings bind:status></Control>
|
|
|
|
<Status bind:settings bind:status></Status>
|
2023-11-17 00:05:35 +00:00
|
|
|
<Settings bind:settings></Settings>
|
|
|
|
</Row>
|
|
|
|
</Container>
|