mirror of https://github.com/Aidaho12/haproxy-wi
parent
eabc02e234
commit
d2a6676fb0
35
app/sql.py
35
app/sql.py
|
@ -365,20 +365,6 @@ def select_groups(**kwargs):
|
|||
con.close()
|
||||
|
||||
|
||||
def select_user_name_group(id):
|
||||
con, cur = get_cur()
|
||||
sql = """select name from groups where id='%s' """ % id
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
funct.out_error(e)
|
||||
else:
|
||||
for group in cur.fetchone():
|
||||
return group
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def select_server_by_name(name):
|
||||
con, cur = get_cur()
|
||||
sql = """select ip from servers where hostname='%s' """ % name
|
||||
|
@ -592,19 +578,6 @@ def get_role_id_by_name(name):
|
|||
con.close()
|
||||
|
||||
|
||||
def get_user_telegram_by_uuid(uuid):
|
||||
con, cur = get_cur()
|
||||
sql = """ select telegram.* from telegram left join user as user on telegram.groups = user.groups left join uuid as uuid on user.id = uuid.user_id where uuid.uuid = '%s' """ % uuid
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
funct.out_error(e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def get_user_telegram_by_group(group):
|
||||
con, cur = get_cur()
|
||||
sql = """ select telegram.* from telegram where groups = '%s' """ % group
|
||||
|
@ -1367,7 +1340,7 @@ def select_servers_metrics(uuid, **kwargs):
|
|||
if group == '1':
|
||||
sql = """ select ip from servers where enable = 1 and metrics = '1' """
|
||||
else:
|
||||
sql = """ select ip from servers where groups like '%{group}%' and metrics = '1'""".format(group=group)
|
||||
sql = """ select ip from servers where groups = '{group}' and metrics = '1'""".format(group=group)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
|
@ -1655,6 +1628,7 @@ def select_roles(**kwargs):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def select_alert(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """select ip from servers where alert = 1 """
|
||||
|
@ -1886,6 +1860,7 @@ def update_smon(id, ip, port, body, telegram, group, desc, en):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def select_en_service():
|
||||
con, cur = get_cur()
|
||||
sql = """ select ip, port, telegram_channel_id, id from smon where en = 1"""
|
||||
|
@ -2054,13 +2029,13 @@ def smon_list(user_group):
|
|||
|
||||
|
||||
form = funct.form
|
||||
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'
|
||||
|
||||
|
||||
def check_token():
|
||||
if not check_token_exists(form.getvalue('token')):
|
||||
print('Content-type: text/html\n')
|
||||
print("Your token has been expired")
|
||||
print("error: Your token has been expired")
|
||||
import sys
|
||||
sys.exit()
|
||||
|
||||
|
|
34
inc/users.js
34
inc/users.js
|
@ -818,11 +818,11 @@ function addNewSmonServer(dialog_id) {
|
|||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
common_ajax_action_after_success(dialog_id, 'newserver', 'ajax-smon', data);
|
||||
$( "input[type=submit], button" ).button();
|
||||
$( "input[type=checkbox]" ).checkboxradio();
|
||||
$( "select" ).selectmenu();
|
||||
$.getScript('/inc/unsers.js');
|
||||
common_ajax_action_after_success(dialog_id, 'newserver', 'ajax-smon', data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1064,10 +1064,10 @@ function addBackup(dialog_id) {
|
|||
if (data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1') {
|
||||
$( "select" ).selectmenu();
|
||||
common_ajax_action_after_success(dialog_id, 'newbackup', 'ajax-backup-table', data);
|
||||
$( "select" ).selectmenu();
|
||||
} else if (data.indexOf('info') != '-1') {
|
||||
toastr.remove();
|
||||
toastr.clear();
|
||||
toastr.info(data);
|
||||
}
|
||||
}
|
||||
|
@ -1324,6 +1324,8 @@ function removeUser(id) {
|
|||
data = data.replace(/\s+/g,' ');
|
||||
if(data == "Ok ") {
|
||||
$("#user-"+id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1341,6 +1343,8 @@ function removeServer(id) {
|
|||
data = data.replace(/\s+/g,' ');
|
||||
if(data == "Ok ") {
|
||||
$("#server-"+id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1360,6 +1364,8 @@ function removeGroup(id) {
|
|||
$("#group-"+id).remove();
|
||||
$('select:regex(id, group) option[value='+id+']').remove();
|
||||
$('select:regex(id, group)').selectmenu("refresh");
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1379,6 +1385,8 @@ function removeSsh(id) {
|
|||
$("#ssh-table-"+id).remove();
|
||||
$('select:regex(id, credentials) option[value='+id+']').remove();
|
||||
$('select:regex(id, credentials)').selectmenu("refresh");
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1396,6 +1404,8 @@ function removeTelegram(id) {
|
|||
data = data.replace(/\s+/g,' ');
|
||||
if(data == "Ok ") {
|
||||
$("#telegram-table-"+id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1416,6 +1426,8 @@ function removeBackup(id) {
|
|||
data = data.replace(/\s+/g,' ');
|
||||
if(data.indexOf('Ok') != '-1') {
|
||||
$("#backup-table-"+id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -1461,7 +1473,7 @@ function updateUser(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.remove();
|
||||
|
@ -1486,7 +1498,7 @@ function updateGroup(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
@ -1541,7 +1553,7 @@ function updateServer(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
@ -1568,7 +1580,7 @@ function uploadSsh() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('danger') != '-1') {
|
||||
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1') {
|
||||
toastr.clear();
|
||||
|
@ -1605,7 +1617,7 @@ function updateSSH(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
@ -1635,7 +1647,7 @@ function updateTelegram(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
@ -1668,7 +1680,7 @@ function updateBackup(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
@ -1704,7 +1716,7 @@ function updateSmon(id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
|
Loading…
Reference in New Issue