Added link with params html component and modify the network report

Former-commit-id: d95cfe164d67e70d5135feb68169bb825ee2d83a
This commit is contained in:
Fermin 2019-03-05 10:08:07 +01:00
parent 942b160a3d
commit a01319464e
3 changed files with 47 additions and 2 deletions

View File

@ -3114,3 +3114,26 @@ function html_print_switch($attributes=[])
<span class='p-slider'></span> <span class='p-slider'></span>
</label>"; </label>";
} }
/**
* Print a link with post params.The component is really a form with a button
* with some inputs hidden.
*
* @param string $text Text to show.
* @param array $params Params to be written like inputs hidden.
*
* @return string With HTML code.
*/
function html_print_link_with_params($text, $params=[])
{
$html = '<form method=post>';
$html .= html_print_submit_button($text, $text, false, 'class="button-as-link"', true);
foreach ($params as $param => $value) {
$html .= html_print_input_hidden($param, $value, true);
}
$html .= '</form>';
return $html;
}

View File

@ -4242,6 +4242,13 @@ tr:first-child > td > a.up_arrow {
margin-right: 5px; margin-right: 5px;
} }
.button-as-link {
text-decoration: underline;
background: none !important;
border: none;
padding: 0 !important;
}
/* /*
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* - MESSAGE LIST POPUP - * - MESSAGE LIST POPUP -

View File

@ -47,6 +47,7 @@ if (!$is_period) {
} }
$top = (int) get_parameter('top', 10); $top = (int) get_parameter('top', 10);
$main_value = get_parameter('main_value', '');
$style_end = ($is_period) ? 'display: none;' : ''; $style_end = ($is_period) ? 'display: none;' : '';
$style_period = ($is_period) ? '' : 'display: none;'; $style_period = ($is_period) ? '' : 'display: none;';
@ -135,7 +136,7 @@ if ($is_network) {
$action === 'talkers', $action === 'talkers',
$utimestamp_lower, $utimestamp_lower,
$utimestamp_greater, $utimestamp_greater,
'' $main_value
); );
} }
@ -152,11 +153,25 @@ if (!$is_network) {
$table->head['pkts'] = __('Packets'); $table->head['pkts'] = __('Packets');
$table->head['bytes'] = __('Bytes'); $table->head['bytes'] = __('Bytes');
// Get the params to return the builder.
$hidden_main_link = [
'time_greater' => $time_greater,
'date_greater' => $date_greater,
'is_period' => $is_period,
'period' => $period,
'time_lower' => $time_lower,
'date_lower' => $date_lower,
'top' => $top,
];
// Print the data. // Print the data.
$table->data = []; $table->data = [];
foreach ($data as $item) { foreach ($data as $item) {
$row = []; $row = [];
$row['main'] = $item['host']; $row['main'] = html_print_link_with_params(
$item['host'],
array_merge($hidden_main_link, ['main_value' => $item['host']])
);
$row['pkts'] = format_for_graph($item['sum_pkts'], 2); $row['pkts'] = format_for_graph($item['sum_pkts'], 2);
$row['bytes'] = format_for_graph( $row['bytes'] = format_for_graph(
$item['sum_bytes'], $item['sum_bytes'],