From d2c55e05be06899157c0ed37052309b5a863b443 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Sat, 22 Apr 2023 11:16:46 -0400 Subject: [PATCH] add API POST command to start process --- octoprint_bedlevelvisualizer/__init__.py | 12 +++++++++++- setup.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/octoprint_bedlevelvisualizer/__init__.py b/octoprint_bedlevelvisualizer/__init__.py index 6204297..fbb3031 100644 --- a/octoprint_bedlevelvisualizer/__init__.py +++ b/octoprint_bedlevelvisualizer/__init__.py @@ -11,6 +11,7 @@ import flask import json from copy import deepcopy +from octoprint.access.permissions import Permissions class bedlevelvisualizer( @@ -480,7 +481,7 @@ def print_mesh_debug(self, message, mesh): # SimpleApiPlugin def get_api_commands(self): - return {'stopProcessing': []} + return {'stopProcessing': [], 'startProcessing': []} def on_api_get(self, request): if request.args.get("stopProcessing"): @@ -499,6 +500,15 @@ def on_api_get(self, request): response = {'stopped': True} return flask.jsonify(response) + def on_api_command(self, command, data): + if not Permissions.CONTROL.can(): + return flask.make_response("Insufficient rights", 403) + + if command == "startProcessing": + self._printer.commands(self._settings.get(["command"]).split("\n")) + response = {'started': True} + return flask.jsonify(response) + # Custom Action Hook def custom_action_handler(self, comm, line, action, *args, **kwargs): diff --git a/setup.py b/setup.py index 0662936..e281494 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "Bed Visualizer" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.1.2rc4" +plugin_version = "1.1.2rc5" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module