mirror of https://github.com/Aidaho12/haproxy-wi
parent
2ae315ea27
commit
456fb657e5
|
@ -26,6 +26,7 @@ For install just [dowload](https://github.com/Aidaho12/haproxy-wi/archive/master
|
|||
$ cd /var/www/
|
||||
$ unzip master.zip
|
||||
$ mv haproxy-wi-master/ haproxy-wi
|
||||
$ pip install -r haproxy-wi/requirements.txt
|
||||
$ cd haproxy-wi/cgi-bin
|
||||
$ chmod +x *.py
|
||||
$ ./create_db.py
|
||||
|
|
|
@ -188,7 +188,7 @@ def links():
|
|||
'</li>')
|
||||
print('</ul>'
|
||||
'</nav>'
|
||||
'<div class="copyright-menu">HAproxy-WI v2.0.2</div>'
|
||||
'<div class="copyright-menu">HAproxy-WI v2.0.2.1</div>'
|
||||
'</div>')
|
||||
|
||||
def show_login_links():
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#Path to files destination
|
||||
fullpath = /var/www/haproxy-wi/
|
||||
cgi_path = %(fullpath)s/cgi-bin/
|
||||
server_bind_ip = 0.0.0.0
|
||||
server_port = 8000
|
||||
log_path = %(fullpath)s/log/
|
||||
time_zone = UTC
|
||||
|
||||
|
|
|
@ -58,11 +58,12 @@ def add_group(name, description):
|
|||
sql = """INSERT INTO groups (name, description) VALUES ('%s', '%s')""" % (name, description)
|
||||
try:
|
||||
with con:
|
||||
cur.executescript(sql)
|
||||
cur.execute(sql)
|
||||
except sqlite.Error as e:
|
||||
print('<span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
|
||||
return False
|
||||
else:
|
||||
print(cur.lastrowid)
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
@ -318,7 +319,7 @@ def show_update_user(user):
|
|||
need_id_group = "usergroup-%s" % users[0]
|
||||
get_groups_select(need_id_group, selected=users[5])
|
||||
print('</td>')
|
||||
print('<td><a class="update-row" onclick="updateUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
#print('<td><a class="update-row" onclick="updateUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
print('<td><a class="delete" onclick="removeUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
print('</tr>')
|
||||
|
||||
|
@ -338,7 +339,7 @@ def show_update_server(server):
|
|||
print('<td>')
|
||||
get_type_ip_checkbox(server[0])
|
||||
print('</td>')
|
||||
print('<td><a class="update-row" onclick="updateServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
#print('<td><a class="update-row" onclick="updateServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
print('<td><a class="delete" onclick="removeServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
print('</tr>')
|
||||
|
||||
|
@ -348,7 +349,7 @@ def show_update_group(group):
|
|||
print('<tr id="group-%s">' % group[0])
|
||||
print('<td class="padding10 first-collumn"><input type="text" name="name-%s" value="%s" class="form-control"></td>' % (group[0], group[1]))
|
||||
print('<td><input type="text" name="descript-%s" value="%s" class="form-control" size="100"></td>' % (group[0], group[2]))
|
||||
print('<td></td>')
|
||||
print('<td><a class="delete" onclick="removeGroup(%s)" style="cursor: pointer;"></a></td>' % group[0])
|
||||
print('<td></td>')
|
||||
print('</tr>')
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ for users in USERS:
|
|||
need_id_group = "usergroup-%s" % users[0]
|
||||
sql.get_groups_select(need_id_group, selected=users[5])
|
||||
print('</td>')
|
||||
print('<td><a class="update-row" onclick="updateUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
#print('<td><a class="update-row" onclick="updateUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
print('<td><a class="delete" onclick="removeUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||
print('</tr>')
|
||||
print('</table>'
|
||||
|
@ -90,7 +90,7 @@ for group in GROUPS:
|
|||
print('<tr id="group-%s">' % group[0])
|
||||
print('<td class="padding10 first-collumn"><input type="text" id="name-%s" value="%s" class="form-control"></td>' % (group[0], group[1]))
|
||||
print('<td><input type="text" id="descript-%s" value="%s" class="form-control" size="100"></td>' % (group[0], group[2]))
|
||||
print('<td><a class="update-row" onclick="updateGroup(%s)" style="cursor: pointer;"></a></td>' % group[0])
|
||||
#print('<td><a class="update-row" onclick="updateGroup(%s)" style="cursor: pointer;"></a></td>' % group[0])
|
||||
print('<td><a class="delete" onclick="removeGroup(%s)" style="cursor: pointer;"></a></td>' % group[0])
|
||||
print('</tr>')
|
||||
print('</table>'
|
||||
|
@ -135,7 +135,7 @@ for server in SERVERS:
|
|||
print('<td>')
|
||||
sql.get_type_ip_checkbox(server[0])
|
||||
print('</td>')
|
||||
print('<td><a class="update-row" onclick="updateServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
#print('<td><a class="update-row" onclick="updateServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
print('<td><a class="delete" onclick="removeServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||
print('</tr>')
|
||||
print('</table>'
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 255 KiB |
|
@ -253,7 +253,6 @@ $( function() {
|
|||
});
|
||||
$( "input[type=submit], button" ).button();
|
||||
$( "input[type=checkbox]" ).checkboxradio();
|
||||
$( "#number" ).spinner();
|
||||
$( ".controlgroup" ).controlgroup();
|
||||
|
||||
function ajaxActionServers(action, id) {
|
||||
|
|
|
@ -266,7 +266,7 @@ pre {
|
|||
font-weight: bold;
|
||||
}
|
||||
.overview tr{
|
||||
border: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
|
|
104
inc/users.js
104
inc/users.js
|
@ -1,6 +1,19 @@
|
|||
var users = '/inc/usersdop.js'
|
||||
var awesome = "/inc/fontawesome.min.js"
|
||||
|
||||
jQuery.expr[':'].regex = function(elem, index, match) {
|
||||
var matchParams = match[3].split(','),
|
||||
validLabels = /^(data|css):/,
|
||||
attr = {
|
||||
method: matchParams[0].match(validLabels) ?
|
||||
matchParams[0].split(':')[0] : 'attr',
|
||||
property: matchParams.shift().replace(validLabels,'')
|
||||
},
|
||||
regexFlags = 'ig',
|
||||
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
|
||||
return regex.test(jQuery(elem)[attr.method](attr.property));
|
||||
}
|
||||
|
||||
$( function() {
|
||||
$('.alert-danger').remove();
|
||||
|
||||
|
@ -41,9 +54,17 @@ $( function() {
|
|||
},
|
||||
type: "GET",
|
||||
success: function( data ) {
|
||||
$("#ajax-group").append(data);
|
||||
$( "#ajax-group tr td" ).addClass( "update", 1000, callbackGroup );
|
||||
window.location.reload();
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajax-group").append(data);
|
||||
$.getScript(users);
|
||||
} else {
|
||||
var getId = new RegExp('[0-9]+');
|
||||
var id = data.match(getId);
|
||||
$("#ajax-group").append(data);
|
||||
$( "#ajax-group tr td" ).addClass( "update", 1000, callbackGroup );
|
||||
$('select:regex(id, group)').append('<option value='+id+'>'+$('#new-group-add').val()+'</option>').selectmenu("refresh");
|
||||
$.getScript(awesome);
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
@ -73,7 +94,7 @@ $( function() {
|
|||
$("#ajax-servers").append(data);
|
||||
$.getScript(users);
|
||||
} else {
|
||||
$('.alert-danger').hide();
|
||||
$('.alert-danger').remove();
|
||||
$("#ajax-servers").append(data);
|
||||
$( "#ajax-servers tr td" ).addClass( "update", 1000, callback );
|
||||
$.getScript(url);
|
||||
|
@ -117,6 +138,26 @@ $( function() {
|
|||
}
|
||||
});
|
||||
|
||||
$( "#ajax-users input" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateUser(id[1])
|
||||
});
|
||||
$( "#ajax-users select" ).on('selectmenuchange',function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateUser(id[1])
|
||||
});
|
||||
$( "#ajax-group input" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateGroup(id[1])
|
||||
});
|
||||
$( "#ajax-servers input" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateServer(id[1])
|
||||
});
|
||||
$( "#ajax-servers select" ).on('selectmenuchange',function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateServer(id[1])
|
||||
});
|
||||
} );
|
||||
function removeUser(id) {
|
||||
$("#user-"+id).css("background-color", "#f2dede");
|
||||
|
@ -162,11 +203,14 @@ function removeGroup(id) {
|
|||
data = data.replace(/\s+/g,' ');
|
||||
if(data == "Ok ") {
|
||||
$("#group-"+id).remove();
|
||||
$('select:regex(id, group) option[value='+id+']').remove();
|
||||
$('select:regex(id, group)').selectmenu("refresh");
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function updateUser(id) {
|
||||
$('.alert-danger').remove();
|
||||
$.ajax( {
|
||||
url: "sql.py",
|
||||
data: {
|
||||
|
@ -180,18 +224,21 @@ function updateUser(id) {
|
|||
type: "GET",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data == "All fields must be completed ") {
|
||||
alert(data);
|
||||
} else {
|
||||
$("#user-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#user-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajax-users").append(data);
|
||||
$.getScript(users);
|
||||
} else {
|
||||
$('.alert-danger').remove();
|
||||
$("#user-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#user-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function updateGroup(id) {
|
||||
$('#error').remove();
|
||||
$.ajax( {
|
||||
url: "sql.py",
|
||||
data: {
|
||||
|
@ -202,18 +249,23 @@ function updateGroup(id) {
|
|||
type: "GET",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data == "All fields must be completed ") {
|
||||
alert(data);
|
||||
} else {
|
||||
$("#group-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#group-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajax-group").append(data);
|
||||
$.getScript(users);
|
||||
} else {
|
||||
$('.alert-danger').remove();
|
||||
$("#group-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#group-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
$('select:regex(id, group) option[value='+id+']').remove();
|
||||
$('select:regex(id, group)').append('<option value='+id+'>'+$('#name-'+id).val()+'</option>').selectmenu("refresh");
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function updateServer(id) {
|
||||
$('.alert-danger').remove();
|
||||
var typeip = 0;
|
||||
var enable = 0;
|
||||
if ($('#typeip-'+id).is(':checked')) {
|
||||
|
@ -235,13 +287,15 @@ function updateServer(id) {
|
|||
type: "GET",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data == "All fields must be completed ") {
|
||||
alert(data);
|
||||
} else {
|
||||
$("#server-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#server-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajax-servers").append(data);
|
||||
$.getScript(users);
|
||||
} else {
|
||||
$('.alert-danger').remove();
|
||||
$("#server-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#server-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue