From 35e5fcf68bd22e405d658884d6f1ddc8a13a35a5 Mon Sep 17 00:00:00 2001 From: David Zwart Date: Tue, 13 Feb 2024 21:55:41 +0100 Subject: [PATCH 1/5] feat: add printrer control dialog --- src/App.vue | 4 +- src/backend/printers.service.ts | 18 ++ src/backend/server.api.ts | 2 + .../Generic/Dialogs/PrinterControlDialog.vue | 117 +++++++++ .../Generic/Dialogs/dialog.constants.ts | 2 + .../PrinterGrid/PrinterGridTile.vue | 222 +++++++++++------- 6 files changed, 281 insertions(+), 84 deletions(-) create mode 100644 src/components/Generic/Dialogs/PrinterControlDialog.vue diff --git a/src/App.vue b/src/App.vue index b654de6b..a50222f2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -26,6 +26,7 @@ + @@ -54,11 +55,12 @@ import { uploadProgressTest } from "./utils/test.util"; import { useAuthStore } from "./store/auth.store"; import AppLoader from "./AppLoader.vue"; import AddOrUpdateCameraStreamDialog from "@/components/Generic/Dialogs/AddOrUpdateCameraStreamDialog.vue"; -import { sleep } from "@/utils/time.utils"; +import PrinterControlDialog from "@/components/Generic/Dialogs/PrinterControlDialog.vue"; export default defineComponent({ name: "AppView", components: { + PrinterControlDialog, AddOrUpdateCameraStreamDialog, AppInfoSnackbar, AppErrorSnackbar, diff --git a/src/backend/printers.service.ts b/src/backend/printers.service.ts index bbc6de8f..e08a2a54 100644 --- a/src/backend/printers.service.ts +++ b/src/backend/printers.service.ts @@ -70,6 +70,24 @@ export class PrintersService extends BaseService { return await this.postApi(path); } + static async sendPrinterJogCommand( + printerId: IdType, + amounts: { x?: number; y?: number; z?: number } + ) { + const path = ServerApi.printerJogCommandRoute(printerId); + + return await this.postApi(path, amounts); + } + + static async sendPrinterHomeCommand( + printerId: IdType, + amounts: { x?: number; y?: number; z?: number } + ) { + const path = ServerApi.printerHomeCommandRoute(printerId); + + return await this.postApi(path, amounts); + } + static async createPrinter(printer: CreatePrinter) { const path = ServerApi.printerRoute; diff --git a/src/backend/server.api.ts b/src/backend/server.api.ts index 9851f769..76d6a69a 100644 --- a/src/backend/server.api.ts +++ b/src/backend/server.api.ts @@ -93,6 +93,8 @@ export class ServerApi { static printerEnabledRoute = (id: IdType) => `${ServerApi.getPrinterRoute(id)}/enabled`; static printerSerialConnectRoute = (id: IdType) => `${ServerApi.getPrinterRoute(id)}/serial-connect`; + static printerJogCommandRoute = (id: IdType) => `${ServerApi.getPrinterRoute(id)}/jog`; + static printerHomeCommandRoute = (id: IdType) => `${ServerApi.getPrinterRoute(id)}/home`; static printerSerialDisconnectRoute = (id: IdType) => `${ServerApi.getPrinterRoute(id)}/serial-disconnect`; diff --git a/src/components/Generic/Dialogs/PrinterControlDialog.vue b/src/components/Generic/Dialogs/PrinterControlDialog.vue new file mode 100644 index 00000000..52e3993c --- /dev/null +++ b/src/components/Generic/Dialogs/PrinterControlDialog.vue @@ -0,0 +1,117 @@ + + + diff --git a/src/components/Generic/Dialogs/dialog.constants.ts b/src/components/Generic/Dialogs/dialog.constants.ts index 978f58f4..72d5303a 100644 --- a/src/components/Generic/Dialogs/dialog.constants.ts +++ b/src/components/Generic/Dialogs/dialog.constants.ts @@ -14,4 +14,6 @@ export enum DialogName { PrinterMaintenanceDialog = "PrinterMaintenanceDialog", // The camera create dialog, which is used to create a new or update a camera. AddOrUpdateCameraDialog = "AddOrUpdateCameraDialog", + // Dialog for moving print head, homing, or retracting/extruding filament + PrinterControlDialog = "PrinterControlDialog", } diff --git a/src/components/PrinterGrid/PrinterGridTile.vue b/src/components/PrinterGrid/PrinterGridTile.vue index 8b2f6070..c848423d 100644 --- a/src/components/PrinterGrid/PrinterGridTile.vue +++ b/src/components/PrinterGrid/PrinterGridTile.vue @@ -76,6 +76,25 @@ usb + + + + + + From b72da05526b2e9f1ad16bec837f637969085f878 Mon Sep 17 00:00:00 2001 From: David Zwart Date: Wed, 14 Feb 2024 23:26:17 +0100 Subject: [PATCH 2/5] feat: printer control only for server with capability --- .../PrinterGrid/PrinterGridTile.vue | 23 +++++++++++++++++-- src/models/server/features.model.ts | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/PrinterGrid/PrinterGridTile.vue b/src/components/PrinterGrid/PrinterGridTile.vue index c848423d..1f2f8cea 100644 --- a/src/components/PrinterGrid/PrinterGridTile.vue +++ b/src/components/PrinterGrid/PrinterGridTile.vue @@ -49,6 +49,14 @@ info  Details + + open_with +  Control + directions  Visit OctoPrint @@ -68,7 +76,8 @@ - +