mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Fixed the networkmap editor.
This commit is contained in:
parent
fe863f61df
commit
255f67c545
@ -36,7 +36,7 @@ if ($create_networkmap) {
|
|||||||
$description = "";
|
$description = "";
|
||||||
$source_period = 60 * 5;
|
$source_period = 60 * 5;
|
||||||
$source = MAP_SOURCE_GROUP;
|
$source = MAP_SOURCE_GROUP;
|
||||||
$source_data = "id_group";
|
$source_data = "";
|
||||||
$generation_method = MAP_GENERATION_CIRCULAR;
|
$generation_method = MAP_GENERATION_CIRCULAR;
|
||||||
$show_groups_filter = false;
|
$show_groups_filter = false;
|
||||||
$show_module_plugins = false;
|
$show_module_plugins = false;
|
||||||
@ -78,10 +78,10 @@ if ($edit_networkmap) {
|
|||||||
$source_period = $values['source_period'];
|
$source_period = $values['source_period'];
|
||||||
$source = $values['source'];
|
$source = $values['source'];
|
||||||
if ($source == 'group') {
|
if ($source == 'group') {
|
||||||
$source_data = 'id_group';
|
$source_data = $values['source_data'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$source_data = 'ip_mask';
|
$source_data = $values['source_data'];
|
||||||
}
|
}
|
||||||
$generation_method = $values['generation_method'];
|
$generation_method = $values['generation_method'];
|
||||||
$filter = json_decode($values['filter'], true);
|
$filter = json_decode($values['filter'], true);
|
||||||
@ -144,6 +144,18 @@ else {
|
|||||||
$table->style[0] = 'font-weight: bold; width: 150px;';
|
$table->style[0] = 'font-weight: bold; width: 150px;';
|
||||||
$table->data = array();
|
$table->data = array();
|
||||||
|
|
||||||
|
$table->data['name'][0] = __('Name');
|
||||||
|
$table->data['name'][1] = html_print_input_text ('name', $name, '',
|
||||||
|
30, 100, true);
|
||||||
|
|
||||||
|
$table->data['group'][0] = __('Group');
|
||||||
|
$table->data['group'][1] = html_print_select_groups(false, "AR", true,
|
||||||
|
'id_group', $id_group, '', '', 0, true);
|
||||||
|
|
||||||
|
$table->data['description'][0] = __('Description');
|
||||||
|
$table->data['description'][1] = html_print_textarea("description",
|
||||||
|
2, 65, $description, '', true);
|
||||||
|
|
||||||
$subtypes = array(
|
$subtypes = array(
|
||||||
MAP_SUBTYPE_TOPOLOGY => 'Topology',
|
MAP_SUBTYPE_TOPOLOGY => 'Topology',
|
||||||
MAP_SUBTYPE_POLICIES => 'Policies',
|
MAP_SUBTYPE_POLICIES => 'Policies',
|
||||||
@ -151,16 +163,24 @@ else {
|
|||||||
MAP_SUBTYPE_RADIAL_DYNAMIC => 'Radial Dynamic'
|
MAP_SUBTYPE_RADIAL_DYNAMIC => 'Radial Dynamic'
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data[0][0] = __('Subtype');
|
$table->data['subtype'][0] = __('Subtype');
|
||||||
$table->data[0][1] = html_print_select($subtypes, 'subtype', $subtype,
|
$table->data['subtype'][1] = html_print_select($subtypes, 'subtype',
|
||||||
'', '', 'Topology', true, false, true, '',
|
$subtype, '', '', 'Topology', true, false, true, '',
|
||||||
$disabled_select);
|
$disabled_select);
|
||||||
|
|
||||||
$table->data['source'][0] = __('Source');
|
$table->data['source'][0] = __('Source type');
|
||||||
$table->data['source'][1] =
|
$table->data['source'][1] =
|
||||||
html_print_radio_button('source', MAP_SOURCE_GROUP, __('Group'), $source, true) .
|
html_print_radio_button('source', MAP_SOURCE_GROUP, __('Group'), $source, true) .
|
||||||
html_print_radio_button('source', MAP_SOURCE_IP_MASK, __('CIDR IP mask'), $source, true);
|
html_print_radio_button('source', MAP_SOURCE_IP_MASK, __('CIDR IP mask'), $source, true);
|
||||||
|
|
||||||
|
$table->data['source_group'][0] = __('Source');
|
||||||
|
$table->data['source_group'][1] = html_print_select_groups(
|
||||||
|
false, "AR", true, 'source_group', $source_data, '', '', 0, true);
|
||||||
|
|
||||||
|
$table->data['source_ip_mask'][0] = __('Source');
|
||||||
|
$table->data['source_ip_mask'][1] = html_print_input_text ('source_ip_mask',
|
||||||
|
$source_data, '', 30, 100,true);
|
||||||
|
|
||||||
$generation_methods = array(
|
$generation_methods = array(
|
||||||
MAP_GENERATION_RADIAL => 'Radial',
|
MAP_GENERATION_RADIAL => 'Radial',
|
||||||
MAP_GENERATION_PLANO => 'Flat',
|
MAP_GENERATION_PLANO => 'Flat',
|
||||||
@ -169,21 +189,14 @@ else {
|
|||||||
MAP_GENERATION_SPRING2 => 'Spring2'
|
MAP_GENERATION_SPRING2 => 'Spring2'
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data[2][0] = __('Method generation networkmap');
|
$table->data['method_generation'][0] = __('Method generation networkmap');
|
||||||
$table->data[2][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
|
$table->data['method_generation'][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
|
||||||
'', '', 'twopi', true, false, true, '',
|
'', '', 'twopi', true, false, true, '',
|
||||||
$disabled_select);
|
$disabled_select);
|
||||||
|
|
||||||
$table->data[3][0] = __('Name');
|
|
||||||
$table->data[3][1] = html_print_input_text ('name', $name, '', 30,
|
|
||||||
100,true);
|
|
||||||
|
|
||||||
$table->data[4][0] = __('Group');
|
|
||||||
$table->data[4][1] = html_print_select_groups(false, "AR", true,
|
|
||||||
'id_group', $id_group, '', '', 0, true);
|
|
||||||
|
|
||||||
$table->data[5][0] = __('Description');
|
|
||||||
$table->data[5][1] = html_print_textarea ("description", 2, 65, $description, '', true);
|
|
||||||
|
|
||||||
$table->data[6][0] = __('Refresh time');
|
$table->data[6][0] = __('Refresh time');
|
||||||
$table->data[6][1] = html_print_input_text ('source_period', $source_period, '', 8,
|
$table->data[6][1] = html_print_input_text ('source_period', $source_period, '', 8,
|
||||||
@ -237,3 +250,35 @@ else {
|
|||||||
echo "</form>";
|
echo "</form>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var MAP_SOURCE_GROUP = <?php echo MAP_SOURCE_GROUP; ?>;
|
||||||
|
var MAP_SOURCE_IP_MASK = <?php echo MAP_SOURCE_IP_MASK; ?>;
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
change_source();
|
||||||
|
|
||||||
|
$("input[name='source']").on("change",
|
||||||
|
function(event) {
|
||||||
|
change_source();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function change_source() {
|
||||||
|
var checked_source_group =
|
||||||
|
$("input[name='source'][value='" + MAP_SOURCE_GROUP + "']")
|
||||||
|
.is(":checked");
|
||||||
|
var checked_source_ip_mask =
|
||||||
|
$("input[name='source'][value='" + MAP_SOURCE_IP_MASK + "']")
|
||||||
|
.is(":checked");
|
||||||
|
|
||||||
|
$("#form_editor-source_group").hide();
|
||||||
|
$("#form_editor-source_ip_mask").hide();
|
||||||
|
if (checked_source_group) {
|
||||||
|
$("#form_editor-source_group").show();
|
||||||
|
}
|
||||||
|
else if (checked_source_ip_mask) {
|
||||||
|
$("#form_editor-source_ip_mask").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@ -93,8 +93,15 @@ if ($save_networkmap) {
|
|||||||
$name = (string) get_parameter('name', "");
|
$name = (string) get_parameter('name', "");
|
||||||
$description = (string) get_parameter('description', "");
|
$description = (string) get_parameter('description', "");
|
||||||
$source_period = (int) get_parameter('source_period', 60 * 5);
|
$source_period = (int) get_parameter('source_period', 60 * 5);
|
||||||
$source = (int) get_parameter('source', MAP_SOURCE_GROUP);
|
$source_data = (string) get_parameter('source_data', MAP_SOURCE_GROUP);
|
||||||
$source_data = (string) get_parameter('source_data', 'group');
|
switch ($source_data) {
|
||||||
|
case MAP_SOURCE_GROUP:
|
||||||
|
$source = (string) get_parameter('source_group', 0);
|
||||||
|
break;
|
||||||
|
case MAP_SOURCE_IP_MASK:
|
||||||
|
$source = (string) get_parameter('source_ip_mask', 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
||||||
$show_groups_filter = (int) get_parameter('show_groups_filter', false);
|
$show_groups_filter = (int) get_parameter('show_groups_filter', false);
|
||||||
$show_module_plugins = (int) get_parameter('show_module_plugins', false);
|
$show_module_plugins = (int) get_parameter('show_module_plugins', false);
|
||||||
@ -129,11 +136,14 @@ if ($save_networkmap) {
|
|||||||
$filter['text'] = $text;
|
$filter['text'] = $text;
|
||||||
$values['filter'] = json_encode($filter);
|
$values['filter'] = json_encode($filter);
|
||||||
$networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap");
|
$networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap");
|
||||||
|
|
||||||
|
$same_name = false;
|
||||||
foreach ($networkmap_names as $networkmap_name) {
|
foreach ($networkmap_names as $networkmap_name) {
|
||||||
if ($networkmap_name == $name) {
|
if ($networkmap_name == $name) {
|
||||||
$same_name = true;
|
$same_name = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($name) && !$same_name) {
|
if (!empty($name) && !$same_name) {
|
||||||
$result_add = maps_save_map($values);
|
$result_add = maps_save_map($values);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user