Pavel Loginov 2020-09-05 12:31:40 +06:00
parent 02edfe08b4
commit 95227a8016
6 changed files with 140 additions and 222 deletions

View File

@ -1572,7 +1572,8 @@ if form.getvalue('newuser') is not None:
template = template.render(users=sql.select_users(user=new_user),
groups=sql.select_groups(),
page=page,
roles=sql.select_roles())
roles=sql.select_roles(),
adding=1)
print(template)
funct.logging('a new user '+new_user, ' has created ', haproxywi=1, login=1)
else:

View File

@ -24,52 +24,11 @@
{% include 'include/login.html' %}
</ul>
<ul id='browse_histroy'></ul>
<div id="users">
<table class="overview" id="ajax-users">
<thead>
<tr class="overviewHead">
<th class="padding10 first-collumn">Login name</th>
<th style="width: 10%">Password</th>
<th style="width: 10%">Active</th>
<th style="width: 20%">Email</th>
<th style="width: 10%">Role</th>
<th style="width: 100%">Group</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr id="user-{{user.0}}" class="{{ loop.cycle('odd', 'even') }}">
{% include 'include/admin_users.html' %}
<td>
<select id="role-{{user.0}}" name="role-{{user.0}}">
<option disabled selected>Choose role</option>
{% for role in roles %}
{% if user.4 == role.1 %}
<option value="{{ role.1 }}" selected>{{ role.1 }}</option>
{% else %}
<option value="{{ role.1 }}">{{ role.1 }}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td>
<span title="Change user groups" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserGroupDialog('{{user.0}}')">
</td>
<td>
<a class="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
<tbody>
</table>
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
<br /><br />
{% include 'include/admin_users.html' %}
</div>
<div id="groups">
<table class="overview" id="ajax-group">
<thead>
@ -121,53 +80,7 @@
</div>
<div id="checker">
<table id="checker_table" class="overview">
<tr class="overviewHead" style="width: 50%;">
<td class="padding10 first-collumn" style="width: 25%;">
<span title="Token that gave you @father_bot">Token</span>
</td>
<td style="width: 25%;">Channel name</td>
<td style="width: 100%;">Group</td>
<td></td>
<td></td>
</tr>
{% for telegram in telegrams %}
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.1, size='30') }}
</td>
<td>
{% set id = 'telegram-chanel-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }}
</td>
<td>
<select id="telegramgroup-{{telegram.0}}" name="telegramgroup-{{telegram.0}}">
<option disabled selected>Choose group</option>
{% for group in groups %}
{% if telegram.3|string() == group.0|string() %}
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
{% else %}
<option value="{{ group.0 }}">{{ group.1 }}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td>
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.2}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteTelegram({{telegram.0}})" title="Delete channel {{telegram.2}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="Add telegram channel" id="add-telegram-button">+ Add</span>
<br /><br />
<div id="ajax-telegram"></div>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>
{% include 'include/admin_telegram.html' %}
</div>
<div id="settings">

View File

@ -1,30 +1,5 @@
{% for user in users %}
<tr id="user-{{user.0}}" class="newuser">
{% include 'include/admin_users.html' %}
<td>
<select id="role-{{user.0}}" name="role-{{user.0}}">
<option disabled selected>Choose role</option>
{% for role in roles %}
{% if user.4 == role.1 %}
<option value="{{ role.1 }}" selected>{{ role.1 }}</option>
{% else %}
<option value="{{ role.1 }}">{{ role.1 }}</option>
{% endif %}
{% endfor %}
</select>
</td>
{% if page != "servers.py" %}
{% if page != "servers.py#users" %}
<td>
<span title="Change user groups" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserGroupDialog('{{user.0}}')">
</td>
{% endif %}
{% endif %}
<td>
<a class="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td><a class="delete" onclick="removeUser({{user.0}})" style="cursor: pointer;"></a></td>
</tr>
{% include 'include/admin_users.html' %}
<script>
$( function() {
$("#role-{{user.0}}" ).selectmenu({

View File

@ -0,0 +1,51 @@
<table id="checker_table" class="overview">
<tr class="overviewHead" style="width: 50%;">
<td class="padding10 first-collumn" style="width: 25%;">
<span title="Token that has given @father_bot">Token</span>
</td>
<td style="width: {% if page == "servers.py" %}100{% else %}20{% endif %}%;">Channel name</td>
{% if page != "servers.py" %}
<td style="width: 100%;">Group</td>
{% endif %}
<td></td>
<td></td>
</tr>
{% for telegram in telegrams %}
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.1, size='30') }}
</td>
<td>
{% set id = 'telegram-chanel-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }}
</td>
{% if page != "servers.py" %}
<td>
<select id="telegramgroup-{{telegram.0}}" name="telegramgroup-{{telegram.0}}">
<option disabled selected>Choose group</option>
{% for group in groups %}
{% if telegram.3|string() == group.0|string() %}
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
{% else %}
<option value="{{ group.0 }}">{{ group.1 }}</option>
{% endif %}
{% endfor %}
</select>
</td>
{% endif %}
<td>
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.2}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteTelegram({{telegram.0}})" title="Delete channel {{telegram.2}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="Add telegram channel" id="add-telegram-button">+ Add</span>
<br /><br />
<div id="ajax-telegram"></div>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>

View File

@ -1,31 +1,82 @@
{% from 'include/input_macros.html' import input, checkbox %}
<td class="padding10 first-collumn">
{% set login_id = 'login-' + user.0|string() %}
{% if user.6 == 1%}
{{ input(login_id, value=user.1, readonly='readonly') }}
{% else %}
{{ input(login_id, value=user.1) }}
{% if not adding %}
<table class="overview" id="ajax-users">
<thead>
<tr class="overviewHead">
<th class="padding10 first-collumn">Login name</th>
<th style="width: 10%">Password</th>
<th style="width: 10%">Active</th>
<th style="width: 20%">Email</th>
<th style="width: {% if page == "servers.py" %}100{% else %}10{% endif %}%">Role</th>
{% if page != "servers.py" %}
<th style="width: 100%">Group</th>
{% endif %}
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{% endif %}
</td>
<td>
{% if user.6 != 1%}
<span title="Change password" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserPasswordDialog('{{user.0}}')">
</span>
{% endif %}
</td>
<td class="checkbox">
{% set activeuser_id = 'activeuser-' + user.0|string() %}
{% if user.7 == 1 %}
{{ checkbox(activeuser_id, checked='checked') }}
{% else %}
{{ checkbox(activeuser_id) }}
{% endif %}
</td>
<td>
{% set email_id = 'email-' + user.0|string() %}
{% if user.6 == 1%}
{{ input(email_id, value=user.2, readonly='readonly') }}
{% else %}
{{ input(email_id, value=user.2) }}
{% endif %}
</td>
{% for user in users %}
<tr id="user-{{user.0}}" class="{{ loop.cycle('odd', 'even') }} {% if adding %}newuser{% endif %}">
<td class="padding10 first-collumn">
{% set login_id = 'login-' + user.0|string() %}
{% if user.6 == 1%}
{{ input(login_id, value=user.1, readonly='readonly') }}
{% else %}
{{ input(login_id, value=user.1) }}
{% endif %}
</td>
<td>
{% if user.6 != 1%}
<span title="Change password" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserPasswordDialog('{{user.0}}')">
</span>
{% endif %}
</td>
<td class="checkbox">
{% set activeuser_id = 'activeuser-' + user.0|string() %}
{% if user.7 == 1 %}
{{ checkbox(activeuser_id, checked='checked') }}
{% else %}
{{ checkbox(activeuser_id) }}
{% endif %}
</td>
<td>
{% set email_id = 'email-' + user.0|string() %}
{% if user.6 == 1%}
{{ input(email_id, value=user.2, readonly='readonly') }}
{% else %}
{{ input(email_id, value=user.2) }}
{% endif %}
</td>
<td>
<select id="role-{{user.0}}" name="role-{{user.0}}">
<option disabled selected>Choose role</option>
{% for role in roles %}
{% if user.4 == role.1 %}
<option value="{{ role.1 }}" selected>{{ role.1 }}</option>
{% else %}
<option value="{{ role.1 }}">{{ role.1 }}</option>
{% endif %}
{% endfor %}
</select>
</td>
{% if page != "servers.py" %}
<td>
<span title="Change user groups" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserGroupDialog('{{user.0}}')">
</td>
{% endif %}
<td>
<a class="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
{% if not adding %}
<tbody>
</table>
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
<br /><br />
{% endif %}

View File

@ -26,45 +26,7 @@
</ul>
<ul id='browse_histroy'></ul>
<div id="users">
<table class="overview" id="ajax-users">
<tr class="overviewHead">
<td class="padding10 first-collumn">Login name</td>
<td style="width: 10%">Password</td>
<td style="width: 10%">Active</td>
<td style="width: 20%">Email</td>
<td style="width: 100%">Role</td>
<td></td>
<td></td>
</tr>
<tr>
{% for user in users %}
<tr id="user-{{user.0}}" class="{{ loop.cycle('odd', 'even') }}">
{% include 'include/admin_users.html' %}
<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="add" onclick="cloneUser({{user.0}})" id="clone-{{user.0}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteUser({{user.0}})" title="Delete user {{user.1}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
<br /><br />
{% include 'include/admin_users.html' %}
</div>
<div id="servers">
@ -76,42 +38,7 @@
</div>
<div id="checker">
<table id="checker_table" class="overview">
<tr class="overviewHead" style="width: 50%;">
<td class="padding10 first-collumn" style="width: 25%;">
<span title="Token that gave you @father_bot">Token</span>
</td>
<td style="width: 100%;">Chanel name</td>
<td></td>
<td></td>
</tr>
{% for telegram in telegrams %}
{% if telegram.3|string() == group %}
<tr style="width: 50%;" id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.1, size='30') }}
</td>
<td>
{% set id = 'telegram-chanel-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }}
</td>
<td>
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.2}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteSsh({{telegram.0}})" style="cursor: pointer;"></a>
</td>
</tr>
{% endif %}
{% endfor %}
</table>
<br /><span class="add-button" title="Telegram channel" id="add-telegram-button">+ Add</span>
<br /><br />
<div id="ajax-telegram"></div>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>
{% include 'include/admin_telegram.html' %}
</div>
<div id="settings">