From 46452e9ff754d8574ba616c8a04eb9898663f609 Mon Sep 17 00:00:00 2001 From: Josef-MrBeam Date: Mon, 25 Sep 2023 10:18:07 +0200 Subject: [PATCH] fix codesmell and add Changes from Code Review --- octoprint_mrbeam/__init__.py | 8 +++++--- octoprint_mrbeam/mrbeam_events.py | 2 ++ .../static/js/app/view-models/settings/maintenance.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/octoprint_mrbeam/__init__.py b/octoprint_mrbeam/__init__.py index bb1dc7007..27a7a7883 100644 --- a/octoprint_mrbeam/__init__.py +++ b/octoprint_mrbeam/__init__.py @@ -514,7 +514,7 @@ def get_settings_defaults(self): ) def on_settings_load(self): - self._send_maintenance_information(trigger="settings_load") + self._send_maintenance_information(trigger=MrBeamEvents.SETTINGS_LOAD) return dict( svgDPI=self._settings.get(["svgDPI"]), dxfScale=self._settings.get(["dxfScale"]), @@ -605,7 +605,7 @@ def _get_usage_data_dict(self): ) def on_airfilter_changed(self, *args, **kwargs): - self._send_maintenance_information(trigger="airfilter_changed") + self._send_maintenance_information(trigger=MrBeamEvents.AIRFILTER_CHANGED) def _send_maintenance_information(self, trigger=None): self._plugin_manager.send_plugin_message( @@ -697,7 +697,9 @@ def on_settings_save(self, data): def set_heavy_duty_prefilter(self, value): if value != self._settings.get(["heavyDutyPrefilter"]): - self._send_maintenance_information(trigger="heavyDutyPrefilter_changed") + self._send_maintenance_information( + trigger=MrBeamEvents.HEAVY_DUTY_PREFILTER_CHANGED + ) self._settings.set_boolean(["heavyDutyPrefilter"], value) def is_heavy_duty_prefilter_enabled(self): diff --git a/octoprint_mrbeam/mrbeam_events.py b/octoprint_mrbeam/mrbeam_events.py index a52a6ff3c..ec85e12eb 100644 --- a/octoprint_mrbeam/mrbeam_events.py +++ b/octoprint_mrbeam/mrbeam_events.py @@ -4,6 +4,8 @@ # NOTICE: This is used by the camera plugin class MrBeamEvents(object): + HEAVY_DUTY_PREFILTER_CHANGED = "HeavyDutyPrefilterChanged" + SETTINGS_LOAD = "SettingsLoad" MRB_PLUGIN_INITIALIZED = "MrbPluginInitialized" BOOT_GRACE_PERIOD_END = "BootGracePeriodEnd" diff --git a/octoprint_mrbeam/static/js/app/view-models/settings/maintenance.js b/octoprint_mrbeam/static/js/app/view-models/settings/maintenance.js index 5a0a38290..bd8287f5a 100644 --- a/octoprint_mrbeam/static/js/app/view-models/settings/maintenance.js +++ b/octoprint_mrbeam/static/js/app/view-models/settings/maintenance.js @@ -494,7 +494,7 @@ $(function () { return; } if ("maintenance_information" in data) { - maintenanceInformation = data.maintenance_information; + const maintenanceInformation = data.maintenance_information; console.log( "Maintenance information received", maintenanceInformation