Change the filters as we need from the last metting.

This commit is contained in:
mdtrooper 2016-02-12 13:05:15 +01:00
parent 625b4044e0
commit ab51866abb
2 changed files with 287 additions and 95 deletions

View File

@ -40,15 +40,18 @@ if ($create_networkmap) {
$source = MAP_SOURCE_GROUP;
$source_data = "";
$generation_method = MAP_GENERATION_CIRCULAR;
$show_groups_filter = false;
$show_module_plugins = false;
$show_snmp_modules = false;
$show_modules = false;
$show_policy_modules = false;
$show_pandora_nodes = false;
$show_module_group = false;
// Filters
$id_tag = 0;
$text = "";
$show_pandora_nodes = false;
$show_agents = false;
$show_modules = false;
$module_group = 0;
$show_module_group = false;
$only_snmp_modules = false;
$only_modules_with_alerts = false;
$only_policy_modules = false;
}
$not_found = false;
@ -88,19 +91,23 @@ if ($edit_networkmap) {
$source_data = $values['source_data'];
}
$generation_method = $values['generation_method'];
$filter = json_decode($values['filter'], true);
$show_groups_filter = $filter['show_groups_filter'];
$show_module_plugins = $filter['show_module_plugins'];
$show_snmp_modules = $filter['show_snmp_modules'];
$show_modules = $filter['show_modules'];
$show_policy_modules = $filter['show_policy_modules'];
$show_pandora_nodes = $filter['show_pandora_nodes'];
$show_module_group = $filter['show_module_group'];
$id_tag = $filter['id_tag'];
$text = io_safe_output($filter['text']);
$show_pandora_nodes = $filter['show_pandora_nodes'];
$show_agents = $filter['show_agents'];
$show_modules = $filter['show_modules'];
$module_group = $filter['module_group'];
$show_module_group = $filter['show_module_group'];
$only_snmp_modules = $filter['only_snmp_modules'];
$only_modules_with_alerts = $filter['only_modules_with_alerts'];
$only_policy_modules = $filter['only_policy_modules'];
}
}
//+++++++++++++++TABLE TO CREATE/EDIT NETWORKMAP++++++++++++++++++++++
$buttons['list'] = array('active' => false,
@ -133,6 +140,8 @@ if ($not_found) {
ui_print_error_message(__('Not found networkmap'));
}
else {
echo '<form method="post" action="index.php?sec=maps&amp;sec2=operation/maps/networkmap_list">';
$table = null;
$table->id = 'form_editor';
@ -148,6 +157,8 @@ else {
$table->style[0] = 'font-weight: bold; width: 150px;';
$table->data = array();
// ----- Main configuration ----------------------------------------
$table->data['name'][0] = __('Name');
$table->data['name'][1] = html_print_input_text ('name', $name, '',
30, 100, true);
@ -172,6 +183,36 @@ else {
$subtype, '', '', 'Topology', true, false, true, '',
$disabled_select);
$generation_methods = array(
MAP_GENERATION_RADIAL => 'Radial',
MAP_GENERATION_PLANO => 'Flat',
MAP_GENERATION_CIRCULAR => 'Circular',
MAP_GENERATION_SPRING1 => 'Spring1',
MAP_GENERATION_SPRING2 => 'Spring2'
);
$table->data['method_generation'][0] = __('Method generation networkmap');
$table->data['method_generation'][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
'', '', 'twopi', true, false, true, '',
$disabled_select);
$table->data['size'][0] = __('Size of networkmap (Width x Height)');
$table->data['size'][1] = html_print_input_text ('width', $width, '', 4,
10,true) . " x ";
$table->data['size'][1] .= html_print_input_text ('height', $height, '',
4, 10,true);
$table->data[7][0] = __('Refresh time');
$table->data[7][1] = html_print_input_text ('source_period', $source_period, '', 8,
20,true);
echo '<fieldset><legend>' . __('Main') . '</legend>';
html_print_table($table);
echo '</fieldset>';
$table->data = array();
// ----- Source configuration --------------------------------------
$table->data['source'][0] = __('Source type');
$table->data['source'][1] =
html_print_radio_button('source', MAP_SOURCE_GROUP, __('Group'), $source, true) .
@ -185,60 +226,61 @@ else {
$table->data['source_ip_mask'][1] = html_print_input_text ('source_ip_mask',
$source_data, '', 30, 100,true);
$generation_methods = array(
MAP_GENERATION_RADIAL => 'Radial',
MAP_GENERATION_PLANO => 'Flat',
MAP_GENERATION_CIRCULAR => 'Circular',
MAP_GENERATION_SPRING1 => 'Spring1',
MAP_GENERATION_SPRING2 => 'Spring2'
);
$table->data['method_generation'][0] = __('Method generation networkmap');
$table->data['method_generation'][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
'', '', 'twopi', true, false, true, '',
$disabled_select);
$table->data[6][0] = __('Size of networkmap (Width x Height)');
$table->data[6][1] = html_print_input_text ('width', $width, '', 4,
10,true) . __("x");
$table->data[6][1] .= html_print_input_text ('height', $height, '',
4, 10,true);
$table->data[7][0] = __('Refresh time');
$table->data[7][1] = html_print_input_text ('source_period', $source_period, '', 8,
20,true);
$table->data[8][0] = __('Show groups filter');
$table->data[8][1] = html_print_checkbox('show_groups_filter', '1', $show_groups_filter, true);
$table->data[9][0] = __('Show module plugins');
$table->data[9][1] = html_print_checkbox('show_module_plugins', '1', $show_module_plugins, true);
$table->data[10][0] = __('Show snmp modules');
$table->data[10][1] = html_print_checkbox('show_snmp_modules', '1', $show_snmp_modules, true);
$table->data[11][0] = __('Show modules');
$table->data[11][1] = html_print_checkbox('show_modules', '1', $show_modules, true);
$table->data[12][0] = __('Show policy modules');
$table->data[12][1] = html_print_checkbox('show_policy_modules', '1', $show_policy_modules, true);
$table->data[13][0] = __('Show pandora nodes');
$table->data[13][1] = html_print_checkbox('show_pandora_nodes', '1', $show_pandora_nodes, true);
$table->data[14][0] = __('Show module group');
$table->data[14][1] = html_print_checkbox('show_module_group', '1', $show_module_group, true);
$table->data[15][0] = __('Filter by tags');
$table->data[15][1] = html_print_select (tags_get_user_tags(), "id_tag", $id_tag, '', __('All'), 0, true, false, true, '', false, '');
$table->data[16][0] = __('Filter by text');
$table->data[16][1] = html_print_input_text ('text', $text, '', 30,
100,true);
echo '<form method="post" action="index.php?sec=maps&amp;sec2=operation/maps/networkmap_list">';
echo '<fieldset><legend>' . __('Source') . '</legend>';
html_print_table($table);
echo '</fieldset>';
$table->data = array();
// ----- Filter configuration --------------------------------------
$table->data["filter_by_tag"][0] = __('Filter by tags');
$table->data["filter_by_tag"][1] = html_print_select(
tags_get_user_tags(), "id_tag", $id_tag, '', __('All'), 0, true, false, true, '', false, '');
$table->data["filter_by_text"][0] = __('Filter by text');
$table->data["filter_by_text"][1] = html_print_input_text ('text',
$text, '', 30, 100,true);
if (is_metaconsole()) {
$table->data[13][0] = __('Show pandora nodes');
$table->data[13][1] = html_print_checkbox('show_pandora_nodes', '1',
$show_pandora_nodes, true);
}
$table->data['show_agents'][0] = __('Show agents');
$table->data['show_agents'][1] = html_print_checkbox(
'show_agents', '1', $show_agents, true);
$table->data['show_modules'][0] = __('Show modules');
$table->data['show_modules'][1] = html_print_checkbox(
'show_modules', '1', $show_modules, true);
$table->data['filter_module_group'][0] = __('Filter by module group');
$table->data['filter_module_group'][1] = html_print_select_from_sql ('
SELECT id_mg, name
FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
$table->data['show_module_group'][0] = __('Show module group');
$table->data['show_module_group'][1] = html_print_checkbox(
'show_module_group', '1', $show_module_group, true);
$table->data['only_snmp_modules'][0] = __('Filter only snmp modules');
$table->data['only_snmp_modules'][1] = html_print_checkbox(
'only_snmp_modules', '1', $only_snmp_modules, true);
$table->data['only_modules_with_alerts'][0] = __('Filter only modules with alerts');
$table->data['only_modules_with_alerts'][1] = html_print_checkbox(
'only_modules_with_alerts', '1', $only_modules_with_alerts, true);
$table->data['only_policy_modules'][0] = __('Filter only policy modules');
$table->data['only_policy_modules'][1] = html_print_checkbox(
'only_policy_modules', '1', $only_policy_modules, true);
echo '<fieldset><legend>' . __('Filters') . '</legend>';
html_print_table($table);
echo '</fieldset>';
echo "<div style='width: " . $table->width . "; text-align: right;'>";
if ($create_networkmap) {
@ -257,19 +299,153 @@ else {
}
?>
<script type="text/javascript">
// id in the edition
var id_networkmap = <?php echo $id; ?>;
// Old values in the edition
var old_filter = {};
old_filter['id_tag'] = <?php echo $id_tag; ?>;
old_filter['text'] = "<?php echo $text; ?>";
old_filter['show_pandora_nodes'] = <?php echo (int)$show_pandora_nodes; ?>;
old_filter['show_agents'] = <?php echo (int)$show_agents; ?>;
old_filter['show_modules'] = <?php echo (int)$show_modules; ?>;
old_filter['module_group'] = <?php echo (int)$module_group; ?>;
old_filter['show_module_group'] = <?php echo (int)$show_module_group; ?>;
old_filter['only_snmp_modules'] = <?php echo (int)$only_snmp_modules; ?>;
old_filter['only_modules_with_alerts'] = <?php echo (int)$only_modules_with_alerts; ?>;
old_filter['only_policy_modules'] = <?php echo (int)$only_policy_modules; ?>;
//Constants
var MAP_SOURCE_GROUP = <?php echo MAP_SOURCE_GROUP; ?>;
var MAP_SOURCE_IP_MASK = <?php echo MAP_SOURCE_IP_MASK; ?>;
var MAP_SUBTYPE_TOPOLOGY = <?php echo MAP_SUBTYPE_TOPOLOGY; ?>;
var MAP_SUBTYPE_POLICIES = <?php echo MAP_SUBTYPE_POLICIES; ?>;
var MAP_SUBTYPE_GROUPS = <?php echo MAP_SUBTYPE_GROUPS; ?>;
var MAP_SUBTYPE_RADIAL_DYNAMIC = <?php echo MAP_SUBTYPE_RADIAL_DYNAMIC; ?>;
$(function() {
change_source();
change_subtype();
change_show_agents();
change_show_modules();
$("input[name='source']").on("change",
function(event) {
change_source();
}
);
$("select[name='subtype']").on("change",
function(event) {
change_subtype();
}
);
$("input[name='show_agents']").on("change",
function(event) {
change_show_agents();
}
);
$("input[name='show_modules']").on("change",
function(event) {
change_show_modules();
}
);
// Set the form editor initial values when is update
if (id_networkmap) {
$("input[name='show_agents']")
.prop("checked", old_filter['show_agents'])
.trigger("change");
$("input[name='show_modules']")
.prop("checked", old_filter['show_modules'])
.trigger("change");
}
});
function change_show_agents() {
if ($("input[name='show_agents']").prop("checked")) {
$("input[name='show_modules']").prop("checked", false)
.trigger("change");
$("#form_editor-show_modules").show();
}
else {
$("input[name='show_modules']").prop("checked", false)
.trigger("change");
$("#form_editor-show_modules").hide();
}
}
function change_show_modules() {
var subtype = parseInt($("select[name='subtype']").val());
if ($("input[name='show_modules']").prop("checked")) {
$("#form_editor-filter_module_group").show();
$("#form_editor-show_module_group").show();
$("#form_editor-only_modules_with_alerts").show();
switch (subtype) {
case MAP_SUBTYPE_GROUPS:
$("#form_editor-only_policy_modules").show();
break;
case MAP_SUBTYPE_POLICIES:
break;
case MAP_SUBTYPE_RADIAL_DYNAMIC:
break;
case MAP_SUBTYPE_TOPOLOGY:
$("#form_editor-only_snmp_modules").show();
break;
}
}
else {
$("#form_editor-filter_module_group").hide();
$("#form_editor-show_module_group").hide();
$("#form_editor-only_modules_with_alerts").hide();
$("#form_editor-only_policy_modules").hide();
$("#form_editor-only_snmp_modules").hide();
}
}
function change_subtype() {
var subtype = parseInt($("select[name='subtype']").val());
$("#form_editor-show_agents").show();
switch (subtype) {
case MAP_SUBTYPE_GROUPS:
$("#form_editor-only_snmp_modules").hide();
$("input[name='show_modules']")
.prop("checked", false)
.trigger("change");
break;
case MAP_SUBTYPE_POLICIES:
$("#form_editor-only_snmp_modules").hide();
$("#form_editor-only_policy_modules").hide();
break;
case MAP_SUBTYPE_RADIAL_DYNAMIC:
$("#form_editor-filter_by_tag").hide();
$("#form_editor-filter_by_text").hide();
$("#form_editor-show_agents").hide();
$("#form_editor-show_modules").hide();
$("#form_editor-show_module_group").hide();
$("#form_editor-only_snmp_modules").hide();
$("#form_editor-only_policy_modules").hide();
$("#form_editor-filter_module_group").show();
break;
case MAP_SUBTYPE_TOPOLOGY:
// Forever show agents
$("input[name='show_agents']")
.prop("checked", true)
.trigger("change");
$("#form_editor-show_agents").hide();
break;
}
}
function change_source() {
var checked_source_group =
$("input[name='source'][value='" + MAP_SOURCE_GROUP + "']")

View File

@ -128,15 +128,20 @@ if ($save_networkmap) {
$width = (int) get_parameter('width', 800);
$height = (int) get_parameter('height', 800);
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
$show_groups_filter = (int) get_parameter('show_groups_filter', false);
$show_module_plugins = (int) get_parameter('show_module_plugins', false);
$show_snmp_modules = (int) get_parameter('show_snmp_modules', false);
$show_modules = (int) get_parameter('show_modules', false);
$show_policy_modules = (int) get_parameter('show_policy_modules', false);
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', false);
$show_module_group = (int) get_parameter('show_module_group', false);
// Filters
$id_tag = (int) get_parameter('id_tag', 0);
$text = (string) get_parameter('text', "");
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', 0);
$show_agents = (int) get_parameter('show_agents', 0);
$show_modules = (int) get_parameter('show_modules', 0);
$module_group = (int) get_parameter('module_group', 0);
$show_module_group = (int) get_parameter('show_module_group', 0);
$only_snmp_modules = (int) get_parameter('only_snmp_modules', 0);
$only_modules_with_alerts = (int) get_parameter('only_modules_with_alerts', 0);
$only_policy_modules = (int) get_parameter('only_policy_modules', 0);
$values = array();
$values['name'] = $name;
@ -151,16 +156,20 @@ if ($save_networkmap) {
$values['width'] = $width;
$values['height'] = $height;
$values['source'] = $source;
$filter = array();
$filter['show_groups_filter'] = 60;
$filter['show_module_plugins'] = $show_module_plugins;
$filter['show_snmp_modules'] = $show_snmp_modules;
$filter['show_modules'] = $show_modules;
$filter['show_policy_modules'] = $show_policy_modules;
$filter['show_pandora_nodes'] = $show_pandora_nodes;
$filter['show_module_group'] = $show_module_group;
$filter['id_tag'] = $id_tag;
$filter['text'] = $text;
$filter['show_pandora_nodes'] = $show_pandora_nodes;
$filter['show_agents'] = $show_agents;
$filter['show_modules'] = $show_modules;
$filter['module_group'] = $module_group;
$filter['show_module_group'] = $show_module_group;
$filter['only_snmp_modules'] = $only_snmp_modules;
$filter['only_modules_with_alerts'] = $only_modules_with_alerts;
$filter['only_policy_modules'] = $only_policy_modules;
$values['filter'] = json_encode($filter);
$networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap");
@ -241,15 +250,20 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) {
$source_data = (string) get_parameter('source_data', 'group');
$width = (int) get_parameter('width', 800);
$height = (int) get_parameter('height', 800);
$show_groups_filter = (int) get_parameter('show_groups_filter', false);
$show_module_plugins = (int) get_parameter('show_module_plugins', false);
$show_snmp_modules = (int) get_parameter('show_snmp_modules', false);
$show_modules = (int) get_parameter('show_modules', false);
$show_policy_modules = (int) get_parameter('show_policy_modules', false);
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', false);
$show_module_group = (int) get_parameter('show_module_group', false);
// Filters
$id_tag = (int) get_parameter('id_tag', 0);
$text = (string) get_parameter('text', "");
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', 0);
$show_agents = (int) get_parameter('show_agents', 0);
$show_modules = (int) get_parameter('show_modules', 0);
$module_group = (int) get_parameter('module_group', 0);
$show_module_group = (int) get_parameter('show_module_group', 0);
$only_snmp_modules = (int) get_parameter('only_snmp_modules', 0);
$only_modules_with_alerts = (int) get_parameter('only_modules_with_alerts', 0);
$only_policy_modules = (int) get_parameter('only_policy_modules', 0);
$values = array();
$values['name'] = $name;
@ -260,16 +274,18 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) {
$values['source'] = $source;
$values['width'] = $width;
$values['height'] = $height;
$filter = array();
$filter['show_groups_filter'] = $show_groups_filter;
$filter['show_module_plugins'] = $show_module_plugins;
$filter['show_snmp_modules'] = $show_snmp_modules;
$filter['show_modules'] = $show_modules;
$filter['show_policy_modules'] = $show_policy_modules;
$filter['show_pandora_nodes'] = $show_pandora_nodes;
$filter['show_module_group'] = $show_module_group;
$filter['id_tag'] = $id_tag;
$filter['text'] = $text;
$filter['show_pandora_nodes'] = $show_pandora_nodes;
$filter['show_agents'] = $show_agents;
$filter['show_modules'] = $show_modules;
$filter['module_group'] = $module_group;
$filter['show_module_group'] = $show_module_group;
$filter['only_snmp_modules'] = $only_snmp_modules;
$filter['only_modules_with_alerts'] = $only_modules_with_alerts;
$filter['only_policy_modules'] = $only_policy_modules;
$values['filter'] = json_encode($filter);
$result_update = false;