From a87c3f6d4de43037dde991c9e99c52aae19cdd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Mar 2015 12:37:07 +0100 Subject: [PATCH] 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. --- src/octoprint/server/__init__.py | 19 +++++++------------ src/octoprint/settings.py | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 0dc27c3d..df71be1e 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -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 diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 816813a5..483aa146 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -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": {