Added ordering header element
Former-commit-id: 11ffbe8c00a8ea9d881321be7c7541eaf0babe92
This commit is contained in:
parent
7b9bbe6b9c
commit
e9061d74b6
|
@ -3132,20 +3132,31 @@ function html_print_switch($attributes=[])
|
|||
* @param string $text Text to show.
|
||||
* @param array $params Params to be written like inputs hidden.
|
||||
* @param string $text Text of image.
|
||||
* @param string $style Additional style for the element.
|
||||
*
|
||||
* @return string With HTML code.
|
||||
*/
|
||||
function html_print_link_with_params($text, $params=[], $type='text')
|
||||
function html_print_link_with_params($text, $params=[], $type='text', $style='')
|
||||
{
|
||||
$html = '<form method=post>';
|
||||
switch ($type) {
|
||||
case 'image':
|
||||
$html .= html_print_input_image($text, $text, $text, '', true);
|
||||
$html .= html_print_input_image($text, $text, $text, $style, true);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
default:
|
||||
$html .= html_print_submit_button($text, $text, false, 'class="button-as-link"', true);
|
||||
if (!empty($style)) {
|
||||
$style = ' style="'.$style.'"';
|
||||
}
|
||||
|
||||
$html .= html_print_submit_button(
|
||||
$text,
|
||||
$text,
|
||||
false,
|
||||
'class="button-as-link"'.$style,
|
||||
true
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,3 +89,33 @@ function network_get_report_actions($network)
|
|||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print the header of the network
|
||||
*
|
||||
* @param string $title Title of header.
|
||||
* @param string $order Current ordering.
|
||||
* @param string $selected Selected order.
|
||||
* @param array $hidden_data All the data to hide into the button.
|
||||
*
|
||||
* @return string With HTML data.
|
||||
*/
|
||||
function network_print_explorer_header(
|
||||
$title,
|
||||
$order,
|
||||
$selected,
|
||||
$hidden_data
|
||||
) {
|
||||
$cell = '<div style="display: flex; align-items: center;">';
|
||||
$cell .= $title;
|
||||
$cell .= html_print_link_with_params(
|
||||
'images/arrow-down-white.png',
|
||||
array_merge($hidden_data, ['order_by' => $order]),
|
||||
'image',
|
||||
($selected === $order) ? 'opacity: 0.5' : ''
|
||||
);
|
||||
$cell .= '</div>';
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ if (!$is_period) {
|
|||
|
||||
$top = (int) get_parameter('top', 10);
|
||||
$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', '');
|
||||
$order_by = get_parameter('order_by', 'bytes');
|
||||
if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) {
|
||||
$order_by = 'bytes';
|
||||
}
|
||||
|
||||
$style_end = ($is_period) ? 'display: none;' : '';
|
||||
$style_period = ($is_period) ? '' : 'display: none;';
|
||||
|
||||
|
@ -157,19 +162,6 @@ if ($is_network) {
|
|||
);
|
||||
}
|
||||
|
||||
unset($table);
|
||||
$table = new stdClass();
|
||||
$table->styleTable = 'width: 100%';
|
||||
// Print the header.
|
||||
$table->head = [];
|
||||
$table->head['main'] = __('IP');
|
||||
if (!$is_network) {
|
||||
$table->head['flows'] = __('Flows');
|
||||
}
|
||||
|
||||
$table->head['pkts'] = __('Packets');
|
||||
$table->head['bytes'] = __('Bytes');
|
||||
|
||||
// Get the params to return the builder.
|
||||
$hidden_main_link = [
|
||||
'time_greater' => $time_greater,
|
||||
|
@ -182,6 +174,37 @@ $hidden_main_link = [
|
|||
'action' => $action,
|
||||
];
|
||||
|
||||
unset($table);
|
||||
$table = new stdClass();
|
||||
$table->styleTable = 'width: 100%';
|
||||
// Print the header.
|
||||
$table->head = [];
|
||||
$table->head['main'] = __('IP');
|
||||
if (!$is_network) {
|
||||
$table->head['flows'] = network_print_explorer_header(
|
||||
__('Flows'),
|
||||
'flows',
|
||||
$order_by,
|
||||
$hidden_main_link
|
||||
);
|
||||
}
|
||||
|
||||
$table->head['pkts'] = network_print_explorer_header(
|
||||
__('Packets'),
|
||||
'pkts',
|
||||
$order_by,
|
||||
$hidden_main_link
|
||||
);
|
||||
$table->head['bytes'] = network_print_explorer_header(
|
||||
__('Bytes'),
|
||||
'bytes',
|
||||
$order_by,
|
||||
$hidden_main_link
|
||||
);
|
||||
|
||||
// Add the order.
|
||||
$hidden_main_link['order_by'] = $order_by;
|
||||
|
||||
if (get_parameter('export_csv')) {
|
||||
// Clean the buffer.
|
||||
while (ob_get_level()) {
|
||||
|
|
Loading…
Reference in New Issue