From 3db2b2e0d4aaa58dd2167e99df68a481b492fa37 Mon Sep 17 00:00:00 2001 From: Jordan Blasenhauer Date: Fri, 23 Feb 2024 16:45:24 +0100 Subject: [PATCH] refactoring jinja template --- src/ui/templates/account.html | 837 +++++++++++++++---------------- src/ui/templates/bans_modal.html | 2 +- src/ui/templates/footer.html | 52 +- src/ui/templates/instances.html | 38 +- src/ui/templates/logs.html | 153 +++--- src/ui/templates/navbar.html | 71 --- src/ui/templates/plugins.html | 198 ++++---- src/ui/templates/reports.html | 364 ++++++-------- 8 files changed, 764 insertions(+), 951 deletions(-) delete mode 100644 src/ui/templates/navbar.html diff --git a/src/ui/templates/account.html b/src/ui/templates/account.html index 2daf9402a..b258ade37 100644 --- a/src/ui/templates/account.html +++ b/src/ui/templates/account.html @@ -1,90 +1,58 @@ {% extends "base.html" %} {% block content %} - {% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip() %}
SETTINGS
+ {% set tabs = [ + { + "name": "Global", + "id": "globlal", + "popover": "Global informations" + }, + { + "name": "Username", + "id": "username", + "popover": "Edit your username" + }, + { + "name": "Password", + "id": "password", + "popover": "Update your password" + }, + { + "name": "TOTP", + "id": "totp", + "popover": "Enabled / Disabled TOTP" + } + ] %} -
@@ -141,131 +96,74 @@

You are using {% if is_pro_version %} - pro{% else %}free{% endif %} version -

- + pro + {% else %} + free + {% endif %} + version +

+ - {% if not is_pro_version %} -
- Upgrade to pro -
- {% endif %} + {% if not is_pro_version %} +
+ Upgrade to pro +
+ {% endif %} - + - -
-
New password
- - -
- - -
-
- - -
-
Confirm new password
- - -
- - -
- Value does not match password -
-
- -
- - + + + + {% endblock content %} diff --git a/src/ui/templates/bans_modal.html b/src/ui/templates/bans_modal.html index 6d3363c66..afa05a998 100644 --- a/src/ui/templates/bans_modal.html +++ b/src/ui/templates/bans_modal.html @@ -47,7 +47,7 @@
-
+
diff --git a/src/ui/templates/footer.html b/src/ui/templates/footer.html index 0939cdbbc..ed22f6eb3 100644 --- a/src/ui/templates/footer.html +++ b/src/ui/templates/footer.html @@ -9,32 +9,36 @@
    + {% set nav_items = [ + { + "name": "BunkerWeb", + "link": "https://www.bunkerweb.io/?utm_campaign=self&utm_source=ui" + }, + { + "name": "Docs", + "link": "https://docs.bunkerweb.io/?utm_campaign=self&utm_source=ui" + }, + { + "name": "Privacy", + "link": "https://www.bunkerweb.io/privacy-policy" + }, + { + "name": "Blog", + "link": "https://www.bunkerity.com/fr/blog/?utm_campaign=self&utm_source=ui" + }, + { + "name": "License", + "link": "https://github.com/bunkerity/bunkerweb/blob/master/LICENSE" + } + ] %} + {% for item in nav_items %} - - - - -
-
+ {% endfor %} +
+ diff --git a/src/ui/templates/instances.html b/src/ui/templates/instances.html index 92c5c81fe..ba41b94b4 100644 --- a/src/ui/templates/instances.html +++ b/src/ui/templates/instances.html @@ -24,31 +24,21 @@
+ {% set instance_details = [{"name" : "TYPE", "value" : instance['_type']},{"name" : "HOSTNAME", "value" : instance['hostname']}] %} -
-

- TYPE -

-

- {{ instance._type }} -

-
- - -
-

- HOSTNAME -

-

- {{ instance.hostname }} -

-
+ {% for detail in instance_details %} +
+

+ {{ detail['name'] }} +

+

+ {{ detail['value'] }} +

+
+ {% endfor %}
diff --git a/src/ui/templates/logs.html b/src/ui/templates/logs.html index c92bb204c..95d20eec3 100644 --- a/src/ui/templates/logs.html +++ b/src/ui/templates/logs.html @@ -152,80 +152,93 @@ + {% set filters = [ + { + "type": "input", + "name": "Search", + "label": "search", + "id": "keyword", + "placeholder": "keyword", + "pattern": "(.*?)" + }, + { + "type": "select", + "name": "Logs type", + "id": "types", + "value": "all", + "values": [ + "all", + "message", + "error", + "warn", + "info", + "misc" + ] + } + ] %}
FILTERS
- -
-
- Search -
- -
- - -
-
- Select types -
- - - - - -
- + {% for filter in filters %} + {% if filter['type'] == 'input' %} + +
+
+ {{ filter['name'] }} +
+ + +
+ + {% endif %} + {% if filter['type'] == 'select' %} + +
+
+ {{ filter['name'] }} +
+ + + + + +
+ + {% endif %} + {% endfor %}
diff --git a/src/ui/templates/navbar.html b/src/ui/templates/navbar.html deleted file mode 100644 index ec7e38d96..000000000 --- a/src/ui/templates/navbar.html +++ /dev/null @@ -1,71 +0,0 @@ -{% set current_endpoint = current_endpoint or url_for(request.endpoint)[1:].split("/")[-1].strip() %} - diff --git a/src/ui/templates/plugins.html b/src/ui/templates/plugins.html index a59219989..2b1f17b10 100644 --- a/src/ui/templates/plugins.html +++ b/src/ui/templates/plugins.html @@ -3,40 +3,24 @@ {% include "plugins_modal.html" %} + {% set plugins_info = [ + {"name" : "TOTAL PLUGINS", "data" : plugins|length|string}, + {"name" : "INTERNAL PLUGINS", "data" : plugins_count_internal|string}, + {"name" : "EXTERNAL PLUGINS", "data" : plugins_count_external|string}, + {"name" : "PRO PLUGINS", "data" : plugins_count_pro|string}, + ] %}
INFO
-
-

- TOTAL PLUGINS -

-

- {{ plugins|length }} -

-
-
-

- INTERNAL PLUGINS -

-

- {{ plugins_count_internal }} -

-
-
-

- EXTERNAL PLUGINS -

-

- {{ plugins_count_external }} -

-
-
-

- PRO PLUGINS -

-

- {{ plugins_count_pro }} -

-
+ {% for info in plugins_info %} +
+

+ {{ info['name'] }} +

+

+ {{ info['data'] }} +

+
+ {% endfor %}
@@ -76,79 +60,91 @@ + {% set filters = [ + { + "type": "input", + "name": "Search", + "label": "search", + "id": "keyword", + "placeholder": "keyword", + "pattern": "(.*?)" + }, + { + "type": "select", + "name": "Plugin type", + "id": "types", + "value": "all", + "values": [ + "all", + "core", + "external", + "pro" + ] + } + ] %}
FILTER
- -
-
- Search -
- - -
- - -
-
- Select types -
- - - - - -
- + {% for filter in filters %} + {% if filter['type'] == 'input' %} + +
+
+ {{ filter['name'] }} +
+ + +
+ + {% endif %} + {% if filter['type'] == 'select' %} + +
+
+ {{ filter['name'] }} +
+ + + + + +
+ + {% endif %} + {% endfor %}
diff --git a/src/ui/templates/reports.html b/src/ui/templates/reports.html index 501559485..960c26235 100644 --- a/src/ui/templates/reports.html +++ b/src/ui/templates/reports.html @@ -1,9 +1,9 @@ {% extends "base.html" %} {% block content %} - {% set methods = [] %} - {% set codes = [] %} - {% set reasons = [] %} - {% set countries = [] %} + {% set methods = ["all"] %} + {% set codes = ["all"] %} + {% set reasons = ["all"] %} + {% set countries = ["all"] %} {% for report in reports %} {% if report["method"] not in methods %} {% if methods.append(report["method"]) %}{% endif %} @@ -53,201 +53,107 @@ + {% set filters = [ + { + "type": "input", + "name": "Search", + "label": "search", + "id": "keyword", + "placeholder": "ip, url, date, data", + "pattern": "(.*?)" + }, + { + "type": "select", + "name": "Country", + "id": "country", + "value": "all", + "values": countries + }, + { + "type": "select", + "name": "Methods", + "id": "methods", + "value": "all", + "values": methods + }, + { + "type": "select", + "name": "Status code", + "id": "status", + "value": "all", + "values": codes + }, + { + "type": "select", + "name": "Reason", + "id": "reason", + "value": "all", + "values": reasons + } + ] %}
FILTER
- -
-
- Search -
- - -
- - -
-
- Country -
- - - - - -
- - -
-
- Method -
- - - - - -
- - -
-
- Status code -
- - - - - -
- - -
-
- Reason -
- - - - - -
- + + + + +
+ + {% endif %} + {% endfor %}
@@ -258,34 +164,50 @@
+ {% set reports_header = [ + { + "name": "Date", + "position": "col-span-1" + }, + { + "name": "IP", + "position": "col-span-1" + }, + { + "name": "Country", + "position": "col-span-1" + }, + { + "name": "Method", + "position": "col-span-1" + }, + { + "name": "URL", + "position": "col-span-2" + }, + { + "name": "Code", + "position": "col-span-1" + }, + { + "name": "User agent", + "position": "col-span-2" + }, + { + "name": "Reason", + "position": "col-span-1" + }, + { + "name": "Data", + "position": "col-span-2" + } + ] %} -

- Date -

-

- IP -

-

- Country -

-

- Method -

-

- URL -

-

- Code -

-

- User agent -

-

- Reason -

-

- Data -

+ {% for header in reports_header %} +

+ {{ header['name'] }} +

+ {% endfor %}