mirror of https://github.com/Aidaho12/haproxy-wi
parent
2374855a5e
commit
a923cf1d40
@ -1,59 +1,167 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% from 'include/input_macros.html' import input, checkbox %}
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Server</td>
|
||||
<td>Disable/Enable server or output any information</td>
|
||||
<td>Command</td>
|
||||
<td class="checkbox-head">Save change</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<form action="{{ action }}" method="post" id="runtimeapiform">
|
||||
{% include 'include/select.html' %}
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
<select required name="servaction" id="servaction">
|
||||
<option disabled>Choose action</option>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/runtimeapi.js"></script>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#runtimeapi">Runtime API</a></li>
|
||||
{% if role <= 2 %}
|
||||
<li><a href="#maxconn">Change Maxconn</a></li>
|
||||
<li><a href="#ip">Change IP and Port</a></li>
|
||||
{% endif %}
|
||||
{% include 'include/login.html' %}
|
||||
</ul>
|
||||
<ul id='browse_histroy'></ul>
|
||||
<div id="runtimeapi">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Server</td>
|
||||
<td>Disable/Enable server or output any information</td>
|
||||
<td>Command</td>
|
||||
<td class="checkbox-head">Save change</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<form action="" method="post" id="runtimeapiform">
|
||||
{% include 'include/select.html' %}
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
<select required name="servaction" id="servaction">
|
||||
<option disabled>Choose action</option>
|
||||
{% if role <= 2 %}
|
||||
<option value="disable">Disable</option>
|
||||
<option value="enable">Enable</option>
|
||||
<option value="set">Set</option>
|
||||
{% endif %}
|
||||
<option value="show" selected>Show</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('servbackend', value=servbackend, title='Frontend, backend/server, show: info, pools or help', required='required') }}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% if role <= 2 %}
|
||||
<option value="disable">Disable</option>
|
||||
<option value="enable">Enable</option>
|
||||
<option value="set">Set</option>
|
||||
{{ checkbox('save', value='123') }}
|
||||
{% endif %}
|
||||
<option value="show" selected>Show</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('servbackend', value=servbackend, title='Frontend, backend/server, show: info, pools or help', required='required') }}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% if role <= 2 %}
|
||||
{{ checkbox('save', value='123') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
if($('#servbackend').val()) {
|
||||
window.onload = {{ onclick }}
|
||||
}
|
||||
if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
|
||||
$( "#servaction" ).selectmenu({
|
||||
width: 150
|
||||
});
|
||||
$( "#serv" ).selectmenu({
|
||||
width: 150
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div id="ajaxruntime"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
You can read the description of all Run Time API <a href="https://haproxy-wi.org/description.py?description=runtimeapi" title="Run Time API description" target="_blank">here</a>
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
|
||||
$( "#servaction" ).selectmenu({
|
||||
width: 150
|
||||
});
|
||||
$( "#serv" ).selectmenu({
|
||||
width: 150
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div id="ajaxruntime"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
You can read the description of all Run Time API <a href="https://haproxy-wi.org/description.py?description=runtimeapi#commands" title="Run Time API description" target="_blank">here</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="maxconn">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Server</td>
|
||||
<td>Choose Frontend</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>Choose server</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
<select required name="maxconnfront" id="maxconnfront">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('maxconnint', title='Enter maxconn', type="number", required='required') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="ajaxmaxconn"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
You can read how it works <a href="https://haproxy-wi.org/description.py?description=runtimeapi#maxconn" title="Change Maxconn" target="_blank">here</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ip">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Server</td>
|
||||
<td>Choose Backend</td>
|
||||
<td>Choose Server</td>
|
||||
<td>New IP</td>
|
||||
<td>New Port</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<form action="" method="post" id="runtimeapiip">
|
||||
<select autofocus required name="ip_select" id="ip_select">
|
||||
<option disabled selected>Choose server</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select required name="ipbackend" id="ipbackend">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select required name="backend_server" id="backend_server">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('backend_ip', title='Set new server IP', required='required', size='16') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ input('backend_port', title='Set new server Port', type="number", required='required', size='6') }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="ajaxip"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
You can read how it works <a href="https://haproxy-wi.org/description.py?description=runtimeapi#ip" title="Change IP and Port" target="_blank">here</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$( function() {
|
||||
if (window.matchMedia('(max-width: 1280px)').matches) {
|
||||
$("#ip_select" ).selectmenu({
|
||||
width: 100
|
||||
});
|
||||
$("#ipbackend" ).selectmenu({
|
||||
width: 100
|
||||
});
|
||||
$("#backend_server" ).selectmenu({
|
||||
width: 100
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -0,0 +1,189 @@
|
||||
function showRuntime() {
|
||||
if($('#save').prop('checked')) {
|
||||
saveCheck = "on";
|
||||
} else {
|
||||
saveCheck = "";
|
||||
}
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
servaction: $('#servaction').val(),
|
||||
serv: $("#serv").val(),
|
||||
servbackend: $("#servbackend").val(),
|
||||
save: saveCheck,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
$("#ajaxruntime").html(data);
|
||||
}
|
||||
} );
|
||||
}
|
||||
$( function() {
|
||||
$('#runtimeapiform').submit(function() {
|
||||
showRuntime();
|
||||
return false;
|
||||
});
|
||||
$( "#maxconn_select" ).on('selectmenuchange',function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
maxconn_select: $('#maxconn_select').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1') {
|
||||
alert(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");
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$('#maxconnform').submit(function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#maxconn_select').val(),
|
||||
maxconn_frontend: $('#maxconnfront').val(),
|
||||
maxconn_int: $('#maxconnint').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajaxmaxconn").html('<div class="alert alert-danger" style="margin: 10px;">'+data+'</div>');
|
||||
} else {
|
||||
$("#ajaxmaxconn").html('<div class="alert alert-success" style="margin: 10px;">'+data+'</div>');
|
||||
}
|
||||
}
|
||||
} );
|
||||
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') {
|
||||
alert(data)
|
||||
} else {
|
||||
var value = data.split('<br>')
|
||||
$('#ipbackend').find('option').remove();
|
||||
$('#ipbackend').append($("<option></option>").attr("value","disabled").text("Choose Backend"));
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$( "#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') {
|
||||
alert(data)
|
||||
} else {
|
||||
var value = data.split('<br>')
|
||||
$('#backend_server').find('option').remove();
|
||||
$('#backend_server').append($("<option></option>").attr("value","disabled").text("Choose Server"));
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$( "#backend_server" ).on('selectmenuchange',function() {
|
||||
$('#backend_ip').val();
|
||||
$('#backend_port').val();
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#ip_select').val(),
|
||||
ipbackend: $('#ipbackend').val(),
|
||||
backend_server: $('#backend_server').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1') {
|
||||
alert(data)
|
||||
} else {
|
||||
var server = data.split(':')[0]
|
||||
var port = data.split(':')[1]
|
||||
port = port.replace(/\s+/g,'');
|
||||
server = server.replace(/\s+/g,'');
|
||||
$('#backend_port').val(port);
|
||||
$('#backend_ip').val(server);
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$('#runtimeapiip').submit(function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $('#ip_select').val(),
|
||||
backend_backend: $('#ipbackend').val(),
|
||||
backend_server: $('#backend_server').val(),
|
||||
backend_ip: $('#backend_ip').val(),
|
||||
backend_port: $('#backend_port').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajaxip").html('<div class="alert alert-danger" style="margin: 10px;">'+data+'</div>');
|
||||
} else {
|
||||
$("#ajaxip").html('<div class="alert alert-success" style="margin: 10px;">'+data+'</div>');
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
});
|
||||
});
|
Loading…
Reference in new issue