parent
67f7580506
commit
0a7f2a209b
3 changed files with 176 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<h3>{{ _('Configure the connectivity check') }}</h3>
|
||||
|
||||
<p>{% trans %}
|
||||
If the connectivity check is enabled, OctoPrint will regularly check if it's connected to the internet.
|
||||
This is <strong>useful to prevent resource intensive operations</strong> (such as checking for updates) if it's already
|
||||
clear that they won't succeed anyhow.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<p>{% 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 %}</p>
|
||||
|
||||
<p>{% trans %}
|
||||
OctoPrint comes preconfigured to perform the connectivity check every 15 minutes. You may change the value here.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}">
|
||||
{% include "snippets/settings/server/serverOnlineCheckInterval.jinja2" %}
|
||||
</form>
|
||||
|
||||
<p>{% trans %}
|
||||
OctoPrint comes preconfigured to utilize Google's DNS server <code>8.8.8.8</code>, 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 %}</p>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}">
|
||||
{% include "snippets/settings/server/serverOnlineCheckHost.jinja2" %}
|
||||
{% include "snippets/settings/server/serverOnlineCheckPort.jinja2" %}
|
||||
</form>
|
||||
|
||||
<p>{% 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 %}</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="#" class="btn span6" data-bind="click: function() { if(!setup()){disableOnlineCheck()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Disable Connectivity Check') }}</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enableOnlineCheck()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Enable Connectivity Check') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="onlinecheck_decision" style="display: none" data-bind="visible: setup()">
|
||||
<div class="text-center" style="display: none" data-bind="visible: decision()">{% trans %}
|
||||
Connectivity check is <strong class="text-success">enabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
<div class="text-center" style="display: none" data-bind="visible: !decision()">{% trans %}
|
||||
Connectivity check is <strong class="text-danger">disabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
</div>
|
||||
Loading…
Reference in a new issue