Skip to content

Commit d2c55e0

Browse files
committed
add API POST command to start process
1 parent 4ad7aa9 commit d2c55e0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

octoprint_bedlevelvisualizer/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import flask
1212
import json
1313
from copy import deepcopy
14+
from octoprint.access.permissions import Permissions
1415

1516

1617
class bedlevelvisualizer(
@@ -480,7 +481,7 @@ def print_mesh_debug(self, message, mesh):
480481
# SimpleApiPlugin
481482

482483
def get_api_commands(self):
483-
return {'stopProcessing': []}
484+
return {'stopProcessing': [], 'startProcessing': []}
484485

485486
def on_api_get(self, request):
486487
if request.args.get("stopProcessing"):
@@ -499,6 +500,15 @@ def on_api_get(self, request):
499500
response = {'stopped': True}
500501
return flask.jsonify(response)
501502

503+
def on_api_command(self, command, data):
504+
if not Permissions.CONTROL.can():
505+
return flask.make_response("Insufficient rights", 403)
506+
507+
if command == "startProcessing":
508+
self._printer.commands(self._settings.get(["command"]).split("\n"))
509+
response = {'started': True}
510+
return flask.jsonify(response)
511+
502512
# Custom Action Hook
503513

504514
def custom_action_handler(self, comm, line, action, *args, **kwargs):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "Bed Visualizer"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "1.1.2rc4"
17+
plugin_version = "1.1.2rc5"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)