new_functions_and_fixes #1

Merged
gru merged 33 commits from new_functions_and_fixes into master 2025-11-03 14:35:20 +01:00
Showing only changes of commit f2c9f166f6 - Show all commits

View File

@@ -43,7 +43,7 @@ def reload_haproxy():
@requires_auth @requires_auth
def index(): def index():
if request.method == 'POST': if request.method == 'POST':
# Frontend IP i port (używane do generowania nazwy frontendu) # Frontend IP i port
frontend_ip = request.form['frontend_ip'] frontend_ip = request.form['frontend_ip']
frontend_port = request.form['frontend_port'] frontend_port = request.form['frontend_port']
frontend_hostname = request.form.get('frontend_hostname', '').strip() frontend_hostname = request.form.get('frontend_hostname', '').strip()
@@ -152,9 +152,8 @@ def index():
acl_action = '' acl_action = ''
acl_backend_name = '' acl_backend_name = ''
# ===== GENERUJ FRONTEND NAME ZAMIAST PRZYJMOWAĆ OD USERA ===== # Frontend name (None - will be generated)
# frontend_name będzie generowany w haproxy_config.py frontend_name = None
frontend_name = None # Będzie wygenerowany automatycznie
# Call update_haproxy_config # Call update_haproxy_config
message = update_haproxy_config( message = update_haproxy_config(
@@ -210,9 +209,25 @@ def index():
custom_acl_redirect_url=custom_acl_redirect_url custom_acl_redirect_url=custom_acl_redirect_url
) )
# ===== RELOAD HAPROXY ===== # ===== DETERMINE MESSAGE TYPE =====
message_type = "success" if "successfully" in message.lower() else "danger" message_type = "success" # Default
# Check for ERROR conditions
if "error" in message.lower():
message_type = "danger"
elif "failed" in message.lower():
message_type = "danger"
elif "already exists" in message.lower():
message_type = "danger"
elif "cannot add" in message.lower():
message_type = "danger"
# SUCCESS conditions
elif "configuration updated successfully" in message.lower():
message_type = "success"
elif "backend added to existing" in message.lower():
message_type = "success"
# ===== RELOAD HAPROXY (JEŚLI SUCCESS) =====
if message_type == "success": if message_type == "success":
reload_ok, reload_msg = reload_haproxy() reload_ok, reload_msg = reload_haproxy()
if reload_ok: if reload_ok:
@@ -225,8 +240,8 @@ def index():
return render_template('index.html', return render_template('index.html',
message=message, message=message,
message_type=message_type) message_type=message_type)
# GET request - display stats # GET request - display stats
frontend_count, backend_count, acl_count, layer7_count, layer4_count = count_frontends_and_backends() frontend_count, backend_count, acl_count, layer7_count, layer4_count = count_frontends_and_backends()
return render_template('index.html', return render_template('index.html',