Merge branch 'maintenance' into devel
This commit is contained in:
commit
c5db904012
4 files changed
+77
-1
No files matched your search
@@ -62,6 +62,25 @@ def getSystemInfo():
|
||||
return jsonify(systeminfo=systeminfo)
|
||||
|
||||
|
||||
@api.route("/system/startup", methods=["GET"])
|
||||
@no_firstrun_access
|
||||
@Permissions.SYSTEM.require(403)
|
||||
def getStartupInformation():
|
||||
from octoprint.server import safe_mode
|
||||
from octoprint.settings import settings
|
||||
|
||||
result = {}
|
||||
|
||||
if safe_mode is not None:
|
||||
result["safe_mode"] = safe_mode
|
||||
|
||||
flagged_basefolders = settings().flagged_basefolders
|
||||
if flagged_basefolders:
|
||||
result["flagged_basefolders"] = flagged_basefolders
|
||||
|
||||
return jsonify(startup=result)
|
||||
|
||||
|
||||
def _usageForFolders():
|
||||
data = {}
|
||||
for folder_name in s().get(["folder"]).keys():
|
||||
|
||||
@@ -493,6 +493,8 @@ class Settings:
|
||||
self._path_update_callbacks = defaultdict(list)
|
||||
self._deprecated_paths = defaultdict(dict)
|
||||
|
||||
self.flagged_basefolders = {}
|
||||
|
||||
self._init_basedir(basedir)
|
||||
|
||||
if configfile is not None:
|
||||
@@ -1800,7 +1802,7 @@ class Settings:
|
||||
check_writable=check_writable,
|
||||
deep_check_writable=deep_check_writable,
|
||||
)
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
if folder != default_folder and allow_fallback:
|
||||
self._logger.exception(
|
||||
"Invalid configured {} folder at {}, attempting to "
|
||||
@@ -1815,6 +1817,7 @@ class Settings:
|
||||
deep_check_writable=deep_check_writable,
|
||||
)
|
||||
folder = default_folder
|
||||
self.flagged_basefolders[type] = str(exc)
|
||||
|
||||
try:
|
||||
self.remove(["folder", type])
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
var url = "api/system";
|
||||
var commandUrl = "api/system/commands";
|
||||
var infoUrl = "api/system/info";
|
||||
var startupUrl = "api/system/startup";
|
||||
|
||||
var OctoPrintSystemClient = function (base) {
|
||||
this.base = base;
|
||||
@@ -29,6 +30,10 @@
|
||||
return this.base.get(infoUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintSystemClient.prototype.getStartupData = function (opts) {
|
||||
return this.base.get(startupUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintClient.registerComponent("system", OctoPrintSystemClient);
|
||||
return OctoPrintSystemClient;
|
||||
});
|
||||
@@ -8,8 +8,11 @@ $(function () {
|
||||
self.lastCommandResponse = undefined;
|
||||
self.systemActions = ko.observableArray([]);
|
||||
|
||||
self._startupNotification = undefined;
|
||||
|
||||
self.requestData = function () {
|
||||
self.requestCommandData();
|
||||
self.requestStartupData();
|
||||
};
|
||||
|
||||
self.requestCommandData = function () {
|
||||
@@ -52,6 +55,52 @@ $(function () {
|
||||
self.systemActions(actions);
|
||||
};
|
||||
|
||||
self.requestStartupData = function () {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.SYSTEM)) {
|
||||
return $.Deferred().reject().promise();
|
||||
}
|
||||
|
||||
return OctoPrint.system.getStartupData().done(self.fromStartupResponse);
|
||||
};
|
||||
|
||||
self.fromStartupResponse = function (response) {
|
||||
const startupData = response.startup;
|
||||
|
||||
if (startupData.flagged_basefolders) {
|
||||
if (self._startupNotification) self._startupNotification.remove();
|
||||
|
||||
let html =
|
||||
"<p>" +
|
||||
gettext(
|
||||
"The following folder(s) were found to be unusable by OctoPrint during startup and have been turned back to the default:"
|
||||
) +
|
||||
"</p>";
|
||||
html += "<ul>";
|
||||
_.each(startupData.flagged_basefolders, (value, key) => {
|
||||
html +=
|
||||
"<li><code>" +
|
||||
_.escape(key) +
|
||||
"</code>: " +
|
||||
_.escape(value) +
|
||||
"</li>";
|
||||
});
|
||||
html += "</ul>";
|
||||
html +=
|
||||
"<p>" +
|
||||
gettext(
|
||||
"Please check the permissions of these folders and make sure they are writable by the user running OctoPrint. In case of network shares, make sure they have been mounted <em>before</em> OctoPrint starts."
|
||||
) +
|
||||
"</p>";
|
||||
|
||||
self._startupNotification = new PNotify({
|
||||
title: gettext("Warning"),
|
||||
text: html,
|
||||
type: "warning",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.triggerCommand = function (commandSpec) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.SYSTEM)) {
|
||||
return $.Deferred().reject().promise();
|
||||
|
||||
Reference in new issue
Block a user