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

@ -217,10 +217,13 @@ $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;
@ -275,70 +278,3 @@ 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);
@ -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) {
@ -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

@ -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) {
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;
}
})
@ -2238,8 +2266,8 @@ function ui_print_agent_autocomplete_input($parameters) {
//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;');
}
$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,8 +32,9 @@ 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 (/>/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');
@ -53,6 +55,7 @@ Array.prototype.in_array = function () {
if(this[j] == arguments[0])
return true;
}
return false;
};

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,91 +296,8 @@ 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;
}
}
});
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");
}
});
function change_action() {
/* <![CDATA[ */
function change_action() {
type = $("#export_type").val();
var f = document.forms.export_form;
@ -388,12 +314,6 @@ function change_action() {
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

@ -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'));
@ -707,7 +650,6 @@ $(document).ready( function() {
document.getElementById(divid).style.display = 'none';
}
}
});
/* ]]> */

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>';
@ -815,6 +820,7 @@ foreach ($result as $event) {
else {
$data[$i] = '';
}
$i++;
}
@ -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('');
@ -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,7 +1360,8 @@ $(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",
{
"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
@ -1370,7 +1388,9 @@ $(document).ready( 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;
}
@ -1396,7 +1416,7 @@ $(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 {
@ -1416,7 +1436,7 @@ $(document).ready( function() {
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update){
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
@ -1467,8 +1487,6 @@ $(document).ready( function() {
});
}
});
});
/* ]]> */
</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
@ -511,8 +501,3 @@ if (isset ($id_inc)) {
}
}
?>
<script>
$(document).ready (function () {
//agent_autocomplete('#text-agent', '#hidden-server_name', '#hidden-id_agent');
});
</script>