mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
2012-09-20 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js, include/functions_api.php: cleaned source code style. And erased deprecated functions. * include/functions_ui.php: I hope that is finished the changes for the function "ui_print_agent_autocomplete_input" (at the moment) and added a huge header doc on the function. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6991 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8772c67f13
commit
f24f80c3b4
@ -1,3 +1,12 @@
|
|||||||
|
2012-09-20 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/javascript/pandora.js, include/functions_api.php: cleaned
|
||||||
|
source code style. And erased deprecated functions.
|
||||||
|
|
||||||
|
* include/functions_ui.php: I hope that is finished the changes for
|
||||||
|
the function "ui_print_agent_autocomplete_input" (at the moment) and
|
||||||
|
added a huge header doc on the function.
|
||||||
|
|
||||||
2012-09-19 Vanessa Gil <vanessa.gil@artica.es>
|
2012-09-19 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
* include/functions_api.php: Added function: tactical
|
* include/functions_api.php: Added function: tactical
|
||||||
|
@ -5351,7 +5351,6 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType) {
|
|||||||
$data = array('type' => 'string', 'data' => $total);
|
$data = array('type' => 'string', 'data' => $total);
|
||||||
|
|
||||||
returnData($returnType, $data);
|
returnData($returnType, $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5422,7 +5421,8 @@ function api_get_alert_action_by_group($id_group, $id_action, $trash2, $returnTy
|
|||||||
|
|
||||||
if ($value === false) {
|
if ($value === false) {
|
||||||
returnError('data_not_found', $returnType);
|
returnError('data_not_found', $returnType);
|
||||||
} else if ($value == '') {
|
}
|
||||||
|
else if ($value == '') {
|
||||||
$value = 0;
|
$value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2027,6 +2027,223 @@ function ui_print_page_header ($title, $icon = "", $return = false, $help = "",
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a input for agent autocomplete, this input search into your
|
||||||
|
* pandora DB (or pandoras DBs when you have metaconsole) for agents
|
||||||
|
* that have name near to equal that you are writing into the input.
|
||||||
|
*
|
||||||
|
* This generate a lot of lines of html and javascript code.
|
||||||
|
*
|
||||||
|
* @parameters array Array with several properties:
|
||||||
|
* - $parameters['return'] boolean, by default is false
|
||||||
|
* true - return as html string the code (html and js)
|
||||||
|
* false - print the code.
|
||||||
|
*
|
||||||
|
* - $parameters['input_name'] the input name (needs to get the value)
|
||||||
|
* string - The name.
|
||||||
|
* default - "agent_autocomplete_<aleatory_uniq_raw_letters/numbers>"
|
||||||
|
*
|
||||||
|
* - $parameters['input_id'] the input id (needs to get the value)
|
||||||
|
* string - The ID.
|
||||||
|
* default - "text-<input_name>"
|
||||||
|
*
|
||||||
|
* - $parameters['selectbox_group'] the id of selectbox with the group
|
||||||
|
* string - The ID of selectbox.
|
||||||
|
* default - "" empty string
|
||||||
|
*
|
||||||
|
* - $parameters['icon_image'] the small icon to show into the input in
|
||||||
|
* the right side.
|
||||||
|
* string - The url for the image.
|
||||||
|
* default - "images/lightning.png"
|
||||||
|
*
|
||||||
|
* - $parameters['value'] The initial value to set the input.
|
||||||
|
* string - The value.
|
||||||
|
* default - "" emtpy string
|
||||||
|
*
|
||||||
|
* - $parameters['show_helptip'] boolean, by default is false
|
||||||
|
* true - print the icon out the field in side right the tiny star
|
||||||
|
* for tip.
|
||||||
|
* false - does not print
|
||||||
|
*
|
||||||
|
* - $parameters['helptip_text'] The text to show in the tooltip.
|
||||||
|
* string - The text to show into the tooltip.
|
||||||
|
* default - "Type at least two characters to search." (translate)
|
||||||
|
*
|
||||||
|
* - $parameters['use_hidden_input_idagent'] boolean, Use a field for
|
||||||
|
* store the id of agent from the ajax query. By default is false.
|
||||||
|
* true - Use the field for id agent and the sourcecode work with
|
||||||
|
* this.
|
||||||
|
* false - Doesn't use the field (maybe this doesn't exist outer)
|
||||||
|
*
|
||||||
|
* - $parameters['print_hidden_input_idagent'] boolean, Print a field
|
||||||
|
* for store the id of agent from the ajax query. By default is
|
||||||
|
* false.
|
||||||
|
* true - Print the field for id agent and the sourcecode work with
|
||||||
|
* this.
|
||||||
|
* false - Doesn't print the field (maybe this doesn't exist outer)
|
||||||
|
*
|
||||||
|
* - $parameters['hidden_input_idagent_name'] The name of hidden input
|
||||||
|
* for to store the id agent.
|
||||||
|
* string - The name of hidden input.
|
||||||
|
* default - "agent_autocomplete_idagent_<aleatory_uniq_raw_letters/numbers>"
|
||||||
|
*
|
||||||
|
* - $parameters['hidden_input_idagent_id'] The id of hidden input
|
||||||
|
* for to store the id agent.
|
||||||
|
* string - The id of hidden input.
|
||||||
|
* default - "hidden-<hidden_input_idagent_name>"
|
||||||
|
*
|
||||||
|
* - $parameters['hidden_input_idagent_value'] The initial value to set
|
||||||
|
* the input id agent for store the id agent.
|
||||||
|
* string - The value.
|
||||||
|
* default - 0
|
||||||
|
*
|
||||||
|
* - $parameters['size'] The size in characters for the input of agent.
|
||||||
|
* string - A number of characters.
|
||||||
|
* default - 30
|
||||||
|
*
|
||||||
|
* - $parameters['maxlength'] The max characters that can store the
|
||||||
|
* input of agent.
|
||||||
|
* string - A number of characters max to store
|
||||||
|
* default - 100
|
||||||
|
*
|
||||||
|
* - $parameters['disabled'] Set as disabled the input of agent. By
|
||||||
|
* default is false
|
||||||
|
* true - Set disabled the input of agent.
|
||||||
|
* false - Set enabled the input of agent.
|
||||||
|
*
|
||||||
|
* - $parameters['selectbox_id'] The id of select box that stores the
|
||||||
|
* list of modules of agent select.
|
||||||
|
* string - The id of select box.
|
||||||
|
* default - "id_agent_module"
|
||||||
|
*
|
||||||
|
* - $parameters['add_none_module'] Boolean, add the list of modules
|
||||||
|
* the "none" entry, with value 0. By default is true
|
||||||
|
* true - add the none entry.
|
||||||
|
* false - does not add the none entry.
|
||||||
|
*
|
||||||
|
* - $parameters['none_module_text'] Boolean, add the list of modules
|
||||||
|
* the "none" entry, with value 0.
|
||||||
|
* string - The text to put for none module for example "select a
|
||||||
|
* module"
|
||||||
|
* default - "none" (translate)
|
||||||
|
*
|
||||||
|
* - $parameters['print_input_server'] Boolean, print the hidden field
|
||||||
|
* to store the server (metaconsole). By default false.
|
||||||
|
* true - Print the hidden input for the server.
|
||||||
|
* false - Does not print.
|
||||||
|
*
|
||||||
|
* - $parameters['use_input_server'] Boolean, use the hidden field
|
||||||
|
* to store the server (metaconsole). By default false.
|
||||||
|
* true - Use the hidden input for the server.
|
||||||
|
* false - Does not print.
|
||||||
|
*
|
||||||
|
* - $parameters['input_server_name'] The name for hidden field to
|
||||||
|
* store the server.
|
||||||
|
* string - The name of field for server.
|
||||||
|
* default - "server_<aleatory_uniq_raw_letters/numbers>"
|
||||||
|
*
|
||||||
|
* - $parameters['input_server_id'] The id for hidden field to store
|
||||||
|
* the server.
|
||||||
|
* string - The id of field for server.
|
||||||
|
* default - "hidden-<input_server_name>"
|
||||||
|
*
|
||||||
|
* - $parameters['input_server_value'] The value to store into the
|
||||||
|
* field server.
|
||||||
|
* string - The name of server.
|
||||||
|
* default - "" empty string
|
||||||
|
*
|
||||||
|
* - $parameters['metaconsole_enabled'] Boolean, set the sourcecode for
|
||||||
|
* to make some others things that run of without metaconsole. By
|
||||||
|
* default false.
|
||||||
|
* true - Set the gears for metaconsole.
|
||||||
|
* false - Run as without metaconsole.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_ajax_page'] The page to send the ajax
|
||||||
|
* queries.
|
||||||
|
* string - The url to ajax page, remember the url must be into your
|
||||||
|
* domain (ajax security).
|
||||||
|
* default - "ajax.php"
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_function_action_after_select'] The name of
|
||||||
|
* function to call after the user select a agent into the list in
|
||||||
|
* the autocomplete field.
|
||||||
|
* string - The name of function.
|
||||||
|
* default - ""
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_function_action_after_select_js_call'] The
|
||||||
|
* call of this function to call after user select a agent into the
|
||||||
|
* list in the autocomplete field. Instead the
|
||||||
|
* $parameters['javascript_function_action_after_select'], this is
|
||||||
|
* overwrite the previous element. And this is necesary when you need
|
||||||
|
* to set some params in your custom function.
|
||||||
|
* string - The call line as javascript code.
|
||||||
|
* default - ""
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_function_action_into_source'] The source
|
||||||
|
* code as block string to call when the autocomplete starts to get
|
||||||
|
* the data from ajax.
|
||||||
|
* string - A huge string with your function as javascript.
|
||||||
|
* default - ""
|
||||||
|
*
|
||||||
|
* - $parameters['javascript'] Boolean, set the autocomplete agent to
|
||||||
|
* use javascript or enabled javascript. By default true.
|
||||||
|
* true - Enabled the javascript.
|
||||||
|
* false - Disabled the javascript.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_is_function_select'] Boolean, set to
|
||||||
|
* enable to call a function when user select a agent in the
|
||||||
|
* autocomplete list. By default false.
|
||||||
|
* true - Enabled this feature.
|
||||||
|
* false - Disabled this feature.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_code_function_select'] The name of
|
||||||
|
* function to call when user select a agent in the autocomplete
|
||||||
|
* list.
|
||||||
|
* string - The name of function but remembers this function pass
|
||||||
|
* the parameter agent_name.
|
||||||
|
* default - "function_select_<input_name>"
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_name_function_select'] The source
|
||||||
|
* code as block string to call when user select a agent into the
|
||||||
|
* list in the autocomplete field. Althought use this element, you
|
||||||
|
* need use the previous parameter to set name of your custom
|
||||||
|
* function or call line.
|
||||||
|
* string - A huge string with your function as javascript.
|
||||||
|
* default - A lot of lines of source code into a string, please this
|
||||||
|
* lines you can read in the source code of function.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_change_ajax_params'] The params to pass in
|
||||||
|
* the ajax query for the list of agents.
|
||||||
|
* array - The associative array with the key and value to pass in
|
||||||
|
* the ajax query.
|
||||||
|
* default - A lot of lines of source code into a string, please this
|
||||||
|
* lines you can read in the source code of function.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_function_change'] The source code as block
|
||||||
|
* string with all javascript code to run autocomplete field.
|
||||||
|
* string - The source code javascript into a string.
|
||||||
|
* default - A lot of lines of source code into a string, please this
|
||||||
|
* lines you can read in the source code of function.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_document_ready'] Boolean, set the
|
||||||
|
* javascript sourcecode to run with the document is ready. By
|
||||||
|
* default is true.
|
||||||
|
* true - Set to run when document is ready.
|
||||||
|
* false - Not set to run.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_tags'] Boolean, print the html tags for
|
||||||
|
* javascript. By default is true.
|
||||||
|
* true - Print the javascript tags.
|
||||||
|
* false - Doesn't print the tags.
|
||||||
|
*
|
||||||
|
* - $parameters['javascript_tags'] Boolean, print the html tags for
|
||||||
|
* javascript. By default is true.
|
||||||
|
* true - Print the javascript tags.
|
||||||
|
* false - Doesn't print the tags.
|
||||||
|
*
|
||||||
|
* @return string HTML code if return parameter is true.
|
||||||
|
*/
|
||||||
function ui_print_agent_autocomplete_input($parameters) {
|
function ui_print_agent_autocomplete_input($parameters) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -2139,8 +2356,8 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$input_server_name = uniqid('server_'); //Default value
|
$input_server_name = uniqid('server_'); //Default value
|
||||||
if (isset($parameters['input_server_id'])) {
|
if (isset($parameters['input_server_name'])) {
|
||||||
$input_server_id = $parameters['input_server_id'];
|
$input_server_name = $parameters['input_server_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$input_server_id = 'hidden-' . $input_server_name; //Default value
|
$input_server_id = 'hidden-' . $input_server_name; //Default value
|
||||||
@ -2319,21 +2536,74 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
}
|
}
|
||||||
$javascript_change_ajax_params_text .= '};';
|
$javascript_change_ajax_params_text .= '};';
|
||||||
|
|
||||||
$javascript_function_change ='';
|
|
||||||
|
|
||||||
|
$spinner_image = html_print_image('images/spinner.gif', true, false, true);
|
||||||
|
|
||||||
|
|
||||||
|
$javascript_function_change = ''; //Default value
|
||||||
$javascript_function_change .='
|
$javascript_function_change .='
|
||||||
function set_functions_change_autocomplete_' . $input_name . '() {
|
function set_functions_change_autocomplete_' . $input_name . '() {
|
||||||
|
var cache_' . $input_name . ' = {};
|
||||||
|
|
||||||
$("#' . $input_id . '").autocomplete({
|
$("#' . $input_id . '").autocomplete({
|
||||||
minLength: 2,
|
minLength: 2,
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
var term = request.term; //Word to search
|
var term = request.term; //Word to search
|
||||||
|
|
||||||
' . $javascript_change_ajax_params_text . '
|
//Set loading
|
||||||
|
$("#' . $input_id . '")
|
||||||
|
.css("background","url(\"' . $spinner_image . '\") right center no-repeat");
|
||||||
|
|
||||||
//Function to call when the source
|
//Function to call when the source
|
||||||
if (' . ((int)!empty($javascript_function_action_into_source_js_call)) . ') {
|
if (' . ((int)!empty($javascript_function_action_into_source_js_call)) . ') {
|
||||||
' . $javascript_function_action_into_source_js_call . '
|
' . $javascript_function_action_into_source_js_call . '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check the cache
|
||||||
|
var found = false;
|
||||||
|
if (term in cache_' . $input_name . ') {
|
||||||
|
response(cache_' . $input_name . '[term]);
|
||||||
|
|
||||||
|
//Set icon
|
||||||
|
$("#' . $input_id . '")
|
||||||
|
.css("background","url(\"' . $icon_image . '\") right center no-repeat");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Check if other terms cached start with same
|
||||||
|
//letters.
|
||||||
|
//TODO: At the moment disabled
|
||||||
|
/*
|
||||||
|
for (i = 1; i < term.length; i++) {
|
||||||
|
var term_match = term.substr(0, term.length - i);
|
||||||
|
|
||||||
|
$.each(cache_' . $input_name . ', function (oldterm, olddata) {
|
||||||
|
var pattern = new RegExp("^" + term_match + ".*","gi");
|
||||||
|
|
||||||
|
if (oldterm.match(pattern)) {
|
||||||
|
response(cache_' . $input_name . '[oldterm]);
|
||||||
|
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
//Set icon
|
||||||
|
$("#' . $input_id . '")
|
||||||
|
.css("background","url(\"' . $icon_image . '\") right center no-repeat");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
' . $javascript_change_ajax_params_text . '
|
||||||
|
|
||||||
jQuery.ajax ({
|
jQuery.ajax ({
|
||||||
data: data_params,
|
data: data_params,
|
||||||
@ -2343,8 +2613,14 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
cache_' . $input_name . '[term] = data; //Save the cache
|
||||||
|
|
||||||
response(data);
|
response(data);
|
||||||
|
|
||||||
|
//Set icon
|
||||||
|
$("#' . $input_id . '")
|
||||||
|
.css("background","url(\"' . $icon_image . '\") right center no-repeat");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2433,10 +2709,6 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
$javascript_tags = $parameters['javascript_tags'];
|
$javascript_tags = $parameters['javascript_tags'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$javascript_code = ''; //Default value
|
|
||||||
if (isset($parameters['disabled'])) {
|
|
||||||
$disabled = $parameters['disabled'];
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
|
@ -432,243 +432,6 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------DEPRECATED------------------------------------------
|
|
||||||
/**
|
|
||||||
* Autocomplete Agent box and module selector functions.
|
|
||||||
*
|
|
||||||
* This function has all the necesary javascript to use the box with to autocomplete
|
|
||||||
* an agent name, and store it's id on a hidden field and fill a selector with the
|
|
||||||
* modules from that agent.
|
|
||||||
*
|
|
||||||
* @param id_agent_name id of the agent name box
|
|
||||||
* @param id_agent_id id of the hidden field to store the agent id
|
|
||||||
* @param id_agent_module_selector id of the selector for the modules of the agent.
|
|
||||||
*/
|
|
||||||
function agent_module_autocomplete (id_agent_name, id_agent_id, id_agent_module_selector, id_server_name, noneValue, homedir) {
|
|
||||||
//Check exist the field with id in the var id_agent_name.
|
|
||||||
if ($(id_agent_name).length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
homedir_path = '';
|
|
||||||
if (homedir == undefined)
|
|
||||||
homedir_path = '.';
|
|
||||||
else
|
|
||||||
homedir_path = homedir;
|
|
||||||
|
|
||||||
$(id_agent_name).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,
|
|
||||||
"q": term};
|
|
||||||
jQuery.ajax ({
|
|
||||||
data: data_params,
|
|
||||||
async: false,
|
|
||||||
type: 'POST',
|
|
||||||
url: action=homedir_path + "/ajax.php",
|
|
||||||
timeout: 10000,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (data) {
|
|
||||||
response(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
select: function( event, ui ) {
|
|
||||||
var agent_name = ui.item.name;
|
|
||||||
var agent_id = ui.item.id;
|
|
||||||
var server_name = ui.item.ip;
|
|
||||||
if (agent_name.indexOf("(") != -1){
|
|
||||||
var server_name_temp = agent_name.split('(');
|
|
||||||
server_name_temp1 = server_name_temp[1].split(')');
|
|
||||||
server_name = server_name_temp1[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Put the name
|
|
||||||
$(this).val(agent_name);
|
|
||||||
|
|
||||||
//Put the id
|
|
||||||
if (typeof(id_agent_id) != "undefined") {
|
|
||||||
$(id_agent_id).val(agent_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Put the server
|
|
||||||
if (typeof(id_server_name) != "undefined") {
|
|
||||||
$(id_server_name).val(server_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Fill the modules select box
|
|
||||||
$(id_agent_module_selector).fadeOut ('normal', function () {
|
|
||||||
$('#module').empty ();
|
|
||||||
|
|
||||||
var data_params = {"page": "operation/agentes/ver_agente",
|
|
||||||
"get_agent_modules_json": 1,
|
|
||||||
"id_agent": agent_id,
|
|
||||||
"server_name": server_name,
|
|
||||||
"filter" : 'disabled=0 AND delete_pending=0',
|
|
||||||
"fields" : "id_agente_modulo,nombre"};
|
|
||||||
jQuery.ajax ({
|
|
||||||
data: data_params,
|
|
||||||
type: 'POST',
|
|
||||||
url: action= homedir_path + "/ajax.php",
|
|
||||||
timeout: 10000,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (data) {
|
|
||||||
$(id_agent_module_selector).empty();
|
|
||||||
if (typeof(noneValue) != "undefined") {
|
|
||||||
if (noneValue == true) {
|
|
||||||
option = $("<option></option>")
|
|
||||||
.attr ("value", 0)
|
|
||||||
.html ("--");
|
|
||||||
$(id_agent_module_selector).append (option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jQuery.each (data, function (i, value) {
|
|
||||||
option = $("<option></option>")
|
|
||||||
.attr ("value", value['id_agente_modulo'])
|
|
||||||
.html (js_html_entity_decode (value['nombre']));
|
|
||||||
$(id_agent_module_selector).append (option);
|
|
||||||
});
|
|
||||||
$(id_agent_module_selector).fadeIn ('normal');
|
|
||||||
$(id_agent_module_selector).removeAttr('disabled');
|
|
||||||
//enable operation select box
|
|
||||||
$(noneValue).removeAttr('disabled');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
//------------------DEPRECATED------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Autocomplete Agent box functions.
|
|
||||||
*
|
|
||||||
* This function has all the necesary javascript to use the box with to autocomplete
|
|
||||||
* an agent name, and store it's id on a hidden field and fill a hidden field with
|
|
||||||
* the server.
|
|
||||||
*
|
|
||||||
* @param id_agent_name id of the agent name box
|
|
||||||
* @param id_server_name id of the hidden field to store the server but if you put false don't save.
|
|
||||||
* @param id_agent_id id of the hidden field to store the agent id
|
|
||||||
* @param metaconsole_exec If defined then path of ajax.php call will be modified
|
|
||||||
*/
|
|
||||||
function agent_autocomplete (id_agent_name, id_server_name, id_agent_id, metaconsole_exec ) {
|
|
||||||
//Check exist the field with id in the var id_agent_name.
|
|
||||||
if ($(id_agent_name).length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Correction over ajax call for metaconsole
|
|
||||||
ajax_path = '';
|
|
||||||
if (metaconsole_exec != undefined)
|
|
||||||
ajax_path = '../../';
|
|
||||||
|
|
||||||
$(id_agent_name).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,
|
|
||||||
"q": term};
|
|
||||||
|
|
||||||
jQuery.ajax ({
|
|
||||||
data: data_params,
|
|
||||||
async: false,
|
|
||||||
type: 'POST',
|
|
||||||
url: action= ajax_path + "ajax.php",
|
|
||||||
timeout: 10000,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (data) {
|
|
||||||
response(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
select: function( event, ui ) {
|
|
||||||
var agent_id = ui.item.id;
|
|
||||||
var server_name = ui.item.ip;
|
|
||||||
var agent_name = ui.item.name;
|
|
||||||
|
|
||||||
//Put the name
|
|
||||||
$(this).val(agent_name);
|
|
||||||
|
|
||||||
//Put the id
|
|
||||||
if (typeof(id_agent_id) != "undefined") {
|
|
||||||
$(id_agent_id).val(agent_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Put the server
|
|
||||||
if (typeof(id_server_name) != "undefined"
|
|
||||||
|| typeof(id_server_name) != "boolean") {
|
|
||||||
$(id_server_name).val(server_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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init values for html_extended_select_for_time
|
* Init values for html_extended_select_for_time
|
||||||
*
|
*
|
||||||
@ -698,7 +461,6 @@ function period_select_init(name) {
|
|||||||
$('#'+name+'_manual').show();
|
$('#'+name+'_manual').show();
|
||||||
$('#'+name+'_default').hide();
|
$('#'+name+'_default').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user