Project

General

Profile

Bug #2763 » dynamic_log.diff

John Bayly, 01/18/2013 06:03 AM

View differences:

/usr/local/www/diag_logs_filter_dynamic.php 2013-01-18 11:47:06.000000000 +0000
81 81
?>
82 82
	/* Called by the AJAX updater */
83 83
	function format_log_line(row) {
84
		var line = '';
85
		line =  '  <span class="log-action" nowrap>' + row[0] + '</span>';
86
		line += '  <span class="log-time" nowrap>' + row[1] + '</span>';
87
		line += '  <span class="log-interface" nowrap>' + row[2] + '</span>';
88
		line += '  <span class="log-source" nowrap>' + row[3] + '</span>';
89
		line += '  <span class="log-destination" nowrap>' + row[4] + '</span>';
90
		line += '  <span class="log-protocol" nowrap>' + row[5] + '</span>';
84
		var i = 0;
85
		var line = '<td class="listMRlr" nowrap="nowrap" align="center">' + row[i++] + '</td>';
86
		while (i < 6) {
87
			line += '<td class="listMRr" nowrap="nowrap">' + row[i++] + '</td>';
88
		}
91 89
		return line;
92 90
	}
93 91
</script>
......
106 104
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
107 105
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
108 106
	$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
109
	$tab_array[] = array(gettext("Wireless"), false, "diag_logs_wireless.php");
110 107
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
111 108
	display_top_tabs($tab_array);
112 109
?>
......
114 111
  <tr>
115 112
     <td>
116 113
	<div id="mainarea">
117
		<div class="tabcont">
118
			<a href="diag_logs_filter.php"><?=gettext("Normal View");?></a> | <?=gettext("Dynamic View");?> | <a href="diag_logs_filter_summary.php"><?=gettext("Summary View");?></a>
119
		</div>
120
		<div class="listtopic">
121
			<?php printf(gettext("Last %s records"),$nentries);?>;   <?=gettext("Pause:");?><input valign="middle" type="checkbox" onClick="javascript:toggle_pause();">
122
		</div>
123
		<div id="log">
124
			<div class="log-header">
125
                                <span class="log-action"><?=gettext("Act");?></span>
126
                                <span class="log-time"><?=gettext("Time");?></span>
127
                                <span class="log-interface"><?=gettext("If");?></span>
128
                                <span class="log-source"><?=gettext("Source");?></span>
129
                                <span class="log-destination"><?=gettext("Destination");?></span>
130
                                <span class="log-protocol"><?=gettext("Proto");?></span>
131
			</div>
132
			<?php $counter=0; foreach ($filterlog as $filterent): ?>
133
			<div class="log-entry"<?php echo is_first_row($counter, count($filterlog)); ?>>
134
				<span class="log-action" nowrap><a href="#" onClick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);">
135
				<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>
136
				<span class="log-time" ><?php echo htmlspecialchars($filterent['time']);?></span>
137
				<span class="log-interface" ><?php echo htmlspecialchars($filterent['interface']);?></span>
138
				<span class="log-source" ><?php echo htmlspecialchars($filterent['src']);?></span>
139
				<span class="log-destination" ><?php echo htmlspecialchars($filterent['dst']);?></span>
114
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
115
			<thead>
116
			<tr>
117
				<td colspan="6" align"left" valign="middle">
118
				<a href="diag_logs_filter.php"><?=gettext("Normal View");?></a> | <?=gettext("Dynamic View");?> | <a href="diag_logs_filter_summary.php"><?=gettext("Summary View");?></a>
119
				<br/><br/>
120
				</td>
121
			</tr>
122
			<tr>
123
				<td colspan="6" class="listtopic">
124
				<?php printf(gettext("Last %s records"),$nentries);?>;   <?=gettext("Pause:");?><input valign="middle" type="checkbox" onClick="javascript:toggle_pause();">
125
				</td>
126
			</tr>
127
			<tr>
128
				<td width="10%" class="listhdrr"><?=gettext("Act");?></ td>
129
				<td width="10%" class="listhdrr"><?=gettext("Time");?></ td>
130
				<td width="15%" class="listhdrr"><?=gettext("If");?></ td>
131
				<td width="25%" class="listhdrr"><?=gettext("Source");?></ td>
132
				<td width="25%" class="listhdrr"><?=gettext("Destination");?></ td>
133
				<td width="15%" class="listhdrr"><?=gettext("Proto");?></ td>
134
			</tr>
135
			</thead>
136
			<tbody id="filter-log-entries">
137
			<?php
138
			$rowIndex = 0;
139
			foreach ($filterlog as $filterent):
140
			$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
141
			$rowIndex++;?>
142
			<tr class="<?=$evenRowClass?>">
143
				<td class="listMRlr" nowrap="nowrap" align="center">
144
				<a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);">
145
				<img border="0" src="<?php echo find_action_image($filterent['act']);?>" width="11" height="11" align="middle" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" />
146
				</a>
147
				</td>
148
				<td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['time']);?></td>
149
				<td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['interface']);?></td>
150
				<td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['src']);?></td>
151
				<td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['dst']);?></td>
140 152
				<?php
141 153
					if ($filterent['proto'] == "TCP")
142 154
						$filterent['proto'] .= ":{$filterent['tcpflags']}";
143 155
				?>
144
				<span class="log-protocol" ><?php echo htmlspecialchars($filterent['proto']);?></span>
145
			</div>
146
			<?php $counter++; endforeach; ?>
147
		</div>
156
				<td class="listMRr" nowrap="nowrap"><?php echo htmlspecialchars($filterent['proto']);?></td>
157
			</tr>
158
			<?php endforeach; ?>
159
			</tbody>
160
		</table>
148 161
	</div>
149 162
     </td>
150 163
  </tr>
151 164
</table>
152 165
<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>
153

  
154 166
<?php include("fend.inc"); ?>
155 167
</body>
156 168
</html>
157
-- /usr/local/www/javascript/filter_log.js.orig	2013-01-08 10:27:09.000000000 +0000
169
++ /usr/local/www/javascript/filter_log.js	2013-01-18 11:18:42.000000000 +0000
......
66 66

  
67 67
		new_data_to_add[new_data_to_add.length] = tmp;
68 68
	}
69
	update_div_rows(new_data_to_add);
69
	update_table_rows(new_data_to_add);
70 70
	isBusy = false;
71 71
}
72 72

  
......
80 80
	return false;
81 81
}
82 82

  
83
function update_div_rows(data) {
83
function update_table_rows(data) {
84 84
	if(isPaused)
85 85
		return;
86 86

  
......
98 98
	}
99 99
	data = data.slice(startat, data.length);
100 100

  
101
	var rows = jQuery('.log-entry-mini');
102
	if (jQuery(rows).length == 0) {
103
		rows = jQuery('.log-entry');
104
	}
101
	var rows = jQuery('#filter-log-entries>tr');
105 102

  
106
	for(var x=0; x<data.length; x++) {
107
		/*    if reverse logging is enabled we need to show the
108
		 *    records in a reverse order with new items appearing
109
		 *    on the top
110
		 */
111
		if(isReverse == false) {
112
			for (var i = 1; i < jQuery(rows).length; i++) {
113
				jQuery(rows[i-1]).html(jQuery(rows[i]).html());
103
	// Number of rows to move by
104
	var move = rows.length + data.length - nentries;
105
	if (move < 0)
106
		move = 0;
107

  
108
	if (isReverse == false) {
109
		for (var i = move; i < rows.length; i++) {
110
			jQuery(rows[i - move]).html(jQuery(rows[i]).html());
111
		}
112
	
113
		var tbody = jQuery('#filter-log-entries');
114
		for (var i = 0; i < data.length; i++) {
115
			var rowIndex = rows.length - move + i;
116
			if (rowIndex < rows.length) {
117
				jQuery(rows[rowIndex]).html(data[i]);
118
			} else {
119
				jQuery(tbody).append('<tr>' + data[i] + '</tr>');
114 120
			}
115
		} else {
116
			for (var i = jQuery(rows).length - 1; i > 0; i--) {
117
				jQuery(rows[i]).html(jQuery(rows[i-1]).html());
121
		}
122
	} else {
123
		for (var i = rows.length - 1; i >= move; i--) {
124
			jQuery(rows[i]).html(jQuery(rows[i - move]).html());
125
		}
126
	
127
		var tbody = jQuery('#filter-log-entries');
128
		for (var i = 0; i < data.length; i++) {
129
			var rowIndex = move - 1 - i;
130
			if (rowIndex >= 0) {
131
				jQuery(rows[rowIndex]).html(data[i]);
132
			} else {
133
				jQuery(tbody).prepend('<tr>' + data[i] + '</tr>');
118 134
			}
119 135
		}
120
		jQuery('#firstrow').html(data[x]);
136
	}
137

  
138
	// Much easier to go through each of the rows once they've all be added.
139
	rows = jQuery('#filter-log-entries>tr');
140
	for (var i = 0; i < rows.length; i++) {
141
		rows[i].className = i % 2 == 0 ? 'listMRodd' : 'listMReven';
121 142
	}
122 143
}
123 144

  
......
144 165
			}
145 166
		}
146 167
	}
147
}
168
}
148
-- /usr/local/www/widgets/widgets/log.widget.php.orig	2013-01-08 10:27:10.000000000 +0000
169
++ /usr/local/www/widgets/widgets/log.widget.php	2013-01-18 10:00:44.000000000 +0000
......
104 104

  
105 105
/* Called by the AJAX updater */
106 106
function format_log_line(row) {
107
	var line = '';
108
	line = '  <span class="log-action-mini" nowrap>&nbsp;' + row[0] + '&nbsp;</span>';
109
	line += '  <span class="log-interface-mini" nowrap>' + row[2] + '</span>';
110
	line += '  <span class="log-source-mini" nowrap>' + row[3] + '</span>';
111
	line += '  <span class="log-destination-mini" nowrap>' + row[4] + '</span>';
112
	line += '  <span class="log-protocol-mini" nowrap>' + row[5] + '</span>';
107
	var line = '<td class="listMRlr" align="center">' + row[0] + '</td>' +
108
		'<td class="listMRr ellipsis" title="' + row[2] + '">' + row[2] + '</td>' +
109
		'<td class="listMRr ellipsis" title="' + row[3] + '">' + row[3] + '</td>' +
110
		'<td class="listMRr ellipsis" title="' + row[4] + '">' + row[4] + '</td>' +
111
		'<td class="listMRr ellipsis" title="' + row[5] + '">' + row[5] + '</td>';
113 112

  
114 113
	var nentriesacts = "<?php echo $nentriesacts; ?>";
115 114
	var nentriesinterfaces = "<?php echo $nentriesinterfaces; ?>";
......
151 150
	</form>
152 151
</div>
153 152

  
154
<div class="log-header">
155
    <span class="log-action-mini-header">Act</span>
156
    <span class="log-interface-mini-header">IF</span>
157
    <span class="log-source-mini-header">Source</span>
158
    <span class="log-destination-mini-header">Destination</span>
159
    <span class="log-protocol-mini-header">Prot</span>
160
</div>
161
<?php $counter=0; foreach ($filterlog as $filterent): ?>
162
<div class="log-entry-mini" <?php echo is_first_row($counter, count($filterlog)); ?> style="clear:both;">
163
	<span class="log-action-mini" nowrap>
164
	&nbsp;<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>&nbsp;</span>
165
	<span class="log-interface-mini"><?php echo htmlspecialchars($filterent['interface']);?>&nbsp;</span>
166
	<span class="log-source-mini"><?php echo htmlspecialchars($filterent['src']);?>&nbsp;</span>
167
	<span class="log-destination-mini"><?php echo (strlen($filterent['dst']) < 19 ? htmlspecialchars($filterent['dst']) : htmlspecialchars(substr($filterent['dst'],0,18))."..."); ?>&nbsp;</span>
153
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed;">
154
	<colgroup>
155
		<col style='width: 6%;' />
156
		<col style='width: 8%;' />
157
		<col style='width: 31%;' />
158
		<col style='width: 31%;' />
159
		<col style='width: 8%;' />
160
	</colgroup>
161
	<thead>
162
		<tr>
163
			<td class="listhdrr"><?=gettext("Act");?></td>
164
			<td class="listhdrr"><?=gettext("IF");?></td>
165
			<td class="listhdrr"><?=gettext("Source");?></td>
166
			<td class="listhdrr"><?=gettext("Destination");?></td>
167
			<td class="listhdrr"><?=gettext("Prot");?></td>
168
		</tr>
169
	</head>
170
	<tbody id='filter-log-entries'>
168 171
	<?php
169
	if ($filterent['proto'] == "TCP")
170
		$filterent['proto'] .= ":{$filterent['tcpflags']}";
172
	$rowIndex = 0;
173
	foreach ($filterlog as $filterent):
174
	$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
175
	$rowIndex++;
171 176
	?>
172
	<span class="log-protocol-mini"><?php echo htmlspecialchars($filterent['proto']);?>&nbsp;</span>
173
</div>
174
<?php $counter++; endforeach; ?>
177
		<tr class="<?=$evenRowClass?>">
178
			<td class="listMRlr" nowrap="nowrap" align="center">
179
			<a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);">
180
			<img border="0" src="<?php echo find_action_image($filterent['act']);?>" width="11" height="11" align="middle" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" />
181
			</a>
182
			</td>
183
			<td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['interface']);?>"><?php echo htmlspecialchars($filterent['interface']);?></td>
184
			<td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['src']);?>"><?php echo htmlspecialchars($filterent['src']);?></td>
185
			<td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['dst']);?>"><?php echo htmlspecialchars($filterent['dst']);?></td>
186
			<?php
187
				if ($filterent['proto'] == "TCP")
188
					$filterent['proto'] .= ":{$filterent['tcpflags']}";
189
			?>
190
			<td class="listMRr ellipsis" nowrap="nowrap" title="<?php echo htmlspecialchars($filterent['proto']);?>"><?php echo htmlspecialchars($filterent['proto']);?></td>
191
		</tr>
192
	<?php endforeach; ?>
193
	</tbody>
194
</table>
175 195

  
176 196
<!-- needed to display the widget settings menu -->
177 197
<script language="javascript" type="text/javascript">
178
-- /usr/local/www/css/table.css.orig	2013-01-08 10:27:09.000000000 +0000
198
++ /usr/local/www/css/table.css	2013-01-18 09:50:58.000000000 +0000
......
40 40
	border-left: none;
41 41
	border-bottom: 2px solid #999999;
42 42
}
43
.ellipsis {
44
	overflow: hidden;
45
	text-overflow: ellipsis;
46
}
(1-1/5)