mirror of https://github.com/Aidaho12/haproxy-wi
				
				
				
			
							parent
							
								
									47dfa23d21
								
							
						
					
					
						commit
						278bf1a90b
					
				| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
#Meet Haproxy-wi 2.0! Now with DB and Admin web interface! Life has become easier, life has become more cheerful!
 | 
			
		||||
# Meet Haproxy-wi 2.0! Now with DB and Admin web interface! Life has become easier, life has become more cheerful!
 | 
			
		||||
 | 
			
		||||
# Haproxy web interface
 | 
			
		||||
A simple web interface(user-frendly web GUI) for managing Haproxy servers. Leave your [feedback](https://github.com/Aidaho12/haproxy-wi/issues)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -161,7 +161,6 @@ def links():
 | 
			
		|||
					'<ul>'
 | 
			
		||||
						'<li><a href=/cgi-bin/overview.py title="Server and service status" class="overview-link">Overview</a> </li>'
 | 
			
		||||
						'<li><a href=/cgi-bin/viewsttats.py title"Show stats" class="stats">Stats</a> </li>'
 | 
			
		||||
						'<li><a href="http://172.28.5.106:3000/d/000000002/haproxy?refresh=1m&orgId=1" title="Mon" target="_blanck" class="mon">Monitoring</a> </li>'
 | 
			
		||||
						'<li><a href=/cgi-bin/logs.py title="View logs" class="logs">Logs</a></li>'
 | 
			
		||||
						'<li><a href=/cgi-bin/map.py title="View map" class="map">Map</a></li>'
 | 
			
		||||
					'</ul>'
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +197,7 @@ def links():
 | 
			
		|||
				'</li>')
 | 
			
		||||
	print('</ul>'
 | 
			
		||||
		  '</nav>'
 | 
			
		||||
		  '<div class="copyright-menu">HAproxy-WI v2.0</div>'
 | 
			
		||||
		  '<div class="copyright-menu">HAproxy-WI v2.0.0.1</div>'
 | 
			
		||||
		  '</div>')	
 | 
			
		||||
 | 
			
		||||
def show_login_links():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,10 @@ def add_user(user, email, password, role, group):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
		return False
 | 
			
		||||
	else:
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close()   
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +34,10 @@ def update_user(user, email, password, role, group, id):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
		return False
 | 
			
		||||
	else:
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +60,10 @@ def add_group(name, description):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
		return False
 | 
			
		||||
	else:
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close() 
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +74,7 @@ def delete_group(id):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
	else: 
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +91,10 @@ def update_group(name, descript, id):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
		return False
 | 
			
		||||
	else:
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +105,10 @@ def add_server(hostname, ip, group):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
		return False
 | 
			
		||||
	else:
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close() 	
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +119,7 @@ def delete_server(id):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
	else: 
 | 
			
		||||
		return True
 | 
			
		||||
	cur.close()    
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +136,7 @@ def update_server(hostname, ip, group, id):
 | 
			
		|||
		with con:
 | 
			
		||||
			cur.executescript(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
	cur.close()    
 | 
			
		||||
	con.close()
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +162,7 @@ def select_groups(**kwargs):
 | 
			
		|||
	try:    
 | 
			
		||||
		cur.execute(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
	else:
 | 
			
		||||
		return cur.fetchall()
 | 
			
		||||
	cur.close()    
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +174,7 @@ def select_user_name_group(id):
 | 
			
		|||
	try:    
 | 
			
		||||
		cur.execute(sql)
 | 
			
		||||
	except sqlite.Error as e:
 | 
			
		||||
		print("An error occurred:", e.args[0])
 | 
			
		||||
		print('<br /><span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + '</span>')
 | 
			
		||||
	else:
 | 
			
		||||
		return cur.fetchone()
 | 
			
		||||
	cur.close()    
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +247,7 @@ def show_update_servers():
 | 
			
		|||
			'</tr>')
 | 
			
		||||
	for server in SERVERS:
 | 
			
		||||
		print('<tr id="server-%s">' % server[0])
 | 
			
		||||
		print('<td class="padding10"><input type="text" name="server-%s" value="%s" class="form-control" onclick="deleteServer(%s)"></td>' % (server[0], server[1], server[0]))
 | 
			
		||||
		print('<td class="padding10 first-collumn"><input type="text" name="server-%s" value="%s" class="form-control"></td>' % (server[0], server[1]))
 | 
			
		||||
		print('<td><input type="text" name="descript-%s" value="%s" class="form-control"></td>' % (server[0], server[2]))
 | 
			
		||||
		print('<td>')
 | 
			
		||||
		get_groups_select("123", selected=server[3])
 | 
			
		||||
| 
						 | 
				
			
			@ -244,7 +259,7 @@ def show_update_user(user):
 | 
			
		|||
	USERS = select_users(user=user)
 | 
			
		||||
	for users in USERS:
 | 
			
		||||
		print('<tr id="user-%s">' % users[0])
 | 
			
		||||
		print('<td class="padding10"><input type="text" id="login-%s" value="%s" class="form-control"></td>' % (users[0], users[1]))
 | 
			
		||||
		print('<td class="padding10 first-collumn"><input type="text" id="login-%s" value="%s" class="form-control"></td>' % (users[0], users[1]))
 | 
			
		||||
		print('<td><input type="password" id="password-%s" value="%s" class="form-control"></td>' % (users[0], users[3]))
 | 
			
		||||
		print('<td><input type="text" id="email-%s" value="%s" class="form-control"></td>' % (users[0], users[2]))
 | 
			
		||||
		print('<td>')
 | 
			
		||||
| 
						 | 
				
			
			@ -263,12 +278,12 @@ def show_update_server(server):
 | 
			
		|||
	SERVERS = select_servers(server=server)
 | 
			
		||||
	for server in SERVERS:
 | 
			
		||||
		print('<tr id="server-%s">' % server[0])
 | 
			
		||||
		print('<td class="padding10"><input type="text" name="hostname-%s" value="%s" class="form-control" onclick="deleteServer(%s)"></td>' % (server[0], server[1], server[0]))
 | 
			
		||||
		print('<td class="padding10 first-collumn"><input type="text" name="hostname-%s" value="%s" class="form-control"></td>' % (server[0], server[1]))
 | 
			
		||||
		print('<td><input type="text" name="ip-%s" value="%s" class="form-control"></td>' % (server[0], server[2]))
 | 
			
		||||
		print('<td>')
 | 
			
		||||
		get_groups_select("123", selected=server[3])
 | 
			
		||||
		print('</td>')
 | 
			
		||||
		print('<td><a class="update-row" onclick="updateServer(%s)"  style="cursor: pointer;"></a></td>' % users[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>')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -323,7 +338,9 @@ def get_roles_select(id, **kwargs):
 | 
			
		|||
				selected = ""
 | 
			
		||||
		print('<option value="%s" %s>%s</option>' % (role[1], selected, role[1]))
 | 
			
		||||
	print('</select>')	
 | 
			
		||||
	
 | 
			
		||||
form = cgi.FieldStorage()
 | 
			
		||||
error_mess = '<br /><span class="alert alert-danger" id="error">All fields must be completed <a title="Close" id="errorMess"><b>X</b></a></span>'
 | 
			
		||||
 | 
			
		||||
if form.getvalue('newusername') is not None:
 | 
			
		||||
	email = form.getvalue('newemail')
 | 
			
		||||
| 
						 | 
				
			
			@ -333,11 +350,11 @@ if form.getvalue('newusername') is not None:
 | 
			
		|||
	new_user = form.getvalue('newusername')	
 | 
			
		||||
	if password is None or role is None or group is None:
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		print("All fields must be completed")
 | 
			
		||||
		print(error_mess)
 | 
			
		||||
	else:		
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		add_user(new_user, email, password, role, group)
 | 
			
		||||
		show_update_user(new_user)
 | 
			
		||||
		if add_user(new_user, email, password, role, group):
 | 
			
		||||
			show_update_user(new_user)
 | 
			
		||||
		
 | 
			
		||||
if form.getvalue('updateuser') is not None:
 | 
			
		||||
	email = form.getvalue('email')
 | 
			
		||||
| 
						 | 
				
			
			@ -348,7 +365,7 @@ if form.getvalue('updateuser') is not None:
 | 
			
		|||
	id = form.getvalue('id')	
 | 
			
		||||
	if password is None or role is None or group is None:
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		print("All fields must be completed")
 | 
			
		||||
		print(error_mess)
 | 
			
		||||
	else:		
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		update_user(new_user, email, password, role, group, id)
 | 
			
		||||
| 
						 | 
				
			
			@ -364,11 +381,11 @@ if form.getvalue('newserver') is not None:
 | 
			
		|||
	group = form.getvalue('newservergroup')
 | 
			
		||||
	if ip is None or group is None:
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		print("All fields must be completed")
 | 
			
		||||
		print(error_mess)
 | 
			
		||||
	else:		
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		add_server(hostname, ip, group)
 | 
			
		||||
		show_update_server(hostname)
 | 
			
		||||
		if add_server(hostname, ip, group):
 | 
			
		||||
			show_update_server(hostname)
 | 
			
		||||
 | 
			
		||||
if form.getvalue('serverdel') is not None:
 | 
			
		||||
	print('Content-type: text/html\n')
 | 
			
		||||
| 
						 | 
				
			
			@ -379,8 +396,8 @@ if form.getvalue('newgroup') is not None:
 | 
			
		|||
	newgroup = form.getvalue('newgroup')	
 | 
			
		||||
	desc = form.getvalue('newdesc')
 | 
			
		||||
	print('Content-type: text/html\n')
 | 
			
		||||
	add_group(newgroup, desc)
 | 
			
		||||
	show_update_group(newgroup)
 | 
			
		||||
	if add_group(newgroup, desc):
 | 
			
		||||
		show_update_group(newgroup)
 | 
			
		||||
 | 
			
		||||
if form.getvalue('groupdel') is not None:
 | 
			
		||||
	print('Content-type: text/html\n')
 | 
			
		||||
| 
						 | 
				
			
			@ -393,7 +410,7 @@ if form.getvalue('updategroup') is not None:
 | 
			
		|||
	id = form.getvalue('id')	
 | 
			
		||||
	if name is None:
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		print("All fields must be completed")
 | 
			
		||||
		print(error_mess)
 | 
			
		||||
	else:		
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		update_group(name, descript, id)
 | 
			
		||||
| 
						 | 
				
			
			@ -405,7 +422,7 @@ if form.getvalue('updateserver') is not None:
 | 
			
		|||
	id = form.getvalue('id')	
 | 
			
		||||
	if name is None or ip is None:
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		print("All fields must be completed")
 | 
			
		||||
		print(error_mess)
 | 
			
		||||
	else:		
 | 
			
		||||
		print('Content-type: text/html\n')
 | 
			
		||||
		update_server(name, ip, group, id)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ sql.get_roles_select("new-role")
 | 
			
		|||
print('</td><td>')
 | 
			
		||||
sql.get_groups_select("new-group")
 | 
			
		||||
print('</td>'
 | 
			
		||||
			'<td><a class="add" id="add-user" style="cursor: pointer;"></a></td>'
 | 
			
		||||
			'<td><a class="add-admin" id="add-user" style="cursor: pointer;"></a></td>'
 | 
			
		||||
		'</tr>')
 | 
			
		||||
print('</table>')
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ print('<br /><br /><table class="overview" id="group-add-table" style="display:
 | 
			
		|||
		'<tr>'
 | 
			
		||||
			'<td class="padding10 first-collumn"><input type="text" name="new-group-add" id="new-group-add" class="form-control"></td>'
 | 
			
		||||
			'<td><input type="text" name="new-desc" id="new-desc" class="form-control" size="100"></td>'
 | 
			
		||||
			'<td><a class="add" id="add-group" style="cursor: pointer;"></a></td>'
 | 
			
		||||
			'<td><a class="add-admin" id="add-group" style="cursor: pointer;"></a></td>'
 | 
			
		||||
		'</tr>'
 | 
			
		||||
'</table>'
 | 
			
		||||
'</div>'
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ print('</table>'
 | 
			
		|||
		'<td><input type="text" name="new-ip" id="new-ip" class="form-control"></td><td>')
 | 
			
		||||
sql.get_groups_select("new-server-group-add")
 | 
			
		||||
print('</td>'
 | 
			
		||||
			'<td><a class="add"  id="add-server" style="cursor: pointer;"></a></td>'
 | 
			
		||||
			'<td><a class="add-admin"  id="add-server" style="cursor: pointer;"></a></td>'
 | 
			
		||||
		'</tr>')
 | 
			
		||||
print('</table>')
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,7 +101,7 @@
 | 
			
		|||
	font-family: "Font Awesome 5 Solid";
 | 
			
		||||
	content: "\f2b9";
 | 
			
		||||
}
 | 
			
		||||
.add:before {
 | 
			
		||||
.add-admin:before {
 | 
			
		||||
	display: none;
 | 
			
		||||
	font-family: "Font Awesome 5 Solid";
 | 
			
		||||
	content: "\f00c";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,7 +108,6 @@ function showStats() {
 | 
			
		|||
		type: "GET",
 | 
			
		||||
		success: function( data ) {
 | 
			
		||||
			$("#ajax").html(data);			
 | 
			
		||||
			$.getScript(url);
 | 
			
		||||
			window.history.pushState("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val());
 | 
			
		||||
		}					
 | 
			
		||||
	} );
 | 
			
		||||
| 
						 | 
				
			
			@ -296,7 +295,7 @@ $( function() {
 | 
			
		|||
    var cur_url = '/cgi-bin/' + location.split('/').pop();
 | 
			
		||||
	cur_url = cur_url.split('?');
 | 
			
		||||
		
 | 
			
		||||
    $('.menu ').each(function () {
 | 
			
		||||
    $('.menu li').each(function () {
 | 
			
		||||
        var link = $(this).find('a').attr('href');
 | 
			
		||||
 | 
			
		||||
        if (cur_url[0] == link)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,7 @@ pre {
 | 
			
		|||
.icon {
 | 
			
		||||
	max-width: 20px;
 | 
			
		||||
	margin-left: 2px;
 | 
			
		||||
	cursor: pointer;
 | 
			
		||||
}
 | 
			
		||||
.top-menu {	
 | 
			
		||||
	position: fixed;
 | 
			
		||||
| 
						 | 
				
			
			@ -385,7 +386,9 @@ pre {
 | 
			
		|||
}
 | 
			
		||||
.ui-state-active {
 | 
			
		||||
	background-color: #5D9CEB !important;
 | 
			
		||||
	border: none !important;
 | 
			
		||||
	border-color: #5D9CEB !important;
 | 
			
		||||
	font-weight: bold !important;
 | 
			
		||||
}
 | 
			
		||||
.ui-button {
 | 
			
		||||
	padding-left: 10px !important;
 | 
			
		||||
| 
						 | 
				
			
			@ -400,6 +403,9 @@ pre {
 | 
			
		|||
.ui-tabs-nav {
 | 
			
		||||
	padding-left: 20px !important; 
 | 
			
		||||
  }
 | 
			
		||||
 .ui-widget-header {
 | 
			
		||||
	background: #5d9ceb !important;
 | 
			
		||||
 }
 | 
			
		||||
a {
 | 
			
		||||
  background-color: transparent;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -503,9 +509,24 @@ a:focus {
 | 
			
		|||
  margin-left: -15px;
 | 
			
		||||
}
 | 
			
		||||
.update {
 | 
			
		||||
	background-color: rgb(0,168,107) !important;
 | 
			
		||||
	background-color: #dff0d8 !important;
 | 
			
		||||
}
 | 
			
		||||
.alert {
 | 
			
		||||
	padding:15px;
 | 
			
		||||
	margin-bottom:20px;
 | 
			
		||||
	border:1px solid transparent;
 | 
			
		||||
	border-radius:4px
 | 
			
		||||
}
 | 
			
		||||
.alert a {
 | 
			
		||||
	cursor: pointer;
 | 
			
		||||
	font-weight: bold;
 | 
			
		||||
	padding-left: 10px;
 | 
			
		||||
}
 | 
			
		||||
.alert-danger {
 | 
			
		||||
	color:#a94442;
 | 
			
		||||
	background-color:#f2dede;
 | 
			
		||||
	border-color:#ebccd1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
label {
 | 
			
		||||
  display: inline-block;
 | 
			
		||||
  max-width: 100%;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										24
									
								
								inc/users.js
								
								
								
								
							
							
						
						
									
										24
									
								
								inc/users.js
								
								
								
								
							| 
						 | 
				
			
			@ -1,5 +1,9 @@
 | 
			
		|||
var users = '/inc/usersdop.js'
 | 
			
		||||
$( function() {
 | 
			
		||||
	$('#error').hide();	
 | 
			
		||||
 | 
			
		||||
	$('#add-user').click(function() {
 | 
			
		||||
		$('#error').hide();	
 | 
			
		||||
		$.ajax( {
 | 
			
		||||
			url: "sql.py",
 | 
			
		||||
			data: {
 | 
			
		||||
| 
						 | 
				
			
			@ -11,12 +15,14 @@ $( function() {
 | 
			
		|||
			},
 | 
			
		||||
			type: "GET",
 | 
			
		||||
			success: function( data ) {
 | 
			
		||||
				if (data == "All fields must be completed ") {
 | 
			
		||||
					alert(data);
 | 
			
		||||
				data = data.replace(/\s+/g,' ');
 | 
			
		||||
				if (data == '<br /><span class="alert alert-danger" id="error">All fields must be completed <a title="Close" id="errorMess"><b>X</b></a></span> ') {
 | 
			
		||||
					$("#ajax-users").append(data);
 | 
			
		||||
					$.getScript(users);
 | 
			
		||||
				} else {
 | 
			
		||||
					$("#ajax-users").append(data);
 | 
			
		||||
					$( "#ajax-users tr td" ).addClass( "update", 1000, callbackUser );
 | 
			
		||||
					$.getScript(url);
 | 
			
		||||
					$.getScript(url);					
 | 
			
		||||
				}	
 | 
			
		||||
			}
 | 
			
		||||
		} );
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +43,7 @@ $( function() {
 | 
			
		|||
		} );
 | 
			
		||||
	});
 | 
			
		||||
	$('#add-server').click(function() {
 | 
			
		||||
		$('#error').hide();	
 | 
			
		||||
		$.ajax( {
 | 
			
		||||
			url: "sql.py",
 | 
			
		||||
			data: {
 | 
			
		||||
| 
						 | 
				
			
			@ -47,8 +54,9 @@ $( function() {
 | 
			
		|||
			type: "GET",
 | 
			
		||||
			success: function( data ) {
 | 
			
		||||
				data = data.replace(/\s+/g,' ');
 | 
			
		||||
				if (data == "All fields must be completed ") {
 | 
			
		||||
					alert(data);
 | 
			
		||||
				if (data == '<br /><span class="alert alert-danger" id="error">All fields must be completed <a title="Close" id="errorMess"><b>X</b></a></span> ') {
 | 
			
		||||
					$("#ajax-servers").append(data);
 | 
			
		||||
					$.getScript(users);
 | 
			
		||||
				} else {
 | 
			
		||||
					$("#ajax-servers").append(data);
 | 
			
		||||
					$( "#ajax-servers tr td" ).addClass( "update", 1000, callback );
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +101,7 @@ $( function() {
 | 
			
		|||
	
 | 
			
		||||
} );
 | 
			
		||||
function removeUser(id) {
 | 
			
		||||
	$("#user-"+id).css("background-color", "#f36223");
 | 
			
		||||
	$("#user-"+id).css("background-color", "#f2dede");
 | 
			
		||||
	$.ajax( {
 | 
			
		||||
			url: "sql.py",
 | 
			
		||||
			data: {
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +117,7 @@ function removeUser(id) {
 | 
			
		|||
		} );	
 | 
			
		||||
	}
 | 
			
		||||
function removeServer(id) {
 | 
			
		||||
	$("#server-"+id).css("background-color", "#f36223");
 | 
			
		||||
	$("#server-"+id).css("background-color", "#f2dede");
 | 
			
		||||
	$.ajax( {
 | 
			
		||||
			url: "sql.py",
 | 
			
		||||
			data: {
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +133,7 @@ function removeServer(id) {
 | 
			
		|||
		} );	
 | 
			
		||||
	}
 | 
			
		||||
function removeGroup(id) {
 | 
			
		||||
	$("#group-"+id).css("background-color", "#f36223");
 | 
			
		||||
	$("#group-"+id).css("background-color", "#f2dede");
 | 
			
		||||
	$.ajax( {
 | 
			
		||||
			url: "sql.py",
 | 
			
		||||
			data: {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
$( function() {
 | 
			
		||||
	$('#errorMess').click(function() {
 | 
			
		||||
				$('#error').hide();	
 | 
			
		||||
		});
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
		Reference in New Issue