diff --git a/projects/tentacles/src/python/tentacles/blueprints/admin_ui.py b/projects/tentacles/src/python/tentacles/blueprints/admin_ui.py index 9438d8a..a5e299b 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/admin_ui.py +++ b/projects/tentacles/src/python/tentacles/blueprints/admin_ui.py @@ -123,7 +123,7 @@ def handle_edit_printers(): args["enabled"] = int(args["enabled"]) args["filament_id"] = int(args["filament_id"]) args["chassis_id"] = int(args["chassis_id"]) - print(args) + args["nozzle_diameter"] = float(args["nozzle_diameter"]) ctx.db.edit_printer(**args) return redirect("/admin") diff --git a/projects/tentacles/src/python/tentacles/db.py b/projects/tentacles/src/python/tentacles/db.py index 4fdf900..5dab149 100644 --- a/projects/tentacles/src/python/tentacles/db.py +++ b/projects/tentacles/src/python/tentacles/db.py @@ -213,3 +213,7 @@ class Db(Queries): def finish_job(self, *, jid: int, state: str, message: Optional[str] = None): super().finish_job(jid=jid, state=state, message=message) + + def create_filament(self, *, name: str): + super().create_filament(name=name) + return super().fetch_filament(name=name) diff --git a/projects/tentacles/src/python/tentacles/sql/jobs.sql b/projects/tentacles/src/python/tentacles/sql/jobs.sql index 301c0c5..51d5a05 100644 --- a/projects/tentacles/src/python/tentacles/sql/jobs.sql +++ b/projects/tentacles/src/python/tentacles/sql/jobs.sql @@ -78,6 +78,7 @@ SELECT , fa.max_end , fa.nozzle_diameter , fa.filament_id + , (SELECT name FROM filament WHERE id = fa.filament_id) AS filament_name FROM jobs j INNER JOIN files f ON j.file_id = f.id diff --git a/projects/tentacles/src/python/tentacles/sql/printers.sql b/projects/tentacles/src/python/tentacles/sql/printers.sql index 3901f46..054ad19 100644 --- a/projects/tentacles/src/python/tentacles/sql/printers.sql +++ b/projects/tentacles/src/python/tentacles/sql/printers.sql @@ -102,6 +102,7 @@ SELECT , p.chassis_id , p.enabled , s.name as status + , p.nozzle_diameter FROM printers p INNER JOIN printer_statuses s ON p.status_id = s.id WHERE p.id = :pid @@ -140,6 +141,7 @@ SELECT , c.limit_bed , c.limit_hotend , p.nozzle_diameter + , p.filament_id FROM printers p LEFT JOIN (SELECT id, printer_id FROM jobs WHERE finished_at IS NULL) j ON p.id = j.printer_id @@ -174,6 +176,7 @@ SET , filament_id = :filament_id , chassis_id = :chassis_id , enabled = :enabled + , nozzle_diameter = :nozzle_diameter WHERE id = :id ; @@ -202,3 +205,9 @@ VALUES ( RETURNING id ; + +-- name: fetch-filament^ +SELECT * +FROM filament +WHERE name = :name +; diff --git a/projects/tentacles/src/python/tentacles/templates/edit_printer.html.j2 b/projects/tentacles/src/python/tentacles/templates/edit_printer.html.j2 index 28a748f..b22cb7a 100644 --- a/projects/tentacles/src/python/tentacles/templates/edit_printer.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/edit_printer.html.j2 @@ -4,10 +4,18 @@