diff options
-rw-r--r-- | src/usr/local/www/diag_tables.php | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/src/usr/local/www/diag_tables.php b/src/usr/local/www/diag_tables.php index a543f83..2c24d8c 100644 --- a/src/usr/local/www/diag_tables.php +++ b/src/usr/local/www/diag_tables.php @@ -122,22 +122,42 @@ exec("/sbin/pfctl -sT", $tables); include("head.inc"); if ($savemsg) { - print_info_box($savemsg); + print_info_box($savemsg, 'success'); } -$form = new Form('Show'); +$form = new Form(false); $section = new Form_Section('Table to display'); +$group = new Form_Group("Table"); -$section->addInput(new Form_Select( +$group->add(new Form_Select( 'type', - 'Table', + null, $tablename, array_combine($tables, $tables) )); +if ($bogons || !empty($entries)) { + if ($bogons) { + $group->add(new Form_Button( + 'Download', + 'Update' + ))->removeClass('btn-primary')->addClass('btn-success btn-sm'); + } elseif (!empty($entries)) { + $group->add(new Form_Button( + 'clearall', + 'Clear Table' + ))->removeClass('btn-primary')->addClass('btn-danger btn-sm'); + } +} + +$section->add($group); $form->add($section); print $form; + +if ($bogons || !empty($entries)) { + print_info_box(gettext("Table last updated on ") . exec('/usr/bin/grep -i -m 1 -E "^# last updated" /etc/' . escapeshellarg($tablename) . '|cut -d"(" -f2|tr -d ")" '), 'info'); +} ?> <script type="text/javascript"> @@ -159,6 +179,11 @@ events.push(function() { }, }); }); + + // Auto-submit the form on table selector change + $('#type').on('change', function() { + $('form').submit(); + }); }); //]]> </script> @@ -196,32 +221,4 @@ events.push(function() { <?php -if ($bogons || !empty($entries)) { - $form = new Form; - - $section = new Form_Section('Table Data'); - - if ($bogons) { - $last_updated = exec('/usr/bin/grep -i -m 1 -E "^# last updated" /etc/' . escapeshellarg($tablename) . '|cut -d"(" -f2|tr -d ")" '); - - $section->addInput(new Form_StaticText( - 'Last update', - $last_updated - )); - - $section->addInput(new Form_Button( - 'Download', - 'Download' - ))->setHelp('Download the latest bogon data')->addClass('btn-warning'); - } elseif (!empty($entries)) { - $section->addInput(new Form_Button( - 'clearall', - 'Clear Table' - ))->setHelp('Clear all of the entries in this table')->addClass('btn-danger'); - } - - $form->add($section); - print $form; -} - include("foot.inc"); |