diff options
-rw-r--r-- | usr/local/www/css/table.css | 4 | ||||
-rwxr-xr-x | usr/local/www/diag_logs_filter_dynamic.php | 84 | ||||
-rw-r--r-- | usr/local/www/javascript/filter_log.js | 59 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/log.widget.php | 70 |
4 files changed, 137 insertions, 80 deletions
diff --git a/usr/local/www/css/table.css b/usr/local/www/css/table.css index 29ae503..3393db3 100644 --- a/usr/local/www/css/table.css +++ b/usr/local/www/css/table.css @@ -40,3 +40,7 @@ if theme changes are needed include a table.css in the /themes/yourtheme/ */ border-left: none; border-bottom: 2px solid #999999; } +.ellipsis { + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/usr/local/www/diag_logs_filter_dynamic.php b/usr/local/www/diag_logs_filter_dynamic.php index 763a7b8..f1b714c 100755 --- a/usr/local/www/diag_logs_filter_dynamic.php +++ b/usr/local/www/diag_logs_filter_dynamic.php @@ -81,13 +81,11 @@ include("head.inc"); ?> /* Called by the AJAX updater */ function format_log_line(row) { - var line = ''; - line = ' <span class="log-action" nowrap>' + row[0] + '</span>'; - line += ' <span class="log-time" nowrap>' + row[1] + '</span>'; - line += ' <span class="log-interface" nowrap>' + row[2] + '</span>'; - line += ' <span class="log-source" nowrap>' + row[3] + '</span>'; - line += ' <span class="log-destination" nowrap>' + row[4] + '</span>'; - line += ' <span class="log-protocol" nowrap>' + row[5] + '</span>'; + var i = 0; + var line = '<td class="listMRlr" nowrap="nowrap" align="center">' + row[i++] + '</td>'; + while (i < 6) { + line += '<td class="listMRr" nowrap="nowrap">' + row[i++] + '</td>'; + } return line; } </script> @@ -106,7 +104,6 @@ include("head.inc"); $tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php"); $tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php"); $tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php"); - $tab_array[] = array(gettext("Wireless"), false, "diag_logs_wireless.php"); $tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); display_top_tabs($tab_array); ?> @@ -114,43 +111,58 @@ include("head.inc"); <tr> <td> <div id="mainarea"> - <div class="tabcont"> - <a href="diag_logs_filter.php"><?=gettext("Normal View");?></a> | <?=gettext("Dynamic View");?> | <a href="diag_logs_filter_summary.php"><?=gettext("Summary View");?></a> - </div> - <div class="listtopic"> - <?php printf(gettext("Last %s records"),$nentries);?>; <?=gettext("Pause:");?><input valign="middle" type="checkbox" onClick="javascript:toggle_pause();"> - </div> - <div id="log"> - <div class="log-header"> - <span class="log-action"><?=gettext("Act");?></span> - <span class="log-time"><?=gettext("Time");?></span> - <span class="log-interface"><?=gettext("If");?></span> - <span class="log-source"><?=gettext("Source");?></span> - <span class="log-destination"><?=gettext("Destination");?></span> - <span class="log-protocol"><?=gettext("Proto");?></span> - </div> - <?php $counter=0; foreach ($filterlog as $filterent): ?> - <div class="log-entry"<?php echo is_first_row($counter, count($filterlog)); ?>> - <span class="log-action" nowrap><a href="#" onClick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);"> - <img border="0" src="<?php echo find_action_image($filterent['act']);?>" width="11" height="11" align="absmiddle" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" /></a></span> - <span class="log-time" ><?php echo htmlspecialchars($filterent['time']);?></span> - <span class="log-interface" ><?php echo htmlspecialchars($filterent['interface']);?></span> - <span class="log-source" ><?php echo htmlspecialchars($filterent['src']);?></span> - <span class="log-destination" ><?php echo htmlspecialchars($filterent['dst']);?></span> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <thead> + <tr> + <td colspan="6" align"left" valign="middle"> + <a href="diag_logs_filter.php"><?=gettext("Normal View");?></a> | <?=gettext("Dynamic View");?> | <a href="diag_logs_filter_summary.php"><?=gettext("Summary View");?></a> + <br/><br/> + </td> + </tr> + <tr> + <td colspan="6" class="listtopic"> + <?php printf(gettext("Last %s records"),$nentries);?>; <?=gettext("Pause:");?><input valign="middle" type="checkbox" onClick="javascript:toggle_pause();"> + </td> + </tr> + <tr> + <td width="10%" class="listhdrr"><?=gettext("Act");?></ td> + <td width="10%" class="listhdrr"><?=gettext("Time");?></ td> + <td width="15%" class="listhdrr"><?=gettext("If");?></ td> + <td width="25%" class="listhdrr"><?=gettext("Source");?></ td> + <td width="25%" class="listhdrr"><?=gettext("Destination");?></ td> + <td width="15%" class="listhdrr"><?=gettext("Proto");?></ td> + </tr> + </thead> + <tbody id="filter-log-entries"> + <?php + $rowIndex = 0; + foreach ($filterlog as $filterent): + $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; + $rowIndex++;?> + <tr class="<?=$evenRowClass?>"> + <td class="listMRlr" nowrap="nowrap" align="center"> + <a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);"> + <img border="0" src="<?php echo find_action_image($filterent['act']);?>" width="11" height="11" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" /> + </a> + </td> + <td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['time']);?></td> + <td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['interface']);?></td> + <td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['src']);?></td> + <td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['dst']);?></td> <?php if ($filterent['proto'] == "TCP") $filterent['proto'] .= ":{$filterent['tcpflags']}"; ?> - <span class="log-protocol" ><?php echo htmlspecialchars($filterent['proto']);?></span> - </div> - <?php $counter++; endforeach; ?> - </div> + <td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['proto']);?></td> + </tr> + <?php endforeach; ?> + </tbody> + </table> </div> </td> </tr> </table> <p><span class="vexpl"><a href="http://doc.pfsense.org/index.php/What_are_TCP_Flags%3F"><?=gettext("TCP Flags"); ?></a>: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, C - CWR</span></p> - <?php include("fend.inc"); ?> </body> </html> diff --git a/usr/local/www/javascript/filter_log.js b/usr/local/www/javascript/filter_log.js index 49c11a4..43d7d49 100644 --- a/usr/local/www/javascript/filter_log.js +++ b/usr/local/www/javascript/filter_log.js @@ -66,7 +66,7 @@ function fetch_new_rules_callback(callback_data) { new_data_to_add[new_data_to_add.length] = tmp; } - update_div_rows(new_data_to_add); + update_table_rows(new_data_to_add); isBusy = false; } @@ -80,7 +80,7 @@ function in_arrayi(needle, haystack) { return false; } -function update_div_rows(data) { +function update_table_rows(data) { if(isPaused) return; @@ -98,26 +98,47 @@ function update_div_rows(data) { } data = data.slice(startat, data.length); - var rows = jQuery('.log-entry-mini'); - if (jQuery(rows).length == 0) { - rows = jQuery('.log-entry'); - } + var rows = jQuery('#filter-log-entries>tr'); + + // Number of rows to move by + var move = rows.length + data.length - nentries; + if (move < 0) + move = 0; + + if (isReverse == false) { + for (var i = move; i < rows.length; i++) { + jQuery(rows[i - move]).html(jQuery(rows[i]).html()); + } - for(var x=0; x<data.length; x++) { - /* if reverse logging is enabled we need to show the - * records in a reverse order with new items appearing - * on the top - */ - if(isReverse == false) { - for (var i = 1; i < jQuery(rows).length; i++) { - jQuery(rows[i-1]).html(jQuery(rows[i]).html()); + var tbody = jQuery('#filter-log-entries'); + for (var i = 0; i < data.length; i++) { + var rowIndex = rows.length - move + i; + if (rowIndex < rows.length) { + jQuery(rows[rowIndex]).html(data[i]); + } else { + jQuery(tbody).append('<tr>' + data[i] + '</tr>'); } - } else { - for (var i = jQuery(rows).length - 1; i > 0; i--) { - jQuery(rows[i]).html(jQuery(rows[i-1]).html()); + } + } else { + for (var i = rows.length - 1; i >= move; i--) { + jQuery(rows[i]).html(jQuery(rows[i - move]).html()); + } + + var tbody = jQuery('#filter-log-entries'); + for (var i = 0; i < data.length; i++) { + var rowIndex = move - 1 - i; + if (rowIndex >= 0) { + jQuery(rows[rowIndex]).html(data[i]); + } else { + jQuery(tbody).prepend('<tr>' + data[i] + '</tr>'); } } - jQuery('#firstrow').html(data[x]); + } + + // Much easier to go through each of the rows once they've all be added. + rows = jQuery('#filter-log-entries>tr'); + for (var i = 0; i < rows.length; i++) { + rows[i].className = i % 2 == 0 ? 'listMRodd' : 'listMReven'; } } @@ -144,4 +165,4 @@ function toggleListDescriptions(){ } } } -}
\ No newline at end of file +} diff --git a/usr/local/www/widgets/widgets/log.widget.php b/usr/local/www/widgets/widgets/log.widget.php index 482e415..61c2acf 100644 --- a/usr/local/www/widgets/widgets/log.widget.php +++ b/usr/local/www/widgets/widgets/log.widget.php @@ -104,12 +104,11 @@ else /* Called by the AJAX updater */ function format_log_line(row) { - var line = ''; - line = ' <span class="log-action-mini" nowrap> ' + row[0] + ' </span>'; - line += ' <span class="log-interface-mini" nowrap>' + row[2] + '</span>'; - line += ' <span class="log-source-mini" nowrap>' + row[3] + '</span>'; - line += ' <span class="log-destination-mini" nowrap>' + row[4] + '</span>'; - line += ' <span class="log-protocol-mini" nowrap>' + row[5] + '</span>'; + var line = '<td class="listMRlr" align="center">' + row[0] + '</td>' + + '<td class="listMRr ellipsis" title="' + row[2] + '">' + row[2] + '</td>' + + '<td class="listMRr ellipsis" title="' + row[3] + '">' + row[3] + '</td>' + + '<td class="listMRr ellipsis" title="' + row[4] + '">' + row[4] + '</td>' + + '<td class="listMRr ellipsis" title="' + row[5] + '">' + row[5] + '</td>'; var nentriesacts = "<?php echo $nentriesacts; ?>"; var nentriesinterfaces = "<?php echo $nentriesinterfaces; ?>"; @@ -151,27 +150,48 @@ function format_log_line(row) { </form> </div> -<div class="log-header"> - <span class="log-action-mini-header">Act</span> - <span class="log-interface-mini-header">IF</span> - <span class="log-source-mini-header">Source</span> - <span class="log-destination-mini-header">Destination</span> - <span class="log-protocol-mini-header">Prot</span> -</div> -<?php $counter=0; foreach ($filterlog as $filterent): ?> -<div class="log-entry-mini" <?php echo is_first_row($counter, count($filterlog)); ?> style="clear:both;"> - <span class="log-action-mini" nowrap> - <a href="#" onClick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);"><img border="0" src="<?php echo find_action_image($filterent['act']);?>" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" /></a> </span> - <span class="log-interface-mini"><?php echo htmlspecialchars($filterent['interface']);?> </span> - <span class="log-source-mini"><?php echo htmlspecialchars($filterent['src']);?> </span> - <span class="log-destination-mini"><?php echo (strlen($filterent['dst']) < 19 ? htmlspecialchars($filterent['dst']) : htmlspecialchars(substr($filterent['dst'],0,18))."..."); ?> </span> +<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed;"> + <colgroup> + <col style='width: 8%;' /> + <col style='width: 10%;' /> + <col style='width: 35%;' /> + <col style='width: 35%;' /> + <col style='width: 12%;' /> + </colgroup> + <thead> + <tr> + <td class="listhdrr"><?=gettext("Act");?></td> + <td class="listhdrr"><?=gettext("IF");?></td> + <td class="listhdrr"><?=gettext("Source");?></td> + <td class="listhdrr"><?=gettext("Destination");?></td> + <td class="listhdrr"><?=gettext("Prot");?></td> + </tr> + </thead> + <tbody id='filter-log-entries'> <?php - if ($filterent['proto'] == "TCP") - $filterent['proto'] .= ":{$filterent['tcpflags']}"; + $rowIndex = 0; + foreach ($filterlog as $filterent): + $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; + $rowIndex++; ?> - <span class="log-protocol-mini"><?php echo htmlspecialchars($filterent['proto']);?> </span> -</div> -<?php $counter++; endforeach; ?> + <tr class="<?=$evenRowClass?>"> + <td class="listMRlr" nowrap="nowrap" align="center"> + <a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);"> + <img border="0" src="<?php echo find_action_image($filterent['act']);?>" width="11" height="11" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" /> + </a> + </td> + <td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['interface']);?>"><?php echo htmlspecialchars($filterent['interface']);?></td> + <td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['src']);?>"><?php echo htmlspecialchars($filterent['src']);?></td> + <td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['dst']);?>"><?php echo htmlspecialchars($filterent['dst']);?></td> + <?php + if ($filterent['proto'] == "TCP") + $filterent['proto'] .= ":{$filterent['tcpflags']}"; + ?> + <td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['proto']);?>"><?php echo htmlspecialchars($filterent['proto']);?></td> + </tr> + <?php endforeach; ?> + </tbody> +</table> <!-- needed to display the widget settings menu --> <script language="javascript" type="text/javascript"> |