Pavel Loginov 2020-07-26 18:26:04 +02:00
parent 77f7c142dd
commit c1f3fe4a97
10 changed files with 609 additions and 341 deletions

View File

@ -166,8 +166,8 @@ def update_db_v_31(**kwargs):
sql.append("INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('token_ttl', '5', 'main', 'Time to live users tokens. In days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'Temp store configs, for check');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'Path to SSL dir');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'Temp store configs, for check. Path must exist');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, enabled by default');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server_enable', '0', 'logs', 'If exist syslog server for HAproxy logs, enable this option');")
@ -475,9 +475,14 @@ def update_db_v_4_3(**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;
"""
if mysql_enable == '1':
sql = """
insert OR IGNORE into user_groups(user_id, user_group_id) select user.id, user.groups from user;
"""
else:
sql = """
insert OR IGNORE into user_groups(user_id, user_group_id) select id, groups from user;
"""
try:
cur.execute(sql)
con.commit()
@ -567,7 +572,7 @@ def update_db_v_4_4(**kwargs):
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.4.0')
print('Updating... go to version 4.4.2')
else:
print("An error occurred:", e)
return False
@ -575,6 +580,32 @@ def update_db_v_4_4(**kwargs):
return True
cur.close()
con.close()
def update_db_v_4_4_2(**kwargs):
con, cur = get_cur()
sql = """CREATE TABLE IF NOT EXISTS `waf_rules` (`id` INTEGER NOT NULL,
serv varchar(64),
`rule_name` varchar(64),
`rule_file` varchar(64),
`desc` varchar(1024),
`en` INTEGER DEFAULT 1,
UNIQUE(serv, rule_name),
PRIMARY KEY(`id`) ); """
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: version' or e == "1060 (42S21): Duplicate column name 'version' ":
print('DB was update to 4.4.2')
else:
print("DB was update to 4.4.2")
return False
else:
return True
cur.close()
con.close()
def update_ver(**kwargs):
@ -609,6 +640,7 @@ def update_all():
update_db_v_4_3_1()
update_db_v_4_3_2()
update_db_v_4_4()
update_db_v_4_4_2()
update_ver()
@ -632,6 +664,7 @@ def update_all_silent():
update_db_v_4_3_1(silent=1)
update_db_v_4_3_2(silent=1)
update_db_v_4_4(silent=1)
update_db_v_4_4_2(silent=1)
update_ver()

View File

@ -523,6 +523,7 @@ def waf_install(serv, **kwargs):
stderr = ssh_command(serv, commands, print_out="1")
sql.insert_waf_metrics_enable(serv, "0")
sql.insert_waf_rules(serv)
def install_nginx(serv):
@ -607,18 +608,23 @@ def upload(serv, path, file, **kwargs):
try:
ssh = ssh_connect(serv)
except Exception as e:
error = e
error = e.args
logging('localhost', str(e.args[0]), haproxywi=1)
print(' Cannot upload '+file+' to '+full_path+' to server: '+serv+' error: '+str(e.args))
pass
try:
sftp = ssh.open_sftp()
except Exception as e:
error = e.args
logging('localhost', str(e.args[0]), haproxywi=1)
print('Cannot upload '+file+' to '+full_path+' to server: '+serv+' error: '+str(e.args))
try:
file = sftp.put(file, full_path)
except Exception as e:
error = e.args
print('Cannot upload '+file+' to '+full_path+' to server: '+serv+' error: '+str(e.args))
logging('localhost', ' Cannot upload '+file+' to '+full_path+' to server: '+serv+' Error: '+str(e.args), haproxywi=1)
pass
@ -628,6 +634,7 @@ def upload(serv, path, file, **kwargs):
except Exception as e:
error = e.args
logging('localhost', str(error[0]), haproxywi=1)
print('Cannot upload '+file+' to '+full_path+' to server: '+serv+' error: '+str(e.args))
pass
return str(error)
@ -903,7 +910,7 @@ def ssh_command(serv, commands, **kwargs):
ssh.close()
except:
logging('localhost', ' '+str(ssh), haproxywi=1)
return "<div class='alert alert-danger' style='margin: 0;'>"+str(ssh)+"<a title='Close' id='errorMess'><b>X</b></a></div>"
return "error: "+str(ssh)
pass

View File

@ -26,17 +26,17 @@ if act == "checkrestart":
if not sql.check_token_exists(form.getvalue("token")):
print('<div class="alert alert-danger" style="margin:20px;">Your token has been expired</div>')
print('error: Your token has been expired')
sys.exit()
if form.getvalue('getcerts') is not None and serv is not None:
cert_path = sql.get_setting('cert_path')
commands = [ "ls -1t "+cert_path+" |grep pem" ]
commands = ["sudo ls -1t "+cert_path+" |grep pem"]
try:
funct.ssh_command(serv, commands, ip="1")
except:
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
except Exception as e:
print('error: Cannot connect to the server: ' + str(e))
if form.getvalue('checkSshConnect') is not None and serv is not None:
@ -50,7 +50,7 @@ if form.getvalue('getcert') is not None and serv is not None:
try:
funct.ssh_command(serv, commands, ip="1")
except:
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
print('error: Can not connect to the server')
if serv and form.getvalue('ssl_cert'):
@ -61,24 +61,24 @@ if serv and form.getvalue('ssl_cert'):
os.makedirs(cert_local_dir)
if form.getvalue('ssl_name') is None:
print('<div class="alert alert-danger" style="float: left;">Please enter desired name</div>')
print('error: Please enter desired name')
else:
name = form.getvalue('ssl_name') + '.pem'
try:
with open(name, "w") as ssl_cert:
ssl_cert.write(form.getvalue('ssl_cert'))
except IOError:
print('<div class="alert alert-danger style="float: left;"">Can\'t save ssl keys file. Check ssh keys path in config</div>')
else:
print('<div class="alert alert-success" style="float: left;">SSL file was upload to %s into: %s %s</div>' % (serv, cert_path, name))
except IOError as e :
print('error: Can\'t save ssl keys file. Check ssh keys path in config '+e.args[0])
MASTERS = sql.is_master(serv)
for master in MASTERS:
if master[0] != None:
funct.upload(master[0], cert_path, name)
try:
funct.upload(serv, cert_path, name)
error = funct.upload(serv, cert_path, name)
if error == '':
print('success: SSL file has been uploaded to %s into: %s%s' % (serv, cert_path, '/'+name))
except Exception as e:
funct.logging('localhost', e.args[0], haproxywi=1)
try:
@ -86,7 +86,7 @@ if serv and form.getvalue('ssl_cert'):
except OSError as e:
funct.logging('localhost', e.args[0], haproxywi=1)
funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name)
funct.logging(serv, "add.py#ssl uploaded a new SSL cert %s" % name, haproxywi=1, login=1)
if form.getvalue('backend') is not None:
@ -200,7 +200,7 @@ if form.getvalue('maxconn_frontend') is not None:
cmd = 'string=`grep %s %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (frontend, cfg, maxconn, cfg)
output, stderr = funct.subprocess_execute(cmd)
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save='save')
print('Maxconn for %s has been set to %s ' % (frontend, maxconn))
print('success: Maxconn for %s has been set to %s ' % (frontend, maxconn))
else:
print('error: '+output[0])
@ -272,9 +272,9 @@ if form.getvalue('action_hap') is not None and serv is not None:
commands = [ "sudo systemctl %s haproxy" % action ]
funct.ssh_command(serv, commands)
funct.logging(serv, 'HAProxy was '+action+'ed', haproxywi=1, login=1)
print("HAproxy was %s" % action)
print("success: HAproxy was %s" % action)
else:
print("Bad config, check please")
print("error: Bad config, check please")
if form.getvalue('action_nginx') is not None and serv is not None:
@ -284,9 +284,9 @@ if form.getvalue('action_nginx') is not None and serv is not None:
commands = [ "sudo systemctl %s nginx" % action ]
funct.ssh_command(serv, commands)
funct.logging(serv, 'Nginx was '+action+'ed', haproxywi=1, login=1)
print("Nginx was %s" % action)
print("success: Nginx was %s" % action)
else:
print("Bad config, check please")
print("error: Bad config, check please")
if form.getvalue('action_waf') is not None and serv is not None:
@ -354,7 +354,7 @@ if act == "overviewHapservers":
try:
print(funct.ssh_command(serv, commands))
except:
print('Cannot get last date')
print('error: Cannot get last date')
if act == "overview":
@ -538,17 +538,17 @@ if serv is not None and act == "stats":
try:
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
except requests.exceptions.ConnectTimeout:
print('Oops. Connection timeout occured!')
print('error: Oops. Connection timeout occured!')
except requests.exceptions.ReadTimeout:
print('Oops. Read timeout occured')
print('error: Oops. Read timeout occured')
except requests.exceptions.HTTPError as errh:
print ("Http Error:",errh)
print ("error: Http Error:",errh)
except requests.exceptions.ConnectionError as errc:
print ('<div class="alert alert-danger">Error Connecting: %s</div>' % errc)
print ('error: Error Connecting: %s' % errc)
except requests.exceptions.Timeout as errt:
print ("Timeout Error:",errt)
print ("error: Timeout Error:",errt)
except requests.exceptions.RequestException as err:
print ("OOps: Something Else",err)
print ("error: OOps: Something Else",err)
data = response.content
if form.getvalue('service') == 'nginx':
@ -627,11 +627,11 @@ if serv is not None and act == "showMap":
error = funct.get_config(serv, cfg)
if error:
print('<div class="alert alert-danger">'+error+'</div>')
print(error)
try:
conf = open(cfg, "r")
except IOError:
print('<div class="alert alert-danger">Can\'t read import config file</div>')
print('error: Can\'t read import config file')
node = ""
line_new2 = [1,""]
@ -703,7 +703,7 @@ if serv is not None and act == "showMap":
plt.savefig("map.png")
plt.show()
except Exception as e:
print('<div class="alert alert-danger">' + str(e) + '</div>')
print(str(e))
cmd = "rm -f "+os.path.dirname(os.getcwd())+"/map*.png && mv map.png "+os.path.dirname(os.getcwd())+"/map"+date+".png"
output, stderr = funct.subprocess_execute(cmd)
@ -1339,7 +1339,7 @@ if form.getvalue('get_hap_v'):
if form.getvalue('get_nginx_v'):
cmd = [ "/usr/sbin/nginx -v" ]
cmd = [ '/usr/sbin/nginx -v' ]
print(funct.ssh_command(serv, cmd))
@ -1355,7 +1355,7 @@ if form.getvalue('bwlists'):
file.close
print(file_read)
except IOError:
print('<div class="alert alert-danger" style="margin:0">Cat\'n read '+form.getvalue('color')+' list</div>')
print('error: Cat\'n read '+form.getvalue('color')+' list , ')
if form.getvalue('bwlists_create'):
@ -1365,13 +1365,13 @@ if form.getvalue('bwlists_create'):
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+color+"/"+list_name
try:
open(list, 'a').close()
print('<div class="alert alert-success" style="margin-left:14px">'+color+' list was created</div>')
print(color)
try:
funct.logging(server[1], 'has created '+color+' list '+list_name, haproxywi=1, login=1)
except:
pass
except IOError as e:
print('<div class="alert alert-danger" style="margin-left:14px">Cat\'n create new '+color+' list. %s </div>' % e)
print('error: Cat\'n create new '+color+' list. %s , ' % e)
if form.getvalue('bwlists_save'):
@ -1382,7 +1382,7 @@ if form.getvalue('bwlists_save'):
with open(list, "w") as file:
file.write(form.getvalue('bwlists_content'))
except IOError as e:
print('<div class="alert alert-danger" style="margin-left:14px">Cat\'n save '+color+' list. %s </div>' % e)
print('error: Cat\'n save '+color+' list. %s , ' % e)
path = sql.get_setting('haproxy_dir')+"/"+color
servers = []
@ -1404,9 +1404,9 @@ if form.getvalue('bwlists_save'):
funct.ssh_command(serv, ["sudo chown $(whoami) "+path])
error = funct.upload(serv, path+"/"+bwlists_save, list, dir='fullpath')
if error:
print('<div class="alert alert-danger">Upload fail: %s</div>' % error)
print('error: Upload fail: %s , ' % error)
else:
print('<div class="alert alert-success" style="margin:10px; margin-left:14px">Edited '+color+' list was uploaded to '+serv+'</div>')
print('success: Edited '+color+' list was uploaded to '+serv+' , ')
try:
funct.logging(serv, 'has edited '+color+' list '+bwlists_save, haproxywi=1, login=1)
except:
@ -1468,7 +1468,7 @@ if form.getvalue('change_waf_mode'):
funct.logging(serv, 'Was changed WAF mod to '+waf_mode, haproxywi=1, login=1)
error_mess = '<span class="alert alert-danger" id="error">All fields must be completed <a title="Close" id="errorMess"><b>X</b></a></span>'
error_mess = 'error: All fields must be completed'
if form.getvalue('newuser') is not None:
@ -1731,9 +1731,9 @@ if form.getvalue('ssh_cert'):
with open(ssh_keys, "w") as conf:
conf.write(form.getvalue('ssh_cert'))
except IOError:
print('<div class="alert alert-danger">Can\'t save ssh keys file. Check ssh keys path in config</div>')
print('error: Can\'t save ssh keys file. Check ssh keys path in config')
else:
print('<div class="alert alert-success">Ssh key was save into: %s </div>' % ssh_keys)
print('success: Ssh key was save into: %s </div>' % ssh_keys)
try:
cmd = 'chmod 600 %s' % ssh_keys
@ -1867,6 +1867,7 @@ if form.getvalue('smondel') is not None:
if sql.delete_smon(id, user_group):
print('Ok')
funct.logging('SMON','Has been delete server from SMON ', haproxywi=1, login=1)
if form.getvalue('showsmon') is not None:
@ -1907,6 +1908,7 @@ if form.getvalue('updateSmonIp') is not None:
sys.exit()
if sql.update_smon(id, ip, port, body, telegram, group, desc, en):
print("Ok")
funct.logging('SMON','Has been update the server '+ip+' to SMON ', haproxywi=1, login=1)
if form.getvalue('showBytes') is not None:

View File

@ -32,10 +32,15 @@
<td>
{% set id = 'smon-body-' + s.0|string() %}
{% if s.5 != 'None' %}
<span id="{{id}}">{{s.5}}</span>
{% else %}
<span id="{{id}}"></span>
{% endif %}
{#{% if s.5 != 'None' %}
{{ input(id, value=s.5, size='10') }}
{% else %}
{{ input(id, size='10') }}
{% endif %}
{% endif %} #}
</td>
<td>
<select id="smon-telegram-{{s.0}}">

View File

@ -283,9 +283,14 @@ function showStats() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Stats", "Stats", cur_url[0]+"?service="+$("#service").val()+"&serv="+$("#serv").val());
wait();
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
window.history.pushState("Stats", "Stats", cur_url[0] + "?service=" + $("#service").val() + "&serv=" + $("#serv").val());
wait();
}
}
} );
}
@ -344,16 +349,21 @@ function showLog() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Logs", "Logs", cur_url[0]+"?service="+service+"&serv="+$("#serv").val()+
'&rows='+rows+
'&exgrep='+exgrep+
'&grep='+grep+
'&hour='+hour+
'&minut='+minut+
'&hour1='+hour1+
'&minut1='+minut1+
'&waf='+waf);
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
window.history.pushState("Logs", "Logs", cur_url[0] + "?service=" + service + "&serv=" + $("#serv").val() +
'&rows=' + rows +
'&exgrep=' + exgrep +
'&grep=' + grep +
'&hour=' + hour +
'&minut=' + minut +
'&hour1=' + hour1 +
'&minut1=' + minut1 +
'&waf=' + waf);
}
}
} );
}
@ -372,8 +382,13 @@ function showMap() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Show map", "Show map", cur_url[0]+'?serv='+$("#serv").val()+'&showMap');
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
window.history.pushState("Show map", "Show map", cur_url[0] + '?serv=' + $("#serv").val() + '&showMap');
}
}
} );
}
@ -389,7 +404,12 @@ function showCompare() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
}
}
} );
}
@ -408,11 +428,16 @@ function showCompareConfigs() {
},
type: "POST",
success: function( data ) {
$("#ajax-compare").html(data);
$( "input[type=submit], button" ).button();
$( "select" ).selectmenu();
window.history.pushState("Show compare config", "Show compare config", cur_url[0]+'?service='+$("#service").val()+'&serv='+$("#serv").val()+'&showCompare');
}
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax-compare").html(data);
$("input[type=submit], button").button();
$("select").selectmenu();
window.history.pushState("Show compare config", "Show compare config", cur_url[0] + '?service=' + $("#service").val() + '&serv=' + $("#serv").val() + '&showCompare');
}
}
} );
}
function showConfig() {
@ -431,9 +456,14 @@ function showConfig() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
$.getScript('/inc/configshow.js');
window.history.pushState("Show config", "Show config", cur_url[0]+"?service="+service+"&serv="+$("#serv").val()+"&showConfig");
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
$.getScript('/inc/configshow.js');
window.history.pushState("Show config", "Show config", cur_url[0] + "?service=" + service + "&serv=" + $("#serv").val() + "&showConfig");
}
}
} );
}
@ -452,9 +482,14 @@ function showUploadConfig() {
},
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Show config", "Show config", cur_url[0]+"?service="+service+"&serv="+serv+"&open=open&configver="+configver);
$.getScript('/inc/configshow.js');
if (data.indexOf('error') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax").html(data);
window.history.pushState("Show config", "Show config", cur_url[0] + "?service=" + service + "&serv=" + serv + "&open=open&configver=" + configver);
$.getScript('/inc/configshow.js');
}
}
} );
}
@ -499,19 +534,24 @@ function viewLogs() {
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("View logs", "View logs", cur_url[0]+"?viewlogs="+viewlogs+
'&rows='+rows+
'&grep='+grep+
'&exgrep='+exgrep+
'&hour='+hour+
'&minut='+minut+
'&hour1='+hour1+
'&minut1='+minut1);
window.history.pushState("View logs", "View logs", cur_url[0] + "?viewlogs=" + viewlogs +
'&rows=' + rows +
'&grep=' + grep +
'&exgrep=' + exgrep +
'&hour=' + hour +
'&minut=' + minut +
'&hour1=' + hour1 +
'&minut1=' + minut1);
}
} );
}
}
$( function() {
toastr.options.closeButton = true;
toastr.options.progressBar = true;
toastr.options.positionClass = 'toast-bottom-full-width';
toastr.options.timeOut = 25000;
toastr.options.extendedTimeOut = 50000;
$('#errorMess').click(function(){
$('#error').remove();
});
@ -1005,7 +1045,7 @@ function showSmon(action) {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
alert(data);
toastr.error(data);
} else {
$("#smon_dashboard").html(data);
if (action == 'not_sort') {

228
inc/toastr.css Normal file
View File

@ -0,0 +1,228 @@
.toast-title {
font-weight: bold;
}
.toast-message {
-ms-word-wrap: break-word;
word-wrap: break-word;
}
.toast-message a,
.toast-message label {
color: #FFFFFF;
}
.toast-message a:hover {
color: #CCCCCC;
text-decoration: none;
}
.toast-close-button {
position: relative;
right: -0.3em;
top: -0.3em;
float: right;
font-size: 20px;
font-weight: bold;
color: #FFFFFF;
-webkit-text-shadow: 0 1px 0 #ffffff;
text-shadow: 0 1px 0 #ffffff;
opacity: 0.8;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
filter: alpha(opacity=80);
line-height: 1;
}
.toast-close-button:hover,
.toast-close-button:focus {
color: #000000;
text-decoration: none;
cursor: pointer;
opacity: 0.4;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
filter: alpha(opacity=40);
}
.rtl .toast-close-button {
left: -0.3em;
float: left;
right: 0.3em;
}
/*Additional properties for button version
iOS requires the button element instead of an anchor tag.
If you want the anchor version, it requires `href="#"`.*/
button.toast-close-button {
padding: 0;
cursor: pointer;
background: transparent;
border: 0;
-webkit-appearance: none;
}
.toast-top-center {
top: 0;
right: 0;
width: 100%;
}
.toast-bottom-center {
bottom: 0;
right: 0;
width: 100%;
}
.toast-top-full-width {
top: 0;
right: 0;
width: 100%;
}
.toast-bottom-full-width {
bottom: 0;
right: 0;
width: 100%;
}
.toast-top-left {
top: 12px;
left: 12px;
}
.toast-top-right {
top: 12px;
right: 12px;
}
.toast-bottom-right {
right: 12px;
bottom: 12px;
}
.toast-bottom-left {
bottom: 12px;
left: 12px;
}
#toast-container {
position: fixed;
z-index: 999999;
pointer-events: none;
/*overrides*/
}
#toast-container * {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#toast-container > div {
position: relative;
pointer-events: auto;
overflow: hidden;
margin: 0 0 6px;
padding: 15px 15px 15px 50px;
width: 300px;
-moz-border-radius: 3px 3px 3px 3px;
-webkit-border-radius: 3px 3px 3px 3px;
border-radius: 3px 3px 3px 3px;
background-position: 15px center;
background-repeat: no-repeat;
-moz-box-shadow: 0 0 12px #999999;
-webkit-box-shadow: 0 0 12px #999999;
box-shadow: 0 0 12px #999999;
color: #FFFFFF;
opacity: 0.8;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
filter: alpha(opacity=80);
}
#toast-container > div.rtl {
direction: rtl;
padding: 15px 50px 15px 15px;
background-position: right 15px center;
}
#toast-container > div:hover {
-moz-box-shadow: 0 0 12px #000000;
-webkit-box-shadow: 0 0 12px #000000;
box-shadow: 0 0 12px #000000;
opacity: 1;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
filter: alpha(opacity=100);
cursor: pointer;
}
#toast-container > .toast-info {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII=") !important;
}
#toast-container > .toast-error {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=") !important;
}
#toast-container > .toast-success {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==") !important;
}
#toast-container > .toast-warning {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGYSURBVEhL5ZSvTsNQFMbXZGICMYGYmJhAQIJAICYQPAACiSDB8AiICQQJT4CqQEwgJvYASAQCiZiYmJhAIBATCARJy+9rTsldd8sKu1M0+dLb057v6/lbq/2rK0mS/TRNj9cWNAKPYIJII7gIxCcQ51cvqID+GIEX8ASG4B1bK5gIZFeQfoJdEXOfgX4QAQg7kH2A65yQ87lyxb27sggkAzAuFhbbg1K2kgCkB1bVwyIR9m2L7PRPIhDUIXgGtyKw575yz3lTNs6X4JXnjV+LKM/m3MydnTbtOKIjtz6VhCBq4vSm3ncdrD2lk0VgUXSVKjVDJXJzijW1RQdsU7F77He8u68koNZTz8Oz5yGa6J3H3lZ0xYgXBK2QymlWWA+RWnYhskLBv2vmE+hBMCtbA7KX5drWyRT/2JsqZ2IvfB9Y4bWDNMFbJRFmC9E74SoS0CqulwjkC0+5bpcV1CZ8NMej4pjy0U+doDQsGyo1hzVJttIjhQ7GnBtRFN1UarUlH8F3xict+HY07rEzoUGPlWcjRFRr4/gChZgc3ZL2d8oAAAAASUVORK5CYII=") !important;
}
#toast-container.toast-top-center > div,
#toast-container.toast-bottom-center > div {
width: 300px;
margin-left: auto;
margin-right: auto;
}
#toast-container.toast-top-full-width > div,
#toast-container.toast-bottom-full-width > div {
width: 96%;
margin-left: auto;
margin-right: auto;
}
.toast {
background-color: #030303;
}
.toast-success {
background-color: #51A351;
}
.toast-error {
background-color: #BD362F;
}
.toast-info {
background-color: #2F96B4;
}
.toast-warning {
background-color: #F89406;
}
.toast-progress {
position: absolute;
left: 0;
bottom: 0;
height: 4px;
background-color: #000000;
opacity: 0.4;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
filter: alpha(opacity=40);
}
/*Responsive Design*/
@media all and (max-width: 240px) {
#toast-container > div {
padding: 8px 8px 8px 50px;
width: 11em;
}
#toast-container > div.rtl {
padding: 8px 50px 8px 8px;
}
#toast-container .toast-close-button {
right: -0.2em;
top: -0.2em;
}
#toast-container .rtl .toast-close-button {
left: -0.2em;
right: 0.2em;
}
}
@media all and (min-width: 241px) and (max-width: 480px) {
#toast-container > div {
padding: 8px 8px 8px 50px;
width: 18em;
}
#toast-container > div.rtl {
padding: 8px 50px 8px 8px;
}
#toast-container .toast-close-button {
right: -0.2em;
top: -0.2em;
}
#toast-container .rtl .toast-close-button {
left: -0.2em;
right: 0.2em;
}
}
@media all and (min-width: 481px) and (max-width: 768px) {
#toast-container > div {
padding: 15px 15px 15px 50px;
width: 25em;
}
#toast-container > div.rtl {
padding: 15px 50px 15px 15px;
}
}

2
inc/toastr.js Normal file

File diff suppressed because one or more lines are too long

1
inc/toastr.js.map Normal file

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,11 @@ $( function() {
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
response(data.split(" "));
if (data.indexOf('error') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
response(data.split(" "));
}
}
} );
},
@ -43,7 +47,11 @@ $( function() {
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
response(data.split(" "));
if (data.indexOf('error') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
response(data.split(" "));
}
}
} );
},
@ -68,11 +76,11 @@ $( function() {
$("#ajax").html('')
if( $("#master").val() == "" || $("#slave").val() == "" || $("#interface").val() == "" ||
$("#vrrp-ip").val() == "") {
$("#ajax").html('<div class="alert alert-danger">Please fill in all fields</div>')
toastr.warning('Please fill in all fields');
} else if(! $("#vrrp-ip").val().match(ipformat)) {
$("#ajax").html('<div class="alert alert-danger">Please enter IP in "VRRP IP" field</div>')
toastr.warning('Please enter IP in "VRRP IP" field');
} else if ($("#master").val() == $("#slave").val() ){
$("#ajax").html('<div class="alert alert-danger">Master and slave must be diff servers</div>')
toastr.warning('Master and slave must be diff servers');
} else {
$("#ajax").html(wait_mess);
$.ajax( {
@ -91,16 +99,16 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('alert') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
toastr.error(data);
} else if (data.indexOf('info') != '-1' ){
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -116,9 +124,9 @@ $( function() {
$("#ajax").html('')
if( $("#master-add").val() == "" || $("#slave-add").val() == "" || $("#interface-add").val() == "" ||
$("#vrrp-ip-add").val() == "") {
$("#ajax").html('<div class="alert alert-danger">Please fill in all fields</div>')
toastr.warning('Please fill in all fields')
} else if(! $("#vrrp-ip-add").val().match(ipformat)) {
$("#ajax").html('<div class="alert alert-danger">Please enter IP in "VRRP IP" field</div>')
toastr.warning('Please enter IP in "VRRP IP" field')
} else {
$("#ajax").html(wait_mess);
$.ajax( {
@ -135,14 +143,14 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
toastr.clear();
toastr.error(data);
} else if (data.indexOf('success') != '-1'){
$('.alert-danger').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -167,19 +175,16 @@ $( 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>');
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
toastr.remove();
toastr.success(data);
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.remove();
toastr.info(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.remove();
toastr.info(data);
}
}
} );
@ -202,19 +207,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>');
toastr.clear();
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -232,19 +235,17 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('FAILED') != '-1') {
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
toastr.clear();
toastr.error(data);;
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -262,21 +263,19 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
toastr.clear();
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
$('#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();
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -294,21 +293,18 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajaxmon").html('<div class="alert alert-danger">'+data+'</div>');
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-success">'+data+'</div>');
toastr.clear();
toastr.success(data);
$('#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();
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajaxmon").html('<div class="alert alert-info">'+data+'</div>');
toastr.clear();
toastr.info(data);
}
}
} );
@ -419,54 +415,46 @@ $( 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>');
toastr.error(data);
} else if (data.indexOf('Complete!') != '-1'){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-success">Update was success!</div>');
toastr.clear();
toastr.success('Update was success!');
} else if (data.indexOf('Unauthorized') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository. How to get HAProxy-WI auth you can read <a href="https://haproxy-wi.org/installation.py" title="How to get HAProxy-WI auth">hear</a> </div>');
toastr.clear();
toastr.error('It is seems like you Unauthorized in the HAProxy-WI repository. How to get HAProxy-WI auth you can read <a href="https://haproxy-wi.org/installation.py" title="How to get HAProxy-WI auth">hear</a>');
} else if (data.indexOf('but not installed') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-warning">You have settings for HAProxy-WI repository, but installed HAProxy-WI without repository. Please reinstall with yum or use update.sh</div>');
toastr.clear();
toastr.error('You have settings for HAProxy-WI repository, but installed HAProxy-WI without repository. Please reinstall with yum');
} else if (data.indexOf('No Match for argument') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-warning">It is seems like you do not have HAProxy-WI repository settings. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></div>');
toastr.clear();
toastr.error('It is seems like you do not have HAProxy-WI repository settings. Please read docs for <a href="https://haproxy-wi.org/updates.py">detail</a>');
} else if (data.indexOf('password for') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-warning">It is seems like you need add Apache user to sudoers. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></div>');
toastr.clear();
toastr.error('It is seems like you need add Apache user to sudoers. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a>');
} else if (data.indexOf('No packages marked for update') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-info">It is seems like you have the lastest version HAProxy-WI</div>');
toastr.clear();
toastr.error('It is seems like you have the lastest version HAProxy-WI');
} else if (data.indexOf('Connection timed out') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-danger">Cannot connect to HAProxy-WI repository. Connection timed out</div>');
toastr.clear();
toastr.error('Cannot connect to HAProxy-WI repository. Connection timed out');
} else if (data.indexOf('--disable') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you have problem with your repositorys.</div>');
toastr.clear();
toastr.error('It is seems like you have problem with your repositorys');
} else if (data.indexOf('Unauthorized') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository.</div>');
toastr.clear();
toastr.error('It is seems like you Unauthorized in the HAProxy-WI repository');
} else if (data.indexOf('Error: Package') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax-update").html('<div class="alert alert-danger">'+data+'</div>');
toastr.clear();
toastr.error(data);
} else if (data.indexOf('conflicts with file from') != '-1') {
toastr.clear();
toastr.error(data);
}
}
} );
});
$('#add-group').click(function() {
$('#error').remove();
$('.alert-danger').remove();
toastr.clear();
$.ajax( {
url: "options.py",
data: {
@ -478,12 +466,9 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
$("#ajax-group").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
toastr.clear();
var getId = new RegExp('[0-9]+');
var id = data.match(getId);
$("#ajax-group").append(data);
@ -495,8 +480,7 @@ $( function() {
} );
});
$('#add-ssh').click(function() {
$('#error').remove();
$('.alert-danger').remove();
toastr.clear();
var ssh_enable = 0;
if ($('#new-ssh_enable').is(':checked')) {
ssh_enable = '1';
@ -515,12 +499,9 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
$("#ajax-ssh").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
toastr.clear();
var getId = new RegExp('ssh-table-[0-9]+');
var id = data.match(getId) + '';
id = id.split('-').pop();;
@ -540,8 +521,7 @@ $( function() {
} );
});
$('#add-telegram').click(function() {
$('#error').remove();
$('.alert-danger').remove();
toastr.clear();
$.ajax( {
url: "options.py",
data: {
@ -554,11 +534,7 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
$("#ajax-telegram").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$("#checker_table").append(data);
$( ".newgroup" ).addClass( "update", 1000, callbackGroup );
@ -794,13 +770,13 @@ $( function() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
alert(data)
toastr.error(data);
$('#new-email').val('');
$('#new-password').attr('readonly', false);
$('#new-password').val('');
} else {
var json = $.parseJSON(data);
$('.alert-danger').remove();
toastr.clear();
$('#new-email').val(json[0]);
$('#new-username').val(user+'@'+json[1]);
$('#new-password').val('aduser');
@ -882,22 +858,19 @@ function addNewSmonServer() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('unique') != '-1') {
$("#ajax").html('<div class="alert alert-danger" style="width: 50%;">'+data+'</div><br /><br />');;
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#ajax-smon").append(data);
$(".newserver").addClass( "update", 1000 );
$( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio();
$( "select" ).selectmenu();
$.getScript(awesome);
$.getScript('/inc/unsers.js');
setTimeout(function() {
$( ".newserver" ).removeClass( "update" );
}, 2500 );
}, 2500 );
clearTips();
$( "#smon-add-table" ).dialog("close" );
}
@ -934,13 +907,9 @@ function addUser() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-users").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.remove();
$("#ajax-users").append(data);
var getId = new RegExp('[0-9]+');
var id = data.match(getId);
@ -953,8 +922,7 @@ function addUser() {
}
}
function addServer() {
$('#error').remove();
$('.alert-danger').remove();
toastr.clear()
var valid = true;
var servername = $('#new-server-add').val();
var newip = $('#new-ip').val();
@ -1004,13 +972,9 @@ function addServer() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-servers").append('<div class="alert alert-danger" style="width: 100%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear()
$("#ajax-servers").append(data);
$(".newserver").addClass( "update", 1000 );
$( "input[type=submit], button" ).button();
@ -1056,13 +1020,9 @@ function addBackup() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-backup").html('<div class="alert alert-danger" style="width: 50%;">'+data+'</div><br /><br />');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else if (data.indexOf('success') != '-1') {
$('.alert-danger').remove();
toastr.remove();
$("#ajax-backup-table").append(data);
$(".newbackup").addClass( "update", 1000 );
setTimeout(function() {
@ -1071,8 +1031,8 @@ function addBackup() {
$( "select" ).selectmenu();
$.getScript(awesome);
} else if (data.indexOf('info') != '-1') {
$('.alert-danger').remove();
$("#ajax-backup").html('<div class="alert alert-info">'+data+'</div><br />');
toastr.remove();
toastr.info(data);
}
}
} );
@ -1081,7 +1041,7 @@ function addBackup() {
}
}
function updateSettings(param, val) {
$('.alert-danger').remove();
toastr.clear();
$.ajax( {
url: "options.py",
data: {
@ -1093,13 +1053,9 @@ function updateSettings(param, val) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#"+param).parent().parent().addClass( "update", 1000 );
setTimeout(function() {
$( "#"+param ).parent().parent().removeClass( "update" );
@ -1444,13 +1400,13 @@ function removeSmon(id) {
if(data == "Ok ") {
$("#smon-"+id).remove();
} else {
alert(data);
toastr.error(data);
}
}
} );
}
function updateUser(id) {
$('.alert-danger').remove();
toastr.remove();
cur_url[0] = cur_url[0].split('#')[0]
var usergroup = Cookies.get('group');
var activeuser = 0;
@ -1472,13 +1428,9 @@ function updateUser(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-users").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.remove();
$("#user-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#user-"+id ).removeClass( "update" );
@ -1488,7 +1440,7 @@ function updateUser(id) {
} );
}
function updateGroup(id) {
$('#error').remove();
toastr.clear();
$.ajax( {
url: "options.py",
data: {
@ -1501,13 +1453,9 @@ function updateGroup(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-group").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#group-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#group-"+id ).removeClass( "update" );
@ -1519,7 +1467,7 @@ function updateGroup(id) {
} );
}
function updateServer(id) {
$('.alert-danger').remove();
toastr.clear();
var typeip = 0;
var enable = 0;
var haproxy = 0;
@ -1560,13 +1508,9 @@ function updateServer(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-servers").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#server-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#server-"+id ).removeClass( "update" );
@ -1576,9 +1520,9 @@ function updateServer(id) {
} );
}
function uploadSsh() {
$('.alert-danger').remove();
toastr.clear();
if ($( "#ssh-key-name option:selected" ).val() == "Choose server" || $('#ssh_cert').val() == '') {
$("#ajax-ssh").html('<div class="alert alert-danger" style="margin: 10px;">All fields must be completed</div>');
toastr.error('All fields must be completed');
} else {
$.ajax( {
url: "options.py",
@ -1591,19 +1535,19 @@ function uploadSsh() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('danger') != '-1') {
$("#ajax-ssh").html(data);
toastr.error(data);
} else if (data.indexOf('success') != '-1') {
$('.alert-danger').remove();
$("#ajax-ssh").html(data);
toastr.clear();
toastr.success(data)
} else {
$("#ajax-ssh").html('<div class="alert alert-danger">Something wrong, check and try again</div>');
toastr.error('Something wrong, check and try again');
}
}
} );
}
}
function updateSSH(id) {
$('#error').remove();
toastr.clear();
var ssh_enable = 0;
if ($('#ssh_enable-'+id).is(':checked')) {
ssh_enable = '1';
@ -1628,13 +1572,9 @@ function updateSSH(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-ssh").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#ssh-table-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#ssh-table-"+id ).removeClass( "update" );
@ -1648,7 +1588,7 @@ function updateSSH(id) {
} );
}
function updateTelegram(id) {
$('#error').remove();
toastr.clear();
$.ajax( {
url: "options.py",
data: {
@ -1662,13 +1602,9 @@ function updateTelegram(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-ssh").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#telegram-table-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#telegram-table-"+id ).removeClass( "update" );
@ -1678,9 +1614,9 @@ function updateTelegram(id) {
} );
}
function updateBackup(id) {
$('#error').remove();
toastr.clear();
if ($( "#backup-type-"+id+" option:selected" ).val() == "Choose server" || $('#backup-rserver-'+id).val() == '' || $('#backup-rpath-'+id).val() == '') {
$("#ajax-backup").html('<div class="alert alert-danger" style="margin: 10px;">All fields must be completed</div>');
toastr.error('All fields must be completed');
} else {
$.ajax( {
url: "options.py",
@ -1699,13 +1635,9 @@ function updateBackup(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-backup").html('<div class="alert alert-danger" style="margin: 10px;">'+data+'</div>');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#backup-table-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#backup-table-"+id ).removeClass( "update" );
@ -1716,7 +1648,7 @@ function updateBackup(id) {
}
}
function updateSmon(id) {
$('#error').remove();
toastr.clear();
var enable = 0;
if ($('#smon-enable-'+id).is(':checked')) {
enable = '1';
@ -1728,7 +1660,7 @@ function updateSmon(id) {
updateSmonPort: $('#smon-port-'+id).val(),
updateSmonEn: enable,
updateSmonHttp: $('#smon-proto1-'+id).text(),
updateSmonBody: $('#smon-body-'+id).val(),
updateSmonBody: $('#smon-body-'+id).text(),
updateSmonTelegram: $('#smon-telegram-'+id).val(),
updateSmonGroup: $('#smon-group-'+id).val(),
updateSmonDesc: $('#smon-desc-'+id).val(),
@ -1739,13 +1671,9 @@ function updateSmon(id) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax").html('<div class="alert alert-danger" style="margin: 10px;">'+data+'</div>');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#smon-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#smon-"+id ).removeClass( "update" );
@ -1778,12 +1706,12 @@ function showApacheLog(serv) {
type: "POST",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Logs", "Logs", cur_url[0]+"?serv="+serv+"&rows1="+rows+"&grep="+grep+
'&exgrep='+exgrep+
'&hour='+hour+
'&minut='+minut+
'&hour1='+hour1+
'&minut1='+minut1);
window.history.pushState("Logs", "Logs", cur_url[0] + "?serv=" + serv + "&rows1=" + rows + "&grep=" + grep +
'&exgrep=' + exgrep +
'&hour=' + hour +
'&minut=' + minut +
'&hour1=' + hour1 +
'&minut1=' + minut1);
}
} );
}
@ -1798,15 +1726,11 @@ function checkSshConnect(ip) {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
$("#checkSshConnect").html(data);
toastr.error(data)
} else {
$("#checkSshConnect").html("<div class='alert alert-success' style='margin: 0; margin-left: 15px;'>Connect is accepted<a title='Close' id='errorMess'><b>X</b></a></div>");
toastr.clear();
toastr.success('Connect is accepted');
}
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
$('.alert-success').remove();
});
}
} );
}
@ -1862,13 +1786,9 @@ function changeUserPassword(id, d) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-users").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$("#user-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#user-"+id ).removeClass( "update" );
@ -1889,9 +1809,9 @@ function changeUserGroupDialog(id) {
type: "POST",
success: function( data ) {
if (data.indexOf('danger') != '-1') {
$("#ajax").html(data);
toastr.error(data);
} else {
$('.alert-danger').remove();
toastr.clear();
$('#change-user-groups-form').html(data);
$( "#change-user-groups-dialog" ).dialog({
resizable: false,
@ -1925,10 +1845,14 @@ function changeUserGroup(id) {
},
type: "POST",
success: function( data ) {
$("#user-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#user-"+id ).removeClass( "update" );
}, 2500 );
if (data.indexOf('error') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
$("#user-" + id).addClass("update", 1000);
setTimeout(function () {
$("#user-" + id).removeClass("update");
}, 2500);
}
}
} );
}
@ -1943,10 +1867,14 @@ function addUserGroup(id) {
},
type: "POST",
success: function( data ) {
$("#user-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#user-"+id ).removeClass( "update" );
}, 2500 );
if (data.indexOf('error') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
$("#user-" + id).addClass("update", 1000);
setTimeout(function () {
$("#user-" + id).removeClass("update");
}, 2500);
}
}
} );
}

View File

@ -66,19 +66,13 @@ function installWaf(ip1) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('Failed') != '-1') {
$("#ajax").html('<div class="alert alert-danger" style="margin: 15px;">'+data+'</data>');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
toastr.error(data);
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</data>');
toastr.clear();
toastr.info(data);
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">WAF service has installed</data>');
toastr.clear();
toastr.success('WAF service has installed');
showOverviewWaf(ip, hostnamea)
}
}
@ -96,11 +90,39 @@ function changeWafMode(id) {
},
type: "POST",
success: function( data ) {
alert('Do not forget restart WAF server: '+server_hostname)
toastr.info('Do not forget restart WAF service');
$( '#'+server_hostname+'-select-line' ).addClass( "update", 1000 );
setTimeout(function() {
$( '#'+server_hostname+'-select-line' ).removeClass( "update" );
}, 2500 );
}
} );
}
$( function() {
$( "#waf_rules input" ).change(function() {
var id = $(this).attr('id').split('-');
waf_rules_en(id[1])
});
});
function waf_rules_en(id) {
var enable = 0;
if ($('#rule_id-'+id).is(':checked')) {
enable = '1';
}
$.ajax( {
url: "options.py",
data: {
waf_rule_id: id,
waf_en: enable,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
toastr.info('Do not forget restart WAF service');
$( '#rule-'+id ).addClass( "update", 1000 );
setTimeout(function() {
$( '#rule-'+id ).removeClass( "update" );
}, 2500 );
}
} );
}