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/
|
$ cd /var/www/
|
||||||
$ unzip master.zip
|
$ unzip master.zip
|
||||||
$ mv haproxy-wi-master/ haproxy-wi
|
$ mv haproxy-wi-master/ haproxy-wi
|
||||||
|
$ pip install -r haproxy-wi/requirements.txt
|
||||||
$ cd haproxy-wi/cgi-bin
|
$ cd haproxy-wi/cgi-bin
|
||||||
$ chmod +x *.py
|
$ chmod +x *.py
|
||||||
$ ./create_db.py
|
$ ./create_db.py
|
||||||
|
|
|
@ -188,7 +188,7 @@ def links():
|
||||||
'</li>')
|
'</li>')
|
||||||
print('</ul>'
|
print('</ul>'
|
||||||
'</nav>'
|
'</nav>'
|
||||||
'<div class="copyright-menu">HAproxy-WI v2.0.2</div>'
|
'<div class="copyright-menu">HAproxy-WI v2.0.2.1</div>'
|
||||||
'</div>')
|
'</div>')
|
||||||
|
|
||||||
def show_login_links():
|
def show_login_links():
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#Path to files destination
|
#Path to files destination
|
||||||
fullpath = /var/www/haproxy-wi/
|
fullpath = /var/www/haproxy-wi/
|
||||||
cgi_path = %(fullpath)s/cgi-bin/
|
cgi_path = %(fullpath)s/cgi-bin/
|
||||||
server_bind_ip = 0.0.0.0
|
|
||||||
server_port = 8000
|
|
||||||
log_path = %(fullpath)s/log/
|
log_path = %(fullpath)s/log/
|
||||||
time_zone = UTC
|
time_zone = UTC
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,12 @@ def add_group(name, description):
|
||||||
sql = """INSERT INTO groups (name, description) VALUES ('%s', '%s')""" % (name, description)
|
sql = """INSERT INTO groups (name, description) VALUES ('%s', '%s')""" % (name, description)
|
||||||
try:
|
try:
|
||||||
with con:
|
with con:
|
||||||
cur.executescript(sql)
|
cur.execute(sql)
|
||||||
except sqlite.Error as e:
|
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>')
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
|
print(cur.lastrowid)
|
||||||
return True
|
return True
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
@ -318,7 +319,7 @@ def show_update_user(user):
|
||||||
need_id_group = "usergroup-%s" % users[0]
|
need_id_group = "usergroup-%s" % users[0]
|
||||||
get_groups_select(need_id_group, selected=users[5])
|
get_groups_select(need_id_group, selected=users[5])
|
||||||
print('</td>')
|
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('<td><a class="delete" onclick="removeUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
|
|
||||||
|
@ -338,7 +339,7 @@ def show_update_server(server):
|
||||||
print('<td>')
|
print('<td>')
|
||||||
get_type_ip_checkbox(server[0])
|
get_type_ip_checkbox(server[0])
|
||||||
print('</td>')
|
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('<td><a class="delete" onclick="removeServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
|
|
||||||
|
@ -348,7 +349,7 @@ def show_update_group(group):
|
||||||
print('<tr id="group-%s">' % group[0])
|
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 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><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('<td></td>')
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ for users in USERS:
|
||||||
need_id_group = "usergroup-%s" % users[0]
|
need_id_group = "usergroup-%s" % users[0]
|
||||||
sql.get_groups_select(need_id_group, selected=users[5])
|
sql.get_groups_select(need_id_group, selected=users[5])
|
||||||
print('</td>')
|
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('<td><a class="delete" onclick="removeUser(%s)" style="cursor: pointer;"></a></td>' % users[0])
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
print('</table>'
|
print('</table>'
|
||||||
|
@ -90,7 +90,7 @@ for group in GROUPS:
|
||||||
print('<tr id="group-%s">' % group[0])
|
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 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><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('<td><a class="delete" onclick="removeGroup(%s)" style="cursor: pointer;"></a></td>' % group[0])
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
print('</table>'
|
print('</table>'
|
||||||
|
@ -135,7 +135,7 @@ for server in SERVERS:
|
||||||
print('<td>')
|
print('<td>')
|
||||||
sql.get_type_ip_checkbox(server[0])
|
sql.get_type_ip_checkbox(server[0])
|
||||||
print('</td>')
|
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('<td><a class="delete" onclick="removeServer(%s)" style="cursor: pointer;"></a></td>' % server[0])
|
||||||
print('</tr>')
|
print('</tr>')
|
||||||
print('</table>'
|
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=submit], button" ).button();
|
||||||
$( "input[type=checkbox]" ).checkboxradio();
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
$( "#number" ).spinner();
|
|
||||||
$( ".controlgroup" ).controlgroup();
|
$( ".controlgroup" ).controlgroup();
|
||||||
|
|
||||||
function ajaxActionServers(action, id) {
|
function ajaxActionServers(action, id) {
|
||||||
|
|
|
@ -266,7 +266,7 @@ pre {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.overview tr{
|
.overview tr{
|
||||||
border: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
70
inc/users.js
70
inc/users.js
|
@ -1,6 +1,19 @@
|
||||||
var users = '/inc/usersdop.js'
|
var users = '/inc/usersdop.js'
|
||||||
var awesome = "/inc/fontawesome.min.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() {
|
$( function() {
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
|
|
||||||
|
@ -41,9 +54,17 @@ $( function() {
|
||||||
},
|
},
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
|
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").append(data);
|
||||||
$( "#ajax-group tr td" ).addClass( "update", 1000, callbackGroup );
|
$( "#ajax-group tr td" ).addClass( "update", 1000, callbackGroup );
|
||||||
window.location.reload();
|
$('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);
|
$("#ajax-servers").append(data);
|
||||||
$.getScript(users);
|
$.getScript(users);
|
||||||
} else {
|
} else {
|
||||||
$('.alert-danger').hide();
|
$('.alert-danger').remove();
|
||||||
$("#ajax-servers").append(data);
|
$("#ajax-servers").append(data);
|
||||||
$( "#ajax-servers tr td" ).addClass( "update", 1000, callback );
|
$( "#ajax-servers tr td" ).addClass( "update", 1000, callback );
|
||||||
$.getScript(url);
|
$.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) {
|
function removeUser(id) {
|
||||||
$("#user-"+id).css("background-color", "#f2dede");
|
$("#user-"+id).css("background-color", "#f2dede");
|
||||||
|
@ -162,11 +203,14 @@ function removeGroup(id) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if(data == "Ok ") {
|
if(data == "Ok ") {
|
||||||
$("#group-"+id).remove();
|
$("#group-"+id).remove();
|
||||||
|
$('select:regex(id, group) option[value='+id+']').remove();
|
||||||
|
$('select:regex(id, group)').selectmenu("refresh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
function updateUser(id) {
|
function updateUser(id) {
|
||||||
|
$('.alert-danger').remove();
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "sql.py",
|
url: "sql.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -180,9 +224,11 @@ function updateUser(id) {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data == "All fields must be completed ") {
|
if (data.indexOf('error') != '-1') {
|
||||||
alert(data);
|
$("#ajax-users").append(data);
|
||||||
|
$.getScript(users);
|
||||||
} else {
|
} else {
|
||||||
|
$('.alert-danger').remove();
|
||||||
$("#user-"+id).addClass( "update", 1000 );
|
$("#user-"+id).addClass( "update", 1000 );
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$( "#user-"+id ).removeClass( "update" );
|
$( "#user-"+id ).removeClass( "update" );
|
||||||
|
@ -192,6 +238,7 @@ function updateUser(id) {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
function updateGroup(id) {
|
function updateGroup(id) {
|
||||||
|
$('#error').remove();
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "sql.py",
|
url: "sql.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -202,18 +249,23 @@ function updateGroup(id) {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data == "All fields must be completed ") {
|
if (data.indexOf('error') != '-1') {
|
||||||
alert(data);
|
$("#ajax-group").append(data);
|
||||||
|
$.getScript(users);
|
||||||
} else {
|
} else {
|
||||||
|
$('.alert-danger').remove();
|
||||||
$("#group-"+id).addClass( "update", 1000 );
|
$("#group-"+id).addClass( "update", 1000 );
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$( "#group-"+id ).removeClass( "update" );
|
$( "#group-"+id ).removeClass( "update" );
|
||||||
}, 2500 );
|
}, 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) {
|
function updateServer(id) {
|
||||||
|
$('.alert-danger').remove();
|
||||||
var typeip = 0;
|
var typeip = 0;
|
||||||
var enable = 0;
|
var enable = 0;
|
||||||
if ($('#typeip-'+id).is(':checked')) {
|
if ($('#typeip-'+id).is(':checked')) {
|
||||||
|
@ -235,9 +287,11 @@ function updateServer(id) {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
data = data.replace(/\s+/g,' ');
|
data = data.replace(/\s+/g,' ');
|
||||||
if (data == "All fields must be completed ") {
|
if (data.indexOf('error') != '-1') {
|
||||||
alert(data);
|
$("#ajax-servers").append(data);
|
||||||
|
$.getScript(users);
|
||||||
} else {
|
} else {
|
||||||
|
$('.alert-danger').remove();
|
||||||
$("#server-"+id).addClass( "update", 1000 );
|
$("#server-"+id).addClass( "update", 1000 );
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$( "#server-"+id ).removeClass( "update" );
|
$( "#server-"+id ).removeClass( "update" );
|
||||||
|
|
Loading…
Reference in New Issue