#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 (check_acl($config['id_user'], 0, 'AW')) {
if ($config['activate_netflow']) { $buttons['net'] = [
$buttons['net'] = [ 'active' => false,
'active' => false, 'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=net').'">'.html_print_image(
'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',
'images/op_netflow.png', true,
true, [
[ 'title' => __('Netflow'),
'title' => __('Netflow'), 'class' => 'invert_filter',
'class' => 'invert_filter', ]
] ).'</a>',
).'</a>', ];
];
}
if ($config['activate_sflow']) { if ($config['activate_sflow']) {
$buttons['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( $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'), __('Enable Sflow'),
html_print_checkbox_switch_extended( html_print_checkbox_switch_extended(
'activate_sflow', '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'), __('General network path'),
html_print_input_text( html_print_input_text(
'general_network_path', 'general_network_path',

View File

@ -36,49 +36,70 @@ check_login();
$update = (bool) get_parameter('update'); $update = (bool) get_parameter('update');
$table = new stdClass(); $table = new stdClass();
$table->id = 'table_netflow';
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filter-table-adv'; $table->class = 'databox filter-table-adv';
$table->border = 0; $table->border = 0;
$table->data = []; $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( $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'), __('Data storage path'),
html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true) 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'), __('Daemon binary path'),
html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true) 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'), __('Nfdump binary path'),
html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true) 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'), __('Nfexpire binary path'),
html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true) 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'), __('Maximum chart resolution'),
html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true) 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'), __('Disable custom live view filters'),
html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true) 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'), __('Netflow max lifetime'),
html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true) 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;"; $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'), __('Name resolution for IP address'),
html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) 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>'; echo '</form>';
?> ?>
<script> <script>
checkNetflow();
$("input[name=netflow_name_dir]").on("input", function() { $("input[name=netflow_name_dir]").on("input", function() {
$(this).val($(this).val().replace(/[^a-z0-9]/gi, "")); $(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> </script>

View File

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