From e812c552645113ab7e8c6caacd32ef3d7a2a3e6d Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 22 Jan 2015 16:55:31 +0100 Subject: [PATCH] Added the modules filter --- pandora_console/include/ajax/tree.ajax.php | 14 ++-- pandora_console/operation/tree2.php | 76 ++++++++++++++-------- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 135c63969d..13639f97fa 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -34,8 +34,15 @@ if (is_ajax ()) { $rootType = get_parameter('rootType', ''); $id = get_parameter('id', -1); $rootID = get_parameter('rootID', -1); - $filter = get_parameter('filter', array('searchAgent' => '', 'statusAgent' => AGENT_STATUS_ALL)); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + + $default_filters = array( + 'searchAgent' => '', + 'statusAgent' => AGENT_STATUS_ALL, + 'searchModule' => '', + 'statusModule' => -1, + ); + $filter = get_parameter('filter', $default_filters); if (class_exists('TreeEnterprise')) { $tree = new TreeEnterprise($type, $rootType, $id, $rootID, $childrenMethod); @@ -44,10 +51,7 @@ if (is_ajax ()) { $tree = new Tree($type, $rootType, $id, $rootID, $childrenMethod); } - $tree->setFilter(array( - 'statusAgent' => $filter['statusAgent'], - 'searchAgent' => $filter['searchAgent']) - ); + $tree->setFilter($filter); echo json_encode(array('success' => 1, 'tree' => $tree->getArray())); return; } diff --git a/pandora_console/operation/tree2.php b/pandora_console/operation/tree2.php index 4bd2642763..58056ce40c 100644 --- a/pandora_console/operation/tree2.php +++ b/pandora_console/operation/tree2.php @@ -17,8 +17,10 @@ global $config; $tab = get_parameter('tab', 'group'); -$search = get_parameter('search', ''); -$status = get_parameter('status', AGENT_STATUS_ALL); +$search_agent = get_parameter('searchAgent', ''); +$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL); +$search_module = get_parameter('searchModule', ''); +$status_module = get_parameter('statusModule', -1); // ---------------------Tabs ------------------------------------------- @@ -105,27 +107,46 @@ ui_print_page_header( // --------------------- form filter ----------------------------------- $table = null; $table->width = "100%"; +$table->data = array(); +$table->rowspan = array(); -$table->data[0][0] = __('Agent status'); -$fields = array (); -$fields[AGENT_STATUS_ALL] = __('All'); //default -$fields[AGENT_STATUS_NORMAL] = __('Normal'); -$fields[AGENT_STATUS_WARNING] = __('Warning'); -$fields[AGENT_STATUS_CRITICAL] = __('Critical'); -$fields[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$fields[AGENT_STATUS_NOT_INIT] = __('Not init'); -$table->data[0][1] = html_print_select($fields, - "status", - $status, - '', - '', - 0, - true); -$table->data[0][2] = __('Search agent'); -$table->data[0][3] = html_print_input_text( - "search", $search, '', 40, 30, true); -$table->data[0][4] = html_print_submit_button( - __('Filter'), "uptbutton", false, 'class="sub search"', true); +// Agent filter +$agent_status_arr = array(); +$agent_status_arr[AGENT_STATUS_ALL] = __('All'); //default +$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); +$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); +$agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical'); +$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); +$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); + +$row = array(); +$row[] = __('Agent status'); +$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); +$row[] = __('Search agent'); +$row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true); + +// Button +$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); +$table->rowspan[][count($row)-1] = 2; + +$table->data[] = $row; + +// Module filter +$module_status_arr = array(); +$module_status_arr[-1] = __('All'); //default +$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); +$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning'); +$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); +$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); +$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); + +$row = array(); +$row[] = __('Module status'); +$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); +$row[] = __('Search module'); +$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); + +$table->data[] = $row; echo '