diff --git a/fichero/api.py b/fichero/api.py index ed00108..75aee00 100644 --- a/fichero/api.py +++ b/fichero/api.py @@ -72,7 +72,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001 app = FastAPI( title="Fichero Printer API", description="REST API for the Fichero D11s (AiYin) thermal label printer.", - version="0.1.9", + version="0.1.13", lifespan=lifespan, docs_url=None, redoc_url=None, diff --git a/fichero_printer/fichero/api.py b/fichero_printer/fichero/api.py index 68f5f51..3e2d06b 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -73,7 +73,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001 app = FastAPI( title="Fichero Printer API", description="REST API for the Fichero D11s (AiYin) thermal label printer.", - version="0.1.9", + version="0.1.13", lifespan=lifespan, docs_url=None, redoc_url=None, @@ -96,324 +96,498 @@ def _ui_html() -> str: default_address = _DEFAULT_ADDRESS or "" default_transport = "classic" if _DEFAULT_CLASSIC else "ble" return f""" - + Fichero Printer -
-
-

Fichero Printer

-

Home Assistant print console for status, text labels, and image uploads.

-

API docs remain available at /docs.

-
-
-
-

Connection

- -
- - -
+
+ FicheroPrinter +
+ + + Unknown + + +
+
-
-
- - -
-
- - -
-
+
-
- - -
-
+ +
+

Connection

-
-

Output

-
Ready.
-
+ +
+ + +
-
-

Print Text

- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - + + -
- -
+
+ + +
+
-
-

Print Image

- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- +
+ + +
+
+ + +
+

Response

+
Waiting for a command…
+
+ + +
+

Print text

+ + + + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + + + +
+ +
+
+ + +
+

Print image

+ + + + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ -
- -
-
-
+ - + // ── Print text ─────────────────────────────────────── + async function printText() {{ + const form = new FormData(); + form.set("text", document.getElementById("text").value); + form.set("density", document.getElementById("text_density").value); + form.set("copies", document.getElementById("text_copies").value); + form.set("font_size", document.getElementById("text_font_size").value); + form.set("label_length", document.getElementById("text_label_length").value); + form.set("paper", document.getElementById("text_paper").value); + form.set("address", document.getElementById("address").value.trim()); + form.set("classic", String(document.getElementById("transport").value === "classic")); + form.set("channel", document.getElementById("channel").value); + setOutput({{ message: "Sending to printer…" }}, true); + const r = await fetch("print/text", {{ method: "POST", body: form }}); + await showResponse(r); + if (r.ok) refreshStatus(); + }} + + // ── Print image ────────────────────────────────────── + async function printImage() {{ + const fi = document.getElementById("image_file"); + if (!fi.files.length) {{ setOutput({{ error: "Select an image file first." }}, false); return; }} + const form = new FormData(); + form.set("file", fi.files[0]); + form.set("density", document.getElementById("image_density").value); + form.set("copies", document.getElementById("image_copies").value); + form.set("label_length", document.getElementById("image_label_length").value); + form.set("paper", document.getElementById("image_paper").value); + form.set("dither", String(document.getElementById("image_dither").checked)); + form.set("address", document.getElementById("address").value.trim()); + form.set("classic", String(document.getElementById("transport").value === "classic")); + form.set("channel", document.getElementById("channel").value); + setOutput({{ message: "Sending to printer…" }}, true); + const r = await fetch("print/image", {{ method: "POST", body: form }}); + await showResponse(r); + if (r.ok) refreshStatus(); + }} + """ diff --git a/web/package.json b/web/package.json index 7ef8a34..9163795 100644 --- a/web/package.json +++ b/web/package.json @@ -2,7 +2,7 @@ "name": "fichero-web", "private": true, "type": "module", - "version": "0.1.9", + "version": "0.1.13", "scripts": { "dev": "vite", "build": "vite build",