Mobile-readi design, bugs fix, improved logging
pull/161/head
Pavel Loginov 2019-10-07 20:07:28 +03:00
parent 5f8cd37f7c
commit 6b9f143bac
12 changed files with 103 additions and 50 deletions

View File

@ -44,6 +44,7 @@ Support the project
25. LDAP support 25. LDAP support
26. Keep active HAProxy service 26. Keep active HAProxy service
27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd" 27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
28. Mobile-ready desing
![alt text](image/haproxy-wi-metrics.png "Merics") ![alt text](image/haproxy-wi-metrics.png "Merics")

View File

@ -217,6 +217,7 @@ def get_config(serv, cfg, **kwargs):
ssh.close() ssh.close()
except Exception as e: except Exception as e:
ssh = str(e) ssh = str(e)
logging('localhost', ssh, haproxywi=1)
return ssh return ssh
def diff_config(oldcfg, cfg): def diff_config(oldcfg, cfg):
@ -404,6 +405,7 @@ def upload(serv, path, file, **kwargs):
ssh = ssh_connect(serv) ssh = ssh_connect(serv)
except Exception as e: except Exception as e:
error = e error = e
logging('localhost', e, haproxywi=1)
pass pass
try: try:
sftp = ssh.open_sftp() sftp = ssh.open_sftp()
@ -412,6 +414,7 @@ def upload(serv, path, file, **kwargs):
ssh.close() ssh.close()
except Exception as e: except Exception as e:
error = e error = e
logging('localhost', e, haproxywi=1)
pass pass
return error return error
@ -451,6 +454,7 @@ def upload_and_restart(serv, cfg, **kwargs):
except Exception as e: except Exception as e:
error += e error += e
if error: if error:
logging('localhost', error, haproxywi=1)
return error return error
def open_port_firewalld(cfg): def open_port_firewalld(cfg):

View File

@ -146,9 +146,9 @@
</td> </td>
<td> <td>
{% if group.2 != "None" %} {% if group.2 != "None" %}
<input type="text" id="descript-{{ group.0 }}" value="{{ group.2 }}" class="form-control" size="100"> <input type="text" id="descript-{{ group.0 }}" value="{{ group.2 }}" class="form-control" size="60">
{% else %} {% else %}
<input type="text" id="descript-{{ group.0 }}" value="" class="form-control" size="100"> <input type="text" id="descript-{{ group.0 }}" value="" class="form-control" size="60">
{% endif %} {% endif %}
</td> </td>
<td> <td>

View File

@ -52,7 +52,7 @@
{% endif %} {% endif %}
{% set backend = line.split(' ') %} {% set backend = line.split(' ') %}
<span class="accordion-link"> <span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}">Stats</a> <a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span> </span>
</span><div> </span><div>
{% continue %} {% continue %}
@ -66,7 +66,7 @@
{% endif %} {% endif %}
{% set backend = line.split(' ') %} {% set backend = line.split(' ') %}
<span class="accordion-link"> <span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}">Stats</a> <a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span> </span>
</span><div> </span><div>
{% continue %} {% continue %}
@ -74,19 +74,35 @@
{% if line.startswith('backend') %} {% if line.startswith('backend') %}
</div><span class="param"> {{ line }} </div><span class="param"> {{ line }}
{% if role %} {% if role %}
<span class="accordion-link"> <span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a> <a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span> </span>
{% endif %} {% endif %}
{% set backend = line.split(' ') %} {% set backend = line.split(' ') %}
<span class="accordion-link"> <span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}">Stats</a> <a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span> </span>
</span><div> </span><div>
{% continue %} {% continue %}
{% endif %} {% endif %}
{% if line.startswith('cache') %} {% if line.startswith('cache') %}
</div><span class="param"> {{ line }} </span><div> </div><span class="param"> {{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('peers') %}
</div><span class="param"> {{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %} {% continue %}
{% endif %} {% endif %}
{% if "acl" in line or "option" in line or "server" in line %} {% if "acl" in line or "option" in line or "server" in line %}

View File

@ -13,10 +13,6 @@
{{ service.0 }} {{ service.0 }}
</a> </a>
</td> </td>
{% if url == "waf.py" %}
<td>
</td>
{% endif %}
<td> <td>
{% if role <= 1 %} {% if role <= 1 %}
<a id="{{ service.1 }}" class="start-waf" title="Start WAF service"> <a id="{{ service.1 }}" class="start-waf" title="Start WAF service">

View File

@ -10,16 +10,16 @@
<th colspan=3>Peak connections</th> <th colspan=3>Peak connections</th>
</tr> </tr>
<tr class="overviewHead"> <tr class="overviewHead">
<th>60 minutes</th> <th>1 hour</th>
<th>24 hours</th> <th>24 hours</th>
<th>3 days</th> <th>3 days</th>
<th>60 minutes</th> <th>1 hour</th>
<th>24 hours</th> <th>24 hours</th>
<th>3 days</th> <th>3 days</th>
<th>60 minutes</th> <th>1 hour</th>
<th>24 hours</th> <th>24 hours</th>
<th>3 days</th> <th>3 days</th>
<th>60 minutes</th> <th>1 hour</th>
<th>24 hours</th> <th>24 hours</th>
<th>3 days</th> <th>3 days</th>
</tr> </tr>

View File

@ -36,6 +36,10 @@
{% if role <= 2 %} {% if role <= 2 %}
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a> <a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
{% endif %} {% endif %}
{% else %}
{% if role <= 2 %}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% endif %}
{% endif %} {% endif %}
</form> </form>
</p> </p>

View File

@ -25,7 +25,6 @@ th, tr, td {
</div> </div>
{% endfor %} {% endfor %}
<div id="metrics_iframe"></div>
<script> <script>
function showMetrics() { function showMetrics() {
{% for s in servers %} {% for s in servers %}

View File

@ -5,9 +5,6 @@
<td class="padding10 first-collumn"> <td class="padding10 first-collumn">
Server Server
</td> </td>
<td>
<!-- WAF status -->
</td>
<td class="padding10"> <td class="padding10">
Action Action
</td> </td>
@ -23,7 +20,6 @@
</tr> </tr>
<tbody id="ajaxwafstatus"></tbody> <tbody id="ajaxwafstatus"></tbody>
</table> </table>
<div id="ajax"></div>
<link href="/inc/chart.min.css" rel="stylesheet"> <link href="/inc/chart.min.css" rel="stylesheet">
<script src="/inc/metrics.js"></script> <script src="/inc/metrics.js"></script>

View File

@ -354,12 +354,13 @@ $( function() {
}); });
$( "#saved-options" ).autocomplete({ $( "#saved-options" ).autocomplete({
dataType: "json", dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(), source: "sql.py?getoption="+$('#newoptiongroup').val()+'&token='+$('#token').val(),
autoFocus: true, autoFocus: true,
minLength: -1, minLength: 1,
select: function( event, ui ) { select: function( event, ui ) {
$("#optionsInput").append(ui.item.value + " \n"); $("#optionsInput").append(ui.item.value + " \n");
$( "#saved-options" ).reset(); $(this).val('');
$(this).autocomplete( "close" );
} }
}); });
$( "#options1" ).autocomplete({ $( "#options1" ).autocomplete({
@ -372,12 +373,13 @@ $( function() {
}); });
$( "#saved-options1" ).autocomplete({ $( "#saved-options1" ).autocomplete({
dataType: "json", dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(), source: "sql.py?getoption="+$('#newoptiongroup').val()+'&token='+$('#token').val(),
autoFocus: true, autoFocus: true,
minLength: -1, minLength: 1,
select: function( event, ui ) { select: function( event, ui ) {
$("#optionsInput1").append(ui.item.value + " \n"); $("#optionsInput1").append(ui.item.value + " \n");
$( "#options1" ).reset(); $(this).val('');
$(this).autocomplete( "close" );
} }
}); });
$( "#options2" ).autocomplete({ $( "#options2" ).autocomplete({
@ -390,12 +392,13 @@ $( function() {
}); });
$( "#saved-options2" ).autocomplete({ $( "#saved-options2" ).autocomplete({
dataType: "json", dataType: "json",
source: "sql.py?getoption="+$('#newoptiongroup').val(), source: "sql.py?getoption="+$('#newoptiongroup').val()+'&token='+$('#token').val(),
autoFocus: true, autoFocus: true,
minLength: -1, minLength: 1,
select: function( event, ui ) { select: function( event, ui ) {
$("#optionsInput2").append(ui.item.value + " \n"); $("#optionsInput2").append(ui.item.value + " \n");
$( "#saved-options2" ).reset(); $(this).val('');
$(this).autocomplete( "close" );
} }
}); });
$('#add-option-button').click(function() { $('#add-option-button').click(function() {

View File

@ -265,6 +265,8 @@ function showOverviewWaf() {
$.getScript('/inc/waf.js'); $.getScript('/inc/waf.js');
$( "input[type=submit], button" ).button(); $( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio(); $( "input[type=checkbox]" ).checkboxradio();
} else {
$('.first-collumn-wi').css('padding', '15px');
} }
} }
} ); } );

View File

@ -21,7 +21,7 @@ h2 {
color: #fff; color: #fff;
margin-top: 0px; margin-top: 0px;
margin-bottom: 0px; margin-bottom: 0px;
width: 99% width: 98.9%;
} }
h3 { h3 {
margin-top: -0; margin-top: -0;
@ -30,6 +30,7 @@ h3 {
padding: 0.3em; padding: 0.3em;
font-size: 1.6em; font-size: 1.6em;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
width: 100.43%;
} }
form { form {
margin: 0; margin: 0;
@ -78,7 +79,7 @@ pre {
.container { .container {
min-height: calc(99vh - 50px); min-height: calc(99vh - 50px);
height: auto; height: auto;
max-width: 91%; max-width: 100%;
min-width: 40%; min-width: 40%;
background-color: #fff; background-color: #fff;
margin-left: 207px; margin-left: 207px;
@ -328,24 +329,14 @@ pre {
padding-left: 10px; padding-left: 10px;
font-style: italic; font-style: italic;
} }
/* .tooltip { */
/* font-size: 12px; */
/* padding-bottom: 10px; */
/* } */
/* .tooltipTop { */
/* margin-bottom: -20px; */
/* padding-top: 10px; */
/* } */
.overview { .overview {
width: 100%; width: 100%;
/* margin-top: 1.5em; */
} }
.overview-wi { .overview-wi {
width: 46%; width: 46%;
min-width: 600px; min-width: 566px ;
max-width: 50%; max-width: 50%;
/* border: 1px solid #A4C7F5; */ min-height: 160px;
height: 160px;
float: left; float: left;
margin: 20px; margin: 20px;
} }
@ -629,8 +620,8 @@ a:focus {
outline: 5px auto -webkit-focus-ring-color; outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; outline-offset: -2px;
} }
.logs_link { .logs_link, .accordion-link {
color: #23527c; color: #23527c !important;
} }
table { table {
border-spacing: 0; border-spacing: 0;
@ -809,7 +800,7 @@ label {
} }
.chart-container { .chart-container {
position: relative; position: relative;
height: 310px; height: 400px;
width: 49%; width: 49%;
float: left; float: left;
margin-top: 20px; margin-top: 20px;
@ -820,9 +811,32 @@ label {
margin-left: 17%; margin-left: 17%;
} }
} }
@media (max-width: 1080px) {
#logo_span {
margin-left: -5%;
}
.chart-container {
position: relative;
height: 410px;
width: 95%;
}
.overview-wi {
width: 95%;
max-width: 95%;
}
}
@media (max-width: 1024px) { @media (max-width: 1024px) {
#logo_span { #logo_span {
margin-left: -5%; margin-left: -5%;
}
.chart-container {
position: relative;
height: 410px;
width: 95%;
}
.overview-wi {
width: 95%;
max-width: 95%;
} }
} }
@media (max-width: 667px) { @media (max-width: 667px) {
@ -830,10 +844,28 @@ label {
margin-left: -12%; margin-left: -12%;
border: none; border: none;
} }
.chart-container {
position: relative;
height: 410px;
width: 95%;
}
.overview-wi {
width: 95%;
max-width: 95%;
}
} }
@media (max-width: 768px) { @media (max-width: 768px) {
#logo_span { #logo_span {
margin-left: -12%; margin-left: -12%;
border: none; border: none;
} }
.chart-container {
position: relative;
height: 410px;
width: 95%;
}
.overview-wi {
width: 95%;
max-width: 95%;
}
} }