diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index e2b1851f..d4ea955b 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -59,8 +59,14 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, #~~ WizardPlugin API def is_wizard_required(self): - methods = self._get_subwizard_attrs("_is_", "_wizard_required") - return self._settings.global_get(["server", "firstRun"]) and any(map(lambda m: m(), methods.values())) + required = self._get_subwizard_attrs("_is_", "_wizard_required") + firstrunonly = self._get_subwizard_attrs("_is_", "_wizard_firstrunonly") + firstrun = self._settings.global_get(["server", "firstRun"]) + + any_not_firstrunonly = any(map(lambda m: not m(), firstrunonly.values())) + any_required = any(map(lambda m: m(), required.values())) + + return (firstrun or any_not_firstrunonly) and any_required def get_wizard_details(self): result = dict() @@ -71,8 +77,14 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, return result + def get_wizard_version(self): + return 1 + #~~ ACL subwizard + def _is_acl_wizard_firstrunonly(self): + return True + def _is_acl_wizard_required(self): return self._user_manager.enabled and not self._user_manager.hasBeenCustomized() @@ -114,6 +126,9 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, #~~ Webcam subwizard + def _is_webcam_wizard_firstrunonly(self): + return True + def _is_webcam_wizard_required(self): webcam_snapshot_url = self._settings.global_get(["webcam", "snapshot"]) webcam_stream_url = self._settings.global_get(["webcam", "stream"]) @@ -129,6 +144,9 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, #~~ Server commands subwizard + def _is_servercommands_wizard_firstrunonly(self): + return True + def _is_servercommands_wizard_required(self): system_shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"]) system_restart_command = self._settings.global_get(["server", "commands", "systemRestartCommand"]) @@ -142,8 +160,28 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, def _get_servercommands_wizard_name(self): return gettext("Server Commands") + #~~ Online check subwizard + + def _is_onlinecheck_wizard_firstrunonly(self): + return False + + def _is_onlinecheck_wizard_required(self): + return self._settings.global_get(["server", "onlineCheck", "enabled"]) is None + + def _get_onlinecheck_wizard_details(self): + return dict(required=self._is_onlinecheck_wizard_required()) + + def _get_onlinecheck_wizard_name(self): + return gettext("Online connectivity check") + + def _get_onlinecheck_additional_wizard_template_data(self): + return dict(mandatory=self._is_onlinecheck_wizard_required()) + #~~ Printer profile subwizard + def _is_printerprofile_wizard_firstrunonly(self): + return True + def _is_printerprofile_wizard_required(self): return self._printer_profile_manager.is_default_unmodified() and self._printer_profile_manager.profile_count == 1 diff --git a/src/octoprint/plugins/corewizard/static/js/corewizard.js b/src/octoprint/plugins/corewizard/static/js/corewizard.js index b59b676b..2a09a07b 100644 --- a/src/octoprint/plugins/corewizard/static/js/corewizard.js +++ b/src/octoprint/plugins/corewizard/static/js/corewizard.js @@ -125,6 +125,88 @@ $(function() { self.settingsViewModel = parameters[0]; } + function CoreWizardOnlineCheckViewModel(parameters) { + var self = this; + + self.settingsViewModel = parameters[0]; + + self.setup = ko.observable(false); + + self.decision = ko.observable(); + self.required = false; + self.active = false; + + self.enableOnlineCheck = function() { + self.settingsViewModel.server_onlineCheck_enabled(true); + self.decision(true); + self._sendData(); + }; + + self.disableOnlineCheck = function() { + self.settingsViewModel.server_onlineCheck_enabled(false); + self.decision(false); + self._sendData(); + }; + + self.onBeforeWizardTabChange = function(next, current) { + if (!self.required) return true; + + if (!current || !_.startsWith(current, "wizard_plugin_corewizard_onlinecheck_") || self.setup()) { + return true; + } + + self._showDecisionNeededDialog(); + return false; + }; + + self.onBeforeWizardFinish = function() { + if (!self.required) return true; + + if (self.setup()) { + return true; + } + + self._showDecisionNeededDialog(); + return false; + }; + + self.onWizardPreventSettingsRefreshDialog = function() { + return self.active; + }; + + self.onWizardDetails = function(response) { + self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.onlinecheck && response.corewizard.details.onlinecheck.required; + }; + + self._showDecisionNeededDialog = function() { + showMessageDialog({ + title: gettext("Please set up the online connectivity check"), + message: gettext("You haven't yet decided on whether to enable or disable the online connectivity check. You need to either enable or disable it before continuing.") + }); + }; + + self._sendData = function() { + var data = { + server: { + onlineCheck: { + enabled: self.settingsViewModel.server_onlineCheck_enabled(), + interval: self.settingsViewModel.server_onlineCheck_interval(), + host: self.settingsViewModel.server_onlineCheck_host(), + port: self.settingsViewModel.server_onlineCheck_port() + } + } + }; + + self.active = true; + self.settingsViewModel.saveData(data) + .done(function() { + self.setup(true); + self.active = false; + }); + }; + + } + function CoreWizardPrinterProfileViewModel(parameters) { var self = this; @@ -172,6 +254,10 @@ $(function() { CoreWizardServerCommandsViewModel, ["settingsViewModel"], "#wizard_plugin_corewizard_servercommands" + ], [ + CoreWizardOnlineCheckViewModel, + ["settingsViewModel"], + "#wizard_plugin_corewizard_onlinecheck" ], [ CoreWizardPrinterProfileViewModel, ["printerProfilesViewModel"], diff --git a/src/octoprint/plugins/corewizard/templates/corewizard_onlinecheck_wizard.jinja2 b/src/octoprint/plugins/corewizard/templates/corewizard_onlinecheck_wizard.jinja2 new file mode 100644 index 00000000..ea115e4c --- /dev/null +++ b/src/octoprint/plugins/corewizard/templates/corewizard_onlinecheck_wizard.jinja2 @@ -0,0 +1,50 @@ +
{% trans %} + If the connectivity check is enabled, OctoPrint will regularly check if it's connected to the internet. + This is useful to prevent resource intensive operations (such as checking for updates) if it's already + clear that they won't succeed anyhow. +{% endtrans %}
+ +{% trans %} + If it is disabled OctoPrint will always assume to have a working connection to the internet. + If that should not actually be the case, server startups, update checks and the like might take longer. +{% endtrans %}
+ +{% trans %} + OctoPrint comes preconfigured to perform the connectivity check every 15 minutes. You may change the value here. +{% endtrans %}
+ + + +{% trans %}
+ OctoPrint comes preconfigured to utilize Google's DNS server 8.8.8.8, port 53 for the connectivity check (if
+ it's enabled). If you have concerns about using that, define the IP and port of a different online server that you
+ trust and that has a high availability.
+{% endtrans %}
{% trans %} + Finally, please decide on whether to enable or disable the connectivity check. You may change the configuration at + any time to a later date through Settings > Server right from within OctoPrint. +{% endtrans %}
+ + + +