mirror of https://github.com/Aidaho12/haproxy-wi
parent
d8a9c3dee3
commit
0e85e79b70
|
@ -383,7 +383,7 @@ def update_db_v_2_61(**kwargs):
|
|||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: cred' or e == "1060 (42S21): Duplicate column name 'cred' ":
|
||||
print('DB was updated. No more run')
|
||||
print('Updating... go to version 2.6.1')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
|
@ -393,6 +393,27 @@ def update_db_v_2_61(**kwargs):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_db_v_2_6_1(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """
|
||||
ALTER TABLE `cred` ADD COLUMN groups INTEGER NOT NULL DEFAULT 1;
|
||||
"""
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: groups' or e == "1060 (42S21): Duplicate column name 'groups' ":
|
||||
print('DB was updated. No more run')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 2.6.1<br />")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_all():
|
||||
update_db_v_2_0_1()
|
||||
update_db_v_2_0_1_1()
|
||||
|
@ -403,6 +424,7 @@ def update_all():
|
|||
update_db_v_2_5_6_1()
|
||||
update_db_v_2_6()
|
||||
update_db_v_2_61()
|
||||
update_db_v_2_6_1()
|
||||
|
||||
def update_all_silent():
|
||||
update_db_v_2_0_1(silent=1)
|
||||
|
@ -414,4 +436,5 @@ def update_all_silent():
|
|||
update_db_v_2_5_6_1(silent=1)
|
||||
update_db_v_2_6(silent=1)
|
||||
update_db_v_2_61(silent=1)
|
||||
update_db_v_2_6_1(silent=1)
|
||||
|
|
@ -10,7 +10,7 @@ template = env.get_template('delver.html')
|
|||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
|
|
@ -9,7 +9,7 @@ template = env.get_template('ha.html')
|
|||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
|
|
@ -9,7 +9,7 @@ template = env.get_template('ihap.html')
|
|||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
|
|
|
@ -11,7 +11,7 @@ template = env.get_template('config.html')
|
|||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
import html, http
|
||||
import cgi
|
||||
import sys
|
||||
import os
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(extensions=["jinja2.ext.do"],loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('servers.html')
|
||||
form = cgi.FieldStorage()
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin(level = 2)
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
user = sql.get_user_name_by_uuid(user_id.value)
|
||||
servers = sql.get_dick_permit()
|
||||
token = sql.get_token(user_id.value)
|
||||
except:
|
||||
pass
|
||||
|
||||
output_from_parsed_template = template.render(title = "Servers manage",
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user,
|
||||
users = sql.select_users(),
|
||||
groups = sql.select_groups(),
|
||||
servers = sql.get_dick_permit(virt=1),
|
||||
roles = sql.select_roles(),
|
||||
masters = sql.select_servers(get_master_servers=1),
|
||||
sshs = sql.select_ssh(),
|
||||
token = token)
|
||||
print(output_from_parsed_template)
|
27
app/sql.py
27
app/sql.py
|
@ -465,9 +465,9 @@ def select_ssh(**kwargs):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
def insert_new_ssh(name, enable, username, password):
|
||||
def insert_new_ssh(name, enable, group, username, password):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """insert into cred(name, enable, username, password) values ('%s', '%s', '%s', '%s') """ % (name, enable, username, password)
|
||||
sql = """insert into cred(name, enable, groups, username, password) values ('%s', '%s', '%s', '%s', '%s') """ % (name, enable, group, username, password)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -493,14 +493,17 @@ def delete_ssh(id):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_ssh(id, name, enable, username, password):
|
||||
def update_ssh(id, name, enable, group, username, password):
|
||||
group = str(group)
|
||||
print(group)
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """
|
||||
update cred set
|
||||
name = '%s',
|
||||
enable = '%s',
|
||||
groups = %s,
|
||||
username = '%s',
|
||||
password = '%s' where id = '%s' """ % (name, enable, username, password, id)
|
||||
password = '%s' where id = '%s' """ % (name, enable, group, username, password, id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -510,14 +513,14 @@ def update_ssh(id, name, enable, username, password):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
def show_update_ssh(name):
|
||||
def show_update_ssh(name, page):
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('/new_ssh.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(sshs = select_ssh(name=name))
|
||||
output_from_parsed_template = template.render(groups = select_groups(), sshs = select_ssh(name=name),page=page)
|
||||
print(output_from_parsed_template)
|
||||
|
||||
def show_update_user(user):
|
||||
|
@ -689,6 +692,7 @@ if form.getvalue('updatessh'):
|
|||
id = form.getvalue('id')
|
||||
name = form.getvalue('name')
|
||||
enable = form.getvalue('ssh_enable')
|
||||
group = form.getvalue('group')
|
||||
username = form.getvalue('ssh_user')
|
||||
password = form.getvalue('ssh_pass')
|
||||
if username is None:
|
||||
|
@ -710,19 +714,22 @@ if form.getvalue('updatessh'):
|
|||
funct.subprocess_execute(cmd)
|
||||
except:
|
||||
pass
|
||||
update_ssh(id, name, enable, username, password)
|
||||
update_ssh(id, name, enable, group, username, password)
|
||||
|
||||
if form.getvalue('new_ssh'):
|
||||
name = form.getvalue('new_ssh')
|
||||
enable = form.getvalue('ssh_enable')
|
||||
group = form.getvalue('new_group')
|
||||
username = form.getvalue('ssh_user')
|
||||
password = form.getvalue('ssh_pass')
|
||||
if username is None:
|
||||
page = form.getvalue('page')
|
||||
page = page.split("#")[0]
|
||||
if username is None or name is None:
|
||||
print('Content-type: text/html\n')
|
||||
print(error_mess)
|
||||
else:
|
||||
if insert_new_ssh(name, enable, username, password):
|
||||
show_update_ssh(name)
|
||||
if insert_new_ssh(name, enable, group, username, password):
|
||||
show_update_ssh(name, page)
|
||||
|
||||
if form.getvalue('sshdel') is not None:
|
||||
import funct
|
||||
|
|
|
@ -310,6 +310,7 @@
|
|||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<span title="If enabled, the key will be used, if turned off - the password. Do not forget to download the keys to all servers or install the sudo without a password">SSH key(?)</span>
|
||||
</td>
|
||||
<td>Group</td>
|
||||
<td>
|
||||
<span title="Enter SSH user name. If SSH key disabled, enter password for ssh user">Credentials(?)</span>
|
||||
</td>
|
||||
|
@ -327,6 +328,17 @@
|
|||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<select id="sshgroup-{{ssh.0}}" name="sshgroup-{{ssh.0}}">
|
||||
{% for group in groups %}
|
||||
{% if ssh.5 == group.0 %}
|
||||
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
||||
{% else %}
|
||||
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
|
||||
|
@ -350,6 +362,7 @@
|
|||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 15%;">Name</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">SSH key</td>
|
||||
<td>Group</td>
|
||||
<td>Credentials</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
@ -360,6 +373,13 @@
|
|||
<td>
|
||||
<label for="new-ssh_enable">Enable SSH key</label><input type="checkbox" id="new-ssh_enable" checked>
|
||||
</td>
|
||||
<td>
|
||||
<select id="new-sshgroup" name="new-sshgroup">
|
||||
{% for group in groups %}
|
||||
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user" class="form-control" value="{{ssh_user}}">
|
||||
|
|
|
@ -1,28 +1,41 @@
|
|||
{% for ssh in sshs %}
|
||||
<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;">
|
||||
</td>
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
{% if ssh.2 == 1 %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
||||
<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;">
|
||||
</td>
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
{% if ssh.2 == 1 %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
||||
{% else %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if page != "servers.py" %}
|
||||
<td>
|
||||
<select id="sshgroup-{{ssh.0}}" name="sshgroup-{{ssh.0}}">
|
||||
{% for group in groups %}
|
||||
{% if ssh.5 == group.0 %}
|
||||
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
||||
{% else %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
||||
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
|
||||
</p>
|
||||
{% if ssh.2 == 1 %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;">
|
||||
{% else %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}">
|
||||
{% endif %}
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
|
||||
</p>
|
||||
{% if ssh.2 == 1 %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;">
|
||||
{% else %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}">
|
||||
{% endif %}
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
|
@ -60,8 +60,6 @@
|
|||
<li><a href=/app/add.py#backend title="Add single backend" class="add head-submenu">Add backend</a></li>
|
||||
<li><a href=/app/add.py#ssl title="Upload SSL cert" class="cert head-submenu">SSL</a></li>
|
||||
<li><a href=/app/config.py title="Edit Haproxy Config" class="edit head-submenu">Edit config</a> </li>
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
<li><a href=/app/ihap.py title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
@ -69,15 +67,19 @@
|
|||
<li><a title="Actions with configs" class="version">Versions</a>
|
||||
<li><a href=/app/configver.py title="Upload old versions configs" class="upload head-submenu">Upload</a></li>
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
{% if role <= 2 %}
|
||||
<li><a href=/app/delver.py title="Delete old versions configs" class="delete head-submenu">Delete</a></li>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% if role <= 1 %}
|
||||
{% if role <= 2 %}
|
||||
<li><a title="Keepalived" class="ha">Keepalived</a>
|
||||
<li><a href=/app/ha.py title="Create HA cluster" class="keepalived head-submenu">HA</a></li>
|
||||
<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="ha">Servers</a>
|
||||
<li><a href=/app/servers.py 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 %}
|
||||
{% if role <= 1 %}
|
||||
<li><a title="Admin area" class="admin">Admin area</a>
|
||||
|
@ -85,7 +87,7 @@
|
|||
<li><a href=/app/users.py#groups title="Actions with groups" class="group head-submenu">Groups</a></li>
|
||||
<li><a href=/app/users.py#servers title="Actions with servers" class="runtime head-submenu">Servers</a></li>
|
||||
<li><a href=/app/users.py#roles title="Users roles" class="role head-submenu">Roles</a></li>
|
||||
<li><a href=/app/users.py#ssh title="Users roles" class="admin head-submenu">SSH credentials</a></li>
|
||||
<li><a href=/app/users.py#ssh title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
|
||||
<li><a href=/app/settings.py title="View settings" class="settings head-submenu">View settings</a></li>
|
||||
<li><a href=/app/viewlogs.py title="View users actions logs" class="logs head-submenu">Users logs</a></li>
|
||||
<li><a href=/app/apachelogs.py title="View Apache logs" class="logs head-submenu">Apache logs</a></li>
|
||||
|
@ -100,7 +102,7 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v2.6
|
||||
HAproxy-WI v2.6.1
|
||||
<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>
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<script src="/inc/users.js"></script>
|
||||
<div id="dialog-confirm" title="Are you sure you want to delete?" style="display: none;">
|
||||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Deleting irreversibly all data will be lost?</p>
|
||||
</div>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#servers">Servers</a></li>
|
||||
<li><a href="#ssh">SSH credentials</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="servers">
|
||||
<table class="overview" id="ajax-servers">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Hostname</td>
|
||||
<td>IP</td>
|
||||
<td>Enable</td>
|
||||
<td><span title="Vitrual IP, something like VRRP">Virt(?)</span></td>
|
||||
<td><span title="Actions with master config will automatically apply on slave">Slave for (?)</span></td>
|
||||
<td>Credentials</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% set ssh_group = [] %}
|
||||
{% for server in servers %}
|
||||
{% do ssh_group.append(server.3) %}
|
||||
<tr id="server-{{server.0}}">
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" class="form-control">
|
||||
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ ssh_group.0 }}" >
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% if server.5 == 1 %}
|
||||
<label for="enable-{{server.0}}"></label><input type="checkbox" id="enable-{{server.0}}" checked>
|
||||
{% else %}
|
||||
<label for="enable-{{server.0}}"></label><input type="checkbox" id="enable-{{server.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if server.4 == 1 %}
|
||||
<label for="typeip-{{server.0}}"></label><input type="checkbox" id="typeip-{{server.0}}" checked>
|
||||
{% else %}
|
||||
<label for="typeip-{{server.0}}"></label><input type="checkbox" id="typeip-{{server.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<select id="slavefor-{{server.0}}">
|
||||
<option disabled selected>Not slave</option>
|
||||
{% for master in masters %}
|
||||
{% if master.0 == server.6 %}
|
||||
<option value="{{master.0}}" selected>{{master.1}}</option>
|
||||
{% else %}
|
||||
<option value="{{master.0}}">{{master.1}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="credentials-{{server.0}}">
|
||||
<option disabled selected>Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
{% if ssh.0 == server.7 %}
|
||||
<option value="{{ssh.0}}" selected>{{ssh.1}}</option>
|
||||
{% else %}
|
||||
<option value="{{ssh.0}}">{{ssh.1}}</option>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteServer({{server.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br /><span class="add-button" title="Add server" id="add-server-button">+ Add</span>
|
||||
<br /><br />
|
||||
<table class="overview" id="server-add-table" style="display: none;">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">New hostname</td>
|
||||
<td>IP</td>
|
||||
<td>Enable</td>
|
||||
<td>Virt</td>
|
||||
<td title="Actions with master config will automatically apply on slave">Slave for</td>
|
||||
<td>Credentials</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" name="new-server-add" id="new-server-add" class="form-control">
|
||||
</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 }}" >
|
||||
</td>
|
||||
<td>
|
||||
<label for="enable"></label><input type="checkbox" id="enable" checked>
|
||||
</td>
|
||||
<td>
|
||||
<label for="typeip"></label><input type="checkbox" id="typeip">
|
||||
</td>
|
||||
<td>
|
||||
<select id="slavefor">
|
||||
<option disabled selected>Not slave</option>
|
||||
{% for master in masters %}
|
||||
<option value="{{master.0}}">{{master.1}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="credentials">
|
||||
<option disabled selected>Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
<option value="{{ssh.0}}">{{ssh.1}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-server" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="ssh">
|
||||
<table id="ssh_enable_table" class="overview">
|
||||
<tr class="overviewHead" style="width: 50%;">
|
||||
<td class="padding10 first-collumn" style="width: 15%;">
|
||||
<span title="It's just name alias. This alias will be userd in 'Servers' page for choose credentials">Name(?)</span>
|
||||
</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<span title="If enabled, the key will be used, if turned off - the password. Do not forget to download the keys to all servers or install the sudo without a password">SSH key(?)</span>
|
||||
</td>
|
||||
<td>
|
||||
<span title="Enter SSH user name. If SSH key disabled, enter password for ssh user">Credentials(?)</span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
<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;">
|
||||
<input type="hidden" id="new-ssh-group-add" name="new-ssh-group-add" value="{{ ssh_group }}" >
|
||||
</td>
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
{% if ssh.2 == 1 %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
||||
{% else %}
|
||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
|
||||
</p>
|
||||
{% if ssh.2 == 1 %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;">
|
||||
{% else %}
|
||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}">
|
||||
{% endif %}
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br /><span class="add-button" title="Add ssh" id="add-ssh-button">+ Add</span>
|
||||
<br /><br />
|
||||
<table class="overview" id="ssh-add-table" style="display: none;">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 15%;">Name</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">SSH key</td>
|
||||
<td>Credentials</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn">
|
||||
<input type="text" name="new-ssh-add" id="new-ssh-add" class="form-control">
|
||||
</td>
|
||||
<td>
|
||||
<label for="new-ssh_enable">Enable SSH key</label><input type="checkbox" id="new-ssh_enable" checked>
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<p>
|
||||
<input type="text" id="ssh_user" class="form-control" value="{{ssh_user}}">
|
||||
</p>
|
||||
<input type="password" id="ssh_pass" class="form-control" value="{{ssh_pass}}" style="display: none;">
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add-admin" id="add-ssh" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="ssh_key">
|
||||
<tr class="overviewHead" style="width: 50%;">
|
||||
<td class="padding10 first-collumn" style="width: 25%;">Upload SSH Key</td>
|
||||
<td>
|
||||
<span title="Private key. Note: The public key must be pre-installed on all servers to which you plan to connect">Key(?)</span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr style="width: 50%;">
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
<select id="ssh-key-name">
|
||||
<option disabled selected>Choose credentials</option>
|
||||
{% for ssh in sshs %}
|
||||
{% if ssh.5|string() == ssh_group.0 %}
|
||||
<option value={{ssh.1}}>{{ssh.1}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<textarea id="ssh_cert" cols="50" rows="5"></textarea><br /><br />
|
||||
<a class="ui-button ui-widget ui-corner-all" id="ssh_key_upload" title="Upload ssh key" onclick="uploadSsh()">Upload</a>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="ajax-ssh"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -215,9 +215,11 @@ $( function() {
|
|||
url: "sql.py",
|
||||
data: {
|
||||
new_ssh: $('#new-ssh-add').val(),
|
||||
new_group: $('#new-sshgroup').val(),
|
||||
ssh_user: $('#ssh_user').val(),
|
||||
ssh_pass: $('#ssh_pass').val(),
|
||||
ssh_enable: ssh_enable,
|
||||
page: cur_url[0]
|
||||
},
|
||||
type: "GET",
|
||||
success: function( data ) {
|
||||
|
@ -300,6 +302,11 @@ $( function() {
|
|||
updateSSH(id[1])
|
||||
sshKeyEnableShow(id[1])
|
||||
});
|
||||
$( "#ssh_enable_table select" ).on('selectmenuchange',function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateSSH(id[1])
|
||||
sshKeyEnableShow(id[1])
|
||||
});
|
||||
$('#new-ssh_enable').click(function() {
|
||||
if ($('#new-ssh_enable').is(':checked')) {
|
||||
$('#ssh_pass').css('display', 'none');
|
||||
|
@ -600,6 +607,7 @@ function updateSSH(id) {
|
|||
data: {
|
||||
updatessh: 1,
|
||||
name: $('#ssh_name-'+id).val(),
|
||||
group: $('#sshgroup-'+id).val(),
|
||||
ssh_enable: ssh_enable,
|
||||
ssh_user: $('#ssh_user-'+id).val(),
|
||||
ssh_pass: $('#ssh_pass-'+id).val(),
|
||||
|
|
Loading…
Reference in New Issue