Now combined version sections(upload and delete)
Appeared "Options" tab where you can save options and after use them for adds your proxy
pull/145/head
Pavel Loginov 2019-09-17 10:18:48 +03:00
parent a7d1fc59c1
commit ec5a310d69
18 changed files with 380 additions and 121 deletions

View File

@ -25,6 +25,7 @@ try:
servers = sql.get_dick_permit()
user_group = sql.get_user_group_by_uuid(user_id.value)
token = sql.get_token(user_id.value)
except:
pass
@ -37,6 +38,7 @@ template = template.render(title = "Add",
conf_add = form.getvalue('conf'),
group = user_group,
versions = funct.versions(),
options = sql.select_options(),
token = token)
print(template)

View File

@ -1,72 +0,0 @@
#!/usr/bin/env python3
import html
import cgi
import os, http.cookies
import funct
import sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('configver.html')
funct.check_login()
funct.page_for_admin(level = 2)
form = cgi.FieldStorage()
serv = form.getvalue('serv')
view = form.getvalue('view')
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
stderr = ""
aftersave = ""
configver = ""
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
if serv is not None and form.getvalue('config') is not None:
configver = form.getvalue('configver')
configver = hap_configs_dir + configver
save = form.getvalue('save')
aftersave = 1
try:
funct.logging(serv, "configver.py upload old config %s" % configver)
except:
pass
MASTERS = sql.is_master(serv)
for master in MASTERS:
if master[0] != None:
funct.upload_and_restart(master[0], configver, just_save=save)
stderr = funct.upload_and_restart(serv, configver, just_save=save)
if save:
c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
c["restart"] = form.getvalue('serv')
print(c)
print('Content-type: text/html\n')
template = template.render(h2 = 1, title = "Old Versions HAProxy config",
role = sql.get_user_role_by_uuid(user_id.value),
action = "configver.py",
user = user,
select_id = "serv",
serv = serv,
return_files = funct.get_files(),
aftersave = aftersave,
configver = configver,
selects = servers,
stderr = stderr,
open = form.getvalue('open'),
onclick = "showUploadConfig()",
note = 1,
token = token,
versions = funct.versions(),
view = view)
print(template)

View File

@ -122,6 +122,8 @@ def create_table(**kwargs):
CREATE TABLE IF NOT EXISTS `metrics` (`serv` varchar(64), curr_con INTEGER, cur_ssl_con INTEGER, sess_rate INTEGER, max_sess_rate INTEGER,`date` timestamp default '0000-00-00 00:00:00');
CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar(64), section varchar(64), `desc` varchar(100));
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
);
"""
try:
cur.executescript(sql)
@ -377,7 +379,7 @@ def update_db_v_3_4_5_22(**kwargs):
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '3.4.6.1'; """
sql = """update version set version = '3.4.7'; """
try:
cur.execute(sql)
con.commit()

View File

@ -24,11 +24,7 @@ try:
servbackend = ""
except:
pass
try:
current_ver = funct.check_ver()
except:
pass
output_from_parsed_template = template.render(h2 = 1,
title = "Runtime API",
@ -39,6 +35,6 @@ output_from_parsed_template = template.render(h2 = 1,
selects = servers,
token = token,
serv = serv,
current_ver = current_ver,
versions = funct.versions(),
servbackend = servbackend)
print(output_from_parsed_template)

View File

@ -99,7 +99,7 @@ def telegram_send_mess(mess, **kwargs):
bot = telebot.TeleBot(token=token_bot)
bot.send_message(chat_id=channel_name, text=mess)
except:
mess = "Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group"
mess = " Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group"
print(mess)
logging('localhost', mess, haproxywi=1)
sys.exit()

View File

@ -14,4 +14,6 @@ CREATE TABLE IF NOT EXISTS `token` (`user_id` INTEGER, `token` varchar(64), `exp
CREATE TABLE IF NOT EXISTS `cred` (`id` integer primary key AUTO_INCREMENT, `name` VARCHAR ( 64 ) UNIQUE, `enable` INTEGER NOT NULL DEFAULT 1, `username` VARCHAR ( 64 ) NOT NULL, `password` VARCHAR ( 64 ) NOT NULL, groups INTEGER NOT NULL DEFAULT 1 );
CREATE TABLE IF NOT EXISTS `telegram` (`id` integer primary key auto_increment, `token` VARCHAR ( 64 ), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1);
CREATE TABLE IF NOT EXISTS `metrics` (`serv` varchar(64), curr_con INTEGER, cur_ssl_con INTEGER, sess_rate INTEGER, max_sess_rate INTEGER,`date` DATETIME default '0000-00-00 00:00:00');
CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar(64), section varchar(64), `desc` varchar(100));
CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar(64), section varchar(64), `desc` varchar(100));
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));

View File

@ -18,6 +18,7 @@ def out_error(e):
error = e
else:
error = e.args[0]
print('Content-type: text/html\n')
print('<span class="alert alert-danger" id="error">An error occurred: ' + error + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
def add_user(user, email, password, role, group, activeuser):
@ -612,6 +613,20 @@ def select_telegram(**kwargs):
cur.close()
con.close()
def insert_new_telegram(token, chanel, group):
con, cur = create_db.get_cur()
sql = """insert into telegram(`token`, `chanel_name`, `groups`) values ('%s', '%s', '%s') """ % (token, chanel, group)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
print('<span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
con.rollback()
else:
return True
cur.close()
con.close()
def update_telegram(token, chanel, group, id):
con, cur = create_db.get_cur()
sql = """ update telegram set
@ -628,6 +643,66 @@ def update_telegram(token, chanel, group, id):
cur.close()
con.close()
def insert_new_option(option, group):
con, cur = create_db.get_cur()
sql = """insert into options(`options`, `groups`) values ('%s', '%s') """ % (option, group)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
out_error(e)
con.rollback()
else:
return True
cur.close()
con.close()
def select_options(**kwargs):
con, cur = create_db.get_cur()
sql = """select * from options """
if kwargs.get('option'):
sql = """select * from options where options = '%s' """ % kwargs.get('option')
if kwargs.get('group'):
sql = """select options from options where groups = '{}' and options like '{}%' """.format(kwargs.get('group'), kwargs.get('term'))
#print(sql)
try:
cur.execute(sql)
except sqltool.Error as e:
out_error(e)
else:
return cur.fetchall()
cur.close()
con.close()
def update_options(option, id):
con, cur = create_db.get_cur()
sql = """ update options set
`option` = '%s',
where id = '%s' """ % (option, id)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
out_error(e)
con.rollback()
cur.close()
con.close()
def delete_option(id):
con, cur = create_db.get_cur()
sql = """ delete from options where id = %s """ % (id)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
out_error(e)
con.rollback()
else:
return True
cur.close()
con.close()
def insert_mentrics(serv, curr_con, cur_ssl_con, sess_rate, max_sess_rate):
con, cur = create_db.get_cur()
if mysql_enable == '1':
@ -1102,6 +1177,15 @@ def get_ver():
cur.close()
con.close()
def show_update_option(option):
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'))
template = env.get_template('/new_option.html')
print('Content-type: text/html\n')
template = template.render(options=select_options(option=option))
print(template)
def show_update_telegram(token, page):
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'))
@ -1371,6 +1455,45 @@ if form.getvalue('telegramdel') is not None:
print('Content-type: text/html\n')
if delete_telegram(form.getvalue('telegramdel')):
print("Ok")
if form.getvalue('getoption'):
group = form.getvalue('getoption')
term = form.getvalue('term')
print('Content-type: application/json\n')
options = select_options(group=group,term=term)
a = ""
a = {}
v = 0
for i in options:
a[v] = i[0]
v = v + 1
import json
print(json.dumps(a))
if form.getvalue('newtoption'):
option = form.getvalue('newtoption')
group = form.getvalue('newoptiongroup')
if option is None or group is None:
print('Content-type: text/html\n')
print(error_mess)
else:
if insert_new_option(option, group):
show_update_option(option)
if form.getvalue('updateoption') is not None:
option = form.getvalue('updateoption')
id = form.getvalue('optionid')
print('Content-type: text/html\n')
if token is None or chanel is None or group is None:
print(error_mess)
else:
update_options(option, id)
if form.getvalue('optiondel') is not None:
print('Content-type: text/html\n')
if delete_option(form.getvalue('optiondel')):
print("Ok")
if form.getvalue('updatetoken') is not None:
token = form.getvalue('updatetoken')

View File

@ -6,6 +6,7 @@
<li><a href="#frontend">Frontend</a></li>
<li><a href="#backend">Backend</a></li>
<li><a href="#ssl">SSL certificates</a></li>
<li><a href="#option">Options</a></li>
{% if user %}
<a href=/app/login.py?logout=logout title="Logout, user name: {{ user }}" class="login"> Logout</a>
{% else %}
@ -63,7 +64,7 @@
<option value="tcp">tcp</option>
</select>
<span id="https-listen-span">
<label for="https-listen" style="margin-top: 5px;" title="Enable ssl">ssl?</label>
<label for="https-listen" style="margin-top: 5px;" title="Enable ssl">SSL?</label>
<input type="checkbox" id="https-listen" name="ssl" value="https" >
</span>
<div id="https-hide-listen" style="display: none;">
@ -165,6 +166,10 @@
<span style="padding-left: 10px;">
or press down. <a href="http://cbonte.github.io/haproxy-dconv/1.7/configuration.html" target="_blanck" style="color: #23527c" title="HAproxy docs">Read more about options</a>
</span>
<br />
<span style="padding-right: 10px;">Start typing saved options: </span>
<input type="text" id="saved-options" class="form-control">
It are the options that you saved in the "Options" tab
</div>
<textarea name="option" title="Options thru" id="optionsInput" cols=80 rows=5 placeholder="acl test hdr_beg(host) -i some_host"></textarea>
</div>
@ -285,7 +290,7 @@
<option value="tcp">tcp</option>
</select>
<span id="https-frontend-span">
<label for="https-frontend" style="margin-top: 5px;">ssl?</label>
<label for="https-frontend" style="margin-top: 5px;">SSL?</label>
<input type="checkbox" id="https-frontend" name="ssl" value="https">
</span>
<div id="https-hide-frontend" style="display: none;">
@ -346,6 +351,10 @@
<span style="padding-left: 10px;">
or press down. <a href="http://cbonte.github.io/haproxy-dconv/1.7/configuration.html" target="_blanck" style="color: #23527c" title="HAproxy docs">Read more about options</a>
</span>
<br />
<span style="padding-right: 10px;">Start typing saved options: </span>
<input type="text" id="saved-options1" class="form-control">
It are the options that you saved in the "Options" tab
</div>
<textarea name="option" title="Options thru" cols=80 rows=5 id="optionsInput1" placeholder="acl test hdr_beg(host) -i some_host"></textarea>
</div>
@ -496,6 +505,10 @@
<span style="padding-left: 10px;">
or press down. <a href="http://cbonte.github.io/haproxy-dconv/1.7/configuration.html" target="_blanck" style="color: #23527c" title="HAproxy docs">Read more about options</a>
</span>
<br />
<span style="padding-right: 10px;">Start typing saved options: </span>
<input type="text" id="saved-options2" class="form-control">
It are the options that you saved in the "Options" tab
</div>
<textarea name="option" title="Options thru" cols=80 rows=5 id="optionsInput2" placeholder="acl test hdr_beg(host) -i some_host"></textarea>
</div>
@ -616,14 +629,61 @@
</table>
<div id="ajax-ssl"></div>
</div>
<div id="option">
<table class="overview" id="option_table">
<tr class="overviewHead">
<td class="padding10 first-collumn">Id</td>
<td class="padding10 first-collumn">Optinons</td>
<td></td>
</tr>
{% for option in options %}
<tr id="option-{{ option.0 }}" class="{{ loop.cycle('odd', 'even') }}">
{% if option.2 == group or group == '1' %}
<td class="padding10 first-collumn">
{{ option.0 }}
</td>
<td class="padding10 first-collumn">
<input type="text" id="option-{{ option.0 }}" value="{{ option.1 }}" size="100" class="form-control">
</td>
<td>
<a class="delete" onclick="confirmDeleteOption({{ option.0 }})" title="Delete option {{option.1}}" style="cursor: pointer;"></a>
</td>
{% endif %}
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="Add option" id="add-option-button">+ Add</span>
<br /><br />
<table class="overview" id="option-add-table" style="display: none;">
<tr class="overviewHead">
<td class="padding10 first-collumn">&nbsp;</td>
<td>Option</td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn">
Enter option for save:
</td>
<td>
<input type="hidden" id="newoptiongroup" name="newoptiongroup" value="{{ group }}">
<input type="text" name="new-option" id="new-option" class="form-control" size="100">
</td>
<td>
<a class="add-admin" id="add-option-new" title="Add new option" style="cursor: pointer;"></a>
</td>
</tr>
</table>
<div id="ajax-option">
</div>
{% if add %}
<div class="alert alert-success">
<h3>{{ add }} was success added</h3>
{{ conf_add }}
</div>
{% endif %}
<div id="dialog-confirm-delete" 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="dialog-confirm" title="View certificate " style="display: none;">
<center><pre id="dialog-confirm-body"></pre></center>
</div>

View File

@ -3,7 +3,7 @@
<p class="accordion-expand-holder">
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
{% if not view %}
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" target="_blank" href="config.py?serv={{serv}}&open=open">Edit</a>
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" target="_blank" href="versions.py?serv={{serv}}&open=open">Edit</a>
{% endif %}
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
@ -80,14 +80,12 @@
{% if configver %}
<br>
<center>
<form action="configver.py#conf" method="get">
<form action="versions.py#conf" method="get">
<input type="hidden" value="{{serv}}" name="serv">
<input type="hidden" value="{{configver}}" name="configver">
<input type="hidden" value="1" name="config">
{% if not view %}
<button type='submit' value='save' name='save' class='btn btn-default'>Just save</button>
<button type='submit' value='' name='' class='btn btn-default'>Upload and restart</button>
{% endif %}
<button type='submit' value='save' name='save' class='btn btn-default'>Just save</button>
<button type='submit' value='' name='' class='btn btn-default'>Upload and restart</button>
</form>
</center>
{% endif %}

View File

@ -0,0 +1,14 @@
{% for option in options %}
<tr style="width: 50%;" id="option-table-{{option.0}}" class="newoption update">
<td class="padding10 first-collumn">
{{ option.0 }}
</td>
<td class="first-collumn">
<input type="text" id="option-{{option.0}}" class="form-control" size="100" value="{{option.1}}">
</td>
<td>
<a class="delete" onclick="confirmDeleteOption({{option.0}})" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}

View File

@ -62,24 +62,16 @@
<li><a href=/app/add.py#listner title="Add single listen" class="add head-submenu" id="add1">Add listen</a></li>
<li><a href=/app/add.py#frontend title="Add single frontend" class="add head-submenu" id="add2">Add frontend</a></li>
<li><a href=/app/add.py#backend title="Add single backend" class="add head-submenu" id="add3">Add backend</a></li>
<li><a href=/app/versions.py title="Actions with configs versions" class="version head-submenu">Versions</a></li>
<li><a href=/app/add.py#ssl title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li>
<li><a href=/app/add.py#option title="Save custom options" class="option head-submenu" id="add5">Options</a></li>
<li><a href=/app/lists.py title="Manage black and white lists" class="lists head-submenu">Lists</a> </li>
<li><a href=/app/waf.py title="Web application firewall" class="waf head-submenu">WAF</a> </li>
<li><a href=/app/ihap.py title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
{% endif %}
</ul>
</li>
{% if role <= 2 %}
<li class="p_menu">
<a title="Actions with configs" class="version">Versions</a>
<ul class="v_menu">
<li><a href=/app/configver.py title="Upload old versions configs" class="upload head-submenu">Upload</a></li>
{% endif %}
{% if role <= 2 %}
<li><a href=/app/delver.py title="Delete old versions configs" class="deleteVer head-submenu">Delete</a></li>
{% endif %}
</ul>
</li>
{% if role <= 2 %}
<li class="p_menu">
<a title="Keepalived" class="ha">Keepalived</a>

View File

@ -48,8 +48,7 @@
</select>
<input type="hidden" value="{{serv}}" name="serv">
<input type="hidden" value="open" name="open">
<input type="hidden" value="{{ view }}" id="view">
<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="{{ onclick }}">Select</a>
<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="showUploadConfig()">Select</a>
</p>
</form>
</center>
@ -72,7 +71,7 @@
{% endif %}
{% endif %}
</center>
{% if view %}
{% if aftersave != 1 %}
<script>
showUploadConfig()
</script>

View File

@ -23,12 +23,14 @@
{% if open %}
<center>
<h3>Choose old version</h3>
<form action="delver.py#conf" method="get">
<form action="versions.py#conf" method="get">
<label for="select_all" id="label_select_all"><b>Select all</b></label>
<input type="checkbox" id="select_all"><br />
{% for file in return_files %}
<label for="{{file}}"> {{file.split('-', maxsplit=1)[1]}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
<a href="/app/configver.py?serv={{serv}}&open=open&configver={{file}}&view=1" class="ui-button ui-widget ui-corner-all" target="_blanck" title="View this version of the config" style="margin-top: -6px;">View</a><br />
<a href="/app/versions.py?serv={{serv}}&open=open&configver={{file}}" class="ui-button ui-widget ui-corner-all" target="_blanc" title="View and upload this version of the config" style="margin-top: -6px;">
Upload
</a><br />
{% endfor %}
<input type="hidden" value="{{serv}}" name="serv">
<input type="hidden" value="open" name="open">

View File

@ -10,7 +10,7 @@
</tr>
<tr>
<td class="padding10 first-collumn" style="width: 25%;">
<form action="{{ action }}" method="get">
<form action="{{ action }}" method="get" id="runtimeapiform">
<select autofocus required id="{{ select_id }}" name="{{ select_id }}">
<option disabled>Choose server</option>
{% for select in selects %}
@ -42,7 +42,7 @@
{% endif %}
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="{{ onclick }}">Enter</a>
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
</td>
</form>
</tr>

View File

@ -25,6 +25,9 @@
<b style="font-size: 20px; display: block; padding-bottom: 10px;">Note:</b>
For update you have to use HAProxy-WI repository. If do not use repositiry then use update.sh script in HAProxy-WI home directory <br />
<br />
If server uses proxy to connection Internet add proxy settings in yum.conf
<br />
<br />
Read more about update in <a href="https://haproxy-wi.org/updates.py" title="Doc" target="_blank">docs</a>
and <a href="https://haproxy-wi.org/changelog.py" title="Changelog" target="_blank">changelog</a>
</div>

View File

@ -14,11 +14,16 @@ funct.page_for_admin(level = 2)
form = cgi.FieldStorage()
serv = form.getvalue('serv')
Select = form.getvalue('del')
configver = form.getvalue('configver')
stderr = ""
aftersave = ""
file = set()
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
if form.getvalue('configver'):
template = env.get_template('configver.html')
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
@ -29,11 +34,7 @@ except:
pass
form = cgi.FieldStorage()
serv = form.getvalue('serv')
Select = form.getvalue('del')
if serv is not None and form.getvalue('open') is not None:
if serv is not None and form.getvalue('del') is not None:
if Select is not None:
aftersave = 1
for get in form:
@ -41,14 +42,37 @@ if serv is not None and form.getvalue('open') is not None:
try:
os.remove(os.path.join(hap_configs_dir, form.getvalue(get)))
file.add(form.getvalue(get) + "<br />")
funct.logging(serv, "delver.py deleted config: %s" % form.getvalue(get))
funct.logging(serv, "versions.py deleted config: %s" % form.getvalue(get))
except OSError as e:
stderr = "Error: %s - %s." % (e.filename,e.strerror)
print('<meta http-equiv="refresh" content="10; url=delver.py?serv=%s&open=open">' % form.getvalue('serv'))
print('<meta http-equiv="refresh" content="10; url=versions.py?serv=%s&open=open">' % form.getvalue('serv'))
if serv is not None and form.getvalue('config') is not None:
configver = hap_configs_dir + configver
save = form.getvalue('save')
aftersave = 1
try:
funct.logging(serv, "configver.py upload old config %s" % configver)
except:
pass
MASTERS = sql.is_master(serv)
for master in MASTERS:
if master[0] != None:
funct.upload_and_restart(master[0], configver, just_save=save)
stderr = funct.upload_and_restart(serv, configver, just_save=save)
if save:
c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
c["restart"] = form.getvalue('serv')
print(c)
output_from_parsed_template = template.render(h2 = 1, title = "Delete old versions HAProxy config",
output_from_parsed_template = template.render(h2 = 1, title = "Working with versions HAProxy configs",
role = sql.get_user_role_by_uuid(user_id.value),
action = "delver.py",
action = "versions.py",
user = user,
select_id = "serv",
serv = serv,
@ -60,5 +84,6 @@ output_from_parsed_template = template.render(h2 = 1, title = "Delete old versio
Select = form.getvalue('del'),
file = file,
versions = funct.versions(),
configver = configver,
token = token)
print(output_from_parsed_template)

View File

@ -66,6 +66,11 @@
font-family: "Font Awesome 5 Solid";
content: "\f0a3";
}
.option::before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f0b0";
}
.edit::before {
display: none;
font-family: "Font Awesome 5 Solid";

View File

@ -248,7 +248,7 @@ function openStats() {
}
function openVersions() {
var serv = $("#serv").val();
var url = "configver.py?serv="+serv+"&open=open"
var url = "versions.py?serv="+serv+"&open=open"
var win = window.open(url, '_blank');
win.focus();
}
@ -897,12 +897,32 @@ $( function() {
$("#options").empty();
}
});
$( "#saved-options" ).autocomplete({
dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(),
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput").append(ui.item.value + " \n");
$( "#saved-options" ).reset();
}
});
$( "#options1" ).autocomplete({
source: availableTags,
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput1").append(ui.item.value + " ");
$("#optionsInput1").append(ui.item.value + " ")
}
});
$( "#saved-options1" ).autocomplete({
dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(),
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput1").append(ui.item.value + " \n");
$( "#options1" ).reset();
}
});
$( "#options2" ).autocomplete({
@ -913,7 +933,50 @@ $( function() {
$("#optionsInput2").append(ui.item.value + " ")
}
});
$( "#saved-options2" ).autocomplete({
dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(),
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput2").append(ui.item.value + " \n");
$( "#saved-options2" ).reset();
}
});
$('#add-option-button').click(function() {
if ($('#option-add-table').css('display', 'none')) {
$('#option-add-table').show("blind", "fast");
}
});
$('#add-option-new').click(function() {
$('#error').remove();
$('.alert-danger').remove();
$.ajax( {
url: "sql.py",
data: {
newtoption: $('#new-option').val(),
newoptiongroup: $('#newoptiongroup').val(),
token: $('#token').val()
},
type: "GET",
success: function( data ) {
if (data.indexOf('error') != '-1') {
$("#ajax-option").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
} else {
$("#option_table").append(data);
setTimeout(function() {
$( ".newoption" ).removeClass( "update" );
}, 2500 );
$.getScript("/inc/fontawesome.min.js");
}
}
} );
});
var ssl_offloading_var = "http-request set-header X-Forwarded-Port %[dst_port] \n"+
"http-request add-header X-Forwarded-Proto https if { ssl_fc } \n"+
"redirect scheme https if !{ ssl_fc } \n"
@ -1127,6 +1190,13 @@ $( function() {
$(this).parent().addClass('current');
$( "#tabs" ).tabs( "option", "active", 3 );
} );
$( "#add5" ).on( "click", function() {
$('.menu li').each(function () {
$(this).removeClass('current');
});
$(this).parent().addClass('current');
$( "#tabs" ).tabs( "option", "active", 4 );
} );
}
if (cur_url[0] == "/app/users.py" || cur_url[0] == "/app/servers.py") {
$( ".users" ).on( "click", function() {
@ -1323,6 +1393,10 @@ $( function() {
$('.advance-show').fadeOut();
$('.advance').fadeIn();
});
$('#runtimeapiform').submit(function() {
showRuntime();
return false;
});
$('#auth').submit(function() {
let searchParams = new URLSearchParams(window.location.search)
@ -1376,6 +1450,40 @@ $( function() {
showUpdates.dialog('open');
});
});
function confirmDeleteOption(id) {
$( "#dialog-confirm-delete" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want to delete " +$('#option-'+id).val() + "?",
buttons: {
"Delete": function() {
$( this ).dialog( "close" );
removeOption(id);
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
function removeOption(id) {
$("#option-"+id).css("background-color", "#f2dede");
$.ajax( {
url: "sql.py",
data: {
optiondel: id,
},
type: "GET",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if(data == "Ok ") {
$("#option-"+id).remove();
}
}
} );
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}