mirror of https://github.com/Aidaho12/haproxy-wi
parent
32be16a69d
commit
b24eb38a3f
|
@ -30,6 +30,7 @@ output_from_parsed_template = template.render(title = "Servers manage",
|
|||
servers = sql.get_dick_permit(virt=1, disable=0),
|
||||
roles = sql.select_roles(),
|
||||
masters = sql.select_servers(get_master_servers=1, uuid=user_id.value),
|
||||
group = sql.get_user_group_by_uuid(user_id.value),
|
||||
sshs = sql.select_ssh(),
|
||||
telegrams = sql.get_user_telegram_by_uuid(user_id.value),
|
||||
token = token)
|
||||
|
|
25
app/sql.py
25
app/sql.py
|
@ -413,6 +413,19 @@ def get_user_role_by_uuid(uuid):
|
|||
return user_id[0]
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def get_user_group_by_uuid(uuid):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """ select user.groups from user left join uuid as uuid on user.id = uuid.user_id where uuid.uuid = '%s' """ % uuid
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
for user_id in cur.fetchall():
|
||||
return user_id[0]
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def get_user_telegram_by_uuid(uuid):
|
||||
con, cur = create_db.get_cur()
|
||||
|
@ -425,6 +438,18 @@ def get_user_telegram_by_uuid(uuid):
|
|||
return cur.fetchall()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def get_telegram_by_ip(ip):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """ select telegram.* from telegram left join servers as serv on serv.groups = telegram.groups where serv.ip = '%s' """ % ip
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def get_dick_permit(**kwargs):
|
||||
import http.cookies
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v2.7.2.1
|
||||
HAproxy-WI v2.7.2.2
|
||||
<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>
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
</td>
|
||||
<td>
|
||||
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" class="form-control">
|
||||
<input type="hidden" id="new-server-group-add" name="servergroup-{{server.0}}" value="{{ ssh_group.0 }}" >
|
||||
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ ssh_group.0 }}" >
|
||||
<input type="hidden" id="new-server-group-add" name="servergroup-{{server.0}}" value="{{ group }}" >
|
||||
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ group }}" >
|
||||
</td>
|
||||
<td>
|
||||
{% if server.5 == 1 %}
|
||||
|
@ -77,7 +77,7 @@
|
|||
<select id="credentials-{{server.0}}">
|
||||
<option disabled selected>Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
{% if ssh.5|string() == group %}
|
||||
{% if ssh.0 == server.7 %}
|
||||
<option value="{{ssh.0}}" selected>{{ssh.1}}</option>
|
||||
{% else %}
|
||||
|
@ -112,7 +112,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<input type="text" name="new-ip" id="new-ip" class="form-control">
|
||||
<input type="hidden" id="new-sshgroup" name="new-sshgroup" value="{{ ssh_group.0 }}" >
|
||||
<input type="hidden" id="new-sshgroup" name="new-sshgroup" value="{{ group }}" >
|
||||
</td>
|
||||
<td>
|
||||
<label for="enable"></label><input type="checkbox" id="enable" checked>
|
||||
|
@ -135,7 +135,7 @@
|
|||
<select id="credentials" required>
|
||||
<option disabled selected value="0">Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
{% if ssh.5|string() == group %}
|
||||
<option value="{{ssh.0}}">{{ssh.1}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
@ -164,7 +164,7 @@
|
|||
<td></td>
|
||||
</tr>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
{% if ssh.5|string() == group %}
|
||||
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}">
|
||||
<td class="first-collumn">
|
||||
<input type="text" id="ssh_name-{{ssh.0}}" class="form-control" value="{{ssh.1}}" style="margin-bottom: 23px;">
|
||||
|
@ -236,7 +236,7 @@
|
|||
<select id="ssh-key-name">
|
||||
<option disabled selected>Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
{% if ssh.5|string() == group %}
|
||||
<option value={{ssh.1}}>{{ssh.1}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
@ -262,7 +262,7 @@
|
|||
<td></td>
|
||||
</tr>
|
||||
{% for telegram in telegrams %}
|
||||
{% if telegram.3|string() == ssh_group.0 %}
|
||||
{% if telegram.3|string() == group %}
|
||||
<tr style="width: 50%;" id="telegram-table-{{telegram.0}}">
|
||||
<td class="first-collumn" style="padding-top: 20px;">
|
||||
<input type="text" id="telegram-token-{{telegram.0}}" class="form-control" value="{{telegram.1}}" style="margin-bottom: 23px;">
|
||||
|
@ -307,4 +307,24 @@
|
|||
<div id="ajax-telegram"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="group_error" style="display: none;">
|
||||
<div class="alert alert-danger">
|
||||
<b>Do not edit this section if your group is "ALL"!</b> Add first<a href="app/users.py#groups" title="Admin Area: Groups">group</a> or edit your own group at<a href="app/users.py#users" title="Admin Area: Users">users</a> page
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if($('#new-server-group-add').val() == 1) {
|
||||
$('#group_error').css('display', 'block');
|
||||
$('#add-server-button').css('display', 'none');
|
||||
$('#add-ssh-button').css('display', 'none');
|
||||
$('#ssh_key_upload').css('display', 'none');
|
||||
$('#add-telegram-button').css('display', 'none');
|
||||
setTimeout(function() {
|
||||
$("input[type=checkbox]").checkboxradio( "disable" );
|
||||
$("select").selectmenu( "disable" );
|
||||
$("input").attr( "readonly", "readonly" );
|
||||
}, 500 );
|
||||
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
Binary file not shown.
Before Width: | Height: | Size: 343 KiB After Width: | Height: | Size: 327 KiB |
Loading…
Reference in New Issue