🔒️ Limit folder config in UI to necessities

uploads, timelapse and watched folder should be
configurable in the UI, but limiting anything else
to the config.yaml file is fair considering it
rarely should have to be touched. This reduces
the likelihood of misconfiguration or abuse.
This commit is contained in:
Gina Häußge committed 2022-09-12 18:30:30 +02:00
1 parent 3c8f8c84f4
commit 0db80dc0c9
3 files changed
+8 -31

No files matched your search

+2 -8
View File
@@ -18,8 +18,7 @@ from octoprint.settings import settings, valid_boolean_trues
# ~~ settings
FOLDER_TYPES = ("uploads", "timelapse", "timelapse_tmp", "logs", "watched")
FOLDER_MAPPING = {"timelapseTmp": "timelapse_tmp"}
FOLDER_TYPES = ("uploads", "timelapse", "watched")
TIMELAPSE_BITRATE_PATTERN = re.compile(r"\d+[KMGTPEZY]?i?B?", flags=re.IGNORECASE)
@@ -269,8 +268,6 @@ def getSettings():
"folder": {
"uploads": s.getBaseFolder("uploads"),
"timelapse": s.getBaseFolder("timelapse"),
"timelapseTmp": s.getBaseFolder("timelapse_tmp"),
"logs": s.getBaseFolder("logs"),
"watched": s.getBaseFolder("watched"),
},
"temperature": {
@@ -464,10 +461,7 @@ def _saveSettings(data):
if "folder" in data:
try:
folders = {
FOLDER_MAPPING.get(folder, folder): path
for folder, path in data["folder"].items()
}
folders = data["folder"]
future = {}
for folder in FOLDER_TYPES:
future[folder] = s.getBaseFolder(folder)
@@ -255,8 +255,6 @@ $(function () {
self.folder_uploads = ko.observable(undefined);
self.folder_timelapse = ko.observable(undefined);
self.folder_timelapseTmp = ko.observable(undefined);
self.folder_logs = ko.observable(undefined);
self.folder_watched = ko.observable(undefined);
self.scripts_gcode_beforePrintStarted = ko.observable(undefined);
@@ -344,7 +342,7 @@ $(function () {
self.server_onlineCheckResolutionBroken(false);
};
var folderTypes = ["uploads", "timelapse", "timelapseTmp", "logs", "watched"];
var folderTypes = ["uploads", "timelapse", "watched"];
var checkForDuplicateFolders = function () {
_.each(folderTypes, function (folderType) {
@@ -20,26 +20,6 @@
<span class="help-block" data-bind="visible: testFolderConfigBroken.timelapse() || testFolderConfigOk.timelapse(), text: testFolderConfigText.timelapse"></span>
</div>
</div>
<div class="control-group" data-bind="css: {error: testFolderConfigError.timelapseTmp, success: testFolderConfigSuccess.timelapseTmp}">
<label class="control-label" for="settings-folderTimelapseTemp">{{ _('Timelapse Temp Folder') }}</label>
<div class="controls">
<div class="input-append input-block-level">
<input type="text" data-bind="value: folder_timelapseTmp, valueUpdate: 'input'" id="settings-folderTimelapseTemp">
<a class="btn add-on" data-bind="click: function() { testFolderConfig('timelapseTmp'); }, enable: folder_timelapseTmp() && !testFolderConfigBusy(), css: {disabled: !folder_timelapseTmp() || testFolderConfigBusy()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testFolderConfigBusy"></i> {{ _('Test') }}</a>
</div>
<span class="help-block" data-bind="visible: testFolderConfigBroken.timelapseTmp() || testFolderConfigOk.timelapseTmp(), text: testFolderConfigText.timelapseTmp"></span>
</div>
</div>
<div class="control-group" data-bind="css: {error: testFolderConfigError.logs, success: testFolderConfigSuccess.logs}">
<label class="control-label" for="settings-folderLogs">{{ _('Logs Folder') }}</label>
<div class="controls">
<div class="input-append input-block-level">
<input type="text" data-bind="value: folder_logs, valueUpdate: 'input'" id="settings-folderLogs">
<a class="btn add-on" data-bind="click: function() { testFolderConfig('logs'); }, enable: folder_logs() && !testFolderConfigBusy(), css: {disabled: !folder_logs() || testFolderConfigBusy()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testFolderConfigBusy"></i> {{ _('Test') }}</a>
</div>
<span class="help-block" data-bind="visible: testFolderConfigBroken.logs() || testFolderConfigOk.logs(), text: testFolderConfigText.logs"></span>
</div>
</div>
<div class="control-group" data-bind="css: {error: testFolderConfigError.watched, success: testFolderConfigSuccess.watched}">
<label class="control-label" for="settings-folderWatched">{{ _('Watched Folder') }}</label>
<div class="controls">
@@ -65,6 +45,11 @@
{% endtrans %}
</div>
<p>{% trans %}
Please note: Not all of the folders used by OctoPrint can be configured through the UI, only those most commonly moved to other places. If you need to configure other folders,
please do so by manually editing the configuration. See the docs for details.
{% endtrans %}</p>
<h3>{{ _('Disk space thresholds') }}</h3>
<p>{{ _('If the free disk space falls below these thresholds, OctoPrint will warn the user.') }}</p>