diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index ad06ebcf..87e3a719 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -32,7 +32,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, octoprint.plugin.SettingsPlugin, octoprint.plugin.AssetPlugin, octoprint.plugin.TemplatePlugin, - octoprint.plugin.StartupPlugin): + octoprint.plugin.StartupPlugin, + octoprint.plugin.WizardPlugin): def __init__(self): self._update_in_progress = False self._configured_checks_mutex = threading.Lock() @@ -177,12 +178,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, checks = self._get_configured_checks() if "octoprint" in checks: - if "checkout_folder" in checks["octoprint"]: - data["octoprint_checkout_folder"] = checks["octoprint"]["checkout_folder"] - elif "update_folder" in checks["octoprint"]: - data["octoprint_checkout_folder"] = checks["octoprint"]["update_folder"] - else: - data["octoprint_checkout_folder"] = None + data["octoprint_checkout_folder"] = self._get_octoprint_checkout_folder(checks=checks) data["octoprint_type"] = checks["octoprint"].get("type", None) else: data["octoprint_checkout_folder"] = None @@ -410,6 +406,14 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, dict(type="settings", name=gettext("Software Update")) ] + ##~~ + + def is_wizard_required(self): + checks = self._get_configured_checks() + check = checks.get("octoprint", None) + checkout_folder = self._get_octoprint_checkout_folder(checks=checks) + return check and "update_script" in check and not checkout_folder + #~~ Updater def get_current_versions(self, check_targets=None, force=False): @@ -780,6 +784,20 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, else: raise exceptions.UnknownUpdateType() + def _get_octoprint_checkout_folder(self, checks=None): + if checks is None: + checks = self._get_configured_checks() + + if not "octoprint" in checks: + return None + + if "checkout_folder" in checks["octoprint"]: + return checks["octoprint"]["checkout_folder"] + elif "update_folder" in checks["octoprint"]: + return checks["octoprint"]["update_folder"] + + return None + __plugin_name__ = "Software Update" __plugin_author__ = "Gina Häußge" diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 907b3fd4..7e434e8e 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -169,6 +169,11 @@ $(function() { self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type()); }; + self._copyConfigBack = function() { + self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder(self.config_checkoutFolder()); + self.settings.settings.plugins.softwareupdate.octoprint_type(self.config_checkType()); + }; + self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) { var versions = []; _.each(data.information, function(value, key) { @@ -415,6 +420,18 @@ $(function() { self.workingOutput.scrollTop(self.workingOutput[0].scrollHeight - self.workingOutput.height()); }; + self.onWizardTabChange = function(current, next) { + if (next && _.startsWith(next, "wizard_plugin_softwareupdate")) { + // switching to the plugin wizard tab + self._copyConfig(); + } else if (current && _.startsWith(current, "wizard_plugin_softwareupdate")) { + // switching away from the plugin wizard tab + self._copyConfigBack(); + } + + return true; + }; + self.onStartup = function() { self.workingDialog = $("#settings_plugin_softwareupdate_workingdialog"); self.workingOutput = $("#settings_plugin_softwareupdate_workingdialog_output"); @@ -616,6 +633,6 @@ $(function() { ADDITIONAL_VIEWMODELS.push([ SoftwareUpdateViewModel, ["loginStateViewModel", "printerStateViewModel", "settingsViewModel"], - ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog"] + ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"] ]); }); diff --git a/src/octoprint/plugins/softwareupdate/templates/_snippets/plugins/softwareupdate/checkoutFolder.jinja2 b/src/octoprint/plugins/softwareupdate/templates/_snippets/plugins/softwareupdate/checkoutFolder.jinja2 new file mode 100644 index 00000000..1804d11f --- /dev/null +++ b/src/octoprint/plugins/softwareupdate/templates/_snippets/plugins/softwareupdate/checkoutFolder.jinja2 @@ -0,0 +1,6 @@ +