Commit 865b51da authored by Ad Schellevis's avatar Ad Schellevis

(dashboard, widgets) refactor services_status.widget.php

parent 85149c0e
...@@ -29,66 +29,75 @@ ...@@ -29,66 +29,75 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("services.inc"); require_once("services.inc");
require_once("system.inc"); require_once("system.inc");
require_once('plugins.inc'); require_once('plugins.inc');
require_once("ipsec.inc"); require_once("ipsec.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("widgets/include/services_status.inc");
$services = services_get(); $services = services_get();
if (isset($_POST['servicestatusfilter'])) { if (isset($_POST['servicestatusfilter'])) {
$config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401); $config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401);
write_config("Saved Service Status Filter via Dashboard"); write_config("Saved Service Status Filter via Dashboard");
header("Location: ../../index.php"); header("Location: /index.php");
} }
?> ?>
<input type="hidden" id="services_status-config" name="services_status-config" value="" />
<div id="services_status-settings" class="widgetconfigdiv" style="display:none;"> <div id="services_status-settings" class="widgetconfigdiv" style="display:none;">
<form action="/widgets/widgets/services_status.widget.php" method="post" name="iformd"> <form action="/widgets/widgets/services_status.widget.php" method="post" name="iformd">
<?= gettext('Comma separated list of services to NOT display in the widget') ?><br /> <table class="table table-condensed">
<input type="text" size="30" name="servicestatusfilter" class="formfld unknown" id="servicestatusfilter" value="<?= $config['widgets']['servicestatusfilter'] ?>" /> <thead>
<tr>
<th><?= gettext('Comma separated list of services to NOT display in the widget') ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="servicestatusfilter" id="servicestatusfilter" value="<?= $config['widgets']['servicestatusfilter'] ?>" /></td>
</tr>
<tr>
<td>
<input id="submitd" name="submitd" type="submit" class="btn btn-primary" value="Save" /> <input id="submitd" name="submitd" type="submit" class="btn btn-primary" value="Save" />
</td>
</tr>
</tbody>
</table>
</form> </form>
</div> </div>
<table class="table table-striped" width="100%" border="0" cellpadding="0" cellspacing="0" summary="services"> <table class="table table-striped table-condensed">
<thead>
<tr> <tr>
<td class="widgetsubheader" align="center"><b><?= gettext('Service') ?></b></td> <th><?= gettext('Service') ?></th>
<td class="widgetsubheader" align="center"><b><?= gettext('Description') ?></b></td> <th><?= gettext('Description') ?></th>
<td class="widgetsubheader" align="center"><b><?= gettext('Status') ?></b></td> <th><?= gettext('Status') ?></th>
<td class="widgetsubheader">&nbsp;</td>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$skipservices = explode(",", $config['widgets']['servicestatusfilter']); $skipservices = explode(",", $config['widgets']['servicestatusfilter']);
if (count($services) > 0):
if (count($services) > 0) {
uasort($services, "service_name_compare"); uasort($services, "service_name_compare");
foreach ($services as $service) { foreach ($services as $service):
if (!$service['name'] || in_array($service['name'], $skipservices)) { if (!$service['name'] || in_array($service['name'], $skipservices)) {
continue; continue;
} }
$service_desc = explode(".", $service['description']); $service_desc = explode(".", $service['description']);?>
echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n"; <tr>
echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n"; <td><?=$service['name'];?></td>
// if service is running then listr else listbg <td><?=$service_desc[0];?></td>
$bgclass = null; <td><?=str_replace('btn ', 'btn btn-xs ', get_service_status_icon($service, false, true));?>
if (get_service_status($service)) { <?=str_replace('btn ', 'btn btn-xs ', get_service_control_links($service));?>
$bgclass = "listr"; </td>
} else { </tr>
$bgclass = "listbg"; <?php
} endforeach;
echo "<td class=\"" . $bgclass . "\" align=\"center\">" . str_replace('btn ', 'btn btn-xs ', get_service_status_icon($service, false, true)) . "</td>\n"; else:?>
echo "<td valign=\"middle\" class=\"list nowrap\">" . str_replace('btn ', 'btn btn-xs ', get_service_control_links($service)) . "</td></tr>\n"; <tr><td colspan="3"><?=gettext("No services found");?></td></tr>
} <?php
} else { endif;?>
echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n"; </tbody>
}
?>
</table> </table>
<!-- needed to display the widget settings menu --> <!-- needed to display the widget settings menu -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment