diff --git a/src/common/db/Database.py b/src/common/db/Database.py index 8bf817983..6d8718595 100644 --- a/src/common/db/Database.py +++ b/src/common/db/Database.py @@ -258,11 +258,12 @@ class Database: if "id" not in plugin: settings = plugin plugin = { - "id": "default", + "id": "general", "order": 999, - "name": "Default", - "description": "Default settings", + "name": "General", + "description": "The general settings for the server", "version": "0.1", + "external": False, } else: settings = plugin.pop("settings", {}) diff --git a/src/ui/src/Config.py b/src/ui/src/Config.py index 50abcb3cd..67703de02 100644 --- a/src/ui/src/Config.py +++ b/src/ui/src/Config.py @@ -139,6 +139,15 @@ class Config: if not exists("/usr/sbin/nginx"): plugins = self.__db.get_plugins() plugins.sort(key=lambda x: x["name"]) + + general_plugin = None + for x, plugin in enumerate(plugins): + if plugin["name"] == "General": + general_plugin = plugin + del plugins[x] + break + plugins.insert(0, general_plugin) + return plugins plugins = [] @@ -167,6 +176,22 @@ class Config: plugins.append(plugin) plugins.sort(key=lambda x: x["name"]) + + with open("/usr/share/bunkerweb/settings.json", "r") as f: + plugins.insert( + 0, + { + "id": "general", + "order": 999, + "name": "General", + "description": "The general settings for the server", + "version": "0.1", + "external": False, + "page": False, + "settings": json_load(f), + }, + ) + return plugins def get_settings(self) -> dict: diff --git a/src/ui/templates/global_config.html b/src/ui/templates/global_config.html index b73f2e9f4..fa0981a0d 100644 --- a/src/ui/templates/global_config.html +++ b/src/ui/templates/global_config.html @@ -35,10 +35,6 @@ config["CONFIG"].get_config() %} > - - {% include "settings_general.html" %} - - {% include "settings_plugins.html" %} diff --git a/src/ui/templates/settings_general.html b/src/ui/templates/settings_general.html deleted file mode 100644 index 5d3cccefc..000000000 --- a/src/ui/templates/settings_general.html +++ /dev/null @@ -1,194 +0,0 @@ -{% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-') -%} - -{% set plugins = config["CONFIG"].get_plugins() %} -{% set global_config = config["CONFIG"].get_config() %} - -
- -
-
GENERAL
-
- General config : HTTP, DNS, LOG, API... -
-
-
- {% for - setting, value in config["CONFIG"].get_settings().items() %} {% - if current_endpoint == "global-config" and value["context"] == "global" and "label" in value %} -
- -
-
{{value["label"]}}
- - - - - - -
- - - - {% if value["type"] != "select" and value["type"] != "check" %} -
- - - {% if value['type'] == "password" %} -
- - -
- {%endif%} -
- {% endif %} - - - - {% if value["type"] == "select" %} - - - - - -
- {% for item in value['select'] %} - {% if global_config[setting]['value'] and global_config[setting]['value'] == item %} - - {% elif not global_config[setting]['value'] and value['default'] == item %} - - {% endif %} - {% endfor %} - - - - -
- - {% endif %} - - - {% if value["type"] == "check" %} -
- - - - -
- {% endif %} - - - - - - -
- - {% endif %} {% endfor %} -
-
- \ No newline at end of file diff --git a/src/ui/templates/settings_plugins.html b/src/ui/templates/settings_plugins.html index e0f9c273e..b100f397a 100644 --- a/src/ui/templates/settings_plugins.html +++ b/src/ui/templates/settings_plugins.html @@ -1,35 +1,14 @@ {% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-') %} {% set global_config = config["CONFIG"].get_config() %} -{% if current_endpoint == "services"%} - {% set plugins = [{ - "id": "general", - "order": 999, - "name": "General", - "description": "The general settings for the server", - "version": "0.1", - "settings": { - "SERVER_NAME": { - "context": "multisite", - "default": "", - "help": "List of the virtual hosts served by bunkerweb.", - "id": "SERVER_NAME", - "label": "Server name", - "regex": ".*", - "type": "text", - } - } - }] + config["CONFIG"].get_plugins() %} -{% else %} - {% set plugins = config["CONFIG"].get_plugins() %} -{%endif%} +{% set plugins = config["CONFIG"].get_plugins() %} {% for plugin in plugins %}
@@ -190,7 +169,6 @@ {% if value["type"] == "check" %}
- + {% if value["type"] == "check" %}
- - +