UX console in progress... (init develop and modules hierachy)

This commit is contained in:
Arturo Gonzalez 2017-01-18 12:45:25 +01:00
parent 362ea41ea2
commit fe6f924d7a
3 changed files with 91 additions and 17 deletions

View File

@ -750,21 +750,32 @@ if ($list_modules) {
$show_context_help_first_time = false;
$hierachy_mode = get_parameter('hierachy_mode', false);
if ($hierachy_mode == "true") {
$modules_hierachy = array();
$modules_hierachy = get_hierachy_modules_tree($modules);
$modules_dt = get_dt_from_modules_tree($modules_hierachy);
$modules = $modules_dt;
}
foreach ($modules as $module) {
//The code add the row of 1 cell with title of group for to be more organice the list.
if ($hierachy_mode !== "true") {
//The code add the row of 1 cell with title of group for to be more organice the list.
if ($module["id_module_group"] != $last_modulegroup)
{
$table->colspan[$rowIndex][0] = count($table->head);
$table->rowclass[$rowIndex] = 'datos4';
if ($module["id_module_group"] != $last_modulegroup)
{
$table->colspan[$rowIndex][0] = count($table->head);
$table->rowclass[$rowIndex] = 'datos4';
array_push ($table->data, array ('<b>'.$module['name'].'</b>'));
array_push ($table->data, array ('<b>'.$module['name'].'</b>'));
$rowIndex++;
$last_modulegroup = $module["id_module_group"];
$rowIndex++;
$last_modulegroup = $module["id_module_group"];
}
//End of title of group
}
//End of title of group
$data = array ();
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
@ -1008,7 +1019,7 @@ if ($list_modules) {
"refresh=" . SECONDS_10MINUTES . "&amp;" .
"draw_events=$draw_events', 'day_".$win_handle."')";
if(!is_snapshot_data($module['datos'])){
if(!is_snapshot_data($module['datos'])){
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
}
$server_name = '';

View File

@ -2511,4 +2511,62 @@ function get_same_modules ($agents, $modules) {
return $modules_to_report;
}
function get_hierachy_modules_tree ($modules) {
$new_modules = array();
$new_modules_root = array_filter($modules, function ($module) {
return (isset($module['parent_module_id']) && ($module['parent_module_id'] == 0));
});
$new_modules_child = array_filter($modules, function ($module) {
return (isset($module['parent_module_id']) && ($module['parent_module_id'] != 0));
});
while (!empty($new_modules_child)) {
foreach ($new_modules_child as $i => $child) {
recursive_modules_tree($new_modules_root, $new_modules_child, $i, $child);
}
}
return $new_modules_root;
}
function recursive_modules_tree (&$new_modules, &$new_modules_child, $i, $child) {
foreach ($new_modules as $index => $module) {
if ($module['id_agente_modulo'] == $child['parent_module_id']) {
$new_modules[$index]['child'][] = $child;
unset($new_modules_child[$i]);
break;
}
else if (isset($new_modules[$index]['child'])) {
recursive_modules_tree ($new_modules[$index]['child'], $new_modules_child, $i, $child);
}
}
}
function get_dt_from_modules_tree ($modules) {
$final_modules = array();
foreach ($modules as $i => $module) {
$final_modules[$module['id_agente_modulo']] = $module;
$final_modules[$module['id_agente_modulo']]['deep'] = 0;
if (isset($modules[$i]['child'])) {
recursive_get_dt_from_modules_tree($final_modules, $modules[$i]['child'], $final_modules[$module['id_agente_modulo']]['deep']);
}
unset($modules[$i]);
}
return $final_modules;
}
function recursive_get_dt_from_modules_tree (&$f_modules, $modules, $deep) {
foreach ($modules as $i => $module) {
$f_modules[$module['id_agente_modulo']] = $module;
$f_modules[$module['id_agente_modulo']]['deep'] = $deep + 1;
if (isset($modules[$i]['child'])) {
recursive_get_dt_from_modules_tree($f_modules, $modules[$i]['child'], $f_modules[$module['id_agente_modulo']]['deep']);
}
}
}
?>

View File

@ -118,6 +118,7 @@ if (!isset ($id_agente)) {
$id_agent = (int)get_parameter('id_agente');
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
$status_text_monitor = get_parameter('status_text_monitor', '');
$status_hierachy_mode = get_parameter('status_hierachy_mode', -1);
$sort_field = get_parameter('sort_field', 'name');
$sort = get_parameter('sort', 'up');
@ -138,7 +139,7 @@ echo "</h4>";
ob_start();
print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor);
print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor, $status_hierachy_mode);
echo "<div id='module_list_loading'>" .
html_print_image('images/spinner.gif', true) .
@ -223,7 +224,8 @@ ui_toggle($html_toggle,
filter_status = $("#status_filter_monitor").val();
filter_group = $("#status_module_group").val();
filter_text = $("input[name='status_text_monitor']").val();
hierachy_mode = $("#checkbox-status_hierachy_mode").is(":checked");
var parameters = {};
parameters["list_modules"] = 1;
@ -233,6 +235,7 @@ ui_toggle($html_toggle,
parameters["status_filter_monitor"] = filter_status;
parameters["status_text_monitor"] = filter_text;
parameters["status_module_group"] = filter_group;
parameters["hierachy_mode"] = hierachy_mode;
parameters["filter_monitors"] = 1;
parameters["monitors_change_filter"] = 1;
parameters["page"] = "include/ajax/module";
@ -411,7 +414,7 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
</script>
<?php
function print_form_filter_monitors($id_agent, $status_filter_monitor = -1,
$status_text_monitor = '', $status_module_group=-1) {
$status_text_monitor = '', $status_module_group=-1, $status_hierachy_mode=-1) {
$form_text = '';
$table = new stdClass();
@ -449,8 +452,10 @@ function print_form_filter_monitors($id_agent, $status_filter_monitor = -1,
$rows_select[$module_group['id_mg']] = __($module_group['name']);
}
$table->data[0][5] = html_print_select ($rows_select,'status_module_group', $status_module_group, '', '',0, true);
$table->data[0][6] = html_print_button(__('Filter'), 'filter', false, 'filter_modules();', 'class="sub search"', true);
$table->data[0][7] = '&nbsp;' . html_print_button(__('Reset'), 'filter', false, 'reset_filter_modules();', 'class="sub upd" style="margin-top:0px;"', true);
$table->data[0][6] = __('Show in hierachy mode');
$table->data[0][6] .= html_print_checkbox ('status_hierachy_mode', "", false, true);
$table->data[0][7] = html_print_button(__('Filter'), 'filter', false, 'filter_modules();', 'class="sub search"', true);
$table->data[0][8] = '&nbsp;' . html_print_button(__('Reset'), 'filter', false, 'reset_filter_modules();', 'class="sub upd" style="margin-top:0px;"', true);
$form_text .= html_print_table($table, true);
$filter_hidden = false;