2012-09-13 Miguel de Dios <miguel.dedios@artica.es>

* operation/incidents/incident_detail.php,
	operation/agentes/exportdata.php, operation/events/events_list.php,
	operation/events/events.php, godmode/events/event_edit_filter.php,
	godmode/massive/massive_edit_agents.php, include/functions_api.php,
	include/constants.php, include/javascript/pandora.js,
	include/functions_ui.php: started to use the new function
	"ui_print_agent_autocomplete_input" to make more easy (and standar)
	the autocomplete agent input.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6974 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-09-13 17:47:21 +00:00
parent 1fcb387ac7
commit 1fdbcd86f6
11 changed files with 339 additions and 523 deletions

View File

@ -1,3 +1,14 @@
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
* operation/incidents/incident_detail.php,
operation/agentes/exportdata.php, operation/events/events_list.php,
operation/events/events.php, godmode/events/event_edit_filter.php,
godmode/massive/massive_edit_agents.php, include/functions_api.php,
include/constants.php, include/javascript/pandora.js,
include/functions_ui.php: started to use the new function
"ui_print_agent_autocomplete_input" to make more easy (and standar)
the autocomplete agent input.
2012-09-13 Sergio Martin <sergio.martin@artica.es>
* include/styles/pandora_legacy.css

View File

@ -80,7 +80,7 @@ else {
$search = '';
$text_agent = __('All');
$pagination = '';
$event_view_hr = '';
$event_view_hr = '';
$id_user_ack = '';
$group_rep = '';
$tag = '';
@ -101,14 +101,14 @@ if ($update) {
$id_user_ack = get_parameter('id_user_ack', '');
$group_rep = get_parameter('group_rep', '');
$tag = get_parameter('tag', '');
$filter_only_alert = get_parameter('filter_only_alert','');
$filter_only_alert = get_parameter('filter_only_alert','');
if ($id_name == '') {
ui_print_error_message (__('Not updated. Blank name'));
}
else {
$values = array ('id_filter' => $id,
'id_name' => $id_name,
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
@ -125,7 +125,7 @@ if ($update) {
);
$result = db_process_sql_update ('tevent_filter', $values, array ('id_filter' => $id));
ui_print_result_message ($result,
__('Successfully updated'),
__('Not updated. Error updating data'));
@ -150,7 +150,7 @@ if ($create) {
$values = array (
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
@ -190,46 +190,49 @@ $table->data[0][1] = html_print_input_text ('id_name', $id_name, false, 20, 80,
$table->data[1][0] = '<b>'.__('Filter group').'</b>' . ui_print_help_tip(__('This group will be use to restrict the visibility of this filter with ACLs'), true);
$table->data[1][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'id_group_filter', $id_group_filter, '', '', -1, true,
false, false);
$own_info['is_admin'], 'id_group_filter', $id_group_filter, '', '', -1, true,
false, false);
$table->data[2][0] = '<b>'.__('Group').'</b>';
$table->data[2][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'id_group', $id_group, '', '', -1, true,
false, false);
$own_info['is_admin'], 'id_group', $id_group, '', '', -1, true,
false, false);
$types = get_event_types ();
// Expand standard array to add not_normal (not exist in the array, used only for searches)
$types["not_normal"] = __("Not normal");
$types["not_normal"] = __("Not normal");
$table->data[3][0] = '<b>' . __('Event type') . '</b>';
$table->data[3][1] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true);
$table->data[4][0] = '<b>' . __('Severity') . '</b>';
$table->data[4][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true);
$fields = events_get_all_status();
$table->data[5][0] = '<b>' . __('Event status') . '</b>';
$table->data[5][1] = html_print_select ($fields, 'status', $status, '', '', '', true);
$table->data[6][0] = '<b>' . __('Free search') . '</b>';
$table->data[6][1] = html_print_input_text ('search', io_safe_output($search), '', 15, 255, true);
$table->data[7][0] = '<b>' . __('Agent search') . '</b>';
$src_code = html_print_image('images/lightning.png', true, false, true);
$table->data[7][1] = html_print_input_text_extended ('text_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '',
array('style' => 'background: url(' . $src_code . ') no-repeat right;'), true)
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
$params = array();
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'text_agent';
$params['selectbox_group'] = 'id_group';
$params['value'] = $text_agent;
$table->data[7][1] = ui_print_agent_autocomplete_input($params);
$lpagination[25] = 25;
$lpagination[50] = 50;
$lpagination[100] = 100;
$lpagination[200] = 200;
$lpagination[500] = 500;
$lpagination[500] = 500;
$table->data[8][0] = '<b>' . __('Block size for pagination') . '</b>';
$table->data[8][1] = html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"], true);
$table->data[9][0] = '<b>' . __('Max. hours old') . '</b>';
$table->data[9][1] = html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255, true);
@ -257,7 +260,7 @@ $table->data[12][1] = html_print_select ($tags_name, "tag", $tag, '', __('All'),
$table->data[13][0] = '<b>' . __('Alert events') . '</b>';
$table->data[13][1] = html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true);
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/event_edit_filter">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
@ -274,71 +277,4 @@ echo '</div>';
echo '</form>';
ui_require_jquery_file ('bgiframe');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready( function() {
$("#text_id_agent").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
var data_params = {
page: "include/ajax/agent",
"search_agents_2": 1,
id_group: function() { return $("#id_group").val(); },
"q": term};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="ajax.php",
timeout: 10000,
dataType: "json",
success: function (data) {
response(data);
return;
}
});
return;
},
select: function( event, ui ) {
var agent_name = ui.item.name;
//Put the name
$(this).val(agent_name);
return false;
}
})
.data( "autocomplete")._renderItem = function( ul, item ) {
if ((item.ip == "") || (typeof(item.ip) == "undefined")) {
text = "<a>" + item.name + "</a>";
}
else {
text = "<a>" + item.name
+ "<br><span style=\"font-size: 70%; font-style: italic;\">IP:" + item.ip + "</span></a>";
}
return $("<li></li>")
.data("item.autocomplete", item)
.append(text)
.appendTo(ul);
};
//Force the size of autocomplete
$(".ui-autocomplete").css("max-height", "100px");
$(".ui-autocomplete").css("overflow-y", "auto");
/* prevent horizontal scrollbar */
$(".ui-autocomplete").css("overflow-x", "hidden");
/* add padding to account for vertical scrollbar */
$(".ui-autocomplete").css("padding-right", "20px");
//Force to style of items
$(".ui-autocomplete").css("text-align", "left");
});
/* ]]> */
</script>
?>

View File

@ -236,9 +236,12 @@ $groups = users_get_groups ($config["id_user"], "AR",false);
$agents = agents_get_group_agents (array_keys ($groups));
$table->data[0][0] = __('Parent');
$table->data[0][1] = html_print_input_text_extended ('id_parent', agents_get_name ($id_parent), 'text-id_parent', '', 30, 100, false, '',
array('style' => 'background: url(images/lightning.png) no-repeat right;'), true)
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
$params = array();
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'id_parent';
$params['value'] = agents_get_name ($id_parent);
$table->data[0][1] = ui_print_agent_autocomplete_input($params);
$table->data[0][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). "&nbsp;" . ui_print_help_icon("cascade_protection", true);
@ -377,7 +380,7 @@ if ($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if ($custom_value === false) {
@ -413,17 +416,12 @@ ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe');
ui_require_jquery_file ('autocomplete');
?>
<script type="text/javascript">
/* <![CDATA[ */
//Use this function for change 3 icons when change the selectbox
$(document).ready (function () {
function get_n_conf_files(idAgents) {
}
$("#id_agents").change (function () {
var idAgents = Array();
jQuery.each ($("#id_agents option:selected"), function (i, val) {
@ -447,7 +445,7 @@ $(document).ready (function () {
},
"json"
);
$("#form_agents").attr("style", "");
});
@ -457,29 +455,6 @@ $(document).ready (function () {
$("select#id_os").pandoraSelectOS ();
$("#text-id_parent").autocomplete ("ajax.php",
{
scroll: true,
minChars: 2,
extraParams: {
page: "godmode/agentes/agent_manager",
search_parents: 1,
id_group: function() { return $("#group").val(); },
id_agent: <?php echo $id_agente ?>
},
formatItem: function (data, i, total) {
if (total == 0)
$("#text-id_parent").css ('background-color', '#cc0000');
else
$("#text-id_parent").css ('background-color', '');
if (data == "")
return false;
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
},
delay: 200
}
);
var recursion;
$("#checkbox-recursion").click(function (){
recursion = this.checked ? 1 : 0;

View File

@ -99,7 +99,7 @@ switch ($config["dbtype"]) {
define ('BACKUP_FULLPATH', $config['homedir'] . '/' . BACKUP_DIR);
break;
case "oracle":
define ('BACKUP_DIR', 'DATA_PUMP_DIR');
define ('BACKUP_DIR', 'DATA_PUMP_DIR');
define ('BACKUP_FULLPATH', 'DATA_PUMP_DIR');
break;
}

View File

@ -37,7 +37,7 @@ enterprise_include_once ('include/functions_local_components.php');
* @return mixed
*/
function parseOtherParameter($other, $otherType) {
switch ($otherType) {
case 'url_encode':
$returnVar = array('type' => 'string', 'data' => urldecode($other));
@ -4737,7 +4737,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$pagination = $filter['limit'];
if (isset($filter['offset']))
$offset = $filter['offset'];
if (isset($filter['id_group'])) {
if (isset($filter['id_group'])) {
$id_group = $filter['id_group'];
//A little hack to make the query fetch all groups and not only "All" (with id=0)
if ($id_group == 0)

View File

@ -2047,6 +2047,11 @@ function ui_print_agent_autocomplete_input($parameters) {
$input_id = $parameters['input_id'];
}
$selectbox_group = ''; //Default value
if (isset($parameters['selectbox_group'])) {
$selectbox_group = $parameters['selectbox_group'];
}
//Default value
$icon_image = html_print_image('images/lightning.png', true, false, true);
if (isset($parameters['icon_image'])) {
@ -2103,6 +2108,16 @@ function ui_print_agent_autocomplete_input($parameters) {
$disabled = $parameters['disabled'];
}
$selectbox_id = 'id_agent_module'; //Default value
if (isset($parameters['selectbox_id'])) {
$selectbox_id = $parameters['selectbox_id'];
}
$add_none_module = true; //Default value
if (isset($parameters['add_none_module'])) {
$add_none_module = $parameters['add_none_module'];
}
// Javascript configurations
//-----------------------------------------
$javascript = true; //Default value
@ -2110,11 +2125,6 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript = $parameters['javascript'];
}
$selectbox_id = 'id_agent_module'; //Default value
if (isset($parameters['selectbox_id'])) {
$selectbox_id = $parameters['selectbox_id'];
}
$javascript_is_function_select = false; //Default value
if (isset($parameters['javascript_is_function_select'])) {
$javascript_is_function_select = $parameters['javascript_is_function_select'];
@ -2130,11 +2140,13 @@ function ui_print_agent_autocomplete_input($parameters) {
function function_select_' . $input_name . '(agent_name) {
$("#' . $selectbox_id . '").empty ();
var inputs = [];
inputs.push ("agent_name=" + agent_name);
inputs.push ("filter=delete_pending = 0");
inputs.push ("get_agent_modules_json=1");
inputs.push ("page=operation/agentes/ver_agente");
jQuery.ajax ({
data: inputs.join ("&"),
type: "GET",
@ -2142,9 +2154,11 @@ function ui_print_agent_autocomplete_input($parameters) {
timeout: 10000,
dataType: "json",
success: function (data) {
$("#' . $selectbox_id . '")
.append($("<option></option>")
.attr("value", 0).text("--"));
if (' . ((int)$add_none_module) . ') {
$("#' . $selectbox_id . '")
.append($("<option></option>")
.attr("value", 0).text("--"));
}
jQuery.each (data, function(i, val) {
s = js_html_entity_decode(val["nombre"]);
@ -2166,7 +2180,7 @@ function ui_print_agent_autocomplete_input($parameters) {
}
//Default value
$javascript_page = 'godmode/agentes/agent_manager';
$javascript_page = 'include/ajax/agent';
if (isset($parameters['javascript_page'])) {
$javascript_page = $parameters['javascript_page'];
}
@ -2181,7 +2195,16 @@ function ui_print_agent_autocomplete_input($parameters) {
var data_params = {
"page": "' . $javascript_page . '",
"search_parents_2": 1,
"search_agents_2": 1,
id_group: function() {
var group_id = 0;
if (' . ((int)!empty($selectbox_group)) . ') {
group_id = $("#' . $selectbox_group . '").val();
}
return group_id;
},
"q": term};
jQuery.ajax ({
@ -2202,6 +2225,7 @@ function ui_print_agent_autocomplete_input($parameters) {
},
select: function( event, ui ) {
var agent_name = ui.item.name;
var agent_id = ui.item.id;
//Put the name
$(this).val(agent_name);
@ -2210,6 +2234,10 @@ function ui_print_agent_autocomplete_input($parameters) {
' . $javascript_name_function_select . '(agent_name);
}
if (' . ((int)$print_hidden_input_idagent) . ') {
$("#' . $hidden_input_idagent_id . '").val(agent_id);
}
return false;
}
})
@ -2227,19 +2255,19 @@ function ui_print_agent_autocomplete_input($parameters) {
.append(text)
.appendTo(ul);
};
//Force the size of autocomplete
$(".ui-autocomplete").css("max-height", "100px");
$(".ui-autocomplete").css("overflow-y", "auto");
/* prevent horizontal scrollbar */
$(".ui-autocomplete").css("overflow-x", "hidden");
/* add padding to account for vertical scrollbar */
$(".ui-autocomplete").css("padding-right", "20px");
//Force to style of items
$(".ui-autocomplete").css("text-align", "left");
}
';
//Force the size of autocomplete
$(".ui-autocomplete").css("max-height", "100px");
$(".ui-autocomplete").css("overflow-y", "auto");
/* prevent horizontal scrollbar */
$(".ui-autocomplete").css("overflow-x", "hidden");
/* add padding to account for vertical scrollbar */
$(".ui-autocomplete").css("padding-right", "20px");
//Force to style of items
$(".ui-autocomplete").css("text-align", "left");
}';
if (isset($parameters['javascript_function_change'])) {
$javascript_function_change = $parameters['javascript_function_change'];
}
@ -2262,10 +2290,8 @@ function ui_print_agent_autocomplete_input($parameters) {
$html = '';
$attrs = '';
if ($show_helptip) {
$attrs = array('style' => 'background: url(' . $icon_image . ') no-repeat right;');
}
$attrs = array('style' => 'background: url(' . $icon_image . ') no-repeat right;');
$html = html_print_input_text_extended($input_name, $value,
$input_id, $helptip_text, $size, $maxlength, $disabled, '', $attrs, true);

View File

@ -4,7 +4,8 @@ var ENTERPRISE_DIR = 'enterprise';
function toggleDiv (divid){
if (document.getElementById(divid).style.display == 'none') {
document.getElementById(divid).style.display = 'block';
} else {
}
else {
document.getElementById(divid).style.display = 'none';
}
}
@ -31,10 +32,11 @@ function js_html_entity_decode (str) {
return "";
str2 = str.replace (/</g, "&lt;").
replace (/>/g,"&gt;").replace(/&lt;/g,'<').replace(/&gt;/g,'>')
.replace(/&#92;/g,'\\').replace(/&quot;/g,'\"').replace(/&#039;/g,'\'')
.replace(/&amp;/g,'&').replace(/&#x20;/g,' ')
.replace(/&#13;/g, '\r').replace(/&#10;/g, '\n');
replace (/>/g,"&gt;").replace(/&lt;/g,'<')
.replace(/&gt;/g,'>').replace(/&#92;/g,'\\')
.replace(/&quot;/g,'\"').replace(/&#039;/g,'\'')
.replace(/&amp;/g,'&').replace(/&#x20;/g,' ')
.replace(/&#13;/g, '\r').replace(/&#10;/g, '\n');
return str2;
}
@ -53,6 +55,7 @@ Array.prototype.in_array = function () {
if(this[j] == arguments[0])
return true;
}
return false;
};
@ -173,50 +176,50 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
homedir = event.data.homedir;
jQuery.post (homedir + '/ajax.php',
{"page": "operation/agentes/ver_agente",
"get_agent_modules_json_for_multiple_agents": 1,
"id_agent[]": idAgents,
"all": find_modules,
"custom_condition": custom_condition,
"selection_mode": selection_mode
},
function (data) {
$('#module').empty ();
if (isEmptyObject(data)) {
var noneText = $("#none_text").html(); //Trick for catch the translate text.
if (noneText == null) {
noneText = 'None';
}
$('#module').append ($('<option></option>').html (noneText).attr ("None", "").attr('selected', true));
return;
}
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
}
}
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
$('#module').append ($('<option></option>').html (s).attr ("value", i));
$('#module').fadeIn ('normal');
});
{"page": "operation/agentes/ver_agente",
"get_agent_modules_json_for_multiple_agents": 1,
"id_agent[]": idAgents,
"all": find_modules,
"custom_condition": custom_condition,
"selection_mode": selection_mode
},
function (data) {
$('#module').empty ();
if (isEmptyObject(data)) {
var noneText = $("#none_text").html(); //Trick for catch the translate text.
if (noneText == null) {
noneText = 'None';
}
$('#module').append ($('<option></option>').html (noneText).attr ("None", "").attr('selected', true));
return;
}
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
}
}
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
$('#module').append ($('<option></option>').html (s).attr ("value", i));
$('#module').fadeIn ('normal');
});
if (selected != undefined)
$('#module').attr ('value', selected);
$('#module').css ("width", "auto");
@ -347,28 +350,28 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
else {
if (typeof(data['any_text']) != 'undefined') {
$('#agents').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#agents').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
}
}
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
$('#agents').append ($('<option></option>').html (s).attr ("value", val));
$('#agents').fadeIn ('normal');
});
if (selected != undefined)
$('#agents').attr ('value', selected);
$('#agents').removeAttr('disabled');
},
"json"
);
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#agents').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
}
}
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
$('#agents').append ($('<option></option>').html (s).attr ("value", val));
$('#agents').fadeIn ('normal');
});
if (selected != undefined)
$('#agents').attr ('value', selected);
$('#agents').removeAttr('disabled');
},
"json"
);
}
/**

View File

@ -190,7 +190,9 @@ if (empty($export_btn)) {
$groups = users_get_groups ($config['id_user'], "AR");
$table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "group", $group, 'submit_group();', '', 0, true, false, true, 'w130', false);
$table->data[0][1] = html_print_select_groups($config['id_user'],
"AR", true, "group", $group, '', '', 0, true, false, true,
'w130', false);
//Agent selector
$table->data[1][0] = '<b>'.__('Source agent').'</b>';
@ -212,9 +214,16 @@ if (empty($export_btn)) {
//Src code of lightning image with skins
$src_code = html_print_image ('images/lightning.png', true, false, true);
$table->data[1][1] = html_print_input_text_extended ('agent', agents_get_name ($agent), 'text-agent', '', 40, 100, false, '',
array('style' => "background: url($src_code) no-repeat right;"), true)
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
$params = array();
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'agent';
$params['selectbox_group'] = 'group';
$params['value'] = agents_get_name ($agent);
$params['javascript_is_function_select'] = true;
$params['add_none_module'] = false;
$params['selectbox_id'] = 'module_arr';
$table->data[1][1] = ui_print_agent_autocomplete_input($params);
//Module selector
$table->data[2][0] = '<b>'.__('Modules').'</b>';
@ -279,7 +288,7 @@ if (empty($export_btn)) {
// Submit button
echo '<div class="action-buttons" style="width:98%;">';
html_print_button (__('Export'), 'export_btn', $disabled_export_button, 'change_action()', 'class="sub wand"');
html_print_button (__('Export'), 'export_btn', false, 'change_action()', 'class="sub wand"');
echo '</div></form>';
}
ui_require_jquery_file ('pandora.controls');
@ -287,113 +296,24 @@ ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
var inputActive = true;
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=operation/agentes/exportdata&search_agents=1&id_group=" + $("#group").val(),
success: function(msg){
if (msg.length == 0) {
$("#text-agent").css ('background-color', '#FF8080');
$("#text-agent").val("<?php echo __("No agents in this category");?>");
$("#text-agent").attr("disabled", true);
$("#text-agent").css ('color', '#000000');
inputActive = false;
}
/* <![CDATA[ */
function change_action() {
type = $("#export_type").val();
var f = document.forms.export_form;
switch (type) {
case 'csv':
f.action = "operation/agentes/exportdata.csv.php";
break;
case 'excel':
f.action = "operation/agentes/exportdata.excel.php";
break;
case 'avg':
case 'data':
f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata&export_btn=1";
break;
}
});
if (inputActive) {
$("#text-agent").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
var data_params = {
page: "include/ajax/agent",
search_agents_2: 1,
id_group: function() { return $("#group").val(); },
"q": term};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="ajax.php",
timeout: 10000,
dataType: "json",
success: function (data) {
response(data);
return;
}
});
return;
},
select: function( event, ui ) {
var agent_name = ui.item.name;
//Put the name
$(this).val(agent_name);
this.form.submit();
return false;
}
})
.data( "autocomplete")._renderItem = function( ul, item ) {
if ((item.ip == "") || (typeof(item.ip) == "undefined")) {
text = "<a>" + item.name + "</a>";
}
else {
text = "<a>" + item.name
+ "<br><span style=\"font-size: 70%; font-style: italic;\">IP:" + item.ip + "</span></a>";
}
return $("<li></li>")
.data("item.autocomplete", item)
.append(text)
.appendTo(ul);
};
//Force the size of autocomplete
$(".ui-autocomplete").css("max-height", "100px");
$(".ui-autocomplete").css("overflow-y", "auto");
/* prevent horizontal scrollbar */
$(".ui-autocomplete").css("overflow-x", "hidden");
/* add padding to account for vertical scrollbar */
$(".ui-autocomplete").css("padding-right", "20px");
//Force to style of items
$(".ui-autocomplete").css("text-align", "left");
$("#export_form").submit();
}
});
function change_action() {
type = $("#export_type").val();
var f = document.forms.export_form;
switch (type) {
case 'csv':
f.action = "operation/agentes/exportdata.csv.php";
break;
case 'excel':
f.action = "operation/agentes/exportdata.excel.php";
break;
case 'avg':
case 'data':
f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata&export_btn=1";
break;
}
$("#export_form").submit();
}
function submit_group() {
var f = document.forms.export_form;
f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata";
f.form.submit();
}
/* ]]> */
/* ]]> */
</script>

View File

@ -78,7 +78,7 @@ if (is_ajax ()) {
$event = events_get_event ($id);
if ($event === false)
return;
alerts_agent_module_standby ($event['id_alert_am'], 1);
return;
}
@ -88,13 +88,13 @@ if (is_ajax ()) {
$similars = (bool) get_parameter ('similars');
$comment = (string) get_parameter ('comment');
$new_status = get_parameter ('new_status');
// Set off the standby mode when close an event
if($new_status == 1) {
$event = events_get_event ($id);
alerts_agent_module_standby ($event['id_alert_am'], 0);
}
$return = events_validate_event ($id, $similars, $comment, $new_status);
if ($return)
echo 'ok';
@ -277,7 +277,7 @@ if ($config["pure"] == 0) {
}
ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $onheader);
?>
<script type="text/javascript">
function openSoundEventWindow() {
@ -348,7 +348,7 @@ if ($validate) {
__('Could not be set in process'));
}
}
if ($standby_alert) {
foreach($ids as $id) {
$event = events_get_event ($id);
@ -389,63 +389,6 @@ ui_require_jquery_file ('bgiframe');
/* <![CDATA[ */
$(document).ready( function() {
$("#text_id_agent").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
var data_params = {
"page": "godmode/agentes/agent_manager",
"search_parents_2": 1,
"q": term};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="ajax.php",
timeout: 10000,
dataType: "json",
success: function (data) {
response(data);
return;
}
});
return;
},
select: function( event, ui ) {
var agent_name = ui.item.name;
//Put the name
$(this).val(agent_name);
return false;
}
})
.data( "autocomplete")._renderItem = function( ul, item ) {
if (item.ip == "") {
text = "<a>" + item.name + "</a>";
}
else {
text = "<a>" + item.name
+ "<br><span style=\"font-size: 70%; font-style: italic;\">IP:" + item.ip + "</span></a>";
}
return $("<li></li>")
.data("item.autocomplete", item)
.append(text)
.appendTo(ul);
};
//Force the size of autocomplete
$(".ui-autocomplete").css("max-height", "100px");
$(".ui-autocomplete").css("overflow-y", "auto");
/* prevent horizontal scrollbar */
$(".ui-autocomplete").css("overflow-x", "hidden");
/* add padding to account for vertical scrollbar */
$(".ui-autocomplete").css("padding-right", "20px");
//Force to style of items
$(".ui-autocomplete").css("text-align", "left");
$("input[name=allbox]").change (function() {
$("input[name='eventid[]']").attr('checked', $(this).attr('checked'));
@ -531,7 +474,7 @@ $(document).ready( function() {
function (data, status) {
$("#comment_row_"+id).html(data);
});
// Get event comment in header
jQuery.post ("ajax.php",
{"page" : "operation/events/events",
@ -645,7 +588,7 @@ $(document).ready( function() {
"get_comment" : 1,
"id" : id
},
function (data, status) {
function (data, status) {
$("#comment_row_"+id).html(data);
});
@ -656,7 +599,7 @@ $(document).ready( function() {
"id" : id
},
function (data, status) {
$("#comment_header_"+id).html(data);
$("#comment_header_"+id).html(data);
});
}
@ -707,13 +650,12 @@ $(document).ready( function() {
document.getElementById(divid).style.display = 'none';
}
}
});
/* ]]> */
function toggleCommentForm(id_event) {
display = $('.event_form_' + id_event).css('display');
$('#select_validate_' + id_event).change (function() {
$option = $('#select_validate_' + id_event).val();
if ($option == 2) {
@ -738,7 +680,7 @@ $(document).ready( function() {
function toggleVisibleExtendedInfo(id_event) {
display = $('.event_info_' + id_event).css('display');
if (display != 'none') {
$('.event_info_' + id_event).css('display', 'none');
}
@ -746,4 +688,4 @@ $(document).ready( function() {
$('.event_info_' + id_event).css('display', '');
}
}
</script>
</script>

View File

@ -308,14 +308,19 @@ html_print_input_text ('search', io_safe_output($search), '', 15);
echo '</td>';
//Agent search
$src_code = html_print_image('images/lightning.png', true, false, true);
echo "<td>".__('Agent search')."</td><td>";
html_print_input_text_extended ('text_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '',
array('style' => 'background: url(' . $src_code . ') no-repeat right;'))
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
echo "<td>" . __('Agent search') . "</td>";
echo '<td class="datos">';
$params = array();
$params['show_helptip'] = false;
$params['input_name'] = 'id_agent';
$params['value'] = $text_agent;
ui_print_agent_autocomplete_input($params);
echo '</td>';
echo "</td></tr>";
echo "</tr>";
// User selectable block size
echo '<tr><td>';
@ -765,7 +770,7 @@ foreach ($result as $event) {
if (in_array('id_agentmodule',$show_fields)) {
$data[$i] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$event["id_agente"].'&amp;tab=data">'
.db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).'</a>';
.db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event["id_agentmodule"]).'</a>';
$i++;
}
@ -776,7 +781,7 @@ foreach ($result as $event) {
WHERE id IN (SELECT id_alert_template
FROM talert_template_modules
WHERE id = ' . $event["id_alert_am"] . ');';
$templateName = db_get_sql($sql);
$data[$i] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$event["id_agente"].'&amp;tab=alert">'.$templateName.'</a>';
}
@ -785,7 +790,7 @@ foreach ($result as $event) {
}
$i++;
}
if (in_array('criticity',$show_fields)) {
$data[$i] = get_priority_name ($event["criticity"]);
$i++;
@ -815,7 +820,8 @@ foreach ($result as $event) {
else {
$data[$i] = '';
}
$i++;
$i++;
}
if (in_array('source',$show_fields)) {
@ -835,7 +841,7 @@ foreach ($result as $event) {
if (($event["estado"] != 1) and (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1)) {
$data[$i] .= '<a href="javascript: toggleCommentForm(' . $event['id_evento'] . ')" id="validate-'.$event["id_evento"].'">';
$data[$i] .= html_print_image ("images/ok.png", true,
array ("title" => __('Validate event')));
array ("title" => __('Validate event')));
$data[$i] .= '</a>&nbsp;';
}
else {
@ -854,12 +860,12 @@ foreach ($result as $event) {
array ("title" => __('Is not allowed delete events in process'))).'&nbsp;';
}
}
$data[$i] .= '<a href="javascript: toggleVisibleExtendedInfo(' . $event["id_evento"] . ');">';
$data[$i] .= html_print_image ("images/eye.png", true,
array ("title" => __('Show more')));
array ("title" => __('Show more')));
$data[$i] .= '</a>&nbsp;';
// Create incident from this event
if (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
if(isset($config['integria_enabled']) && $config['integria_enabled'] == 1) {
@ -874,7 +880,7 @@ foreach ($result as $event) {
$data[$i] .= '</a>';
}
$i++;
if (check_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
//Checkbox
$data[$i] = html_print_checkbox_extended ("eventid[]", $event["id_evento"], false, false, false, 'class="chk"', true);
@ -889,16 +895,16 @@ foreach ($result as $event) {
$string .= '<td align="left" width="450px"><b>' . html_print_textarea("comment_".$event["id_evento"], 2, 10, '', 'style="min-height: 10px; width: 250px;"', true) . '</b></td>';
$string .= '<td align="left" width="200px">';
$string .= '<div style="text-align:center;">';
if($event["estado"] == 0) {
$string .= html_print_select(array('1' => __('Validate'), '2' => __('Set in process'), '3' => __('Add comment')), 'select_validate_'.$event["id_evento"], '', '', '', 0, true, false, false, 'select_validate').'<br><br>';
}
if($event["estado"] == 2) {
$string .= html_print_select(array('1' => __('Validate'), '3' => __('Add comment')), 'select_validate_'.$event["id_evento"], '', '', '', 0, true, false, false, 'select_validate').'<br><br>';
}
$string .= '<a class="validate_event" href="javascript: toggleCommentForm(' . $event['id_evento'] . ')" id="validate-'.$event["id_evento"].'">';
$string .= html_print_button (__('Update'), 'validate', false, '', 'class="sub ok validate_event" id="validate-'.$event["id_evento"].'"', true).'</div>';
$string .= '</a>';
$string .= '</td><td width="400px">';
@ -915,14 +921,14 @@ foreach ($result as $event) {
$table->colspan[$idx][0] = 10;
$table->rowstyle[$idx] = 'display: none;';
array_push ($table->data, $data);
//Hiden row with extended description
$string = '<table width="99%" style="border:solid 1px #D3D3D3;" class="toggle" cellpadding="6"><tr>';
$string .= '<td align="left" valign="top" width="25%" border="solid 1px">';
$string .= '<b>' . __('Event ID') . '</b></td><td align="left">';
$string .= io_safe_output($event["id_evento"]);
$string .= '</td></tr><tr class="rowOdd">';
$string .= '<td align="left" valign="top" width="25%" border="solid 1px">';
$string .= '<b>' . __('Event name') . '</b></td><td align="left">';
$string .= io_safe_output($event["evento"]);
@ -953,7 +959,7 @@ foreach ($result as $event) {
$string .= date ($config["date_format"], strtotime($event["timestamp"]));
}
$string .= '</td></tr><tr>';
$odd = 'rowOdd';
$string .= '<td align="left" valign="top" width="15%">';
@ -965,7 +971,7 @@ foreach ($result as $event) {
$string .= '<i>- ' . __('Empty') . ' -</i>';
}
$string .= '</td></tr><tr class="'. $odd .'">';
$odd = ($odd == '')? 'rowOdd' : '';
if ($event["id_agentmodule"] != 0) {
@ -1053,7 +1059,7 @@ foreach ($result as $event) {
$string .= '</td></tr><tr class="' . $odd . '">';
$odd = ($odd == '')? 'rowOdd' : '';
}
$string .= '</td></tr>';
$odd = ($odd == '')? 'rowOdd' : '';
$string .= '<tr class="' . $odd . '"><td align="left" valign="top">' . '<b>' . __('Comments') . '</td><td id="comment_row_' . $event['id_evento'] . '" align="left">';
@ -1085,7 +1091,7 @@ foreach ($result as $event) {
$string .= '<i>- ' . __('Empty') . ' -</i>';
$odd = ($odd == '')? 'rowOdd' : '';
}
$string .= '<tr class="' . $odd . '"><td align="left" valign="top">' . '<b>' . __('Source') . '</td><td align="left">';
if ($event["source"] != '') {
$string .= $event["source"];
@ -1157,6 +1163,17 @@ foreach ($result as $event) {
$string .= '</td></tr>';
}
$string .= '<tr class="' . $odd . '"><td align="left" valign="top">' . '<b>' . __('Unknown instructions') . '</td><td align="left">';
if ($event["unknown_instructions"] != '') {
$string .= $event["unknown_instructions"];
$string .= '</td></tr><tr>';
$odd = ($odd == '')? 'rowOdd' : '';
}
else {
$string .= '<i>- ' . __('Empty') . ' -</i>';
}
$string .= '</td></tr>';
$string .= '</table>';
$data = array($string);
@ -1210,7 +1227,6 @@ unset ($table);
/*
<![CDATA[ */
$(document).ready( function() {
// Don't collapse filter if update button has been pushed
if ($("#hidden-toogle_filter").val() == 'false'){
$("#event_control").toggle ();
@ -1224,7 +1240,7 @@ $(document).ready( function() {
$("#filter_id").change(function () {
// If selected 'none' flush filter
if ( $("#filter_id").val() == 0 ){
if ( $("#filter_id").val() == 0 ) {
$("#text-id_name").val('');
$("#ev_group").val(0);
$("#event_type").val('');
@ -1238,9 +1254,9 @@ $(document).ready( function() {
$("#group_rep").val(1);
$("#tag").val('');
$("#filter_only_alert").val(-1);
$("#row_name").css('visibility', 'hidden');
$("#row_name").css('visibility', 'hidden');
$("#submit-update_filter").css('visibility', 'hidden');
$("#id_group").val(0);
$("#id_group").val(0);
}
// If filter selected then load filter
else {
@ -1253,35 +1269,35 @@ $(document).ready( function() {
},
function (data) {
jQuery.each (data, function (i, val) {
if (i == 'id_name')
$("#text-id_name").val(val);
if (i == 'id_group')
$("#ev_group").val(val);
if (i == 'event_type')
$("#event_type").val(val);
if (i == 'severity')
$("#severity").val(val);
if (i == 'status')
$("#status").val(val);
if (i == 'search')
$("#text-search").val(val);
if (i == 'text_agent')
$("#text_id_agent").val(val);
if (i == 'pagination')
$("#pagination").val(val);
if (i == 'event_view_hr')
$("#text-event_view_hr").val(val);
if (i == 'id_user_ack')
$("#id_user_ack").val(val);
if (i == 'group_rep')
$("#group_rep").val(val);
if (i == 'tag')
$("#tag").val(val);
if (i == 'filter_only_alert')
$("#filter_only_alert").val(val);
if (i == 'id_group_filter')
$("#id_group").val(val);
});
if (i == 'id_name')
$("#text-id_name").val(val);
if (i == 'id_group')
$("#ev_group").val(val);
if (i == 'event_type')
$("#event_type").val(val);
if (i == 'severity')
$("#severity").val(val);
if (i == 'status')
$("#status").val(val);
if (i == 'search')
$("#text-search").val(val);
if (i == 'text_agent')
$("#text_id_agent").val(val);
if (i == 'pagination')
$("#pagination").val(val);
if (i == 'event_view_hr')
$("#text-event_view_hr").val(val);
if (i == 'id_user_ack')
$("#id_user_ack").val(val);
if (i == 'group_rep')
$("#group_rep").val(val);
if (i == 'tag')
$("#tag").val(val);
if (i == 'filter_only_alert')
$("#filter_only_alert").val(val);
if (i == 'id_group_filter')
$("#id_group").val(val);
});
},
"json"
);
@ -1293,7 +1309,8 @@ $(document).ready( function() {
// Checks if the filter has name or not
if ($('#row_name').css('visibility') == 'hidden') {
$('#row_name').css('visibility', '');
$('#show_filter_error').html('<h3 class="error"> <?php echo __('Define name and group for the filter and click on Save filter again'); ?> </h3>');
$('#show_filter_error')
.html('<h3 class="error"> <?php echo __('Define name and group for the filter and click on Save filter again'); ?> </h3>');
$('#filter_name_color').css('color', '#CC0000');
$('#filter_group_color').css('color', '#CC0000');
// If the filter has name insert in database
@ -1343,36 +1360,39 @@ $(document).ready( function() {
$('#filter_id').append ($('<option></option>').html ( <?php echo "'" . __('none') . "'" ?> ).attr ("value", 0));
// Reload filters select
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_save){
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
{
"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_save){
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
$("#submit-update_filter").css('visibility', '');
}
return false;
});
// This updates an event filter
$("#submit-update_filter").click(function () {
$("#submit-update_filter").click(function () {
// If the filter name is blank show error
if ($('#text-id_name').val() == '') {
$('#show_filter_error').html('<h3 class="error"> <?php echo __('Filter name cannot be left blank'); ?> </h3>');
$('#show_filter_error')
.html('<h3 class="error"> <?php echo __('Filter name cannot be left blank'); ?> </h3>');
return false;
}
}
var id_filter_update = $("#filter_id").val();
@ -1388,7 +1408,7 @@ $(document).ready( function() {
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
@ -1396,13 +1416,13 @@ $(document).ready( function() {
"id_group_filter": $("#id_group").val()
},
function (data) {
if (data == 'ok'){
if (data == 'ok') {
$('#show_filter_error').html('<h3 class="suc"> <?php echo __('Filter updated'); ?> </h3>');
}
else {
$('#show_filter_error').html('<h3 class="error"> <?php echo __('Error updating filter'); ?> </h3>');
}
});
});
// First remove all options of filters select
$('#filter_id').find('option').remove().end();
@ -1415,20 +1435,20 @@ $(document).ready( function() {
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update){
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
}
});
},
"json"
);
"json"
);
return false;
});
return false;
});
// Change toggle arrow when it's clicked
$("#tgl_event_control").click(function() {
@ -1447,7 +1467,7 @@ $(document).ready( function() {
success: function (data) {
$("#toggle_arrow").attr('src', data);
}
});
});
}
else {
var params = [];
@ -1467,8 +1487,6 @@ $(document).ready( function() {
});
}
});
});
/* ]]> */
</script>
</script>

View File

@ -340,17 +340,7 @@ echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="datos"><b>'.__('Agent').'</b></td>';
echo '<td class="datos">';
//html_print_input_hidden('id_agent', $id_agent);
//html_print_input_text_extended ('agent', agents_get_name ($id_agent), 'text-agent', '', 30, 100, false, '', array('style' => 'background: url(images/lightning.png) no-repeat right;'));
//ui_print_help_tip(__("Type at least two characters to search"), false);
echo '</td>';
echo '</tr>';
//////////
echo '<tr>';
echo '<td class="datos"><b>'.__('Teste').'</b></td>';
echo '<td class="datos"><b>' . __('Agent') . '</b></td>';
echo '<td class="datos">';
$params = array();
$params['show_helptip'] = true;
@ -389,9 +379,9 @@ echo "</div></form>";
//If we're actually working on an incident
if (isset ($id_inc)) {
// ********************************************************************
//******************************************************************
// Notes
// ********************************************************************
//******************************************************************
echo '<div>';
@ -439,9 +429,9 @@ if (isset ($id_inc)) {
unset ($table);
// ************************************************************
//******************************************************************
// Files attached to this incident
// ************************************************************
//******************************************************************
$result = incidents_get_attach ($id_inc);
@ -487,9 +477,9 @@ if (isset ($id_inc)) {
}
unset ($table);
// ************************************************************
//******************************************************************
// Upload control
// ************************************************************
//******************************************************************
// Upload control
@ -510,9 +500,4 @@ if (isset ($id_inc)) {
</table></form></div>';
}
}
?>
<script>
$(document).ready (function () {
//agent_autocomplete('#text-agent', '#hidden-server_name', '#hidden-id_agent');
});
</script>
?>