Pavel Loginov 2021-08-25 20:38:32 +06:00
parent 801c345dc6
commit f345a4980f
3 changed files with 72 additions and 23 deletions

View File

@ -129,26 +129,6 @@ def update_db_v_3_4_5_22():
print('Cannot insert version %s' % e)
def update_db_v_4(**kwargs):
data_source = [
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx', 'desc': 'Nginx error log', 'group': '1'},
{'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for Stats web page Nginx', 'group': '1'},
{'param': 'nginx_stats_password', 'value': 'password', 'section': 'nginx', 'desc': 'Password for Stats web page Nginx', 'group': '1'},
{'param': 'nginx_stats_port', 'value': '8086', 'section': 'nginx', 'desc': 'Stats port for web page Nginx', 'group': '1'},
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx', 'group': '1'},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', 'desc': 'Path to Nginx dir', 'group': '1'},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx', 'desc': 'Path to Nginx config', 'group': '1'},
]
try:
Setting.insert_many(data_source).on_conflict_ignore().execute()
except:
pass
else:
if kwargs.get('silent') != 1:
print('Updating... one more for version 4.0.0')
def update_db_v_41(**kwargs):
cursor = conn.cursor()
sql = """
@ -750,7 +730,6 @@ def update_ver():
def update_all():
if check_ver() is None:
update_db_v_3_4_5_22()
update_db_v_4()
update_db_v_41()
update_db_v_42()
update_db_v_4_3_0()
@ -775,7 +754,6 @@ def update_all():
def update_all_silent():
if check_ver() is None:
update_db_v_3_4_5_22()
update_db_v_4(silent=1)
update_db_v_41(silent=1)
update_db_v_42(silent=1)
update_db_v_4_3_0(silent=1)

View File

@ -39,7 +39,7 @@ class User(BaseModel):
class Server(BaseModel):
server_id = AutoField(column_name='id')
hostname = CharField()
ip = CharField()
ip = CharField(constraints=[SQL('UNIQUE')])
groups = CharField()
type_ip = IntegerField(constraints=[SQL('DEFAULT 0')])
enable = IntegerField(constraints=[SQL('DEFAULT 1')])

View File

@ -0,0 +1,71 @@
<style>
.select-css {
display: block;
font-size: 16px;
font-family: sans-serif;
font-weight: 700;
color: #444;
line-height: 1.3;
padding: .6em 1.4em .5em .8em;
width: 80%;
max-width: 90%;
box-sizing: border-box;
margin: 0;
border: 1px solid #aaa;
box-shadow: 0 1px 0 1px rgba(0,0,0,.04);
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-color: #f9fcf9;
background-size: .65em auto, 100%;
}
.select-css::-ms-expand {
display: none;
}
.select-css:hover {
border-color: #888;
}
.select-css:focus {
border-color: #aaa;
box-shadow: 0 0 1px 3px rgba(59, 153, 252, .7);
box-shadow: 0 0 0 3px -moz-mac-focusring;
color: #222;
outline: none;
}
.select-css option {
font-weight:normal;
padding: 3px;
margin-left: 0;
padding-right: 1200px;
padding-left: 10px;
}
*[dir="rtl"] .select-css, :root:lang(ar) .select-css, :root:lang(iw) .select-css {
background-position: left .7em top 50%, 0 0;
padding: .6em .8em .5em 1.4em;
}
.select-css:disabled, .select-css[aria-disabled=true] {
color: graytext;
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22graytext%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'),
linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
}
.select-css:disabled:hover, .select-css[aria-disabled=true] {
border-color: #aaa;
}
</style>
{% set services = {'1': 'HAProxy', '2': 'Nginx', '3': 'Keepalived' } %}
<table class="overview">
<tr style="border: none;">
<td class="padding20" style="width: 40%;"><b>Select one or more services</b></td>
<td>
<select id="userservice-{{id}}" name="userservice-{{id}}" multiple class="select-css">
{% for key, value in services.items() %}
{% if key in user_services %}
<option value="{{ key }}" selected>{{ value }}</option>
{% else %}
<option value="{{ key }}">{{ value }}</option>
{% endif %}
{% endfor %}
</select>
</td>
</tr>
</table>