🚸 Improve guidance if printer undetected

* If no ports are detected, don't even allow to
    connect, instead show a hint to refresh and
    link an FAQ entry.
  * When auto detection fails, show a notification
    with a link to the FAQ.

Implements #4237
This commit is contained in:
Gina Häußge committed 2021-12-01 17:09:22 +01:00
1 parent 90b762f8ce
commit e2ef96b637
3 files changed
+42 -8

No files matched your search

+10 -2
View File
@@ -344,6 +344,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
hide: false
});
} else if (type === "Error" && payload.error) {
severity = "error";
switch (payload.reason) {
case "firmware": {
title = gettext("Error reported by printer");
@@ -388,7 +389,14 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
break;
}
case "autodetect": {
// ignore
title = gettext("Could not autodetect your printer");
text = _.sprintf(
gettext(
'No working connection parameters could be found. Are you sure your printer is physically connected and supported? Refer to <a href="%(url)s" target="_blank" rel="noopener noreferer">the FAQ</a> for help in debugging this.'
),
{url: "https://faq.octoprint.org/no-candidates"}
);
severity = "alert";
break;
}
default: {
@@ -410,7 +418,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
self._printerErrorDisconnectNotification = new PNotify({
title: title,
text: text,
type: "error",
type: severity,
hide: false
});
}
@@ -38,11 +38,33 @@ $(function () {
self.isReady = ko.observable(undefined);
self.isLoading = ko.observable(undefined);
self.enableConnect = ko.pureComputed(function () {
return self.enablePort() || !self.isErrorOrClosed();
});
self.buttonText = ko.pureComputed(function () {
if (self.isErrorOrClosed()) return gettext("Connect");
else return gettext("Disconnect");
});
self.portCaption = ko.pureComputed(function () {
return self.portOptions().length > 0
? "AUTO"
: gettext("No serial port found");
});
self.enablePort = ko.pureComputed(function () {
return self.portOptions().length > 0 && self.isErrorOrClosed();
});
self.enableSaveSettings = ko.pureComputed(function () {
return self.enableConnect() && self.isErrorOrClosed();
});
self.enableAutoConnect = ko.pureComputed(function () {
return self.enableConnect() && self.isErrorOrClosed();
});
self.previousIsOperational = undefined;
self.refreshVisible = ko.observable(true);
@@ -1,13 +1,17 @@
<div style="margin-bottom: 10px" class="alert alert-error" data-bind="visible: portOptions().length === 0"><small>{% trans link="<a href='https://faq.octoprint.org/no-candidates' target='_blank' rel='noopener noreferer'>", endlink="</a>", refresh="<a href='javascript:void(0)' data-bind='click: $root.requestData'>", endrefresh="</a>" %}
No serial port found, are you sure your printer is physically connected and supported?
Try {{ refresh }}refreshing{{ endrefresh }} and if that doesn't help please see {{ link }}the FAQ{{ endlink }}.
{% endtrans %}</small></div>
<label for="connection_ports" data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Serial Port') }}</label>
<select id="connection_ports" data-test-id="connection-ports" data-bind="options: portOptions, optionsCaption: 'AUTO', value: selectedPort, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
<select id="connection_ports" data-test-id="connection-ports" data-bind="options: portOptions, optionsCaption: portCaption, value: selectedPort, css: {disabled: !isErrorOrClosed()}, enable: enablePort()"></select>
<label for="connection_baudrates" data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Baudrate') }}</label>
<select id="connection_baudrates" data-test-id="connection-baudrates" data-bind="options: baudrateOptions, optionsCaption: 'AUTO', value: selectedBaudrate, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
<label for="connection_printers" data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Printer Profile') }}</label>
<select id="connection_printers" data-test-id="connection-printer-profiles" data-bind="options: printerOptions, optionsText: 'name', optionsValue: 'id', value: selectedPrinter, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
<label class="checkbox">
<input type="checkbox" id="connection_save" data-bind="checked: saveSettings, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"> {{ _('Save connection settings') }}
<label class="checkbox" data-bind="css: {muted: !enableSaveSettings()}">
<input type="checkbox" id="connection_save" data-bind="checked: saveSettings, enable: enableSaveSettings()"> {{ _('Save connection settings') }}
</label>
<label class="checkbox">
<input type="checkbox" id="connection_autoconnect" data-bind="checked: settings.serial_autoconnect, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"> {{ _('Auto-connect on server startup') }}
<label class="checkbox" data-bind="css: {muted: !enableAutoConnect()}">
<input type="checkbox" id="connection_autoconnect" data-bind="checked: settings.serial_autoconnect, enable: enableAutoConnect()"> {{ _('Auto-connect on server startup') }}
</label>
<button class="btn btn-block" id="printer_connect" data-test-id="connection-connect" data-bind="click: connect, text: buttonText">{{ _('Connect') }}</button>
<button class="btn btn-block" id="printer_connect" data-test-id="connection-connect" data-bind="click: connect, text: buttonText, enable: enableConnect">{{ _('Connect') }}</button>