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') print('Content-type: text/html\n')
funct.check_login() funct.check_login()
funct.page_for_admin(level = 2)
form = cgi.FieldStorage() form = cgi.FieldStorage()
serv = form.getvalue('serv') 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") 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), role = sql.get_user_role_by_uuid(user_id.value),
action = "config.py", action = "config.py",
user = user, 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 %} {% 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="config.py?serv={{serv}}&open=open">Edit</a>
{% endif %} {% endif %}
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
</p> </p>
</center> </center>
<div style="margin-left: 16%" class="configShow"> <div style="margin-left: 16%" class="configShow">

View File

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

View File

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

View File

@ -27,10 +27,12 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
{% if onclick %} {% if role <= 2 %}
<a class="ui-button ui-widget ui-corner-all" id="show" title="Show config" onclick="{{ onclick }}">Show</a> <button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% else %} {% endif %}
<button type="submit" value="open" name="open" class="btn btn-default">Open</button> {% 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 %} {% endif %}
</form> </form>
</p> </p>
@ -45,20 +47,24 @@
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if note %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
{% endif %}
{% if config %} {% if config %}
<h3>Config from {{ serv }}</h3> {% if role <= 2 %}
<form action="{{ action }}" name="saveconfig" method="get"> <div id="config">
<input type="hidden" value="{{ serv }}" name="serv"> {% if note %}
<input type="hidden" value="{{ cfg }}.old" name="oldconfig"> <div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea> {% endif %}
<p> <h3>Config from {{ serv }}</h3>
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button> <form action="{{ action }}" name="saveconfig" method="get">
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button> <input type="hidden" value="{{ serv }}" name="serv">
</p> <input type="hidden" value="{{ cfg }}.old" name="oldconfig">
</form> <textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea>
<p>
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
</p>
</form>
</div>
{% endif %}
{% endif %} {% endif %}
{% if aftersave %} {% if aftersave %}
<div class="alert alert-info">New config was saved as: {{ cfg }} </div> <div class="alert alert-info">New config was saved as: {{ cfg }} </div>

View File

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

View File

@ -27,7 +27,7 @@
<label for="select_all" id="label_select_all"><b>Select all</b></label> <label for="select_all" id="label_select_all"><b>Select all</b></label>
<input type="checkbox" id="select_all"><br /> <input type="checkbox" id="select_all"><br />
{% for file in return_files %} {% 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 /> <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 %} {% endfor %}
<input type="hidden" value="{{serv}}" name="serv"> <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-resume').css('margin-left', "-25px");
$('.auto-refresh img').remove(); $('.auto-refresh img').remove();
} }
function setRefreshInterval(interval) { function setRefreshInterval(interval) {
if (interval == "0") { if (interval == "0") {
Cookies.remove('auto-refresh'); Cookies.remove('auto-refresh');
@ -317,6 +318,9 @@ function showCompare() {
} ); } );
} }
function showCompareConfigs() { function showCompareConfigs() {
$("#ajax").empty();
$("#config").empty();
$(".alert-info").empty();
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
@ -330,10 +334,15 @@ function showCompareConfigs() {
$("#ajax-compare").html(data); $("#ajax-compare").html(data);
$( "input[type=submit], button" ).button(); $( "input[type=submit], button" ).button();
$( "select" ).selectmenu(); $( "select" ).selectmenu();
window.history.pushState("Compare configs", "Compare configs", cur_url[0]);
} }
} ); } );
} }
function showConfig() { function showConfig() {
$("#ajax").empty();
$("#ajax-compare").empty();
$("#config").empty();
$(".alert-info").empty();
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
@ -345,6 +354,7 @@ function showConfig() {
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
$.getScript('/inc/configshow.js'); $.getScript('/inc/configshow.js');
window.history.pushState("Show config", "Show config", cur_url[0]);
} }
} ); } );
} }