diff options
author | Phil Davis <phil.davis@inf.org> | 2017-01-10 22:15:46 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2017-01-10 22:15:46 +0545 |
commit | ada6bfa7ca68169408b80af6325afe3948ee85f7 (patch) | |
tree | 91f45678cfbd1a1aed74eba76e234b0d5d47a898 /src | |
parent | 3870dcb7fd985af8add32544b61e201e914f92dc (diff) | |
download | pfsense-ada6bfa7ca68169408b80af6325afe3948ee85f7.zip pfsense-ada6bfa7ca68169408b80af6325afe3948ee85f7.tar.gz |
Services widget filter checkboxes
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/local/www/widgets/widgets/services_status.widget.php | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/src/usr/local/www/widgets/widgets/services_status.widget.php b/src/usr/local/www/widgets/widgets/services_status.widget.php index 1ef5b5b..864432e 100644 --- a/src/usr/local/www/widgets/widgets/services_status.widget.php +++ b/src/usr/local/www/widgets/widgets/services_status.widget.php @@ -56,8 +56,8 @@ if ($_POST) { array_push($validNames, $service['dispname']); } - if (isset($_POST['servicestatusfilter'])) { - $user_settings['widgets']['servicestatusfilter'] = implode(',', array_intersect($validNames, $_POST['servicestatusfilter'])); + if (is_array($_POST['show'])) { + $user_settings['widgets']['servicestatusfilter'] = implode(',', array_diff($validNames, $_POST['show'])); } else { $user_settings['widgets']['servicestatusfilter'] = ""; } @@ -67,16 +67,17 @@ if ($_POST) { } ?> -<table class="table table-striped table-hover"> -<thead> - <tr> - <th></th> - <th><?=gettext('Service')?></th> - <th><?=gettext('Description')?></th> - <th><?=gettext('Action')?></th> - </tr> -</thead> -<tbody> +<div class="table-responsive"> + <table class="table table-striped table-hover table-condensed"> + <thead> + <tr> + <th></th> + <th><?=gettext('Service')?></th> + <th><?=gettext('Description')?></th> + <th><?=gettext('Action')?></th> + </tr> + </thead> + <tbody> <?php $skipservices = explode(",", $user_settings['widgets']['servicestatusfilter']); @@ -94,67 +95,74 @@ if (count($services) > 0) { $service_desc = explode(".",$service['description']); ?> - <tr> - <td><?=get_service_status_icon($service, false, true, false, "state")?></td> - <td><?=$service['dispname']?></td> - <td><?=$service_desc[0]?></td> - <td><?=get_service_control_links($service)?></td> - </tr> + <tr> + <td><?=get_service_status_icon($service, false, true, false, "state")?></td> + <td><?=$service['dispname']?></td> + <td><?=$service_desc[0]?></td> + <td><?=get_service_control_links($service)?></td> + </tr> <?php } } else { echo "<tr><td colspan=\"3\" class=\"text-center\">" . gettext("No services found") . ". </td></tr>\n"; } ?> -</tbody> -</table> - + </tbody> + </table> +</div> <!-- close the body we're wrapped in and add a configuration-panel --> </div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse"> <form action="/widgets/widgets/services_status.widget.php" method="post" class="form-horizontal"> - <div class="form-group"> - <label class="col-sm-3 control-label"><?=gettext('Hidden services')?></label> - <div class="col-sm-6"> - <select multiple id="servicestatusfilter" name="servicestatusfilter[]" class="form-control"> - <?php + <div class="panel panel-default col-sm-10"> + <div class="panel-body"> + <div class="table responsive"> + <table class="table table-striped table-hover table-condensed"> + <thead> + <tr> + <th><?=gettext("Service")?></th> + <th><?=gettext("Show")?></th> + </tr> + </thead> + <tbody> +<?php + $skipservices = explode(",", $user_settings['widgets']['servicestatusfilter']); + $idx = 0; + foreach ($services as $service): if (!empty(trim($service['dispname'])) || is_numeric($service['dispname'])) { - ?> - <option <?=(in_array($service['dispname'], $skipservices)?'selected':'')?>><?=$service['dispname']?></option> - <?php +?> + <tr> + <td><?=$service['dispname']?></td> + <td class="col-sm-2"><input id="show[]" name ="show[]" value="<?=$service['dispname']?>" type="checkbox" <?=(!in_array($service['dispname'], $skipservices) ? 'checked':'')?>></td> + </tr> +<?php } endforeach; - ?> - </select> +?> + </tbody> + </table> + </div> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-6"> <button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button> - <button id="clearall" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('Clear')?></button> + <button id="showallservices" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button> </div> </div> </form> <script> //<![CDATA[ -events.push(function(){ - $("select[multiple] option").mousedown(function(){ - var $self = $(this); + events.push(function(){ + $("#showallservices").click(function() { + $("[id^=show]").each(function() { + $(this).prop("checked", true); + }); + }); - if ($self.prop("selected")) - $self.prop("selected", false); - else - $self.prop("selected", true); - - return false; }); - - $("#clearall").click(function() { - $('select#servicestatusfilter option').removeAttr("selected"); - }); -}); //]]> </script> |