Skip to content

Commit

Permalink
add API POST command to start process
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Apr 22, 2023
1 parent 4ad7aa9 commit d2c55e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion octoprint_bedlevelvisualizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import flask
import json
from copy import deepcopy
from octoprint.access.permissions import Permissions


class bedlevelvisualizer(
Expand Down Expand Up @@ -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"):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2c55e0

Please sign in to comment.