diff --git a/octoprint_zbolt_octoscreen/__init__.py b/octoprint_zbolt_octoscreen/__init__.py index d84db83..12e405a 100644 --- a/octoprint_zbolt_octoscreen/__init__.py +++ b/octoprint_zbolt_octoscreen/__init__.py @@ -21,7 +21,6 @@ class ZBoltOctoScreenPlugin(octoprint.plugin.SettingsPlugin, def initialize(self): Notifications.initialize(self._plugin_manager) self.Settings = ZBoltOctoScreenSettings(self._settings) - def get_assets(self): return dict( @@ -31,7 +30,7 @@ def get_assets(self): ) def get_settings_defaults(self): - return ZBoltOctoScreenSettings.default_settings() + return ZBoltOctoScreenSettings.default_settings() def get_template_vars(self): return ZBoltOctoScreenSettings.template_vars() @@ -46,34 +45,44 @@ def on_settings_save(self, data): octoprint.plugin.SettingsPlugin.on_settings_save(self, data) def on_api_command(self, command, data): + # Warning! get_notification and get_settings have been moved. + # They are no longer POST operations and are now GET operations. + # This code will remain here for a few release but will eventually + # be deprecated. if command == "get_notification": return flask.jsonify(message = Notifications.get_message_to_display()) - elif command == "get_settings": + elif command == "get_settings": return flask.jsonify(self.Settings.get_all()) def on_api_get(self, request): - return flask.jsonify(printer_name="test2") - + if len(request.values) != 0: + command = request.values["command"] + if command == "get_notification": + msg = Notifications.get_message_to_display() + if msg is None: + msg = "" + return flask.jsonify(message = msg) + elif command == "get_settings": + return flask.jsonify(self.Settings.get_all()) def get_template_configs(self): return [ dict(type="settings", name="Z-Bolt OctoScreen", custom_bindings=False), ] - ##~~ Softwareupdate hook def get_update_information(self): return dict( - zbolt_octoscreen=dict( - displayName = "Z-Bolt OctoScreen", - displayVersion = self._plugin_version, + zbolt_octoscreen = dict( + displayName = "Z-Bolt OctoScreen", + displayVersion = self._plugin_version, - type="github_release", - user="Z-Bolt", - repo="OctoPrint-Z-Bolt-OctoScreen", - current=self._plugin_version, + type = "github_release", + user = "Z-Bolt", + repo = "OctoPrint-Z-Bolt-OctoScreen", + current = self._plugin_version, - pip="https://github.com/Z-Bolt/OctoPrint-Z-Bolt-OctoScreen/archive/{target_version}.zip" + pip = "https://github.com/Z-Bolt/OctoPrint-Z-Bolt-OctoScreen/archive/{target_version}.zip" ) ) @@ -82,7 +91,7 @@ def get_update_information(self): __plugin_pythoncompat__ = ">=2.7,<4" def __plugin_load__(): - global __plugin_implementation__ + global __plugin_implementation__ __plugin_implementation__ = ZBoltOctoScreenPlugin() global __plugin_hooks__ diff --git a/octoprint_zbolt_octoscreen/notifications.py b/octoprint_zbolt_octoscreen/notifications.py index 8f052c6..70f5dd8 100644 --- a/octoprint_zbolt_octoscreen/notifications.py +++ b/octoprint_zbolt_octoscreen/notifications.py @@ -22,7 +22,6 @@ def send_message(self, message): payload['text'] = message['text'] self._plugin_manager.send_plugin_message("zbolt_octoscreen", payload) - def get_message_to_display(self): if not self._message: return None @@ -32,7 +31,3 @@ def get_message_to_display(self): return m Notifications = NotificationsStorage() - - - - diff --git a/octoprint_zbolt_octoscreen/settings.py b/octoprint_zbolt_octoscreen/settings.py index a23fa22..f75f681 100644 --- a/octoprint_zbolt_octoscreen/settings.py +++ b/octoprint_zbolt_octoscreen/settings.py @@ -1,7 +1,5 @@ import json -zbolt_toolchanger_installed = True - default_menu_structure = """[ { @@ -20,9 +18,9 @@ "panel": "move" }, { - "name": "Extrude", - "icon": "filament", - "panel": "extrude_multitool" + "name": "Filament", + "icon": "filament-spool", + "panel": "filament" }, { "name": "Fan", @@ -38,18 +36,13 @@ "name": "Control", "icon": "control", "panel": "control" - }, - { - "name": "ToolChanger", - "icon": "toolchanger", - "panel": "toolchanger" } ] }, { "name": "Filament", - "icon": "filament", - "panel": "filament_multitool" + "icon": "filament-spool", + "panel": "filament" }, { "name": "Configuration", @@ -87,6 +80,15 @@ def __init__(self, settings): self.default_menu_structure = default_menu_structure def get_all(self): + json_menu_structure = None + try: + menu_structure = self._settings.get(["menu_structure"]) + if menu_structure is None or menu_structure == "": + menu_structure = "[]" + json_menu_structure = json.loads(menu_structure) + except: + json_menu_structure = [] + return { "filament_in_length": float(self._settings.get(["filament_in_length"])), "filament_out_length": float(self._settings.get(["filament_out_length"])), @@ -95,23 +97,22 @@ def get_all(self): "x_axis_inverted": bool(self._settings.get(["x_axis_inverted"])), "y_axis_inverted": bool(self._settings.get(["y_axis_inverted"])), "z_axis_inverted": bool(self._settings.get(["z_axis_inverted"])), - "menu_structure": json.loads(self._settings.get(["menu_structure"])), + "menu_structure": json_menu_structure, } @staticmethod def default_settings(): return dict( - filament_in_length=750, - filament_out_length=800, - toolchanger=False, - x_axis_inverted=False, - y_axis_inverted=False, - z_axis_inverted=True, - gcodes=dict(auto_bed_level="G29"), + filament_in_length = 750, + filament_out_length = 800, + toolchanger = False, + x_axis_inverted = False, + y_axis_inverted = False, + z_axis_inverted = False, + gcodes=dict(auto_bed_level = "G29"), menu_structure=default_menu_structure, ) @staticmethod def template_vars(): - return dict(default_menu_structure=default_menu_structure) - + return dict(default_menu_structure = default_menu_structure) diff --git a/setup.py b/setup.py index 98fa1b7..8a2ec19 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-Z-Bolt-OctoScreen" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.2.0" +plugin_version = "2.6.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module