mirror of https://github.com/Aidaho12/haproxy-wi
parent
d58b3b9ee2
commit
f02408155e
|
@ -797,7 +797,7 @@ def update_db_v_6_3_8():
|
|||
|
||||
def update_ver():
|
||||
try:
|
||||
Version.update(version='6.3.9.0').execute()
|
||||
Version.update(version='6.3.10.0').execute()
|
||||
except Exception:
|
||||
print('Cannot update version')
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ def change_ip_and_port() -> None:
|
|||
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
MASTERS = sql.is_master(serv)
|
||||
for master in MASTERS:
|
||||
masters = sql.is_master(serv)
|
||||
for master in masters:
|
||||
if master[0] is not None:
|
||||
cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (
|
||||
backend_backend, backend_server, backend_ip, backend_port, backend_port, master[0], haproxy_sock_port)
|
||||
|
@ -165,31 +165,59 @@ def change_ip_and_port() -> None:
|
|||
config_mod.master_slave_upload_and_restart(serv, cfg, just_save='save')
|
||||
|
||||
|
||||
def change_maxconn() -> None:
|
||||
frontend = common.checkAjaxInput(form.getvalue('maxconn_frontend'))
|
||||
maxconn = common.checkAjaxInput(form.getvalue('maxconn_int'))
|
||||
def change_maxconn_global() -> None:
|
||||
if form.getvalue('maxconn_global') is None:
|
||||
print('error: Maxconn must be integer and not 0')
|
||||
return
|
||||
|
||||
maxconn = common.checkAjaxInput(form.getvalue('maxconn_global'))
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
masters = sql.is_master(serv)
|
||||
|
||||
for master in masters:
|
||||
if master[0] is not None:
|
||||
cmd = f'echo "set maxconn global {maxconn}" |nc {master[0]} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
roxywi_common.logging(master[0], f'Maxconn has been changed. Globally to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
|
||||
cmd = f'echo "set maxconn global {maxconn}" |nc {serv} {haproxy_sock_port}'
|
||||
print(cmd)
|
||||
roxywi_common.logging(serv, f'Maxconn has been changed. Globally to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
if stderr != '':
|
||||
print(stderr[0])
|
||||
elif output[0] == '':
|
||||
configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = f"{configs_dir}{serv}-{get_date.return_date('config')}.cfg"
|
||||
|
||||
config_mod.get_config(serv, cfg)
|
||||
cmd = 'string=`grep global %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` ' \
|
||||
'&& sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (cfg, maxconn, cfg)
|
||||
server_mod.subprocess_execute(cmd)
|
||||
config_mod.master_slave_upload_and_restart(serv, cfg, just_save='save')
|
||||
print(f'success: Maxconn globally has been set to {maxconn} ')
|
||||
else:
|
||||
print(f'error: {output[0]}')
|
||||
|
||||
|
||||
def change_maxconn_frontend() -> None:
|
||||
if form.getvalue('maxconn_int') is None:
|
||||
print('error: Maxconn must be integer and not 0')
|
||||
return
|
||||
|
||||
frontend = common.checkAjaxInput(form.getvalue('maxconn_frontend'))
|
||||
maxconn = common.checkAjaxInput(form.getvalue('maxconn_int'))
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
masters = sql.is_master(serv)
|
||||
|
||||
for master in masters:
|
||||
if master[0] is not None:
|
||||
if frontend == 'global':
|
||||
cmd = 'echo "set maxconn %s %s" |nc %s %s' % (frontend, maxconn, master[0], haproxy_sock_port)
|
||||
else:
|
||||
cmd = 'echo "set maxconn frontend %s %s" |nc %s %s' % (frontend, maxconn, master[0], haproxy_sock_port)
|
||||
cmd = f'echo "set maxconn frontend {frontend} {maxconn}" |nc {master[0]} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
roxywi_common.logging(master[0], f'Maxconn has been changed. On: {frontend} to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
|
||||
if frontend == 'global':
|
||||
cmd = 'echo "set maxconn %s %s" |nc %s %s' % (frontend, maxconn, serv, haproxy_sock_port)
|
||||
else:
|
||||
cmd = 'echo "set maxconn frontend %s %s" |nc %s %s' % (frontend, maxconn, serv, haproxy_sock_port)
|
||||
print(cmd)
|
||||
cmd = f'echo "set maxconn frontend {frontend} {maxconn}" |nc {serv} {haproxy_sock_port}'
|
||||
roxywi_common.logging(serv, f'Maxconn has been changed. On: {frontend} to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
|
@ -209,6 +237,44 @@ def change_maxconn() -> None:
|
|||
print(f'error: {output[0]}')
|
||||
|
||||
|
||||
def change_maxconn_backend() -> None:
|
||||
if form.getvalue('maxconn_int') is None:
|
||||
print('error: Maxconn must be integer and not 0')
|
||||
return
|
||||
|
||||
backend = common.checkAjaxInput(form.getvalue('maxconn_backend'))
|
||||
backend_server = common.checkAjaxInput(form.getvalue('maxconn_backend_server'))
|
||||
maxconn = common.checkAjaxInput(form.getvalue('maxconn_int'))
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
masters = sql.is_master(serv)
|
||||
for master in masters:
|
||||
if master[0] is not None:
|
||||
cmd = f'echo "set maxconn server {backend}/{backend_server} {maxconn}" |nc {master[0]} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
roxywi_common.logging(master[0], f'Maxconn has been changed. On: {backend}/{backend_server} to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
|
||||
cmd = f'echo "set maxconn server {backend}/{backend_server} {maxconn}" |nc {serv} {haproxy_sock_port}'
|
||||
print(cmd)
|
||||
roxywi_common.logging(serv, f'Maxconn has been changed. On: {backend} to {maxconn}', login=1, keep_history=1, service='haproxy')
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
if stderr != '':
|
||||
print(stderr[0])
|
||||
elif output[0] == '':
|
||||
configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = f"{configs_dir}{serv}-{get_date.return_date('config')}.cfg"
|
||||
|
||||
config_mod.get_config(serv, cfg)
|
||||
cmd = 'string=`grep %s %s -n -A10 |grep maxcon -n|grep %s |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` ' \
|
||||
'&& sed -Ei "$( echo $string)s/maxconn [0-9]+/maxconn %s/g" %s' % (backend, cfg, backend_server, maxconn, cfg)
|
||||
server_mod.subprocess_execute(cmd)
|
||||
config_mod.master_slave_upload_and_restart(serv, cfg, just_save='save')
|
||||
print(f'success: Maxconn for {backend}/{backend_server} has been set to {maxconn} ')
|
||||
else:
|
||||
print(f'error: {output[0]}')
|
||||
|
||||
|
||||
def table_select():
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
||||
|
@ -245,7 +311,7 @@ def delete_ip_from_stick_table() -> None:
|
|||
cmd = f'echo "clear table {table} key {ip}" |nc {serv} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
if stderr[0] != '':
|
||||
print('error: ' + stderr[0])
|
||||
print(f'error: {stderr[0]}')
|
||||
|
||||
|
||||
def clear_stick_table() -> None:
|
||||
|
@ -255,7 +321,7 @@ def clear_stick_table() -> None:
|
|||
cmd = f'echo "clear table {table} " |nc {serv} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
if stderr[0] != '':
|
||||
print('error: ' + stderr[0])
|
||||
print(f'error: {stderr[0]}')
|
||||
|
||||
|
||||
def list_of_lists() -> None:
|
||||
|
@ -345,11 +411,11 @@ def select_session() -> None:
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
||||
serv = common.checkAjaxInput(form.getvalue('sessions_select'))
|
||||
session = common.checkAjaxInput(form.getvalue('sessions_select'))
|
||||
lang = roxywi_common.get_user_lang()
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
cmd = f'echo "show sess" |nc {serv} {haproxy_sock_port}'
|
||||
cmd = f'echo "show sess" |nc {session} {haproxy_sock_port}'
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
template = env.get_template('ajax/sessions_table.html')
|
||||
|
@ -359,10 +425,10 @@ def select_session() -> None:
|
|||
|
||||
|
||||
def show_session() -> None:
|
||||
serv = common.checkAjaxInput(form.getvalue('sessions_select_show'))
|
||||
session = common.checkAjaxInput(form.getvalue('sessions_select_show'))
|
||||
sess_id = common.checkAjaxInput(form.getvalue('sessions_select_id'))
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
cmd = f'echo "show sess {sess_id}" |nc {serv} {haproxy_sock_port}'
|
||||
cmd = f'echo "show sess {sess_id}" |nc {session} {haproxy_sock_port}'
|
||||
|
||||
output, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
|
|
|
@ -2282,6 +2282,8 @@ def select_update_keep_alive_restart(server_id: int, service: str) -> int:
|
|||
out_error(e)
|
||||
else:
|
||||
return restarted or 0
|
||||
finally:
|
||||
return 0
|
||||
|
||||
|
||||
def update_keep_alive_restart(server_id: int, service: str, restarted: int) -> None:
|
||||
|
|
|
@ -113,10 +113,20 @@ if form.getvalue('maxconn_select') is not None:
|
|||
serv = common.checkAjaxInput(form.getvalue('maxconn_select'))
|
||||
runtime.get_backends_from_config(serv, backends='frontend')
|
||||
|
||||
if form.getvalue('maxconn_global') is not None:
|
||||
import modules.config.runtime as runtime
|
||||
|
||||
runtime.change_maxconn_global()
|
||||
|
||||
if form.getvalue('maxconn_frontend') is not None:
|
||||
import modules.config.runtime as runtime
|
||||
|
||||
runtime.change_maxconn()
|
||||
runtime.change_maxconn_frontend()
|
||||
|
||||
if form.getvalue('maxconn_backend') is not None:
|
||||
import modules.config.runtime as runtime
|
||||
|
||||
runtime.change_maxconn_backend()
|
||||
|
||||
if form.getvalue('table_serv_select') is not None:
|
||||
import modules.config.runtime as runtime
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% import 'languages/'+lang|default('en')+'.html' as lang %}
|
||||
{% for ssh in sshs %}
|
||||
<tr style="width: 50%;" id="ssh-table-{{ssh.id}}" class="ssh-table-{{ssh.id}}">
|
||||
<td class="first-collumn">
|
||||
<td class="first-collumn padding10">
|
||||
<input type="text" id="ssh_name-{{ssh.id}}" class="form-control" value="{{ssh.name}}" style="margin-bottom: 23px;">
|
||||
</td>
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button onclick="checkSshConnect('{{server.2}}')" title="Check SSH connect to the server {{server.1}}" class="overflow" style="width: 70px;height: 28px;">{{lang.words.check}}</button>
|
||||
<button onclick="checkSshConnect('{{server.2}}')" title="Check SSH connect to the server {{server.1}}" class="overflow" style="width: 70px;height: 25px;">{{lang.words.check}}</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -80,34 +80,103 @@
|
|||
{% if role <= 3 %}
|
||||
<div id="maxconn">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
|
||||
<td>{{lang.words.select|title()}} {{lang.words.frontend|title()}}</td>
|
||||
<td>Maxconn</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<form action="" method="post" id="maxconnform">
|
||||
<select autofocus required name="serv" id="maxconn_select">
|
||||
<option disabled selected>------</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
<caption><h3>{{lang.words.global|title()}}</h3></caption>
|
||||
<thead>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
|
||||
<td>Maxconn</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 20%;">
|
||||
<form action="" method="post" id="maxconnglobalform">
|
||||
<select autofocus required name="serv" id="maxconn_global_select">
|
||||
<option disabled selected>------</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 75%;">
|
||||
{{ input('maxconnintglobal', title=lang.words.enter|title() + ' maxconn', type="number", required='required') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="global_enter">{{lang.words.enter|title()}}</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="overview">
|
||||
<caption><h3>{{lang.words.frontends|title()}}</h3></caption>
|
||||
<thead>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
|
||||
<td>{{lang.words.select|title()}} {{lang.words.frontend|title()}}</td>
|
||||
<td>Maxconn</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 20%;">
|
||||
<form action="" method="post" id="maxconnform">
|
||||
<select autofocus required name="serv" id="maxconn_select">
|
||||
<option disabled selected>------</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%">
|
||||
<select required name="maxconnfront" id="maxconnfront">
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
<select required name="maxconnfront" id="maxconnfront">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('maxconnint', title=lang.words.enter|title() + ' maxconn', type="number", required='required') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">{{lang.words.enter|title()}}</button>
|
||||
</td>
|
||||
</td>
|
||||
<td style="width: 50%;">
|
||||
{{ input('maxconnint', title=lang.words.enter|title() + ' maxconn', type="number", required='required') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">{{lang.words.enter|title()}}</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table>
|
||||
<caption><h3>{{lang.words.backends|title()}}</h3></caption>
|
||||
<thead>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
|
||||
<td>{{lang.words.select|title()}} {{lang.words.backend|title()}}</td>
|
||||
<td>{{lang.words.select|title()}} {{lang.words.server}}</td>
|
||||
<td>Maxconn</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 20%;">
|
||||
<form action="" method="post" id="maxconnbackform">
|
||||
<select autofocus required name="serv" id="maxconn_backend_select">
|
||||
<option disabled selected>------</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%;"><select required name="maxconnbackend" id="maxconnbackend"></select></td>
|
||||
<td style="width: 25%;"><select required name="maxconn_backend_server" id="maxconn_backend_server"></select></td>
|
||||
<td style="width: 25%;">
|
||||
{{ input('maxconn_backend_int', title=lang.words.enter|title() + ' maxconn', type="number", required='required') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="backend_enter">{{lang.words.enter|title()}}</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="ajaxmaxconn"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
|
@ -136,12 +205,10 @@
|
|||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select required name="ipbackend" id="ipbackend">
|
||||
</select>
|
||||
<select required name="ipbackend" id="ipbackend"></select>
|
||||
</td>
|
||||
<td>
|
||||
<select required name="backend_server" id="backend_server">
|
||||
</select>
|
||||
<select required name="backend_server" id="backend_server"></select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('backend_ip', title=lang.words.set|title()+' '+lang.words.new + ' ' + lang.words.server + ' IP', required='required', size='16') }}
|
||||
|
|
|
@ -4,7 +4,7 @@ function showRuntime() {
|
|||
} else {
|
||||
saveCheck = "";
|
||||
}
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
servaction: $('#servaction').val(),
|
||||
|
@ -14,7 +14,7 @@ function showRuntime() {
|
|||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
success: function (data) {
|
||||
$("#ajaxruntime").html(data);
|
||||
}
|
||||
} );
|
||||
|
@ -25,6 +25,7 @@ $( function() {
|
|||
return false;
|
||||
});
|
||||
$( "#maxconn_select" ).on('selectmenuchange',function() {
|
||||
let server_ip = $('#maxconn_select').val();
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -33,27 +34,44 @@ $( function() {
|
|||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
var value = data.split('<br>')
|
||||
$('#maxconnfront').find('option').remove();
|
||||
$('#maxconnfront').append($("<option></option>").attr("value","disabled").text("Choose Frontend"));
|
||||
$('#maxconnfront').append($("<option></option>").attr("value","global").text("global"));
|
||||
|
||||
for(let i = 0; i < data.split('<br>').length; i++){
|
||||
if(value[i] != '') {
|
||||
$('#maxconnfront').append($("<option></option>")
|
||||
.attr("value",value[i])
|
||||
.text(value[i]));
|
||||
}
|
||||
}
|
||||
$('#maxconnfront').selectmenu("refresh");
|
||||
}
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
generate_select(data, '#maxconnfront');
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$('#maxconnbackend').on('selectmenuchange', function (){
|
||||
let server_ip = $('#maxconn_backend_select').val();
|
||||
let backend = $('#maxconnbackend').val();
|
||||
get_backend_servers(server_ip, backend, '#maxconn_backend_server', 0);
|
||||
});
|
||||
$( "#maxconn_backend_select" ).on('selectmenuchange',function() {
|
||||
let server_ip = $('#maxconn_backend_select').val();
|
||||
get_backends(server_ip, '#maxconnbackend', 0);
|
||||
});
|
||||
$('#maxconnglobalform').submit(function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#maxconn_global_select').val(),
|
||||
maxconn_global: $('#maxconnintglobal').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
});
|
||||
$('#maxconnform').submit(function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
|
@ -65,80 +83,46 @@ $( function() {
|
|||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
});
|
||||
$('#maxconnbackform').submit(function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#maxconn_backend_select').val(),
|
||||
maxconn_backend: $('#maxconnbackend').val(),
|
||||
maxconn_backend_server: $('#maxconn_backend_server').val(),
|
||||
maxconn_int: $('#maxconn_backend_int').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
});
|
||||
$( "#ip_select" ).on('selectmenuchange',function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
ip_select: $('#ip_select').val(),
|
||||
serv: $('#ip_select').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
var value = data.split('<br>')
|
||||
$('#ipbackend').find('option').remove();
|
||||
$('#ipbackend').append($("<option></option>").attr("value","disabled").text("------"));
|
||||
$('#backend_server').find('option').remove();
|
||||
$('#backend_port').val('');
|
||||
$('#backend_ip').val('');
|
||||
for(let i = 0; i < data.split('<br>').length; i++){
|
||||
if(value[i] != '') {
|
||||
$('#ipbackend').append($("<option></option>")
|
||||
.attr("value",value[i])
|
||||
.text(value[i]));
|
||||
}
|
||||
}
|
||||
$('#ipbackend').selectmenu("refresh");
|
||||
$('#backend_server').selectmenu("refresh");
|
||||
}
|
||||
}
|
||||
} );
|
||||
let server_ip = $('#ip_select').val();
|
||||
get_backends(server_ip, '#ipbackend', 1);
|
||||
});
|
||||
$( "#ipbackend" ).on('selectmenuchange',function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#ip_select').val(),
|
||||
ipbackend: $('#ipbackend').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
var value = data.split('<br>')
|
||||
$('#backend_server').find('option').remove();
|
||||
$('#backend_server').append($("<option></option>").attr("value","disabled").text("------"));
|
||||
$('#backend_port').val('');
|
||||
$('#backend_ip').val('');
|
||||
for(let i = 0; i < data.split('<br>').length; i++){
|
||||
if(value[i] != ' ') {
|
||||
value[i] = value[i].replace(/\s+/g,'');
|
||||
$('#backend_server').append($("<option></option>")
|
||||
.attr("value",value[i])
|
||||
.text(value[i]));
|
||||
}
|
||||
}
|
||||
$('#backend_server').selectmenu("refresh");
|
||||
}
|
||||
}
|
||||
} );
|
||||
let server_ip = $('#ip_select').val();
|
||||
let backend = $('#ipbackend').val();
|
||||
get_backend_servers(server_ip, backend, '#backend_server', 1);
|
||||
});
|
||||
$( "#backend_server" ).on('selectmenuchange',function() {
|
||||
$('#backend_ip').val();
|
||||
|
@ -168,7 +152,7 @@ $( function() {
|
|||
} );
|
||||
});
|
||||
$('#runtimeapiip').submit(function() {
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#ip_select').val(),
|
||||
|
@ -179,13 +163,13 @@ $( function() {
|
|||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error: ') != '-1' || data.indexOf('Invalid ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1' || data.indexOf('Invalid ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.success(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
|
@ -204,19 +188,7 @@ $( function() {
|
|||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
var value = data.split(',')
|
||||
$('#table_select').find('option').remove();
|
||||
$('#table_select').append($("<option titile='Show all tables'></option>").attr("value","All").text("All"));
|
||||
|
||||
for(let i = 0; i < data.split(',').length; i++){
|
||||
if(value[i] != '') {
|
||||
value[i] = value[i].replace(/\s+/g,'');
|
||||
$('#table_select').append($("<option title=\"Show table "+value[i]+"\"></option>")
|
||||
.attr("value",value[i])
|
||||
.text(value[i]));
|
||||
}
|
||||
}
|
||||
$('#table_select').selectmenu("refresh");
|
||||
generate_select(data, '#table_select', 'All', ',');
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -234,7 +206,7 @@ $( function() {
|
|||
return false;
|
||||
});
|
||||
$( "#list_serv_select" ).on('selectmenuchange',function() {
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#list_serv_select').val(),
|
||||
|
@ -242,7 +214,7 @@ $( function() {
|
|||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
success: function (data) {
|
||||
data = data.replace(/, /g, ',');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
|
@ -271,8 +243,6 @@ $( function() {
|
|||
}
|
||||
} );
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
function deleteTableEntry(id, table, ip) {
|
||||
$(id).parent().parent().css("background-color", "#f2dede");
|
||||
|
@ -327,7 +297,7 @@ function getTable() {
|
|||
} else {
|
||||
$("#ajaxtable").html(data);
|
||||
$( "input[type=submit], button" ).button();
|
||||
$.getScript("/inc/script.js");
|
||||
$.getScript("/inc/script-6.3.9.js");
|
||||
$.getScript("/inc/fontawesome.min.js");
|
||||
FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };
|
||||
}
|
||||
|
@ -350,7 +320,7 @@ function getList() {
|
|||
} else {
|
||||
$("#ajaxlist").html(data);
|
||||
$( "input[type=submit], button" ).button();
|
||||
$.getScript("/inc/script.js");
|
||||
$.getScript("/inc/script-6.3.9.js");
|
||||
$.getScript("/inc/fontawesome.min.js");
|
||||
FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };
|
||||
}
|
||||
|
@ -408,7 +378,6 @@ function addNewIp() {
|
|||
$( "#list_add_ip_form" ).dialog("destroy" );
|
||||
toastr.success('IP ' + ip + ' has been added');
|
||||
toastr.info('Do not forget upload updated list to the properly server. Restart does not need');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -428,7 +397,7 @@ function getSessions() {
|
|||
} else {
|
||||
$("#ajaxsessions").html(data);
|
||||
$( "input[type=submit], button" ).button();
|
||||
$.getScript("/inc/script.js");
|
||||
$.getScript("/inc/script-6.3.9.js");
|
||||
$.getScript("/inc/fontawesome.min.js");
|
||||
FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };
|
||||
}
|
||||
|
@ -489,3 +458,68 @@ function deleteSession(id, sess_id) {
|
|||
}
|
||||
} );
|
||||
}
|
||||
function get_backends(server_ip, backends_select_tag, ip_and_port=0) {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
ip_select: 1,
|
||||
serv: server_ip,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
generate_select(data, backends_select_tag);
|
||||
if (ip_and_port == 1) {
|
||||
$('#backend_server').find('option').remove();
|
||||
$('#backend_server').selectmenu("refresh");
|
||||
$('#backend_port').val('');
|
||||
$('#backend_ip').val('');
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function get_backend_servers(server_ip, backend, servers_select_tag, ip_and_port=0) {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: server_ip,
|
||||
ipbackend: backend,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
generate_select(data, servers_select_tag);
|
||||
if (ip_and_port == 1) {
|
||||
$('#backend_port').val('');
|
||||
$('#backend_ip').val('');
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function generate_select(values, select_tag, custom_value=0, separator='<br>') {
|
||||
var value = values.split(separator)
|
||||
$(select_tag).find('option').remove();
|
||||
$(select_tag).append($("<option></option>").attr("value", "disabled").text("------"));
|
||||
if (custom_value) {
|
||||
$(select_tag).append($("<option></option>").attr("value", custom_value).text(custom_value));
|
||||
}
|
||||
for (let i = 0; i < values.split(separator).length; i++) {
|
||||
if (value[i] != ' ' && value[i] != '' ) {
|
||||
value[i] = value[i].replace(/\s+/g, '');
|
||||
$(select_tag).append($("<option></option>")
|
||||
.attr("value", value[i])
|
||||
.text(value[i]));
|
||||
}
|
||||
}
|
||||
$(select_tag).selectmenu("refresh");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue