Pavel Loginov 5 years ago
parent 2374855a5e
commit a923cf1d40

@ -473,7 +473,7 @@ def update_db_v_4_3(**kwargs):
con.close()
def update_db_v_4_3_1(**kwargs):
def update_db_v_4_3_0(**kwargs):
con, cur = get_cur()
sql = """
insert OR IGNORE into user_groups(user_id, user_group_id) select id, groups from user;
@ -484,11 +484,33 @@ def update_db_v_4_3_1(**kwargs):
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
print('DB was update to 4.3.0')
print('Updating... go to version 4.3.1')
else:
print("An error occurred:", e)
return False
else:
return True
cur.close()
con.close()
def update_db_v_4_3_1(**kwargs):
con, cur = get_cur()
sql = """
ALTER TABLE `servers` ADD COLUMN pos INTEGER NOT NULL DEFAULT 0;
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: pos' or e == " 1060 (42S21): Duplicate column name 'pos' ":
print('DB was update to 4.3.1')
else:
print("An error occurred:", e)
return False
else:
print("DB was update to 4.3.1")
return True
cur.close()
con.close()
@ -496,7 +518,7 @@ def update_db_v_4_3_1(**kwargs):
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '4.3.0.0'; """
sql = """update version set version = '4.3.1.0'; """
try:
cur.execute(sql)
con.commit()
@ -522,6 +544,7 @@ def update_all():
update_db_v_42()
update_db_v_4_2_3()
update_db_v_4_3()
update_db_v_4_3_0()
update_db_v_4_3_1()
update_ver()
@ -542,6 +565,7 @@ def update_all_silent():
update_db_v_42(silent=1)
update_db_v_4_2_3(silent=1)
update_db_v_4_3(silent=1)
update_db_v_4_3_0(silent=1)
update_db_v_4_3_1(silent=1)
update_ver()

@ -90,8 +90,14 @@ if form.getvalue('backend') is not None:
funct.show_backends(serv)
if form.getvalue('change_pos') is not None:
import sql
pos = form.getvalue('change_pos')
sql.update_server_pos(pos, serv)
if form.getvalue('ip') is not None and serv is not None:
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
funct.ssh_command(serv, commands, ip="1")
@ -143,6 +149,7 @@ if form.getvalue('action_service') is not None:
output, stderr = funct.subprocess_execute(cmd)
funct.logging('localhost', ' The service '+serv+ 'was '+action+'ed', haproxywi=1, login=1)
if act == "overviewHapserverBackends":
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
@ -598,7 +605,7 @@ if form.getvalue('servaction') is not None:
haproxy_sock = sql.get_setting('haproxy_sock')
enable = form.getvalue('servaction')
backend = form.getvalue('servbackend')
cmd='echo "%s %s" |sudo socat stdio %s | cut -d "," -f 1-2,5-10,18,34-36 | column -s, -t' % (enable, backend, haproxy_sock)
cmd='echo "%s %s" |sudo socat stdio %s' % (enable, backend, haproxy_sock)
if form.getvalue('save') == "on":
save_command = 'echo "show servers state" | sudo socat %s stdio > %s' % (haproxy_sock, server_state_file)

@ -654,9 +654,9 @@ def get_dick_permit(**kwargs):
if select_user_groups(user, check_id=grp):
con, cur = get_cur()
if grp == '1':
sql = """ select * from servers where enable = 1 %s %s %s """ % (disable, type_ip, nginx)
sql = """ select * from servers where enable = 1 %s %s %s order by pos""" % (disable, type_ip, nginx)
else:
sql = """ select * from servers where groups = '{group}' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived}
sql = """ select * from servers where groups = '{group}' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
try:
@ -1670,6 +1670,21 @@ def update_haproxy(serv):
con.close()
def update_server_pos(pos, id):
con, cur = get_cur()
sql = """ update servers set
pos = '%s'
where id = '%s'""" % (pos, id)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
funct.out_error(e)
con.rollback()
cur.close()
con.close()
def check_token_exists(token):
try:
import http.cookies

@ -94,7 +94,8 @@
<li><a href="/app/servers.py#users" title="Actions with users" class="users head-submenu">Users</a></li>
<li><a href="/app/servers.py#servers" title="Server manage" class="runtime head-submenu">Servers</a></li>
<li><a href="/app/servers.py#ssh" title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
<li><a href="/app/servers.py#installhaproxy" title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
<li><a href="/app/servers.py#installproxy" title="Installation Proxy services" class="hap head-submenu">Installation Proxy</a> </li>
<li><a href="/app/servers.py#installmon" title="Installation Monitoring services" class="hap1 head-submenu">Installation Monitoring</a> </li>
<li><a href="/app/servers.py#backup" title="Backups HAProxy's config files" class="backup head-submenu">Backups</a> </li>
</ul>
</li>

@ -30,6 +30,24 @@
host = host.replace(/\./g, '\\.');
hostnamea.push(host)
{% endfor %}
$( function() {
$( ".sortable" ).sortable({
revert: true,
placeholder: "ui-state-highlight"
});
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
stop: function(event, ui) {
var itemOrder = $('.sortable').sortable("toArray");
for (var i = 0; i < itemOrder.length; i++) {
var pos = i;
var id = itemOrder[i].split('-')[2]
change_pos(pos, id);
}
}
});
});
</script>
<div id="up-pannel" class="sortable">
{% if servers|length == 0 %}

@ -28,27 +28,19 @@ th, tr, td {
<canvas id="{{s.0}}" role="img"></canvas>
</div>
{% endfor %}
</div>
<script>
$( function() {
$( "#sortable" ).sortable({
revert: true,
items: "> div",
placeholder: "ui-state-highlight"
});
$( "sortable" ).disableSelection();
} );
function showMetrics() {
let metrics = new Promise(
(resolve, reject) => {
{% for s in servers %}
getChartData('{{s.0}}')
{% endfor %}
loadMetrics()
});
metrics.then();
}
showMetrics()
function showMetrics() {
let metrics = new Promise(
(resolve, reject) => {
{% for s in servers %}
getChartData('{{s.0}}')
{% endfor %}
loadMetrics()
});
metrics.then();
}
showMetrics()
</script>
{% endif %}
{% endblock %}

@ -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 %}

@ -17,7 +17,8 @@
<li><a href="#servers">Servers</a></li>
<li><a href="#ssh">SSH credentials</a></li>
<li><a href="#checker">Checker</a></li>
<li><a href="#installhaproxy">Installation</a></li>
<li><a href="#installproxy">Installation Proxy</a></li>
<li><a href="#installmon">Installation Monitoring</a></li>
<li><a href="#backup">Backup</a></li>
{% include 'include/login.html' %}
</ul>
@ -276,7 +277,7 @@
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>
</div>
<div id="installhaproxy">
<div id="installproxy">
<table class="overview">
<caption><h3>Install HAProxy</h3></caption>
<tr class="overviewHead">
@ -341,6 +342,10 @@
</td>
</tr>
</table>
<div id="ajax"></div>
</div>
<div id="installmon">
<table>
<caption><h3>Install Grafana and Prometheus servers</h3></caption>
<tr class="overviewHead">
@ -434,7 +439,7 @@
</td>
</tr>
</table>
<div id="ajax"></div>
<div id="ajaxmon"></div>
</div>
<div id="backup">

@ -92,6 +92,11 @@
font-family: "Font Awesome 5 Solid";
content: "\f074";
}
.hap1::before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f074";
}
.backup::before {
display: none;
font-family: "Font Awesome 5 Solid";

@ -134,53 +134,53 @@ function ajaxActionServers(action, id) {
} );
}
function ajaxActionNginxServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_nginx: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
if (cur_url[0] == "hapservers.py") {
location.reload()
} else {
setTimeout(showOverview(ip, hostnamea), 2000)
}
}
},
error: function(){
alert(w.data_error);
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_nginx: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
if (cur_url[0] == "hapservers.py") {
location.reload()
} else {
setTimeout(showOverview(ip, hostnamea), 2000)
}
} );
}
}
},
error: function(){
alert(w.data_error);
}
} );
}
function ajaxActionWafServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_waf: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
setTimeout(showOverviewWaf(ip, hostnamea), 2000)
}
},
error: function(){
alert(w.data_error);
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_waf: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
setTimeout(showOverviewWaf(ip, hostnamea), 2000)
}
} );
}
},
error: function(){
alert(w.data_error);
}
} );
}
$( function() {
$( "#show-all-users" ).click( function() {
$( ".show-users" ).show("fast");
@ -305,3 +305,16 @@ function updateHapWIServer(id) {
}
} );
}
function change_pos(pos, id) {
$.ajax( {
url: "options.py",
data: {
change_pos: pos,
serv: id,
token: $('#token').val()
},
error: function(){
console.log(w.data_error);
}
} );
}

@ -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;
});
});

@ -854,6 +854,15 @@ $( function() {
});
$( "#tabs" ).tabs( "option", "active", 4 );
} );
$( ".hap1" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children(".hap1").css('padding-left', '30px');
$(this).children(".hap1").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 5 );
} );
$( ".backup" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
@ -861,7 +870,7 @@ $( function() {
$(this).children(".backup").css('padding-left', '30px');
$(this).children(".backup").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 5 );
$( "#tabs" ).tabs( "option", "active", 6 );
} );
}
}

@ -220,8 +220,8 @@ $( function() {
} );
});
$('#grafna_install').click(function() {
$("#ajax").html('')
$("#ajax").html(wait_mess);
$("#ajaxmon").html('')
$("#ajaxmon").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -232,26 +232,26 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );
});
$('#haproxy_exp_install').click(function() {
$("#ajax").html('')
$("#ajax").html(wait_mess);
$("#ajaxmon").html('')
$("#ajaxmon").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -262,17 +262,17 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
$('#cur_haproxy_exp_ver').text('HAProxy expoter is installed');
$('#haproxy_exp_install').text('Update');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
@ -282,8 +282,8 @@ $( function() {
} );
});
$('#nginx_exp_install').click(function() {
$("#ajax").html('')
$("#ajax").html(wait_mess);
$("#ajaxmon").html('')
$("#ajaxmon").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -294,21 +294,21 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
$('#cur_nginx_exp_ver').text('Nginx expoter is installed');
$('#nginx_exp_install').text('Update');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );

Loading…
Cancel
Save