diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst
index 10a59aefb..271911218 100644
--- a/docs/configuration/config_yaml.rst
+++ b/docs/configuration/config_yaml.rst
@@ -290,6 +290,9 @@ The following settings are only relevant to you if you want to do OctoPrint deve
# Whether to delete generated web assets on server startup (forcing a regeneration)
clean_on_startup: true
+ # enable or disable the loading animation
+ showLoadingAnimation: true
+
# Settings for the virtual printer
virtualPrinter:
diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py
index 434dd824a..e8560e4cc 100644
--- a/src/octoprint/server/views.py
+++ b/src/octoprint/server/views.py
@@ -185,6 +185,7 @@ def index():
enable_accesscontrol = userManager.enabled
enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"])
enable_timelapse = settings().getBoolean(["webcam", "timelapseEnabled"])
+ enable_loading_animation = settings().getBoolean(["devel", "showLoadingAnimation"])
def default_template_filter(template_type, template_key):
if template_type == "navbar":
@@ -202,6 +203,7 @@ def index():
default_additional_etag = [enable_accesscontrol,
enable_gcodeviewer,
enable_timelapse,
+ enable_loading_animation,
wizard_active(_templates.get(locale))] + sorted(["{}:{}".format(to_unicode(k, errors="replace"),
to_unicode(v, errors="replace"))
for k, v in _plugin_vars.items()])
@@ -368,6 +370,7 @@ def index():
enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]),
enableAccessControl=enable_accesscontrol,
accessControlActive=accesscontrol_active,
+ enableLoadingAnimation=enable_loading_animation,
enableSdSupport=settings().get(["feature", "sdSupport"]),
gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]),
gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]),
diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py
index e16de3458..849a45661 100644
--- a/src/octoprint/settings.py
+++ b/src/octoprint/settings.py
@@ -410,6 +410,7 @@ default_settings = {
"clean_on_startup": True
},
"useFrozenDictForPrinterState": True,
+ "showLoadingAnimation": True,
"virtualPrinter": {
"enabled": False,
"okAfterResend": False,
diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js
index 949edaa77..0da53f3f7 100644
--- a/src/octoprint/static/js/app/main.js
+++ b/src/octoprint/static/js/app/main.js
@@ -590,113 +590,118 @@ $(function() {
}
var bindViewModels = function() {
- log.info("Going to bind " + allViewModelData.length + " view models...");
- _.each(allViewModelData, function(viewModelData) {
- try {
- if (!Array.isArray(viewModelData) || viewModelData.length !== 2) {
- log.error("View model data for", viewModel.constructor.name, "has wrong format, expected 2-tuple (viewModel, targets), got:", viewModelData);
- return;
- }
-
- var viewModel = viewModelData[0];
- var targets = viewModelData[1];
-
- if (targets === undefined) {
- log.error("No binding targets defined for view model", viewMode.constructor.name);
- return;
- }
-
- if (!_.isArray(targets)) {
- targets = [targets];
- }
-
+ try {
+ log.info("Going to bind " + allViewModelData.length + " view models...");
+ _.each(allViewModelData, function (viewModelData) {
try {
- callViewModel(viewModel, "onBeforeBinding", undefined, true);
- } catch (exc) {
- log.error("Error calling onBeforeBinding on view model", viewModel.constructor.name, ":", (exc.stack || exc));
- return;
- }
+ if (!Array.isArray(viewModelData) || viewModelData.length !== 2) {
+ log.error("View model data for", viewModelData.constructor.name, "has wrong format, expected 2-tuple (viewModel, targets), got:", viewModelData);
+ return;
+ }
+
+ var viewModel = viewModelData[0];
+ var targets = viewModelData[1];
+
+ if (targets === undefined) {
+ log.error("No binding targets defined for view model", viewMode.constructor.name);
+ return;
+ }
- if (targets !== undefined) {
if (!_.isArray(targets)) {
targets = [targets];
}
- viewModel._bindings = [];
+ try {
+ callViewModel(viewModel, "onBeforeBinding", undefined, true);
+ } catch (exc) {
+ log.error("Error calling onBeforeBinding on view model", viewModel.constructor.name, ":", (exc.stack || exc));
+ return;
+ }
- _.each(targets, function (target) {
- if (target === undefined) {
- log.error("Undefined target for view model", viewModel.constructor.name);
- return;
+ if (targets !== undefined) {
+ if (!_.isArray(targets)) {
+ targets = [targets];
}
- var object;
- if (!(target instanceof jQuery)) {
- try {
- object = $(target);
- } catch (exc) {
- log.error("Error while attempting to jquery-fy target", target, "of view model", viewModel.constructor.name, ":", (exc.stack || exc));
+ viewModel._bindings = [];
+
+ _.each(targets, function (target) {
+ if (target === undefined) {
+ log.error("Undefined target for view model", viewModel.constructor.name);
return;
}
- } else {
- object = target;
- }
- if (object === undefined || !object.length) {
- log.info("Did not bind view model", viewModel.constructor.name, "to target", target, "since it does not exist");
- return;
- }
+ var object;
+ if (!(target instanceof jQuery)) {
+ try {
+ object = $(target);
+ } catch (exc) {
+ log.error("Error while attempting to jquery-fy target", target, "of view model", viewModel.constructor.name, ":", (exc.stack || exc));
+ return;
+ }
+ } else {
+ object = target;
+ }
- var element = object.get(0);
- if (element === undefined) {
- log.info("Did not bind view model", viewModel.constructor.name, "to target", target, "since it does not exist");
- return;
- }
+ if (object === undefined || !object.length) {
+ log.info("Did not bind view model", viewModel.constructor.name, "to target", target, "since it does not exist");
+ return;
+ }
- try {
- ko.applyBindings(viewModel, element);
- viewModel._bindings.push(target);
+ var element = object.get(0);
+ if (element === undefined) {
+ log.info("Did not bind view model", viewModel.constructor.name, "to target", target, "since it does not exist");
+ return;
+ }
- callViewModel(viewModel, "onBoundTo", [target, element], true);
+ try {
+ ko.applyBindings(viewModel, element);
+ viewModel._bindings.push(target);
- log.debug("View model", viewModel.constructor.name, "bound to", target);
- } catch (exc) {
- log.error("Could not bind view model", viewModel.constructor.name, "to target", target, ":", (exc.stack || exc));
- }
- });
- }
+ callViewModel(viewModel, "onBoundTo", [target, element], true);
- viewModel._unbound = viewModel._bindings === undefined || viewModel._bindings.length === 0;
- viewModel._bound = viewModel._bindings && viewModel._bindings.length > 0;
+ log.debug("View model", viewModel.constructor.name, "bound to", target);
+ } catch (exc) {
+ log.error("Could not bind view model", viewModel.constructor.name, "to target", target, ":", (exc.stack || exc));
+ }
+ });
+ }
- callViewModel(viewModel, "onAfterBinding");
- } catch (exc) {
- var name;
- try {
- name = viewModel.constructor.name;
+ viewModel._unbound = viewModel._bindings === undefined || viewModel._bindings.length === 0;
+ viewModel._bound = viewModel._bindings && viewModel._bindings.length > 0;
+
+ callViewModel(viewModel, "onAfterBinding");
} catch (exc) {
- name = "n/a";
+ var name;
+ try {
+ name = viewModel.constructor.name;
+ } catch (exc) {
+ name = "n/a";
+ }
+ log.error("Error while processing view model", name, "for binding:", (exc.stack || exc));
}
- log.error("Error while processing view model", name, "for binding:", (exc.stack || exc));
- }
- });
+ });
- callViewModels(allViewModels, "onAllBound", [allViewModels]);
- log.info("... binding done");
+ callViewModels(allViewModels, "onAllBound", [allViewModels]);
+ log.info("... binding done");
- // make sure we can track the browser tab visibility
- OctoPrint.coreui.onBrowserVisibilityChange(function(status) {
- log.debug("Browser tab is now " + (status ? "visible" : "hidden"));
- callViewModels(allViewModels, "onBrowserTabVisibilityChange", [status]);
- });
+ // make sure we can track the browser tab visibility
+ OctoPrint.coreui.onBrowserVisibilityChange(function (status) {
+ log.debug("Browser tab is now " + (status ? "visible" : "hidden"));
+ callViewModels(allViewModels, "onBrowserTabVisibilityChange", [status]);
+ });
- $(window).on("hashchange", function() {
- OctoPrint.coreui.updateTab();
- });
+ $(window).on("hashchange", function () {
+ OctoPrint.coreui.updateTab();
+ });
- log.info("Application startup complete");
+ log.info("Application startup complete");
- viewModelMap["uiStateViewModel"].loading(false);
+ viewModelMap["uiStateViewModel"].loading(false);
+ } catch (exc) {
+ viewModelMap["uiStateViewModel"].showLoadingError("Application startup failed.");
+ throw(exc);
+ }
// startup complete
callViewModels(allViewModels, "onStartupComplete");
@@ -740,6 +745,9 @@ $(function() {
// Decoupling all consecutive calls from this done event handler hence is an easy way
// to avoid this problem. A zero timeout should do the trick nicely.
window.setTimeout(bindViewModels, 0);
+ })
+ .fail(function() {
+ viewModelMap["uiStateViewModel"].showLoadingError("Initial settings fetch failed.");
});
};
@@ -787,6 +795,9 @@ $(function() {
// This is to ensure that we have no concurrent requests triggered by socket events
// overriding each other's session during app initialization
dataUpdater.initialized();
+ })
+ .fail(function() {
+ viewModelMap["uiStateViewModel"].showLoadingError("Passive login failed.");
});
};
@@ -797,10 +808,14 @@ $(function() {
dataUpdater.connectCallback = onServerConnect;
// perform passive login first
- onServerConnect().done(function() {
- // then trigger a settings fetch
- window.setTimeout(fetchSettings, 0);
- });
+ onServerConnect()
+ .done(function() {
+ // then trigger a settings fetch
+ window.setTimeout(fetchSettings, 0);
+ });
+ })
+ .fail(function() {
+ viewModelMap["uiStateViewModel"].showLoadingError("Socket connection failed.");
});
}
);
diff --git a/src/octoprint/static/js/app/viewmodels/uistate.js b/src/octoprint/static/js/app/viewmodels/uistate.js
index 0acfcecb8..30559be46 100644
--- a/src/octoprint/static/js/app/viewmodels/uistate.js
+++ b/src/octoprint/static/js/app/viewmodels/uistate.js
@@ -5,7 +5,8 @@ $(function() {
self.loginState = parameters[0];
self.access = parameters[1];
- self.loading = ko.observable(true);
+ self.loading = ko.observable(CONFIG_LOADINGANIMATION);
+ self.loading_error = ko.observable(false);
self.needlogin = ko.computed(function() {
return !self.loading() && !self.loginState.hasPermissionKo(self.access.permissions.STATUS)();
});
@@ -38,6 +39,15 @@ $(function() {
}
});
};
+
+ self.showLoadingError = function(error) {
+ log.error("Loading error: " + error + " Please check prior messages and 'octoprint.log' for possible reasons.");
+
+ // we can't do this with bindings since the bindings are not initialized yet if we need this
+ $("#page-container-loading-header").text("Loading failed");
+ $("#page-container-loading-spinner").removeClass("fa-spinner fa-spin").addClass("fa-exclamation-triangle text-error");
+ $("#page-container-loading-error").html(error + " " + _.sprintf("Please check your browser's error console and octoprint.log for possible reasons.", {browser: "https://faq.octoprint.org/browser-console", octoprint: "https://faq.octoprint.org/logs"})).show();
+ };
}
OCTOPRINT_VIEWMODELS.push({
diff --git a/src/octoprint/templates/index.jinja2 b/src/octoprint/templates/index.jinja2
index fe4b6192d..198692723 100644
--- a/src/octoprint/templates/index.jinja2
+++ b/src/octoprint/templates/index.jinja2
@@ -16,7 +16,7 @@
{% include 'initscript.jinja2' %}