#12001 added autoselect module in inventory
This commit is contained in:
parent
32b7a103eb
commit
73d179e52f
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Ajax script for Inventory
|
||||
*
|
||||
* @category Inventory
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprises
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Pandora FMS
|
||||
* Please see https://pandorafms.com/community/ for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
check_login();
|
||||
|
||||
if (is_ajax() === true) {
|
||||
$id_agent = get_parameter('id_agent', '0');
|
||||
$id_server = get_parameter('id_server', '0');
|
||||
if (is_metaconsole() === true) {
|
||||
$agent_modules = [];
|
||||
$server_name = metaconsole_get_names(['id' => $id_server]);
|
||||
if (is_array($server_name) === true && count($server_name) > 0) {
|
||||
$agent_modules = inventory_get_agent_modules($id_agent, 'all', $id_server, reset($server_name));
|
||||
}
|
||||
} else {
|
||||
$agent_modules = inventory_get_agent_modules($id_agent);
|
||||
}
|
||||
|
||||
echo json_encode($agent_modules);
|
||||
}
|
|
@ -680,6 +680,7 @@ $params['print_hidden_input_idagent'] = true;
|
|||
$params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent';
|
||||
$params['hidden_input_idagent_name'] = 'agent_id';
|
||||
$params['hidden_input_idagent_value'] = $inventory_id_agent;
|
||||
$params['javascript_function_action_after_select'] = 'loadModulesFromAgent';
|
||||
if ($is_metaconsole === true) {
|
||||
$params['print_input_id_server'] = true;
|
||||
$params['input_id_server_id'] = 'hidden-autocomplete_id_server';
|
||||
|
@ -1361,7 +1362,7 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript
|
|||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
<?php if (is_metaconsole() === true) : ?>
|
||||
active_inventory_submit();
|
||||
//active_inventory_submit();
|
||||
<?php endif; ?>
|
||||
$("#id_group").click (
|
||||
function () {
|
||||
|
@ -1439,5 +1440,38 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript
|
|||
closeText: '<?php echo __('Close'); ?>'
|
||||
});*/
|
||||
});
|
||||
|
||||
function loadModulesFromAgent(e){
|
||||
const id_agent = $('#hidden-autocomplete_id_agent').val();
|
||||
const text_agent = $('#text-agent').val();
|
||||
let server = 0;
|
||||
if($('#hidden-autocomplete_id_server').length > 0) {
|
||||
server = $('#hidden-autocomplete_id_server').val();
|
||||
}
|
||||
|
||||
if(text_agent === 'All') return;
|
||||
jQuery.ajax ({
|
||||
data: {
|
||||
id_agent,
|
||||
page: 'include/ajax/inventory.ajax',
|
||||
id_server: server
|
||||
},
|
||||
type: "POST",
|
||||
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data) {
|
||||
console.log(data);
|
||||
$("#module_inventory_general_view").empty();
|
||||
$("#module_inventory_general_view").append ($("<option value=basic>Basic info</option>"));
|
||||
$("#module_inventory_general_view").append ($("<option value=0>All</option>"));
|
||||
jQuery.each (data, function (id, value) {
|
||||
$("#module_inventory_general_view").append ($("<option value=" + id + ">" + value + "</option>"));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue