diff --git a/app/config.py b/app/config.py index 5a52e1c6..afe94339 100644 --- a/app/config.py +++ b/app/config.py @@ -9,7 +9,7 @@ from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('config.html') -print('Content-type: text/html\n') + funct.check_login() form = cgi.FieldStorage() @@ -34,7 +34,7 @@ hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir') if serv is not None: cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg" -if form.getvalue('serv') is not None and form.getvalue('open') is not None : +if serv is not None and form.getvalue('open') is not None : try: funct.logging(serv, "config.py open config") @@ -52,7 +52,7 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None : os.system("/bin/mv %s %s.old" % (cfg, cfg)) -if form.getvalue('serv') is not None and form.getvalue('config') is not None: +if serv is not None and form.getvalue('config') is not None: try: funct.logging(serv, "config.py edited config") except: @@ -76,21 +76,27 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None: stderr = funct.upload_and_restart(serv, cfg, just_save=save) funct.diff_config(oldcfg, cfg) + + if save: + c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) + c["restart"] = form.getvalue('serv') + print(c) os.system("/bin/rm -f " + hap_configs_dir + "*.old") -output_from_parsed_template = template.render(h2 = 1, title = "Working with HAProxy configs", - role = sql.get_user_role_by_uuid(user_id.value), - action = "config.py", - user = user, - select_id = "serv", - serv = serv, - aftersave = aftersave, - config = config_read, - cfg = cfg, - selects = servers, - stderr = stderr, - error = error, - note = 1, - token = token) -print(output_from_parsed_template) \ No newline at end of file +print('Content-type: text/html\n') +template = template.render(h2 = 1, title = "Working with HAProxy configs", + role = sql.get_user_role_by_uuid(user_id.value), + action = "config.py", + user = user, + select_id = "serv", + serv = serv, + aftersave = aftersave, + config = config_read, + cfg = cfg, + selects = servers, + stderr = stderr, + error = error, + note = 1, + token = token) +print(template) \ No newline at end of file diff --git a/app/configver.py b/app/configver.py index d768696f..24b48ddb 100644 --- a/app/configver.py +++ b/app/configver.py @@ -8,19 +8,16 @@ from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('configver.html') -print('Content-type: text/html\n') funct.check_login() funct.page_for_admin(level = 2) form = cgi.FieldStorage() serv = form.getvalue('serv') view = form.getvalue('view') -configver = form.getvalue('configver') hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir') -config_read = "" stderr = "" aftersave = "" -error = "" +configver = "" try: cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) @@ -31,10 +28,11 @@ try: except: pass -if form.getvalue('serv') is not None and form.getvalue('config') is not None: +if serv is not None and form.getvalue('config') is not None: configver = form.getvalue('configver') configver = hap_configs_dir + configver save = form.getvalue('save') + aftersave = 1 try: funct.logging(serv, "configver.py upload old config %s" % configver) except: @@ -46,25 +44,27 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None: funct.upload_and_restart(master[0], configver, just_save=save) stderr = funct.upload_and_restart(serv, configver, just_save=save) - aftersave = 1 - -output_from_parsed_template = template.render(h2 = 1, title = "Old Versions HAProxy config", - role = sql.get_user_role_by_uuid(user_id.value), - action = "configver.py", - user = user, - select_id = "serv", - serv = serv, - return_files = funct.get_files(), - aftersave = aftersave, - config = config_read, - configver = configver, - selects = servers, - stderr = stderr, - open = form.getvalue('open'), - onclick = "showUploadConfig()", - error = error, - note = 1, - token = token, - view = view) -print(output_from_parsed_template) + if save: + c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) + c["restart"] = form.getvalue('serv') + print(c) + +print('Content-type: text/html\n') +template = template.render(h2 = 1, title = "Old Versions HAProxy config", + role = sql.get_user_role_by_uuid(user_id.value), + action = "configver.py", + user = user, + select_id = "serv", + serv = serv, + return_files = funct.get_files(), + aftersave = aftersave, + configver = configver, + selects = servers, + stderr = stderr, + open = form.getvalue('open'), + onclick = "showUploadConfig()", + note = 1, + token = token, + view = view) +print(template) diff --git a/app/map.py b/app/map.py deleted file mode 100644 index edcc8d28..00000000 --- a/app/map.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -import os -import sql -import http -import funct -import sql -from jinja2 import Environment, FileSystemLoader -env = Environment(loader=FileSystemLoader('templates/')) -template = env.get_template('config.html') - -print('Content-type: text/html\n') -funct.check_login() - -try: - cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) - user_id = cookie.get('uuid') - user = sql.get_user_name_by_uuid(user_id.value) - servers = sql.get_dick_permit() - token = sql.get_token(user_id.value) -except: - pass - -output_from_parsed_template = template.render(h2 = 1, title = "Show Map", - role = sql.get_user_role_by_uuid(user_id.value), - user = user, - onclick = "showMap()", - select_id = "serv", - selects = servers, - token = token) -print(output_from_parsed_template) \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index badfd130..52468137 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -48,8 +48,7 @@
  • Stats
  • Overview
  • Stats
  • -
  • Logs
  • -
  • Map
  • +
  • Logs
  • Runtime API
  • Metrics
  • diff --git a/app/templates/config.html b/app/templates/config.html index 52bd84db..71742aa5 100644 --- a/app/templates/config.html +++ b/app/templates/config.html @@ -33,6 +33,7 @@ {% if not keepalived %} Show Compare + Map {% endif %}

    diff --git a/image/haproxy-wi-compare.jpeg b/image/haproxy-wi-compare.jpeg index 7050ca99..27dda513 100644 Binary files a/image/haproxy-wi-compare.jpeg and b/image/haproxy-wi-compare.jpeg differ diff --git a/image/haproxy-wi-config-edit.jpeg b/image/haproxy-wi-config-edit.jpeg index ce20bc1c..4693cb40 100644 Binary files a/image/haproxy-wi-config-edit.jpeg and b/image/haproxy-wi-config-edit.jpeg differ diff --git a/image/haproxy-wi-config-show.jpeg b/image/haproxy-wi-config-show.jpeg index 2346eb52..f50d779c 100644 Binary files a/image/haproxy-wi-config-show.jpeg and b/image/haproxy-wi-config-show.jpeg differ diff --git a/image/haproxy-wi-map.jpeg b/image/haproxy-wi-map.jpeg index 1c2e54b9..6f38ce12 100644 Binary files a/image/haproxy-wi-map.jpeg and b/image/haproxy-wi-map.jpeg differ diff --git a/inc/script.js b/inc/script.js index 1ffe991e..e782368e 100644 --- a/inc/script.js +++ b/inc/script.js @@ -266,6 +266,10 @@ function showLog() { } ); } function showMap() { + $("#ajax").empty(); + $("#ajax-compare").empty(); + $("#config").empty(); + $(".alert-info").empty(); var unique = $.now(); $.ajax( { url: "options.py", @@ -277,10 +281,10 @@ function showMap() { type: "GET", success: function( data ) { $("#ajax").html(data); + window.history.pushState("Show map", "Show map", cur_url[0]); } } ); } - function showRuntime() { if($('#save').prop('checked')) { saveCheck = "on";