mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 10:04:41 +00:00
(legacy) rework status_services, optional tag for script, fix typo
This commit is contained in:
parent
f9d6ddc408
commit
cef101f5e2
@ -2687,7 +2687,7 @@ function services_get()
|
||||
$services[] = array(
|
||||
'pidfile' => '/var/run/lighttpd-api-dispatcher.pid',
|
||||
'description' => gettext('Captive Portal'),
|
||||
'confidg' => array(
|
||||
'configd' => array(
|
||||
'restart' => array('captiveportal restart'),
|
||||
'start' => array('captiveportal start'),
|
||||
'stop' => array('captiveportal stop'),
|
||||
@ -2782,26 +2782,28 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
|
||||
return $output;
|
||||
}
|
||||
|
||||
function get_service_control_links($service, $addname = false)
|
||||
function get_service_control_links($service, $addname = false, $add_script = true)
|
||||
{
|
||||
$stitle = $addname ? $service['name'] . ' ' : '';
|
||||
$output = "
|
||||
<script type='text/javascript'>
|
||||
$( document ).ready(function() {
|
||||
$('.srv_status_act').click(function(event){
|
||||
event.preventDefault();
|
||||
params = {};
|
||||
params['action'] = $(this).data('service_action');
|
||||
params['service'] = $(this).data('service');
|
||||
params['id'] = $(this).data('service_id');
|
||||
$.post('/status_services.php',params, function(data) {
|
||||
// refresh page after service action
|
||||
location.reload();
|
||||
});
|
||||
if ($add_script) {
|
||||
$output = "
|
||||
<script type='text/javascript'>
|
||||
$( document ).ready(function() {
|
||||
$('.srv_status_act').click(function(event){
|
||||
event.preventDefault();
|
||||
params = {};
|
||||
params['action'] = $(this).data('service_action');
|
||||
params['service'] = $(this).data('service');
|
||||
params['id'] = $(this).data('service_id');
|
||||
$.post('/status_services.php',params, function(data) {
|
||||
// refresh page after service action
|
||||
//location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
if (get_service_status($service)) {
|
||||
if (isset($service['id'])) {
|
||||
|
||||
@ -45,13 +45,13 @@ if (!empty($_POST['service'])) {
|
||||
$service_name = $_POST['service'];
|
||||
switch ($_POST['action']) {
|
||||
case 'restart':
|
||||
service_control_restart($service_name, $_POST);
|
||||
echo service_control_restart($service_name, $_POST);
|
||||
break;
|
||||
case 'start':
|
||||
service_control_start($service_name, $_POST);
|
||||
echo service_control_start($service_name, $_POST);
|
||||
break;
|
||||
case 'stop':
|
||||
service_control_stop($service_name, $_POST);
|
||||
echo service_control_stop($service_name, $_POST);
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
@ -69,7 +69,6 @@ function service_control_start($name, $extras)
|
||||
if (!isset($service['name'])) {
|
||||
return sprintf(gettext("Could not start unknown service `%s'"), htmlspecialchars($name));
|
||||
}
|
||||
|
||||
if (isset($service['configd']['start'])) {
|
||||
foreach ($service['configd']['start'] as $cmd) {
|
||||
configd_run($cmd);
|
||||
@ -180,6 +179,22 @@ include("head.inc");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<script type='text/javascript'>
|
||||
$( document ).ready(function() {
|
||||
$('.srv_status_act').click(function(event){
|
||||
event.preventDefault();
|
||||
params = {};
|
||||
params['action'] = $(this).data('service_action');
|
||||
params['service'] = $(this).data('service');
|
||||
params['id'] = $(this).data('service_id');
|
||||
$.post('/status_services.php',params, function(data) {
|
||||
// refresh page after service action
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
@ -205,7 +220,7 @@ include("head.inc");
|
||||
<td><?=$service['description'];?></td>
|
||||
<td>
|
||||
<?=get_service_status_icon($service, true, true);?>
|
||||
<?=get_service_control_links($service);?>
|
||||
<?=get_service_control_links($service, false, false);?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user