mirror of https://github.com/Aidaho12/haproxy-wi
parent
eabc02e234
commit
d2a6676fb0
37
app/sql.py
37
app/sql.py
|
@ -365,20 +365,6 @@ def select_groups(**kwargs):
|
||||||
con.close()
|
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):
|
def select_server_by_name(name):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """select ip from servers where hostname='%s' """ % name
|
sql = """select ip from servers where hostname='%s' """ % name
|
||||||
|
@ -590,19 +576,6 @@ def get_role_id_by_name(name):
|
||||||
return user_id[0]
|
return user_id[0]
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
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):
|
def get_user_telegram_by_group(group):
|
||||||
|
@ -1367,7 +1340,7 @@ def select_servers_metrics(uuid, **kwargs):
|
||||||
if group == '1':
|
if group == '1':
|
||||||
sql = """ select ip from servers where enable = 1 and metrics = '1' """
|
sql = """ select ip from servers where enable = 1 and metrics = '1' """
|
||||||
else:
|
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:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
except sqltool.Error as e:
|
except sqltool.Error as e:
|
||||||
|
@ -1654,7 +1627,8 @@ def select_roles(**kwargs):
|
||||||
return cur.fetchall()
|
return cur.fetchall()
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def select_alert(**kwargs):
|
def select_alert(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """select ip from servers where alert = 1 """
|
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()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def select_en_service():
|
def select_en_service():
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ select ip, port, telegram_channel_id, id from smon where en = 1"""
|
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
|
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():
|
def check_token():
|
||||||
if not check_token_exists(form.getvalue('token')):
|
if not check_token_exists(form.getvalue('token')):
|
||||||
print('Content-type: text/html\n')
|
print('Content-type: text/html\n')
|
||||||
print("Your token has been expired")
|
print("error: Your token has been expired")
|
||||||
import sys
|
import sys
|
||||||
sys.exit()
|
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') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
|
common_ajax_action_after_success(dialog_id, 'newserver', 'ajax-smon', data);
|
||||||
$( "input[type=submit], button" ).button();
|
$( "input[type=submit], button" ).button();
|
||||||
$( "input[type=checkbox]" ).checkboxradio();
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
$( "select" ).selectmenu();
|
$( "select" ).selectmenu();
|
||||||
$.getScript('/inc/unsers.js');
|
$.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') {
|
if (data.indexOf('error:') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else if (data.indexOf('success') != '-1') {
|
} else if (data.indexOf('success') != '-1') {
|
||||||
$( "select" ).selectmenu();
|
|
||||||
common_ajax_action_after_success(dialog_id, 'newbackup', 'ajax-backup-table', data);
|
common_ajax_action_after_success(dialog_id, 'newbackup', 'ajax-backup-table', data);
|
||||||
|
$( "select" ).selectmenu();
|
||||||
} else if (data.indexOf('info') != '-1') {
|
} else if (data.indexOf('info') != '-1') {
|
||||||
toastr.remove();
|
toastr.clear();
|
||||||
toastr.info(data);
|
toastr.info(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1324,6 +1324,8 @@ function removeUser(id) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if(data == "Ok ") {
|
if(data == "Ok ") {
|
||||||
$("#user-"+id).remove();
|
$("#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,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if(data == "Ok ") {
|
if(data == "Ok ") {
|
||||||
$("#server-"+id).remove();
|
$("#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();
|
$("#group-"+id).remove();
|
||||||
$('select:regex(id, group) option[value='+id+']').remove();
|
$('select:regex(id, group) option[value='+id+']').remove();
|
||||||
$('select:regex(id, group)').selectmenu("refresh");
|
$('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();
|
$("#ssh-table-"+id).remove();
|
||||||
$('select:regex(id, credentials) option[value='+id+']').remove();
|
$('select:regex(id, credentials) option[value='+id+']').remove();
|
||||||
$('select:regex(id, credentials)').selectmenu("refresh");
|
$('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,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if(data == "Ok ") {
|
if(data == "Ok ") {
|
||||||
$("#telegram-table-"+id).remove();
|
$("#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,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if(data.indexOf('Ok') != '-1') {
|
if(data.indexOf('Ok') != '-1') {
|
||||||
$("#backup-table-"+id).remove();
|
$("#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",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.remove();
|
toastr.remove();
|
||||||
|
@ -1486,7 +1498,7 @@ function updateGroup(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1541,7 +1553,7 @@ function updateServer(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1568,7 +1580,7 @@ function uploadSsh() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
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);
|
toastr.error(data);
|
||||||
} else if (data.indexOf('success') != '-1') {
|
} else if (data.indexOf('success') != '-1') {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1605,7 +1617,7 @@ function updateSSH(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1635,7 +1647,7 @@ function updateTelegram(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1668,7 +1680,7 @@ function updateBackup(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
@ -1704,7 +1716,7 @@ function updateSmon(id) {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
|
|
Loading…
Reference in New Issue