From 4379e21ea50e937b252e6e17ba7a93f89ae864d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Wed, 14 Dec 2022 11:27:00 +0100 Subject: [PATCH] Show dirs of every services even if they don't have a custom config --- src/ui/main.py | 7 ++++++- src/ui/utils.py | 40 +++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/ui/main.py b/src/ui/main.py index 890b93025..a4c68af8a 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -684,7 +684,12 @@ def configs(): "configs.html", folders=[ path_to_dict( - "/etc/bunkerweb/configs", db_configs=db_configs, integration=integration + "/etc/bunkerweb/configs", + db_configs=db_configs, + integration=integration, + services=app.config["CONFIG"] + .get_config()["SERVER_NAME"]["value"] + .split(" "), ) ], dark_mode=app.config["DARK_MODE"], diff --git a/src/ui/utils.py b/src/ui/utils.py index 7aaf727e5..9a44ffa10 100644 --- a/src/ui/utils.py +++ b/src/ui/utils.py @@ -32,6 +32,7 @@ def path_to_dict( is_cache: bool = False, db_configs: List[dict] = [], integration: str = "Linux", + services: List[str] = [], ) -> dict: if integration == "Linux": d = {"name": os.path.basename(path)} @@ -116,10 +117,22 @@ def path_to_dict( "type": "folder", "path": f"{path}/{config}", "can_create_files": True, - "can_create_folders": True, + "can_create_folders": False, "can_edit": False, "can_delete": False, - "children": [], + "children": [ + { + "name": service, + "type": "folder", + "path": f"{path}/{config}/{service}", + "can_create_files": True, + "can_create_folders": False, + "can_edit": False, + "can_delete": False, + "children": [], + } + for service in services + ], } for config in config_types ], @@ -136,15 +149,7 @@ def path_to_dict( "content": conf["data"].decode("utf-8"), } - if ( - d["children"][config_types.index(type_lower)]["children"] - and conf["service_id"] - and conf["service_id"] - in [ - x["name"] - for x in d["children"][config_types.index(type_lower)]["children"] - ] - ): + if conf["service_id"]: d["children"][config_types.index(type_lower)]["children"][ [ x["name"] @@ -155,18 +160,7 @@ def path_to_dict( ]["children"].append(file_info) else: d["children"][config_types.index(type_lower)]["children"].append( - { - "name": conf["service_id"], - "type": "folder", - "path": f"{path}/{type_lower}/{conf['service_id']}", - "can_create_files": True, - "can_create_folders": False, - "can_edit": True, - "can_delete": True, - "children": [file_info], - } - if conf["service_id"] - else file_info + file_info ) return d