2014-03-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/massive/massive_edit_agents.php, godmode/massive/massive_delete_agents.php, godmode/groups/group_list.php, include/functions_agents.php, include/javascript/jquery.pandora.controls.js, operation/agentes/ver_agente.php, operation/agentes/estado_monitores.php: added the feature to filter by agent status in the massive operations into "massive agent deletion" and "massive agent edition". Incident: #669 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9639 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
147d81bcd5
commit
7e4a2ba7a9
|
@ -1,3 +1,16 @@
|
|||
2014-03-24 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/massive/massive_edit_agents.php,
|
||||
godmode/massive/massive_delete_agents.php,
|
||||
godmode/groups/group_list.php, include/functions_agents.php,
|
||||
include/javascript/jquery.pandora.controls.js,
|
||||
operation/agentes/ver_agente.php,
|
||||
operation/agentes/estado_monitores.php: added the feature to filter
|
||||
by agent status in the massive operations into
|
||||
"massive agent deletion" and "massive agent edition".
|
||||
|
||||
Incident: #669
|
||||
|
||||
2014-03-21 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/constants.php: added lost constant for
|
||||
|
|
|
@ -71,6 +71,7 @@ if (is_ajax ()) {
|
|||
$keys_prefix = (string) get_parameter ('keys_prefix', '');
|
||||
// Ids of agents to be include in the SQL clause as id_agent IN ()
|
||||
$filter_agents_json = (string) get_parameter ('filter_agents_json', '');
|
||||
$status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL);
|
||||
|
||||
if (! check_acl ($config['id_user'], $id_group, "AR")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
|
@ -89,7 +90,11 @@ if (is_ajax ()) {
|
|||
$filter['string'] = $search;
|
||||
}
|
||||
|
||||
$agents = agents_get_group_agents ($id_group, $filter, "none", false, $recursion);
|
||||
if ($status_agents != AGENT_STATUS_ALL) {
|
||||
$filter['status'] = $status_agents;
|
||||
}
|
||||
|
||||
$agents = agents_get_group_agents($id_group, $filter, "none", false, $recursion);
|
||||
|
||||
// Add keys prefix
|
||||
if ($keys_prefix !== "") {
|
||||
|
|
|
@ -102,16 +102,29 @@ $table->size[3] = '35%';
|
|||
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Group');
|
||||
$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group,
|
||||
false, '', '', true);
|
||||
$table->data[0][1] = html_print_select_groups(false, "AR", true,
|
||||
'id_group', $id_group, false, '', '', true);
|
||||
$table->data[0][2] = __('Group recursion');
|
||||
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false);
|
||||
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion,
|
||||
true, false);
|
||||
|
||||
$table->data[1][0] = __('Agents');
|
||||
$table->data[1][0] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[1][0] .= html_print_image('images/spinner.png', true);
|
||||
$table->data[1][0] .= '</span>';
|
||||
$table->data[1][1] = html_print_select (agents_get_group_agents ($id_group, false, "none"),
|
||||
$status_list = array ();
|
||||
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
|
||||
$status_list[AGENT_STATUS_WARNING] = __('Warning');
|
||||
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
|
||||
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
|
||||
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||
$table->data[1][0] = __('Status');
|
||||
$table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected',
|
||||
'', __('All'), AGENT_STATUS_ALL, true);
|
||||
|
||||
$table->data[2][0] = __('Agents');
|
||||
$table->data[2][0] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[2][0] .= html_print_image('images/spinner.png', true);
|
||||
$table->data[2][0] .= '</span>';
|
||||
$table->data[2][1] = html_print_select(
|
||||
agents_get_group_agents($id_group, false, "none"),
|
||||
'id_agents[]', 0, false, '', '', true, true);
|
||||
|
||||
echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">';
|
||||
|
@ -130,15 +143,27 @@ ui_require_jquery_file ('pandora.controls');
|
|||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
var recursion;
|
||||
$("#checkbox-recursion").click(function () {
|
||||
recursion = this.checked ? 1 : 0;
|
||||
$("#id_group").trigger("change");
|
||||
$(document).ready (function () {
|
||||
var recursion;
|
||||
|
||||
$("#checkbox-recursion").click(function () {
|
||||
recursion = this.checked ? 1 : 0;
|
||||
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
status_agents: function () {
|
||||
return $("#status_agents").val();
|
||||
},
|
||||
agentSelect: "select#id_agents",
|
||||
recursion: function() {
|
||||
return recursion;
|
||||
}
|
||||
});
|
||||
|
||||
$("#status_agents").change(function() {
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
});
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
agentSelect: "select#id_agents",
|
||||
recursion: function() {return recursion}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -198,14 +198,26 @@ $table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id
|
|||
$table->data[0][2] = __('Group recursion');
|
||||
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false);
|
||||
|
||||
$table->data[1][0] = __('Agents');
|
||||
$table->data[1][0] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[1][0] .= html_print_image('images/spinner.png', true);
|
||||
$table->data[1][0] .= '</span>';
|
||||
|
||||
$status_list = array ();
|
||||
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
|
||||
$status_list[AGENT_STATUS_WARNING] = __('Warning');
|
||||
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
|
||||
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
|
||||
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||
$table->data[1][0] = __('Status');
|
||||
$table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected',
|
||||
'', __('All'), AGENT_STATUS_ALL, true);
|
||||
|
||||
$table->data[2][0] = __('Agents');
|
||||
$table->data[2][0] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[2][0] .= html_print_image('images/spinner.png', true);
|
||||
$table->data[2][0] .= '</span>';
|
||||
$enabled_agents = agents_get_group_agents ($id_group, array('disabled' => 0), "none");
|
||||
$all_agents = agents_get_group_agents ($id_group, array('disabled' => 1), "none") + $enabled_agents;
|
||||
|
||||
$table->data[1][1] = html_print_select ($all_agents,
|
||||
$table->data[2][1] = html_print_select ($all_agents,
|
||||
'id_agents[]', 0, false, '', '', true, true);
|
||||
|
||||
echo '<form method="post" id="form_agent" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_agents">';
|
||||
|
@ -463,9 +475,16 @@ $(document).ready (function () {
|
|||
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
agentSelect: "select#id_agents",
|
||||
status_agents: function () {
|
||||
return $("#status_agents").val();
|
||||
},
|
||||
recursion: function() {return recursion}
|
||||
});
|
||||
|
||||
$("#status_agents").change(function() {
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
|
||||
$("#id_group").pandoraSelectGroupAgentDisabled ({
|
||||
agentSelect: "select#id_agents",
|
||||
recursion: function() {return recursion}
|
||||
|
|
|
@ -820,6 +820,36 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
|
|||
unset ($search["name"]);
|
||||
}
|
||||
|
||||
if (isset($search['status'])) {
|
||||
switch ($search['status']) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$search_sql .=
|
||||
" AND normal_count = total_count";
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
$search_sql .=
|
||||
" AND critical_count = 0 AND warning_count > 0";
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$search_sql .=
|
||||
" AND critical_count > 0";
|
||||
break;
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
$search_sql .=
|
||||
" AND critical_count = 0 AND warning_count = 0
|
||||
AND unknown_count > 0";
|
||||
break;
|
||||
case AGENT_STATUS_NOT_NORMAL:
|
||||
$search_sql .= " AND normal_count <> total_count";
|
||||
break;
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$search_sql .= " AND notinit_count = total_count";
|
||||
break;
|
||||
}
|
||||
unset($search['status']);
|
||||
}
|
||||
|
||||
|
||||
if (! empty ($search)) {
|
||||
$search_sql .= ' AND '.db_format_array_where_clause_sql ($search);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
var dummyFunc = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
var _pandoraSelectGroupAgent = function (disabled) {
|
||||
var that = this;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
agentSelect: "select#id_agent",
|
||||
status_agents: -1,
|
||||
recursion: 0,
|
||||
filter_agents_json: "",
|
||||
loading: "#agent_loading",
|
||||
|
@ -18,22 +19,22 @@
|
|||
debug: false,
|
||||
disabled: disabled || false,
|
||||
};
|
||||
|
||||
|
||||
/* public methods */
|
||||
this.construct = function (settings) {
|
||||
return this.each (function() {
|
||||
this.config = {};
|
||||
|
||||
|
||||
this.config = $.extend (this.config, that.defaults, settings);
|
||||
var config = this.config;
|
||||
|
||||
|
||||
$(this).change (function () {
|
||||
var $select = $(config.agentSelect).disable ();
|
||||
$(config.loading).show ();
|
||||
$("option[value!=0]", $select).remove ();
|
||||
if (! config.callbackBefore (this))
|
||||
return;
|
||||
|
||||
|
||||
var opts = {
|
||||
"page" : "godmode/groups/group_list",
|
||||
"get_group_agents" : 1,
|
||||
|
@ -41,17 +42,18 @@
|
|||
"recursion" : config.recursion,
|
||||
"filter_agents_json" : config.filter_agents_json,
|
||||
"disabled" : config.disabled ? 1 : 0,
|
||||
"status_agents" : config.status_agents,
|
||||
// Add a key prefix to avoid auto sorting in js object conversion
|
||||
"keys_prefix" : "_"
|
||||
};
|
||||
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
opts,
|
||||
function (data, status) {
|
||||
jQuery.each (data, function (id, value) {
|
||||
// Remove keys_prefix from the index
|
||||
id = id.substring(1);
|
||||
if (id !== 'keycount'){
|
||||
if (id !== 'keycount') {
|
||||
config.callbackPre ();
|
||||
option = $("<option></option>")
|
||||
.attr ("value", id)
|
||||
|
@ -137,7 +139,7 @@
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -162,7 +164,7 @@
|
|||
this.config = $.extend (this.config, $.pandoraSelectAgentAlert.defaults, settings);
|
||||
|
||||
var config = this.config;
|
||||
|
||||
|
||||
$(this).change (function () {
|
||||
var $select = $(config.alertSelect).disable ();
|
||||
$(config.loading).show ();
|
||||
|
@ -212,7 +214,7 @@
|
|||
this.config = $.extend (this.config, $.pandoraSelectOS.defaults, settings);
|
||||
|
||||
var config = this.config;
|
||||
|
||||
|
||||
$(this).change (function () {
|
||||
var id_os = this.value;
|
||||
|
||||
|
@ -259,7 +261,7 @@
|
|||
this.config = $.extend (this.config, $.pandoraSelectGroupIcon.defaults, settings);
|
||||
|
||||
var config = this.config;
|
||||
|
||||
|
||||
$(this).change (function () {
|
||||
var id_group = this.value;
|
||||
|
||||
|
|
|
@ -383,7 +383,13 @@ foreach ($modules as $module) {
|
|||
$data = array ();
|
||||
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
|
||||
if ($module["flag"] == 0) {
|
||||
$data[0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module["id_agente_modulo"].'&flag=1&refr=60">' . html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '</a>';
|
||||
$data[0] = '<a href="index.php?' .
|
||||
'sec=estado&' .
|
||||
'sec2=operation/agentes/ver_agente&' .
|
||||
'id_agente=' . $id_agente . '&' .
|
||||
'id_agente_modulo=' . $module["id_agente_modulo"] . '&' .
|
||||
'flag=1&' .
|
||||
'refr=60">' . html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '</a>';
|
||||
}
|
||||
else {
|
||||
$data[0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module["id_agente_modulo"].'&refr=60">' . html_print_image("images/refresh.png", true, array("border" => "0", "title" => __("Refresh"))) . '</a>';
|
||||
|
|
|
@ -52,7 +52,8 @@ if (is_ajax ()) {
|
|||
if ($id_group > 0) {
|
||||
$groups = array($id_group);
|
||||
if ($recursion) {
|
||||
$groups = array_merge($groups, groups_get_id_recursive($id_group, true));
|
||||
$groups = array_merge($groups,
|
||||
groups_get_id_recursive($id_group, true));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -61,13 +62,14 @@ if (is_ajax ()) {
|
|||
$groups = array_keys($groups_orig);
|
||||
}
|
||||
|
||||
$filter = " WHERE id_grupo IN (". implode(',', $groups) .") ORDER BY nombre ASC";
|
||||
$filter = " WHERE id_grupo IN (" . implode(',', $groups) . ")
|
||||
ORDER BY nombre ASC";
|
||||
$agents = db_get_all_rows_sql("SELECT id_agente, nombre
|
||||
FROM tagente" . $filter);
|
||||
|
||||
// Add keys prefix
|
||||
if ($keys_prefix !== "") {
|
||||
foreach($agents as $k => $v) {
|
||||
foreach ($agents as $k => $v) {
|
||||
$agents[$keys_prefix . $k] = $v;
|
||||
unset($agents[$k]);
|
||||
}
|
||||
|
@ -689,7 +691,8 @@ if ($flag !== '') {
|
|||
if ($flag == 1 && check_acl ($config['id_user'], $id_grupo, "AW")) {
|
||||
$id_agent_module = get_parameter('id_agente_modulo');
|
||||
|
||||
db_process_sql_update('tagente_modulo', array('flag' => 1), array('id_agente_modulo' => $id_agent_module));
|
||||
db_process_sql_update('tagente_modulo',
|
||||
array('flag' => 1), array('id_agente_modulo' => $id_agent_module));
|
||||
}
|
||||
}
|
||||
// Check for Network FLAG change request
|
||||
|
|
Loading…
Reference in New Issue