Feature: Search by status module in bulk module delete/edit actions. Ticket: #4190

This commit is contained in:
m-lopez-f 2016-11-17 12:55:29 +01:00
parent 9667151fa1
commit 88879e8e6e
5 changed files with 97 additions and 9 deletions

View File

@ -460,7 +460,19 @@ $table->data['form_agents_2'][1] = html_print_select($status_list,
'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true); 'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data['form_agents_2'][3] = ''; $table->data['form_agents_2'][3] = '';
$table->rowclass['form_modules_3'] = '';
$table->data['form_modules_3'][0] = __('Module Status');
$table->colspan['form_modules_3'][1] = 2;
$status_list = array ();
$status_list[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$status_list[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$status_list[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
$table->data['form_modules_3'][1] = html_print_select($status_list,
'status_module', 'selected', '', __('All'), AGENT_MODULE_STATUS_ALL, true);
$table->data['form_modules_3'][3] = '';
$table->rowstyle['form_modules_2'] = 'vertical-align: top;'; $table->rowstyle['form_modules_2'] = 'vertical-align: top;';
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2'; $table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
@ -569,6 +581,10 @@ $(document).ready (function () {
if (this.value != '0') if (this.value != '0')
params['id_tipo_modulo'] = this.value; params['id_tipo_modulo'] = this.value;
var status_module = $('#status_module').val();
if (status_module != '-1')
params['status_module'] = status_module;
$("#module_loading").show (); $("#module_loading").show ();
$("tr#delete_table-edit1, tr#delete_table-edit2").hide (); $("tr#delete_table-edit1, tr#delete_table-edit2").hide ();
$("#module_name").attr ("disabled", "disabled") $("#module_name").attr ("disabled", "disabled")
@ -712,6 +728,16 @@ $(document).ready (function () {
return false; return false;
} }
}); });
$("#status_module").change(function() {
selector = $("#form_modules input[name=selection_mode]:checked").val();
if(selector == 'agents') {
$("#id_agents").trigger("change");
}
else if(selector == 'modules') {
$("#module_type").trigger("change");
}
});
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -289,6 +289,19 @@ $table->data['form_agents_1'][3] = __('Select all modules of this group') . ' '
'', 'style="margin-right: 40px;"', true); '', 'style="margin-right: 40px;"', true);
$table->rowclass['form_modules_3'] = '';
$table->data['form_modules_3'][0] = __('Module Status');
$table->colspan['form_modules_3'][1] = 2;
$status_list = array ();
$status_list[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$status_list[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$status_list[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
$table->data['form_modules_3'][1] = html_print_select($status_list,
'status_module', 'selected', '', __('All'), AGENT_MODULE_STATUS_ALL, true);
$table->data['form_modules_3'][3] = '';
$table->rowstyle['form_modules_2'] = 'vertical-align: top;'; $table->rowstyle['form_modules_2'] = 'vertical-align: top;';
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2'; $table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
@ -308,7 +321,7 @@ $table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]',
$table->rowclass['form_agents_2'] = 'select_agents_row'; $table->rowclass['form_agents_2'] = 'select_agents_row';
$table->data['form_agents_2'][0] = __('Status'); $table->data['form_agents_2'][0] = __('Agent Status');
$table->colspan['form_agents_2'][1] = 2; $table->colspan['form_agents_2'][1] = 2;
$status_list = array (); $status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_NORMAL] = __('Normal');
@ -695,6 +708,10 @@ $(document).ready (function () {
if (this.value != '0') if (this.value != '0')
params['id_tipo_modulo'] = this.value; params['id_tipo_modulo'] = this.value;
var status_module = $('#status_module').val();
if (status_module != '-1')
params['status_module'] = status_module;
$("#module_loading").show (); $("#module_loading").show ();
$("tr#delete_table-edit1, tr#delete_table-edit0, tr#delete_table-edit2").hide (); $("tr#delete_table-edit1, tr#delete_table-edit0, tr#delete_table-edit2").hide ();
$("#module_name").attr ("disabled", "disabled") $("#module_name").attr ("disabled", "disabled")
@ -889,7 +906,7 @@ $(document).ready (function () {
$("#id_agents").change (show_form); $("#id_agents").change (show_form);
$("#form_edit input[name=selection_mode]").change (function () { $("#form_edit input[name=selection_mode]").change (function () {
selector = this.value; selector = $("#form_edit input[name=selection_mode]:checked").val();
clean_lists(); clean_lists();
if(selector == 'agents') { if(selector == 'agents') {
@ -988,10 +1005,15 @@ $(document).ready (function () {
$("#groups_select").trigger("change"); $("#groups_select").trigger("change");
}); });
//Dynamic_interval; $("#status_module").change(function() {
disabled_status();
$('#dynamic_interval_select').change (function() { selector = $("#form_edit input[name=selection_mode]:checked").val();
disabled_status(); if(selector == 'agents') {
$("#id_agents").trigger("change");
}
else if(selector == 'modules') {
$("#module_type").trigger("change");
}
}); });
}); });

View File

@ -1169,6 +1169,9 @@ function agents_get_modules ($id_agent = null, $details = false,
break; break;
} }
} }
else if (preg_match('/\bin\b/i',$field)) {
array_push ($fields, $field.' '.$value);
}
else { else {
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":

View File

@ -157,6 +157,15 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
} }
} }
var module_status = -1;
if (typeof $("#status_module") !== 'undefined') {
try {
module_status = $("#status_module").val();
}
catch (error) {
}
}
// Module name // Module name
var module_name = $("#text-module_filter").val(); var module_name = $("#text-module_filter").val();
@ -222,7 +231,8 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
"name": module_name, "name": module_name,
"selection_mode": selection_mode, "selection_mode": selection_mode,
"serialized": serialized, "serialized": serialized,
"id_server": id_server "id_server": id_server,
"status_module": module_status
}, },
function (data) { function (data) {
$('#module').empty (); $('#module').empty ();
@ -382,6 +392,15 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
$('#agents').empty (); $('#agents').empty ();
$('#agents').append ($('<option></option>').html ("Loading...").attr ("value", 0)); $('#agents').append ($('<option></option>').html ("Loading...").attr ("value", 0));
var status_module = -1;
if (typeof $("#status_module") !== 'undefined') {
try {
status_module = $("#status_module").val();
}
catch (error) {
}
}
var selection_mode = $('#agents_selection_mode').val(); var selection_mode = $('#agents_selection_mode').val();
if(selection_mode == undefined) { if(selection_mode == undefined) {
selection_mode = 'common'; selection_mode = 'common';
@ -390,6 +409,7 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
jQuery.post('ajax.php', jQuery.post('ajax.php',
{"page": "operation/agentes/ver_agente", {"page": "operation/agentes/ver_agente",
"get_agents_json_for_multiple_modules": 1, "get_agents_json_for_multiple_modules": 1,
"status_module": status_module,
"module_name[]": idModules, "module_name[]": idModules,
"selection_mode": selection_mode "selection_mode": selection_mode
}, },

View File

@ -178,6 +178,7 @@ if (is_ajax ()) {
if ($get_agents_json_for_multiple_modules) { if ($get_agents_json_for_multiple_modules) {
$nameModules = get_parameter('module_name'); $nameModules = get_parameter('module_name');
$selection_mode = get_parameter('selection_mode','common'); $selection_mode = get_parameter('selection_mode','common');
$status_modulo = (int) get_parameter ('status_module', -1);
$groups = users_get_groups ($config["id_user"], "AW", false); $groups = users_get_groups ($config["id_user"], "AW", false);
$group_id_list = ($groups ? join(",",array_keys($groups)):"0"); $group_id_list = ($groups ? join(",",array_keys($groups)):"0");
@ -188,6 +189,10 @@ if (is_ajax ()) {
AND t1.id_grupo IN (' . $group_id_list .') AND t1.id_grupo IN (' . $group_id_list .')
AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')'; AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')';
if ($status_modulo != -1) {
$sql .= ' AND t2.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = ' . $status_modulo . ') ';
}
if ($selection_mode == 'common') { if ($selection_mode == 'common') {
$sql .= 'AND ( $sql .= 'AND (
SELECT count(t3.nombre) SELECT count(t3.nombre)
@ -258,6 +263,7 @@ if (is_ajax ()) {
$selection_mode = get_parameter('selection_mode', 'common'); $selection_mode = get_parameter('selection_mode', 'common');
$serialized = get_parameter('serialized', ''); $serialized = get_parameter('serialized', '');
$id_server = (int) get_parameter('id_server', 0); $id_server = (int) get_parameter('id_server', 0);
$status_modulo = (int) get_parameter ('status_module', -1);
$metaconsole_server_name = null; $metaconsole_server_name = null;
if (!empty($id_server)) { if (!empty($id_server)) {
$metaconsole_server_name = db_get_value('server_name', $metaconsole_server_name = db_get_value('server_name',
@ -294,6 +300,11 @@ if (is_ajax ()) {
} }
} }
if ($status_modulo != -1) {
$filter .= ' AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = ' . $status_modulo . ')';
}
if (is_metaconsole()) { if (is_metaconsole()) {
$result = array(); $result = array();
$nameModules = array(); $nameModules = array();
@ -475,6 +486,7 @@ HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))';
$delete_pending = (int) get_parameter ('delete_pending', -1); $delete_pending = (int) get_parameter ('delete_pending', -1);
// Use 0 as not received // Use 0 as not received
$id_tipo_modulo = (int) get_parameter ('id_tipo_modulo', 0); $id_tipo_modulo = (int) get_parameter ('id_tipo_modulo', 0);
$status_modulo = (int) get_parameter ('status_module', -1);
// Filter // Filter
$filter = array(); $filter = array();
@ -487,6 +499,11 @@ HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))';
if (empty($filter)) if (empty($filter))
$filter = false; $filter = false;
if ($status_modulo != -1) {
$filter['id_agente_modulo IN'] = ' (SELECT id_agente_modulo FROM tagente_estado where estado = '.$status_modulo.') ';
}
$get_id_and_name = (bool) get_parameter ('get_id_and_name'); $get_id_and_name = (bool) get_parameter ('get_id_and_name');
$get_distinct_name = (bool) get_parameter ('get_distinct_name'); $get_distinct_name = (bool) get_parameter ('get_distinct_name');