Fixed code to use <screen> tags as base for the xml. Confirmed layout works now.

This commit is contained in:
2026-03-15 15:08:23 -04:00
parent ebb0ccecf4
commit f64860125c
5 changed files with 49 additions and 53 deletions

View File

@@ -10,7 +10,7 @@
let savingMac = $state('');
let saveResult = $state('');
const DEFAULT_XML = `<lv_obj width="100%" height="100%" flex_flow="column" align="center" style_pad_row="10">\n <lv_label text="Hello World" />\n <lv_label bind_text="device_mac" />\n</lv_obj>`;
let defaultXml = $state('');
// Debug states
let debugRegistering = $state(false);
@@ -19,7 +19,9 @@
loading = true;
error = '';
try {
devices = await getDevices();
const data = await getDevices();
devices = data.devices;
defaultXml = data.default_layout;
} catch (e) {
error = e.message || 'Failed to load devices';
} finally {
@@ -107,7 +109,7 @@
</div>
<div class="flex items-center gap-2">
{#if device.has_layout}
{#if device.xml_layout === DEFAULT_XML}
{#if device.xml_layout === defaultXml}
<span class="text-[10px] bg-accent/20 text-accent px-2 py-0.5 rounded-full uppercase tracking-wider font-semibold">
Default Layout
</span>
@@ -133,9 +135,9 @@
<textarea
id="xml-{device.mac}"
class="w-full h-32 bg-bg-primary border border-border rounded-lg p-3 text-xs font-mono text-text-primary resize-y focus:border-accent focus:outline-none transition-colors placeholder:text-text-secondary/50"
placeholder={DEFAULT_XML}
placeholder={defaultXml}
value={editingXml[device.mac] ?? device.xml_layout}
oninput={(e) => editingXml[device.mac] = e.target.value}
oninput={(e) => editingXml[device.mac] = e.currentTarget.value}
></textarea>
<div class="flex items-center justify-between">

View File

@@ -278,8 +278,8 @@ export async function deleteTask(id) {
// ─── Device Management ───────────────────────────────────────────────────────
/**
* Fetch all registered devices.
* @returns {Promise<Array<{mac: string, has_layout: boolean}>>}
* Fetch all registered devices and the default layout.
* @returns {Promise<{default_layout: string, devices: Array<{mac: string, has_layout: boolean, xml_layout: string}>}>}
*/
export async function getDevices() {
const res = await trackedFetch(`${API_BASE}/api/devices`);