#12248 change setup netflow tab

This commit is contained in:
Jonathan 2023-11-03 09:54:56 +01:00
parent d05ffaac56
commit 1412480b4d
4 changed files with 57 additions and 39 deletions

View File

@ -141,19 +141,17 @@ $buttons['vis'] = [
];
if (check_acl($config['id_user'], 0, 'AW')) {
if ($config['activate_netflow']) {
$buttons['net'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=net').'">'.html_print_image(
'images/op_netflow.png',
true,
[
'title' => __('Netflow'),
'class' => 'invert_filter',
]
).'</a>',
];
}
$buttons['net'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=net').'">'.html_print_image(
'images/op_netflow.png',
true,
[
'title' => __('Netflow'),
'class' => 'invert_filter',
]
).'</a>',
];
if ($config['activate_sflow']) {
$buttons['sflow'] = [

View File

@ -391,20 +391,6 @@ $table->data[$i][] = html_print_label_input_block(
);
$table->data[$i++][] = html_print_label_input_block(
__('Enable Netflow'),
html_print_checkbox_switch_extended(
'activate_netflow',
1,
$config['activate_netflow'],
$rbt_disabled,
'',
'',
true
)
);
$table->data[$i][] = html_print_label_input_block(
__('Enable Sflow'),
html_print_checkbox_switch_extended(
'activate_sflow',
@ -417,7 +403,7 @@ $table->data[$i][] = html_print_label_input_block(
),
);
$table->data[$i++][] = html_print_label_input_block(
$table->data[$i][] = html_print_label_input_block(
__('General network path'),
html_print_input_text(
'general_network_path',

View File

@ -36,49 +36,70 @@ check_login();
$update = (bool) get_parameter('update');
$table = new stdClass();
$table->id = 'table_netflow';
$table->width = '100%';
$table->class = 'databox filter-table-adv';
$table->border = 0;
$table->data = [];
// Enable Netflow.
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$rbt_disabled = true;
} else {
$rbt_disabled = false;
}
$table->data[0][] = html_print_label_input_block(
__('Enable Netflow'),
html_print_checkbox_switch_extended(
'activate_netflow',
1,
$config['activate_netflow'],
$rbt_disabled,
'',
'',
true
)
);
$table->data[1][] = html_print_label_input_block(
__('Data storage path'),
html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true)
);
$table->data[0][] = html_print_label_input_block(
$table->data[1][] = html_print_label_input_block(
__('Daemon binary path'),
html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true)
);
$table->data[1][] = html_print_label_input_block(
$table->data[2][] = html_print_label_input_block(
__('Nfdump binary path'),
html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true)
);
$table->data[1][] = html_print_label_input_block(
$table->data[2][] = html_print_label_input_block(
__('Nfexpire binary path'),
html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true)
);
$table->data[2][] = html_print_label_input_block(
$table->data[3][] = html_print_label_input_block(
__('Maximum chart resolution'),
html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true)
);
$table->data[2][] = html_print_label_input_block(
$table->data[3][] = html_print_label_input_block(
__('Disable custom live view filters'),
html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true)
);
$table->data[3][] = html_print_label_input_block(
$table->data[4][] = html_print_label_input_block(
__('Netflow max lifetime'),
html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true)
);
$onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;";
$table->data[3][] = html_print_label_input_block(
$table->data[4][] = html_print_label_input_block(
__('Name resolution for IP address'),
html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true)
);
@ -98,7 +119,20 @@ html_print_action_buttons(
echo '</form>';
?>
<script>
checkNetflow();
$("input[name=netflow_name_dir]").on("input", function() {
$(this).val($(this).val().replace(/[^a-z0-9]/gi, ""));
});
$('#checkbox-activate_netflow').on('change', function(){
checkNetflow();
});
function checkNetflow(){
if ($('#checkbox-activate_netflow').is(':checked') === true){
$("#table_netflow tr:not(:first-child)").show();
} else {
$("#table_netflow tr:not(:first-child)").hide();
}
}
</script>

View File

@ -245,10 +245,6 @@ function config_update_config()
$error_update[] = __('Enable GIS features');
}
if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) {
$error_update[] = __('Enable Netflow');
}
if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
$error_update[] = __('Enable Sflow');
}
@ -1579,6 +1575,10 @@ function config_update_config()
break;
case 'net':
if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) {
$error_update[] = __('Enable Netflow');
}
if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) {
$error_update[] = __('Name storage path');
} else {