Pavel Loginov 4 years ago
parent 069aba1c03
commit 08b21981df

@ -1221,7 +1221,7 @@ def update_db_v_5_1_0_1(**kwargs):
def update_ver():
con, cur = get_cur()
sql = """update version set version = '5.1.0.0'; """
sql = """update version set version = '5.1.1.0'; """
try:
cur.execute(sql)
con.commit()

@ -439,6 +439,16 @@ def rewrite_section(start_line, end_line, config, section):
return return_config
def get_userlists(config, **kwargs):
return_config = ''
with open(config, 'r') as f:
for line in f:
if line.startswith('userlist'):
line = line.strip()
return_config += line + ','
return return_config
def get_backends_from_config(serv, backends='', **kwargs):
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
format_cfg = 'cfg'

@ -56,6 +56,9 @@ if serv is not None and form.getvalue('config') is not None:
end_line = form.getvalue('end_line')
aftersave = 1
if save == 'delete':
config = ''
config = funct.rewrite_section(start_line, end_line, oldcfg, config)
try:

@ -920,6 +920,29 @@
</tr>
</table>
</form>
<br />
<table>
<caption><h3>Existing UserList</h3></caption>
<tr>
<td class="addName">Select server: </td>
<td class="addOption">
<select required name="serv" id="existing_userlist_serv">
<option disabled selected>Choose server</option>
{% for select in selects %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
<div class="tooltip tooltipTop"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" title="Add Userlist" onclick="showUserlists()">Show Userlist</a>
</td>
</tr>
<tr id="existing_userlist_tr" style="display: none;">
<td class="addName">Existing Userlist:</td>
<td class="addOption" id="existing_userlist_ajax"></td>
</tr>
</table>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
In this section you can create userlists. And after use them in the "Add" sections
</div>

@ -87,12 +87,12 @@
</div><span class="param">{{- line -}}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
{%- set backend = line.split(' ') -%}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{-serv-}}#{{- backend[1]-}}" target="_blank">Stats</a>
<a href="/app/viewsttats.py?service=haproxy&serv={{-serv-}}#{{- backend[1]-}}" target="_blank">Stats</a>
</span>
{%- set backend = backend|join('_') -%}
{%- do section_name.update({i: backend}) -%}
@ -104,7 +104,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
@ -121,7 +121,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
@ -135,7 +135,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
@ -145,7 +145,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
@ -155,7 +155,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
@ -165,7 +165,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
@ -175,7 +175,7 @@
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
@ -208,10 +208,11 @@
</span><br />
{% endif %}
{%- if "bind" in line -%}
{%- set bind = line.split(':') -%}
{%- set bind = line.split(':')[1] -%}
{%- set bind = bind.split(' ') -%}
<script>
{% set k = i - 1 %}
$('#{{-section_name[k]|replace("\n", "")-}}').html('<a href="http://{{-serv-}}:{{-bind[1]|replace("\n", "")-}}" title="Open {{serv-}}:{{-bind[1]|replace("\n", "")-}}" target="_blank">Open</a>')
$('#{{-section_name[k]|replace("\n", "")-}}').html('<a href="http://{{-serv-}}:{{-bind[0]|replace("\n", "")-}}" title="Open {{serv-}}:{{-bind[0]|replace("\n", "")-}}" target="_blank">Open</a>')
</script>
{%- endif -%}
{%- endif -%}

@ -22,7 +22,7 @@
</td>
</tr>
{% for s in services %}
{% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' %}
{% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' or s.0 == 'portscanner' %}
<tr>
{% set is_need_update = 0 %}
{% if s.0 == 'smon' %}
@ -53,6 +53,13 @@
{% if s.3|float < metrics_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
{% elif s.0 == 'portscanner' %}
{% set service_name = 'Port scanner' %}
{% set service_link = 'portscanner' %}
{% set desc_link = 'https://haproxy-wi.org/services.py?service={{service_link}}' %}
{% if s.3|float < portscanner_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
{% endif %}
<td class="padding10 first-collumn">
{{service_name}}
@ -72,6 +79,8 @@
{{keep_ver}}
{% elif s.0 == 'metrics_haproxy' %}
{{metrics_ver}}
{% elif s.0 == 'portscanner' %}
{{portscanner_ver}}
{% endif %}
</b>
</td>

@ -42,13 +42,11 @@
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
{% if section != 'globals' and section != 'defaults' %}
<button type="submit" value="delete" name="save" class="btn btn-default">Delete this section</button>
{% endif %}
</p>
</form>
<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>

@ -1727,3 +1727,31 @@ function makeid(length) {
}
return result;
}
function showUserlists() {
var serv = $( "#existing_userlist_serv option:selected" ).val();
if (serv == 'Choose server') {
toastr.warning('Choose a server before');
} else {
$.ajax({
url: "options.py",
data: {
show_userlists: 1,
serv: serv,
token: $('#token').val()
},
type: "POST",
success: function (data) {
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
$('#existing_userlist_tr').show();
$('#existing_userlist_ajax').text('');
data = data.split(",");
for (i = 0; i < data.length; i++) {
$('#existing_userlist_ajax').append('<a href="sections.py?serv='+serv+'&section='+data[i]+'" title="Edit/Delete this userlist" target="_blank">'+data[i]+'</a> ');
}
}
}
});
}
}

@ -360,6 +360,7 @@ pre {
}
.overview-wi .overviewHead {
border-bottom: 1px solid #A4C7F5;
height: 25px;
}
.overview tr{
border-bottom: 1px solid #ddd;
@ -713,6 +714,8 @@ td,th {
margin-top: 220px;
margin-right: 50px;
width: 300px;
text-align: center;
margin-left: 40%;
}
.validateTips {
width: 540px;

Loading…
Cancel
Save