Massive operation over service elements

This commit is contained in:
fbsanchez 2021-06-18 15:36:52 +02:00
parent bbbadff426
commit 1f34cf8596
3 changed files with 56 additions and 2 deletions

View File

@ -915,7 +915,25 @@ function html_print_select(
ui_require_javascript_file('select2.min');
}
$output .= '<script>$("#'.$id.'").select2();</script>';
$output .= '<script type="text/javascript">';
$output .= '$("#'.$id.'").select2();';
if ($required !== false) {
$require_message = __('Please select an item from this list.');
$output .= '$("#'.$id.'").on("change", function(e) {
e.currentTarget.setCustomValidity("");
});';
$output .= '$("#'.$id.'").on("invalid", function(e) {
if ($(e.currentTarget).val() == null) {
e.currentTarget.setCustomValidity(
"'.$require_message.'"
);
}
});';
}
$output .= '</script>';
}
if ($return) {

View File

@ -88,7 +88,8 @@ class Module extends Entity
* @param array $params Search parameters (fields from tagente_modulo).
* @param integer $limit Limit results to N rows.
*
* @return array|null of PandoraFMS\Module found or null if not found.
* @return object|array|null PandoraFMS\Module found if limited, array of Modules
* or null if not found.
* @throws \Exception On error.
*/
public static function search(

View File

@ -48,6 +48,7 @@ if (is_ajax()) {
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
$get_agents_group_json = (bool) get_parameter('get_agents_group_json');
$get_modules_group_json = (bool) get_parameter('get_modules_group_json');
$filter_modules_group_json = (bool) get_parameter('filter_modules_group_json');
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_json_for_multiple_agents');
$get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_alerts_json_for_multiple_agents');
@ -283,6 +284,40 @@ if (is_ajax()) {
}
}
if ($filter_modules_group_json) {
$modules = (array) get_parameter('modules', []);
$existing_modules = [];
foreach ($modules as $def) {
$data = explode('|', $def);
$id_agent = $data[0];
$module_name = $data[1];
try {
$module = PandoraFMS\Module::search(
[
'id_agente' => $id_agent,
'nombre' => $module_name,
],
1
);
if ($module !== null) {
$existing_modules[] = [
'id' => $module->id_agente_modulo(),
'text' => io_safe_output(
$module->agent()->alias().' &raquo; '.$module->nombre()
),
];
}
} catch (Exception $e) {
continue;
}
}
echo json_encode($existing_modules);
}
if ($get_modules_group_value_name_json) {
$id_agents = get_parameter('id_agents');
$selection = get_parameter('selection');