Was optimized "Configs" sections. Now all action with configs in one place
pull/56/head
Aidaho12 2018-09-26 21:10:35 +06:00
parent 5244945eb4
commit 64d5095985
10 changed files with 47 additions and 95 deletions

View File

@ -11,7 +11,6 @@ template = env.get_template('config.html')
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
form = cgi.FieldStorage()
serv = form.getvalue('serv')
@ -80,7 +79,7 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
os.system("/bin/rm -f " + hap_configs_dir + "*.old")
output_from_parsed_template = template.render(h2 = 1, title = "Edit Runnig HAProxy config",
output_from_parsed_template = template.render(h2 = 1, title = "Working with HAProxy configs",
role = sql.get_user_role_by_uuid(user_id.value),
action = "config.py",
user = user,

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python3
import os
import sql
import http.cookies, cgi
import funct
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('config.html')
print('Content-type: text/html\n')
funct.check_login()
form = cgi.FieldStorage()
serv = form.getvalue('serv')
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(h2 = 1, title = "Show Runnig config",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
onclick = "showConfig()",
select_id = "serv",
serv = serv,
selects = servers,
note = 0,
token = token)
print(output_from_parsed_template)

View File

@ -1,30 +0,0 @@
#!/usr/bin/env python3
import os
import sql
import http
import funct
import sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('config.html')
print('Content-type: text/html\n')
funct.check_login()
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(h2 = 1, title = "Compare configs",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
onclick = "showCompareConfigs()",
select_id = "serv",
selects = servers,
token = token)
print(output_from_parsed_template)

View File

@ -5,6 +5,8 @@
{% 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>
{% endif %}
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
</p>
</center>
<div style="margin-left: 16%" class="configShow">

View File

@ -9,9 +9,9 @@
<option disabled selected>Choose version</option>
{% for file in return_files %}
{% if file == left %}
<option value="{{ file }}" selected>{{ file }}</option>
<option value="{{ file }}" selected>{{ file.split('-', maxsplit=1)[1] }}</option>
{% else %}
<option value="{{ file }}">{{ file }}</option>
<option value="{{ file }}">{{ file.split('-', maxsplit=1)[1] }}</option>
{% endif %}
{% endfor %}
</select>
@ -19,8 +19,7 @@
<select autofocus required name="right" id="right">
<option disabled selected>Choose version</option>
{% for file in return_files %}
<option value="{{ file }}">{{ file }}</option>
<option value="{{ file }}">{{ file.split('-', maxsplit=1)[1] }}</option>
{% endfor %}
</select>

View File

@ -54,15 +54,13 @@
<li><a href=/app/metrics.py title="Metrics" class="metrics head-submenu">Metrics</a></li>
</li>
<li><a title="Actions with Haproxy configs" class="config-show">Haproxy</a>
<li><a href=/app/configshow.py title="Show Haproxy Config" class="config-show head-submenu">Show config</a></li>
<li><a href=/app/diff.py title="Compare Haproxy Configs" class="compare head-submenu">Compare configs</a></li>
{% if user %}
<li><a href=/app/config.py title="Working with Haproxy Configs" class="edit head-submenu">Configs</a> </li>
{% if role <= 2 %}
<li><a href=/app/add.py#listner title="Add single listen" class="add head-submenu">Add listen</a></li>
<li><a href=/app/add.py#frontend title="Add single frontend" class="add head-submenu">Add frontend</a></li>
<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>
<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>
@ -101,7 +99,7 @@
</ul>
</nav>
<div class="copyright-menu">
HAproxy-WI v3.2.8
HAproxy-WI v3.2.9
<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>

View File

@ -27,10 +27,12 @@
{% endif %}
{% endfor %}
</select>
{% if onclick %}
<a class="ui-button ui-widget ui-corner-all" id="show" title="Show config" onclick="{{ onclick }}">Show</a>
{% else %}
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
{% if role <= 2 %}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% endif %}
{% if not keepalived %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Show</a>
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
{% endif %}
</form>
</p>
@ -45,10 +47,12 @@
</div>
{% endif %}
{% endif %}
{% if config %}
{% if role <= 2 %}
<div id="config">
{% if note %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
{% endif %}
{% if config %}
<h3>Config from {{ serv }}</h3>
<form action="{{ action }}" name="saveconfig" method="get">
<input type="hidden" value="{{ serv }}" name="serv">
@ -59,6 +63,8 @@
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
</p>
</form>
</div>
{% endif %}
{% endif %}
{% if aftersave %}
<div class="alert alert-info">New config was saved as: {{ cfg }} </div>

View File

@ -40,9 +40,9 @@
<option disabled selected>Choose version</option>
{% for file in return_files %}
{% if file == configver %}
<option {{file}} selected>{{file}}</option>
<option value="{{file}}" selected>{{file.split('-', maxsplit=1)[1]}}</option>
{% else %}
<option {{file}}>{{file}}</option>
<option value="{{file}}">{{file.split('-', maxsplit=1)[1]}}</option>
{% endif %}
{% endfor %}
</select>

View File

@ -27,7 +27,7 @@
<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}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
<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 />
{% endfor %}
<input type="hidden" value="{{serv}}" name="serv">

View File

@ -85,6 +85,7 @@ function autoRefreshStyle(autoRefresh) {
$('.auto-refresh-resume').css('margin-left', "-25px");
$('.auto-refresh img').remove();
}
function setRefreshInterval(interval) {
if (interval == "0") {
Cookies.remove('auto-refresh');
@ -317,6 +318,9 @@ function showCompare() {
} );
}
function showCompareConfigs() {
$("#ajax").empty();
$("#config").empty();
$(".alert-info").empty();
$.ajax( {
url: "options.py",
data: {
@ -330,10 +334,15 @@ function showCompareConfigs() {
$("#ajax-compare").html(data);
$( "input[type=submit], button" ).button();
$( "select" ).selectmenu();
window.history.pushState("Compare configs", "Compare configs", cur_url[0]);
}
} );
}
function showConfig() {
$("#ajax").empty();
$("#ajax-compare").empty();
$("#config").empty();
$(".alert-info").empty();
$.ajax( {
url: "options.py",
data: {
@ -345,6 +354,7 @@ function showConfig() {
success: function( data ) {
$("#ajax").html(data);
$.getScript('/inc/configshow.js');
window.history.pushState("Show config", "Show config", cur_url[0]);
}
} );
}