Rebuild the editor as a Vue app: sidebar, pages side by side, tile settings in a drawer (0.2.74)
The page is now web/ (Vue 3 + Vite + TypeScript), built into screen_manager/app/static with hashed file names; server.py serves index.html as built and /assets/. The Python API, the data and the firmware are unchanged. Your screens sit in a sidebar, the pages of a screen stand next to each other at the screen's own shape, the library sits on the right, and a tile's settings slide in as a drawer while the mockup stays in view. New screen, Firmware & USB, Alerts, Override YAML and Settings are pages of their own. Fonts moved to web/src/assets; the tests read the source through tests/editor_sources.py. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Relative URLs on purpose: the page lives under Home Assistant's ingress path
|
||||
// (/api/hassio_ingress/<token>/) and on http://127.0.0.1:8099 in SCREEN_DEV; `api/...`
|
||||
// resolves against the page in both. Writes carry the CSRF token the inventory handed out.
|
||||
let csrf = "";
|
||||
export function setCsrf(token: string) {
|
||||
csrf = token || "";
|
||||
}
|
||||
|
||||
export async function api(path: string, options: RequestInit = {}): Promise<Response> {
|
||||
const response = await fetch(`api/${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Screen-CSRF": csrf,
|
||||
...(options.headers as Record<string, string> | undefined),
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
let message = "That didn't work. Refresh the page and try again.";
|
||||
try {
|
||||
message = (await response.json()).error || message;
|
||||
} catch {}
|
||||
throw new Error(message);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
export const getJson = async <T = any>(path: string): Promise<T> => (await api(path)).json();
|
||||
export const send = async <T = any>(path: string, method: string, body?: unknown, extra: RequestInit = {}): Promise<T> => {
|
||||
const response = await api(path, { method, body: body === undefined ? undefined : JSON.stringify(body), ...extra });
|
||||
const text = await response.text();
|
||||
return (text ? JSON.parse(text) : null) as T;
|
||||
};
|
||||
Reference in New Issue
Block a user