Allow defining order of UI components through config.yaml
config.yaml now has a new section "components" located under "appearance" which allows configuring the order and list of disabled components. Example:
appearance:
components:
order:
tab:
- control
- temperature
- gcodeviewer
- terminal
- timelapse
disabled:
sidebar:
- files
This would make the "Control" tab the first tab, followed by the usual order (plugins afterwards), and disable the Files sidebar component.
This commit is contained in:
parent
2b51501a57
commit
a87c3f6d4d
2 changed files with 28 additions and 13 deletions
|
|
@ -286,24 +286,19 @@ def index():
|
|||
|
||||
#~~ order internal templates and plugins
|
||||
|
||||
templates["navbar"]["order"] = ["settings", "systemmenu", "login"]
|
||||
templates["sidebar"]["order"] = ["connection", "state", "files"]
|
||||
templates["tab"]["order"] = ["temperature", "control", "gcodeviewer", "terminal", "timelapse"]
|
||||
templates["settings"]["order"] = [
|
||||
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
||||
"section_features", "features", "webcam", "accesscontrol", "api",
|
||||
"section_octoprint", "folders", "appearance", "logs"
|
||||
]
|
||||
|
||||
# make sure that
|
||||
# 1) we only have keys in our ordered list that we have entries for and
|
||||
# 2) we have all entries located somewhere within the order
|
||||
|
||||
for t in ("navbar", "sidebar", "tab", "settings", "generic"):
|
||||
templates[t]["order"] = [x for x in templates[t]["order"] if x in templates[t]["entries"]]
|
||||
all_ordered = set(templates[t]["order"])
|
||||
configured_order = settings().get(["appearance", "components", "order", t], merged=True)
|
||||
configured_disabled = settings().get(["appearance", "components", "disabled", t])
|
||||
templates[t]["order"] = [x for x in configured_order if x in templates[t]["entries"] and not x in configured_disabled]
|
||||
|
||||
missing_in_order = set(templates[t]["entries"].keys()).difference(all_ordered)
|
||||
all_ordered = set(templates[t]["order"])
|
||||
all_disabled = set(configured_disabled)
|
||||
|
||||
missing_in_order = set(templates[t]["entries"].keys()).difference(all_ordered).difference(all_disabled)
|
||||
if len(missing_in_order) == 0:
|
||||
continue
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,27 @@ default_settings = {
|
|||
"appearance": {
|
||||
"name": "",
|
||||
"color": "default",
|
||||
"colorTransparent": False
|
||||
"colorTransparent": False,
|
||||
"components": {
|
||||
"order": {
|
||||
"navbar": ["settings", "systemmenu", "login"],
|
||||
"sidebar": ["connection", "state", "files"],
|
||||
"tab": ["temperature", "control", "gcodeviewer", "terminal", "timelapse"],
|
||||
"settings": [
|
||||
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
||||
"section_features", "features", "webcam", "accesscontrol", "api",
|
||||
"section_octoprint", "folders", "appearance", "logs"
|
||||
],
|
||||
"generic": []
|
||||
},
|
||||
"disabled": {
|
||||
"navbar": [],
|
||||
"sidebar": [],
|
||||
"tab": [],
|
||||
"settings": [],
|
||||
"generic": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"controls": [],
|
||||
"system": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue