diff options
author | Phil Davis <phil.davis@inf.org> | 2017-03-19 11:21:31 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2017-03-19 11:21:31 +0545 |
commit | fba53b438540eb544c43adf4598e07320a910347 (patch) | |
tree | af60a3e9fdd909df7fed16379bb8e3de29e4bb3d /src/usr/local | |
parent | 405dfaad144de90a6e401354b80b82baf5ae3d59 (diff) | |
download | pfsense-fba53b438540eb544c43adf4598e07320a910347.zip pfsense-fba53b438540eb544c43adf4598e07320a910347.tar.gz |
Redmine #7318 None button for widget filters
Diffstat (limited to 'src/usr/local')
10 files changed, 56 insertions, 50 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index cfd4578..2b74a9e 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -445,6 +445,53 @@ function updateWidgets(newWidget) { $('input[name=sequence]', $('#widgetSequence_form')).val(sequence); } +// Determine if all the checkboxes are checked +function are_all_checked(checkbox_panel_ref) { + var allBoxesChecked = true; + $(checkbox_panel_ref).each(function() { + if ((this.type == 'checkbox') && !this.checked) { + allBoxesChecked = false; + } + }); + return allBoxesChecked; +} + +// If the checkboxes are all checked, then clear them all. +// Otherwise set them all. +function set_clear_checkboxes(checkbox_panel_ref) { + checkTheBoxes = !are_all_checked(checkbox_panel_ref); + + $(checkbox_panel_ref).each(function() { + $(this).prop("checked", checkTheBoxes); + }); +} + +// Set the given id to All or None button depending if the checkboxes are all checked. +function set_all_none_button(checkbox_panel_ref, all_none_button_id) { + if (are_all_checked(checkbox_panel_ref)) { + text = "<?=gettext('None')?>"; + } else { + text = "<?=gettext('All')?>"; + } + + $("#" + all_none_button_id).html('<i class="fa fa-undo icon-embed-btn"></i>' + text); +} + +// Setup the necessary events to manage the All/None button and included checkboxes +// used for selecting the items to show on a widget. +function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) { + set_all_none_button(checkbox_panel_ref, all_none_button_id); + + $(checkbox_panel_ref).change(function() { + set_all_none_button(checkbox_panel_ref, all_none_button_id); + }); + + $("#" + all_none_button_id).click(function() { + set_clear_checkboxes(checkbox_panel_ref); + set_all_none_button(checkbox_panel_ref, all_none_button_id); + }); +} + events.push(function() { // Make panels destroyable diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php index 23e9bf4..1776dbb 100644 --- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php +++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php @@ -285,12 +285,7 @@ function get_dyndns_service_text($dyndns_type) { setTimeout('dyndns_getstatus()', 5*60*1000); } events.push(function(){ - $("#showalldyndns").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); - + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showalldyndns"); }); // Do the first status check 2 seconds after the dashboard opens setTimeout('dyndns_getstatus()', 2000); diff --git a/src/usr/local/www/widgets/widgets/gateways.widget.php b/src/usr/local/www/widgets/widgets/gateways.widget.php index 2e1ce5c..1df91c8 100644 --- a/src/usr/local/www/widgets/widgets/gateways.widget.php +++ b/src/usr/local/www/widgets/widgets/gateways.widget.php @@ -188,11 +188,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period } events.push(function(){ - $("#showallgateways").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallgateways"); // Start polling for updates some small random number of seconds from now (so that all the widgets don't // hit the server at exactly the same time) diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php index 6f4d501..84cbcd6 100644 --- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -185,11 +185,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period } events.push(function(){ - $("#showallinterfacesforstats").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallinterfacesforstats"); // Start polling for updates some small random number of seconds from now (so that all the widgets don't // hit the server at exactly the same time) diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php index 5060a86..758abd1 100644 --- a/src/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php @@ -188,12 +188,7 @@ endif; <script> //<![CDATA[ events.push(function(){ - $("#showallinterfaces").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); - + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallinterfaces"); }); //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/openvpn.widget.php b/src/usr/local/www/widgets/widgets/openvpn.widget.php index 5c4fcc7..01a1d1e 100644 --- a/src/usr/local/www/widgets/widgets/openvpn.widget.php +++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php @@ -364,11 +364,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period } events.push(function(){ - $("#showallovpns").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallovpns"); // Start polling for updates some small random number of seconds from now (so that all the widgets don't // hit the server at exactly the same time) 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 2d04a93..f28a1ed 100644 --- a/src/usr/local/www/widgets/widgets/services_status.widget.php +++ b/src/usr/local/www/widgets/widgets/services_status.widget.php @@ -164,12 +164,7 @@ if (count($services) > 0) { <script type="text/javascript"> //<![CDATA[ events.push(function(){ - $("#showallservices").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); - + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallservices"); }); //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/smart_status.widget.php b/src/usr/local/www/widgets/widgets/smart_status.widget.php index c6884db..3ade4fc 100644 --- a/src/usr/local/www/widgets/widgets/smart_status.widget.php +++ b/src/usr/local/www/widgets/widgets/smart_status.widget.php @@ -162,12 +162,7 @@ if (count($devs) > 0) { <script type="text/javascript"> //<![CDATA[ events.push(function(){ - $("#showallsmartdrives").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); - + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallsmartdrives"); }); //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php index 0676a25..09d5971 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -487,11 +487,7 @@ function updateMeters() { } events.push(function(){ - $("#showallsysinfoitems").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallsysinfoitems"); }); var update_interval = "<?=$widgetperiod?>"; diff --git a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php index 19992ec..4557214 100644 --- a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php +++ b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php @@ -183,12 +183,7 @@ if (is_array($config['dhcpd'])) { <script> //<![CDATA[ events.push(function(){ - $("#showallwols").click(function() { - $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() { - $(this).prop("checked", true); - }); - }); - + set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallwols"); }); //]]> </script> |