From a8f62da8dba66cc8b7902e2f7bf31b97497f347f Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 17 Mar 2024 00:42:10 +0100 Subject: [PATCH] ui - better wizard user experience, fix duplicate logs, remove useless print, rename version section and force recheck of pro license when updated --- src/ui/main.py | 10 +++++++--- src/ui/templates/account.html | 24 ++++++++++++------------ src/ui/templates/setup.html | 8 ++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/ui/main.py b/src/ui/main.py index 48f9e6b37..10e183be5 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -88,10 +88,9 @@ app.config["SECRET_KEY"] = getenv("FLASK_SECRET", urandom(32)) PROXY_NUMBERS = int(getenv("PROXY_NUMBERS", "1")) app.wsgi_app = ReverseProxied(app.wsgi_app, x_for=PROXY_NUMBERS, x_proto=PROXY_NUMBERS, x_host=PROXY_NUMBERS, x_prefix=PROXY_NUMBERS) gunicorn_logger = getLogger("gunicorn.error") -app.logger.handlers = gunicorn_logger.handlers +app.logger = gunicorn_logger app.logger.setLevel(gunicorn_logger.level) - login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = "login" @@ -686,6 +685,12 @@ def account(): if error: return redirect_flash_error("The license key variable checks returned error", "account", True) + # Force job to contact PRO API + # by setting the last check to None + metadata = db.get_metadata() + metadata["last_pro_check"] = None + db.set_pro_metadata(metadata) + # Reload instances app.config["RELOADING"] = True app.config["LAST_RELOAD"] = time() @@ -988,7 +993,6 @@ def global_config(): if request.method == "POST": # Check variables variables = request.form.to_dict().copy() - print(variables, flush=True) del variables["csrf_token"] # Edit check fields and remove already existing ones diff --git a/src/ui/templates/account.html b/src/ui/templates/account.html index c0c95392c..7d21b08b2 100644 --- a/src/ui/templates/account.html +++ b/src/ui/templates/account.html @@ -5,9 +5,9 @@
SETTINGS
{% set tabs = [ { - "name": "Version", - "id": "version", - "description": "Version informations" + "name": "PRO", + "id": "pro", + "description": "BunkerWeb PRO" }, { "name": "Username", @@ -55,23 +55,23 @@ - {% set version_info = { + {% set pro_info = { "message" : "Pro version" if is_pro_version else "Pro version but exceeding services" if pro_status == "active" and pro_overlapped else "Pro version is expired" if pro_status == "expired" else "Pro version suspended" if pro_status == "suspended" else "You are using free version", "link_message" : "All features available" if is_pro_version else "Awaiting compliance" if pro_status == "active" and pro_overlapped else "Renew license" if pro_status == "expired" else "Talk to team" if pro_status == "suspended" else "Upgrade to pro", "icon" : "pro" if is_pro_version else "free" } %} -
- VERSION + PRO
-

{{ version_info['message'] }}

+

{{ pro_info['message'] }}

- {% if version_info['link_message'] %} + {% if pro_info['link_message'] %}
{{ version_info['link_message'] }} + href="https://panel.bunkerweb.io/?utm_campaign=self&utm_source=ui#pro">{{ pro_info['link_message'] }}
{% endif %} @@ -139,7 +139,7 @@ id="license" name="license" class="col-span-12 regular-input" - placeholder="key from panel" + placeholder="enter new license key" value="" pattern="^.*$" required /> diff --git a/src/ui/templates/setup.html b/src/ui/templates/setup.html index 813cda4f6..fe771b61c 100644 --- a/src/ui/templates/setup.html +++ b/src/ui/templates/setup.html @@ -414,9 +414,13 @@ } updateResume() { + this.servInp.value = this.servInp.value.replace('https://', '').replace('http://', ''); + if (!this.urlInp.value.startsWith("/")) { + this.urlInp.value = "/" + this.urlInp.value; + } this.resumeEl.textContent = `http${ this.sslCheck.getAttribute("data-checked") === "true" ? "s" : "" - }://${this.servInp.value.replace('https://', '').replace('http://', '')}${this.urlInp.value}`; + }://${this.servInp.value}${this.urlInp.value}`; } } @@ -562,7 +566,7 @@ const api = `http${ this.sslCheck.getAttribute("data-checked") === "true" ? "s" : "" - }://${this.servInp.value.replace('https://', '').replace('http://', '')}${this.urlInp.value}`; + }://${this.servInp.value}${this.urlInp.value}`; fetch(window.location.href, { method: "POST",