WizardPlugins can now report back more details
In case a wizard plugin needs to communicate more info with its frontend, such as which kind of information is missing, this is now possible through a new API endpoint that will collect such information from the plugins and provide it to callees.
This commit is contained in:
parent
3f147c9272
commit
f2b9337fae
3 changed files with 23 additions and 1 deletions
|
|
@ -103,7 +103,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
|||
EventHandlerPlugin,
|
||||
SlicerPlugin,
|
||||
AppPlugin,
|
||||
ProgressPlugin]
|
||||
ProgressPlugin,
|
||||
WizardPlugin]
|
||||
if plugin_entry_points is None:
|
||||
plugin_entry_points = "octoprint.plugin"
|
||||
if plugin_disabled_list is None:
|
||||
|
|
|
|||
|
|
@ -455,6 +455,9 @@ class WizardPlugin(OctoPrintPlugin, ReloadNeedingPlugin):
|
|||
def is_wizard_required(self):
|
||||
return False
|
||||
|
||||
def get_wizard_details(self):
|
||||
return dict()
|
||||
|
||||
|
||||
class SimpleApiPlugin(OctoPrintPlugin):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -98,6 +98,24 @@ def pluginCommand(name):
|
|||
|
||||
#~~ first run setup
|
||||
|
||||
@api.route("/setup/wizard", methods=["GET"])
|
||||
def wizardState():
|
||||
if not s().getBoolean(["server", "firstRun"]) and not admin_permission.can():
|
||||
abort(403)
|
||||
|
||||
result = dict()
|
||||
wizard_plugins = octoprint.server.pluginManager.get_implementations(octoprint.plugin.WizardPlugin)
|
||||
for implementation in wizard_plugins:
|
||||
name = implementation._identifier
|
||||
try:
|
||||
required = implementation.is_wizard_required()
|
||||
details = implementation.get_wizard_details()
|
||||
except:
|
||||
logging.getLogger(__name__).exception("There was an error fetching wizard details for {}, ignoring".format(name))
|
||||
else:
|
||||
result[name] = dict(required=required, details=details)
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
@api.route("/setup", methods=["POST"])
|
||||
def firstRunSetup():
|
||||
|
|
|
|||
Loading…
Reference in a new issue