mirror of https://github.com/Aidaho12/haproxy-wi
parent
0ffd81bd69
commit
74b9e9b8a9
|
@ -132,6 +132,17 @@ if form.getvalue('action_waf') is not None and serv is not None:
|
||||||
funct.ssh_command(serv, commands)
|
funct.ssh_command(serv, commands)
|
||||||
|
|
||||||
|
|
||||||
|
if form.getvalue('action_service') is not None:
|
||||||
|
action = form.getvalue('action_service')
|
||||||
|
if action == 'stop':
|
||||||
|
cmd="sudo systemctl disable %s --now" % serv
|
||||||
|
elif action == "start":
|
||||||
|
cmd="sudo systemctl enable %s --now" % serv
|
||||||
|
elif action == "restart":
|
||||||
|
cmd="sudo systemctl restart %s --now" % serv
|
||||||
|
output, stderr = funct.subprocess_execute(cmd)
|
||||||
|
funct.logging('localhost', ' The service '+serv+ 'was '+action+'ed', haproxywi=1, login=1)
|
||||||
|
|
||||||
if act == "overviewHapserverBackends":
|
if act == "overviewHapserverBackends":
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<li><a href="#ssh">SSH credentials</a></li>
|
<li><a href="#ssh">SSH credentials</a></li>
|
||||||
<li><a href="#checker">Checker</a></li>
|
<li><a href="#checker">Checker</a></li>
|
||||||
<li><a href="#settings">Settings</a></li>
|
<li><a href="#settings">Settings</a></li>
|
||||||
|
<li><a href="#services">Services</a></li>
|
||||||
<li><a href="#updatehapwi">Update</a></li>
|
<li><a href="#updatehapwi">Update</a></li>
|
||||||
<li><a href="#backup">Backup</a></li>
|
<li><a href="#backup">Backup</a></li>
|
||||||
{% include 'include/login.html' %}
|
{% include 'include/login.html' %}
|
||||||
|
@ -437,6 +438,53 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="services">
|
||||||
|
<table id="services_table" class="overview">
|
||||||
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
Service
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn" style="width: 35%;">
|
||||||
|
Actions
|
||||||
|
</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
{% for s in services %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s.0}}">
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{% if s.1.0 == 'active' %}
|
||||||
|
<span title="{{s.0}} is started"><span class="serverUp server-status"></span></span>
|
||||||
|
{% else %}
|
||||||
|
{% if s.1.0 == 'inactive' or s.1.0 == 'failed' %}
|
||||||
|
<span title="{{s.0}} is stoped"><span class="serverDown server-status"></span></span>
|
||||||
|
{% else %}
|
||||||
|
<span title="{{s.0}} is not installed"><span class="serverNone server-status"></span></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{{s.0}}
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
<a id="start-{{ s.0 }}" class="start" title="Start and enable {{s.0}} service">
|
||||||
|
<span class="service-start" onclick="confirmAjaxServiceAction('start', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{s.0}} service">
|
||||||
|
<span class="service-reload service-restart" onclick="confirmAjaxServiceAction('restart', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
<a id="stop-{{ s.0 }}" class="stop" title="Stop and disable {{s.0}} service">
|
||||||
|
<span class="service-stop" onclick="confirmAjaxServiceAction('stop', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ s.2 }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
|
You can read about services <a href="https://haproxy-wi.org/services.py" title="HAProxy-WI services" target="_blank">here</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="updatehapwi">
|
<div id="updatehapwi">
|
||||||
{% set current_ver = versions.0 %}
|
{% set current_ver = versions.0 %}
|
||||||
{% set new_ver = versions.1 %}
|
{% set new_ver = versions.1 %}
|
||||||
|
@ -597,6 +645,9 @@
|
||||||
<div id="change-user-groups-dialog" style="display: none;">
|
<div id="change-user-groups-dialog" style="display: none;">
|
||||||
<div id="change-user-groups-form"></div>
|
<div id="change-user-groups-form"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="dialog-confirm-services" style="display: none;">
|
||||||
|
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Are you sure?</p>
|
||||||
|
</div>
|
||||||
<style>
|
<style>
|
||||||
.ui-selectmenu-button.ui-button {
|
.ui-selectmenu-button.ui-button {
|
||||||
width: 10em;
|
width: 10em;
|
||||||
|
|
|
@ -108,6 +108,7 @@
|
||||||
<li><a href="/app/users.py#servers" title="Actions with servers" class="runtime head-submenu">Servers</a></li>
|
<li><a href="/app/users.py#servers" title="Actions with servers" class="runtime head-submenu">Servers</a></li>
|
||||||
<li><a href="/app/users.py#ssh" title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
|
<li><a href="/app/users.py#ssh" title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
|
||||||
<li><a href="/app/users.py#settings" title="HAProxy-WI settings" class="settings head-submenu">Settings</a></li>
|
<li><a href="/app/users.py#settings" title="HAProxy-WI settings" class="settings head-submenu">Settings</a></li>
|
||||||
|
<li><a href="/app/users.py#services" title="HAProxy-WI services" class="services head-submenu">Services</a></li>
|
||||||
<li><a href="/app/viewlogs.py" title="View internal logs" class="logs head-submenu">Internal logs</a></li>
|
<li><a href="/app/viewlogs.py" title="View internal logs" class="logs head-submenu">Internal logs</a></li>
|
||||||
<li><a href="/app/users.py#updatehapwi" title="Update HAProxy-WI" class="upload updatehapwi head-submenu">Update</a></li>
|
<li><a href="/app/users.py#updatehapwi" title="Update HAProxy-WI" class="upload updatehapwi head-submenu">Update</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
12
app/users.py
12
app/users.py
|
@ -16,6 +16,17 @@ try:
|
||||||
users = sql.select_users()
|
users = sql.select_users()
|
||||||
settings = sql.get_setting('', all=1)
|
settings = sql.get_setting('', all=1)
|
||||||
ldap_enable = sql.get_setting('ldap_enable')
|
ldap_enable = sql.get_setting('ldap_enable')
|
||||||
|
services = []
|
||||||
|
services_name = {"checker_haproxy":"Master checker service",
|
||||||
|
"keep_alive":"Auto start service",
|
||||||
|
"metrics_haproxy":"Master metrics service",
|
||||||
|
"prometheus":"Prometheus service",
|
||||||
|
"grafana-server":"Grafana service",
|
||||||
|
"fail2ban": "Fail2ban service"}
|
||||||
|
for s, v in services_name.items():
|
||||||
|
cmd = "systemctl status %s |grep Act |awk '{print $2}'" %s
|
||||||
|
status, stderr = funct.subprocess_execute(cmd)
|
||||||
|
services.append([s, status, v])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -34,5 +45,6 @@ template = template.render(title = "Admin area: users manage",
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
settings = settings,
|
settings = settings,
|
||||||
backups = sql.select_backups(),
|
backups = sql.select_backups(),
|
||||||
|
services = services,
|
||||||
ldap_enable = ldap_enable)
|
ldap_enable = ldap_enable)
|
||||||
print(template)
|
print(template)
|
||||||
|
|
|
@ -117,6 +117,11 @@
|
||||||
font-family: "Font Awesome 5 Solid";
|
font-family: "Font Awesome 5 Solid";
|
||||||
content: "\f021";
|
content: "\f021";
|
||||||
}
|
}
|
||||||
|
.services::before {
|
||||||
|
display: none;
|
||||||
|
font-family: "Font Awesome 5 Solid";
|
||||||
|
content: "\f144";
|
||||||
|
}
|
||||||
.upload::before {
|
.upload::before {
|
||||||
display: none;
|
display: none;
|
||||||
font-family: "Font Awesome 5 Solid";
|
font-family: "Font Awesome 5 Solid";
|
||||||
|
|
|
@ -245,7 +245,7 @@ function confirmAjaxAction(action, service, id) {
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
if(service == "hap") {
|
if(service == "hap") {
|
||||||
ajaxActionServers(action, id);
|
ajaxActionServers(action, id);
|
||||||
if(action == "restart") {
|
if(action == "restart" || action == "reload") {
|
||||||
if(Cookies.get('restart')) {
|
if(Cookies.get('restart')) {
|
||||||
Cookies.remove('restart', { path: '' });
|
Cookies.remove('restart', { path: '' });
|
||||||
$("#apply").css('display', 'none');
|
$("#apply").css('display', 'none');
|
||||||
|
|
|
@ -808,6 +808,15 @@ $( function() {
|
||||||
});
|
});
|
||||||
$( "#tabs" ).tabs( "option", "active", 5 );
|
$( "#tabs" ).tabs( "option", "active", 5 );
|
||||||
} );
|
} );
|
||||||
|
$( ".services" ).on( "click", function() {
|
||||||
|
$('.menu li ul li').each(function () {
|
||||||
|
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||||
|
$(this).find('a').css('padding-left', '20px')
|
||||||
|
$(this).children(".services").css('padding-left', '30px');
|
||||||
|
$(this).children(".services").css('border-left', '4px solid #5D9CEB');
|
||||||
|
});
|
||||||
|
$( "#tabs" ).tabs( "option", "active", 6 );
|
||||||
|
} );
|
||||||
$( ".updatehapwi" ).on( "click", function() {
|
$( ".updatehapwi" ).on( "click", function() {
|
||||||
$('.menu li ul li').each(function () {
|
$('.menu li ul li').each(function () {
|
||||||
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||||
|
@ -815,7 +824,7 @@ $( function() {
|
||||||
$(this).children(".updatehapwi").css('padding-left', '30px');
|
$(this).children(".updatehapwi").css('padding-left', '30px');
|
||||||
$(this).children(".updatehapwi").css('border-left', '4px solid #5D9CEB');
|
$(this).children(".updatehapwi").css('border-left', '4px solid #5D9CEB');
|
||||||
});
|
});
|
||||||
$( "#tabs" ).tabs( "option", "active", 6 );
|
$( "#tabs" ).tabs( "option", "active", 7 );
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
$( ".runtime" ).on( "click", function() {
|
$( ".runtime" ).on( "click", function() {
|
||||||
|
|
35
inc/users.js
35
inc/users.js
|
@ -1771,4 +1771,39 @@ function addUserGroup(id) {
|
||||||
}, 2500 );
|
}, 2500 );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
function confirmAjaxServiceAction(action, service) {
|
||||||
|
$( "#dialog-confirm-services" ).dialog({
|
||||||
|
resizable: false,
|
||||||
|
height: "auto",
|
||||||
|
width: 400,
|
||||||
|
modal: true,
|
||||||
|
title: "Are you sure you want to "+ action + " " + service+"?",
|
||||||
|
buttons: {
|
||||||
|
"Sure": function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
ajaxActionServies(action, service)
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function ajaxActionServies(action, service) {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
action_service: action,
|
||||||
|
serv: service,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
success: function( data ) {
|
||||||
|
window.history.pushState("services", "services", cur_url[0].split("#")[0]+"#services")
|
||||||
|
location.reload()
|
||||||
|
},
|
||||||
|
error: function(){
|
||||||
|
alert(w.data_error);
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
|
@ -31,6 +31,9 @@
|
||||||
<script defer src="/inc/fa-solid.min.js"></script>
|
<script defer src="/inc/fa-solid.min.js"></script>
|
||||||
<script defer src="/inc/fontawesome.min.js"></script>
|
<script defer src="/inc/fontawesome.min.js"></script>
|
||||||
<link href="/inc/awesome.css" rel="stylesheet">
|
<link href="/inc/awesome.css" rel="stylesheet">
|
||||||
|
<link href="/inc/chart.min.css" rel="stylesheet">
|
||||||
|
<script src="/inc/metrics.js"></script>
|
||||||
|
<script src="/inc/chart.min.js"></script>
|
||||||
<meta http-equiv="refresh" content="0; url=/app/overview.py" />
|
<meta http-equiv="refresh" content="0; url=/app/overview.py" />
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color: #239dee;">
|
<body style="background-color: #239dee;">
|
||||||
|
|
Loading…
Reference in New Issue