Pavel Loginov 2020-11-06 10:39:44 +06:00
parent 92103b2e37
commit 5d591fdf7f
3 changed files with 33 additions and 32 deletions

View File

@ -2,7 +2,7 @@
import os
import funct
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,extensions=['jinja2.ext.loopcontrols'])
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=['jinja2.ext.loopcontrols'])
template = env.get_template('sections.html')
print('Content-type: text/html\n')
@ -22,7 +22,7 @@ end_line = ""
try:
user, user_id, role, token, servers = funct.get_users_params()
except:
except Exception:
pass
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
@ -32,11 +32,11 @@ if serv is not None and open is not None:
error = funct.get_config(serv, cfg)
sections = funct.get_sections(cfg)
if serv is not None and section is not None :
if serv is not None and section is not None:
try:
funct.logging(serv, "sections.py open config")
except:
except Exception:
pass
start_line, end_line, config_read = funct.get_section_from_config(cfg, section)
@ -46,7 +46,7 @@ if serv is not None and section is not None :
if serv is not None and form.getvalue('config') is not None:
try:
funct.logging(serv, "config.py edited config")
except:
except Exception:
pass
config = form.getvalue('config')
@ -71,23 +71,22 @@ if serv is not None and form.getvalue('config') is not None:
os.system("/bin/rm -f " + hap_configs_dir + "*.old")
template = template.render(h2 = 1, title = "Working with HAProxy configs",
role = role,
action = "sections.py",
user = user,
select_id = "serv",
serv = serv,
aftersave = aftersave,
config = config_read,
cfg = cfg,
selects = servers,
stderr = stderr,
error = error,
start_line = start_line,
end_line = end_line,
section = section,
sections = sections,
note = 1,
versions = funct.versions(),
token = token)
template = template.render(h2=1, title="Working with HAProxy configs",
role=role,
action="sections.py",
user=user,
select_id="serv",
serv=serv,
aftersave=aftersave,
config=config_read,
cfg=cfg,
selects=servers,
stderr=stderr,
error=error,
start_line=start_line,
end_line=end_line,
section=section,
sections=sections,
versions=funct.versions(),
token=token)
print(template)

View File

@ -70,7 +70,7 @@
</p>
</form>
{% if note %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
<div class="alert alert-info"><b>Note:</b> When reconfiguring the master server, the slave will be reconfigured automatically</div>
{% endif %}
{% endif %}
{% endif %}
@ -80,7 +80,7 @@
{% include 'include/errors.html' %}
{% else %}
<div class="alert alert-success">Config is ok</div>
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to stats</a>
{% endif %}
{% endif %}
</center>

View File

@ -26,7 +26,7 @@
{% if config %}
{% if role <= 3 %}
<div id="config">
<h4>You are editting "{{section}}" from server {{ serv }}</h4>
<h4>You are editing "{{section}}" section from server {{ serv }}</h4>
</center>
<form action="{{ action }}" name="saveconfig" method="post">
<input type="hidden" value="{{ serv }}" name="serv">
@ -44,9 +44,11 @@
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
</p>
</form>
{% if note %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
{% endif %}
<div class="alert alert-info">
<p><b>Note:</b></p>
<p>When reconfiguring the master server, the slave will be reconfigured automatically</p>
<p>Unable to delete entire section</p>
</div>
<script>
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "haproxy", lineNumbers: true});
</script>
@ -68,8 +70,8 @@
{% include 'include/errors.html' %}
{% else %}
<div class="alert alert-success">Config is ok</div>
<a href="config.py?serv={{ serv }}" title="Working with HAProxy configs">Configs</a> |
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
<a href="config.py?serv={{ serv }}" title="Working with HAProxy config">Config</a> |
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to stats</a>
{% endif %}
<script>window.history.pushState("Config", "Config", cur_url[0])</script>
{% endif %}