mirror of https://github.com/Aidaho12/haproxy-wi
parent
069aba1c03
commit
08b21981df
|
@ -1221,7 +1221,7 @@ def update_db_v_5_1_0_1(**kwargs):
|
||||||
|
|
||||||
def update_ver():
|
def update_ver():
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """update version set version = '5.1.0.0'; """
|
sql = """update version set version = '5.1.1.0'; """
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
10
app/funct.py
10
app/funct.py
|
@ -439,6 +439,16 @@ def rewrite_section(start_line, end_line, config, section):
|
||||||
return return_config
|
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):
|
def get_backends_from_config(serv, backends='', **kwargs):
|
||||||
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
||||||
format_cfg = 'cfg'
|
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')
|
end_line = form.getvalue('end_line')
|
||||||
aftersave = 1
|
aftersave = 1
|
||||||
|
|
||||||
|
if save == 'delete':
|
||||||
|
config = ''
|
||||||
|
|
||||||
config = funct.rewrite_section(start_line, end_line, oldcfg, config)
|
config = funct.rewrite_section(start_line, end_line, oldcfg, config)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -920,6 +920,29 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</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;">
|
<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
|
In this section you can create userlists. And after use them in the "Add" sections
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -87,12 +87,12 @@
|
||||||
</div><span class="param">{{- line -}}
|
</div><span class="param">{{- line -}}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- set backend = line.split(' ') -%}
|
{%- set backend = line.split(' ') -%}
|
||||||
<span class="accordion-link">
|
<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>
|
</span>
|
||||||
{%- set backend = backend|join('_') -%}
|
{%- set backend = backend|join('_') -%}
|
||||||
{%- do section_name.update({i: backend}) -%}
|
{%- do section_name.update({i: backend}) -%}
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set backend = line.split(' ') %}
|
{% set backend = line.split(' ') %}
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set backend = line.split(' ') %}
|
{% set backend = line.split(' ') %}
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span><div>
|
</span><div>
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span><div>
|
</span><div>
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span><div>
|
</span><div>
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span><div>
|
</span><div>
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
<span class="accordion-link">
|
<span class="accordion-link">
|
||||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit/Delete</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span><div>
|
</span><div>
|
||||||
|
@ -208,10 +208,11 @@
|
||||||
</span><br />
|
</span><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if "bind" in line -%}
|
{%- if "bind" in line -%}
|
||||||
{%- set bind = line.split(':') -%}
|
{%- set bind = line.split(':')[1] -%}
|
||||||
|
{%- set bind = bind.split(' ') -%}
|
||||||
<script>
|
<script>
|
||||||
{% set k = i - 1 %}
|
{% 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>
|
</script>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% for s in services %}
|
{% 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>
|
<tr>
|
||||||
{% set is_need_update = 0 %}
|
{% set is_need_update = 0 %}
|
||||||
{% if s.0 == 'smon' %}
|
{% if s.0 == 'smon' %}
|
||||||
|
@ -53,6 +53,13 @@
|
||||||
{% if s.3|float < metrics_ver|float %}
|
{% if s.3|float < metrics_ver|float %}
|
||||||
{% set is_need_update = 1 %}
|
{% set is_need_update = 1 %}
|
||||||
{% endif %}
|
{% 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 %}
|
{% endif %}
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
{{service_name}}
|
{{service_name}}
|
||||||
|
@ -72,6 +79,8 @@
|
||||||
{{keep_ver}}
|
{{keep_ver}}
|
||||||
{% elif s.0 == 'metrics_haproxy' %}
|
{% elif s.0 == 'metrics_haproxy' %}
|
||||||
{{metrics_ver}}
|
{{metrics_ver}}
|
||||||
|
{% elif s.0 == 'portscanner' %}
|
||||||
|
{{portscanner_ver}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</b>
|
</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -42,13 +42,11 @@
|
||||||
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
|
<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="" name="" class="btn btn-default">Save and restart</button>
|
||||||
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</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>
|
</p>
|
||||||
</form>
|
</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>
|
<script>
|
||||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "haproxy", lineNumbers: true});
|
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "haproxy", lineNumbers: true});
|
||||||
</script>
|
</script>
|
||||||
|
|
28
inc/add.js
28
inc/add.js
|
@ -1727,3 +1727,31 @@ function makeid(length) {
|
||||||
}
|
}
|
||||||
return result;
|
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+'§ion='+data[i]+'" title="Edit/Delete this userlist" target="_blank">'+data[i]+'</a> ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -360,6 +360,7 @@ pre {
|
||||||
}
|
}
|
||||||
.overview-wi .overviewHead {
|
.overview-wi .overviewHead {
|
||||||
border-bottom: 1px solid #A4C7F5;
|
border-bottom: 1px solid #A4C7F5;
|
||||||
|
height: 25px;
|
||||||
}
|
}
|
||||||
.overview tr{
|
.overview tr{
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
|
@ -713,6 +714,8 @@ td,th {
|
||||||
margin-top: 220px;
|
margin-top: 220px;
|
||||||
margin-right: 50px;
|
margin-right: 50px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
text-align: center;
|
||||||
|
margin-left: 40%;
|
||||||
}
|
}
|
||||||
.validateTips {
|
.validateTips {
|
||||||
width: 540px;
|
width: 540px;
|
||||||
|
|
|
@ -1941,7 +1941,7 @@ function ajaxActionServies(action, service) {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
window.history.pushState("services", "services", cur_url[0].split("#")[0] + "#services");
|
window.history.pushState("services", "services", cur_url[0].split("#")[0] + "#services");
|
||||||
toastr.success('The ' + service + 'has been ' + action +'ed');
|
toastr.success('The ' + service + ' has been ' + action +'ed');
|
||||||
loadServices();
|
loadServices();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue