mirror of https://github.com/Aidaho12/haproxy-wi
parent
ef10f8829f
commit
429e306ce0
|
@ -123,9 +123,10 @@ def get_map(serv):
|
|||
j, m = 0, 0
|
||||
for line in conf:
|
||||
if "listen" in line or "frontend" in line:
|
||||
if "stats" not in line:
|
||||
node = line
|
||||
i = i - 500
|
||||
if ":" not in line:
|
||||
if "stats" not in line:
|
||||
node = line
|
||||
i = i - 500
|
||||
if line.find("backend") == 0:
|
||||
node = line
|
||||
i = i - 500
|
||||
|
|
16
app/sql.py
16
app/sql.py
|
@ -977,16 +977,17 @@ def show_update_telegram(token, page):
|
|||
output_from_parsed_template = template.render(groups = select_groups(), telegrams = select_telegram(token=token),page=page)
|
||||
print(output_from_parsed_template)
|
||||
|
||||
def show_update_user(user):
|
||||
def show_update_user(user,page):
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('/new_user.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
output_from_parsed_template = template.render(users = select_users(user=user),
|
||||
groups = select_groups(),
|
||||
roles = select_roles())
|
||||
print(output_from_parsed_template)
|
||||
template = template.render(users = select_users(user=user),
|
||||
groups = select_groups(),
|
||||
page=page,
|
||||
roles = select_roles())
|
||||
print(template)
|
||||
|
||||
def show_update_server(server, page):
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
@ -1046,12 +1047,13 @@ if form.getvalue('newuser') is not None:
|
|||
role = form.getvalue('newrole')
|
||||
group = form.getvalue('newgroupuser')
|
||||
new_user = form.getvalue('newusername')
|
||||
page = form.getvalue('page')
|
||||
print('Content-type: text/html\n')
|
||||
if password is None or role is None or group is None:
|
||||
print(error_mess)
|
||||
else:
|
||||
if add_user(new_user, email, password, role, group):
|
||||
show_update_user(new_user)
|
||||
show_update_user(new_user, page)
|
||||
|
||||
if form.getvalue('updateuser') is not None:
|
||||
email = form.getvalue('email')
|
||||
|
@ -1233,4 +1235,4 @@ if form.getvalue('updatetoken') is not None:
|
|||
|
||||
if form.getvalue('updatesettings') is not None:
|
||||
print('Content-type: text/html\n')
|
||||
update_setting(form.getvalue('updatesettings'), form.getvalue('val') )
|
||||
update_setting(form.getvalue('updatesettings'), form.getvalue('val') )
|
|
@ -28,7 +28,6 @@
|
|||
<td>Role</td>
|
||||
<td>Group</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for user in users %}
|
||||
|
@ -102,7 +101,7 @@
|
|||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-user" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-user" title="Add new user" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -114,7 +113,6 @@
|
|||
<td class="padding10 first-collumn">Name</td>
|
||||
<td>Desciption</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% for group in groups %}
|
||||
<tr id="group-{{ group.0 }}" class="{{ loop.cycle('odd', 'even') }}">
|
||||
|
@ -152,7 +150,7 @@
|
|||
<input type="text" name="new-desc" id="new-desc" class="form-control" size="100">
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-group" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-group" title="Add new group" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -329,7 +327,7 @@
|
|||
<input type="text" id="desc" size="30" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-server" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-server" title="Add new server" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -340,8 +338,6 @@
|
|||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Name</td>
|
||||
<td>Desciption</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for role in roles %}
|
||||
|
@ -440,7 +436,7 @@
|
|||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-ssh" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-ssh" title="Add new SSH credentials" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -534,7 +530,7 @@
|
|||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-telegram" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-telegram" title="Add new Telegram channel" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
{% for user in users %}
|
||||
<tr id="user-{{user.0}}" class="newuser">
|
||||
<td class="padding10 first-collumn"><input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control"></td>
|
||||
<td><input type="password" id="password-{{user.0}}" value="{{user.3}}" class="form-control"></td>
|
||||
<td><input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control"></td>
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" id="password-{{user.0}}" value="{{user.3}}" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<select id="role-{{user.0}}" name="role-{{user.0}}">
|
||||
<option disabled selected>Choose role</option>
|
||||
|
@ -15,6 +21,7 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
{% if page != "servers.py" %}
|
||||
<td>
|
||||
<select id="usergroup-{{user.0}}" name="usergroup-{{user.0}}">
|
||||
<option disabled selected>Choose group</option>
|
||||
|
@ -27,6 +34,17 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td><a class="delete" onclick="removeUser({{user.0}})" style="cursor: pointer;"></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
<script>
|
||||
$( "#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])
|
||||
});
|
||||
</script>
|
|
@ -79,7 +79,8 @@
|
|||
<li><a href=/app/keepalivedconfig.py title="Edit keepalived config" class="edit head-submenu">Edit config</a></li>
|
||||
</li>
|
||||
<li><a title="Servers manage" class="runtime">Servers</a>
|
||||
<li><a href=/app/servers.py title="Server manage" class="runtime head-submenu">Servers</a></li>
|
||||
<li><a href=/app/servers.py#users title="Actions with users" class="users head-submenu">Users</a></li>
|
||||
<li><a href=/app/servers.py#servers title="Server manage" class="runtime head-submenu">Servers</a></li>
|
||||
<li><a href=/app/servers.py#ssh title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -98,7 +99,7 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v3.2.9
|
||||
HAproxy-WI v3.2.10
|
||||
<br>
|
||||
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 30px; color: red;" class="patreon"> Patreon</a>
|
||||
</div>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
</div>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#users">Users</a></li>
|
||||
<li><a href="#servers">Servers</a></li>
|
||||
<li><a href="#ssh">SSH credentials</a></li>
|
||||
<li><a href="#checker">Checker</a></li>
|
||||
|
@ -15,7 +16,84 @@
|
|||
<a href=/app/login.py title="Login" class="login"> Login</a>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<div id="users">
|
||||
<table class="overview" id="ajax-users">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Login name</td>
|
||||
<td>Password</td>
|
||||
<td>Email</td>
|
||||
<td>Role</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for user in users %}
|
||||
{% if user.5 == group %}
|
||||
<tr id="user-{{user.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control">
|
||||
<input type="hidden" id="new-group" name="new-group" value="{{ group }}">
|
||||
<input type="hidden" id="usergroup-{{user.0}}" name="usergroup-{{user.0}}" value="{{ group }}">
|
||||
</td>
|
||||
<td><input type="password" id="password-{{user.0}}" value="{{user.3}}" class="form-control"></td>
|
||||
<td><input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control"></td>
|
||||
<td>
|
||||
<select id="role-{{user.0}}" name="role-{{user.0}}">
|
||||
<option disabled selected>Choose role</option>
|
||||
{% for role in roles %}
|
||||
{% if role.1 != "admin" %}
|
||||
{% if user.4 == role.1 %}
|
||||
<option value="{{ role.1 }}" selected>{{ role.1 }}</option>
|
||||
{% else %}
|
||||
<option value="{{ role.1 }}">{{ role.1 }}</option>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
|
||||
<br /><br />
|
||||
<table class="overview" id="user-add-table" style="display: none;">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">New user</td>
|
||||
<td>Password</td>
|
||||
<td>Email</td>
|
||||
<td>Role</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" name="new-username" id="new-username" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" name="new-password" id="new-password" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="new-email" id="new-email" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<select id="new-role" name="new-role">
|
||||
<option disabled selected>Choose role</option>
|
||||
{% for role in roles %}
|
||||
{% if role.1 != "admin" %}
|
||||
<option value="{{ role.1 }}">{{ role.1 }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-user" title="Add new user" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div id="servers">
|
||||
<table class="overview" id="ajax-servers">
|
||||
<tr class="overviewHead">
|
||||
|
@ -172,7 +250,7 @@
|
|||
<input type="text" id="desc" size="30" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-server" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-server" title="Add new server" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -249,7 +327,7 @@
|
|||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-ssh" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-ssh" title="Add new SSH credentials" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -330,7 +408,7 @@
|
|||
<input type="text" id="telegram-chanel-add" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-telegram" style="cursor: pointer;"></a>
|
||||
<a class="add-admin" id="add-telegram" title="Add new Telegram channel" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -1094,6 +1094,36 @@ $( function() {
|
|||
change_select_acceleration("3");
|
||||
});
|
||||
}
|
||||
if (cur_url[0] == "/app/users.py" || cur_url[0] == "/app/servers.py") {
|
||||
$( ".users" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 0 );
|
||||
} );
|
||||
if (cur_url[0] == "/app/users.py") {
|
||||
$( ".group" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 1 );
|
||||
} );
|
||||
} else {
|
||||
$( ".runtime" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 1 );
|
||||
} );
|
||||
}
|
||||
if (cur_url[0] == "/app/servers.py") {
|
||||
$( ".admin" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 2 );
|
||||
} );
|
||||
}
|
||||
if (cur_url[0] == "/app/users.py") {
|
||||
$( ".runtime" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 2 );
|
||||
} );
|
||||
}
|
||||
$( ".role" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 3 );
|
||||
} );
|
||||
$( ".admin" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 4 );
|
||||
} );
|
||||
}
|
||||
$( "#path-cert-listen" ).autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.ajax( {
|
||||
|
|
|
@ -70,13 +70,13 @@ pre {
|
|||
float: left;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
min-height: calc(100vh - 0px);
|
||||
max-width: 91%;
|
||||
min-width: 40%;
|
||||
background-color: #fff;
|
||||
margin-left: 207px;
|
||||
margin-right: 20px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
#cover {
|
||||
|
@ -537,6 +537,7 @@ caption {
|
|||
td,th {
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
min-width: 30px;
|
||||
}
|
||||
a,
|
||||
a:visited {
|
||||
|
|
|
@ -134,6 +134,7 @@ $( function() {
|
|||
newpassword: $('#new-password').val(),
|
||||
newemail: $('#new-email').val(),
|
||||
newrole: $('#new-role').val(),
|
||||
page: cur_url[0],
|
||||
newgroupuser: $('#new-group').val()
|
||||
},
|
||||
type: "GET",
|
||||
|
@ -640,6 +641,11 @@ function removeTelegram(id) {
|
|||
}
|
||||
function updateUser(id) {
|
||||
$('.alert-danger').remove();
|
||||
if (cur_url[0] != "servers.py") {
|
||||
var usergroup = $('#usergroup-'+id+' option:selected' ).val();
|
||||
} else {
|
||||
var usergroup = $('#usergroup-'+id ).val();
|
||||
}
|
||||
$.ajax( {
|
||||
url: "sql.py",
|
||||
data: {
|
||||
|
@ -647,7 +653,7 @@ function updateUser(id) {
|
|||
password: $('#password-'+id).val(),
|
||||
email: $('#email-'+id).val(),
|
||||
role: $('#role-'+id).val(),
|
||||
usergroup: $('#usergroup-'+id+' option:selected' ).val(),
|
||||
usergroup: usergroup,
|
||||
id: id
|
||||
},
|
||||
type: "GET",
|
||||
|
|
Loading…
Reference in New Issue