Merge branch 'ent-6000-operaciones-masivas-de-servicios' into 'develop'

Ent 6000 operaciones masivas de servicios

See merge request artica/pandorafms!3361
This commit is contained in:
Alejandro Fraguas 2020-07-09 17:02:59 +02:00
commit ddc8a98dc0
11 changed files with 280 additions and 18 deletions

View File

@ -1,15 +1,5 @@
START TRANSACTION;
ALTER TABLE `tservice_element` ADD COLUMN `rules` text;
ALTER TABLE `tservice` ADD COLUMN `unknown_as_critical` tinyint(1) NOT NULL default 0 AFTER `warning`;
UPDATE `tservice` SET `auto_calculate`=0;
UPDATE `tservice` SET `cps`= `cps` - 1 WHERE `cps` > 0;
UPDATE `tagente` SET `cps`= `cps` - 1 WHERE `cps` > 0;
UPDATE `tagente_modulo` SET `cps`= `cps` - 1 WHERE `cps` > 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `manufacturer_id` varchar(200) NOT NULL;
ALTER TABLE `tnetwork_component` ADD COLUMN `protocol` tinytext NOT NULL;
ALTER TABLE `tnetwork_component` ADD COLUMN `module_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;

View File

@ -0,0 +1,12 @@
START TRANSACTION;
ALTER TABLE `tservice_element` ADD COLUMN `rules` text;
ALTER TABLE `tservice` ADD COLUMN `unknown_as_critical` tinyint(1) NOT NULL default 0 AFTER `warning`;
UPDATE `tservice` SET `auto_calculate`=0;
UPDATE `tservice` SET `cps`= `cps` - 1 WHERE `cps` > 0;
UPDATE `tagente` SET `cps`= `cps` - 1 WHERE `cps` > 0;
UPDATE `tagente_modulo` SET `cps`= `cps` - 1 WHERE `cps` > 0;
COMMIT;

View File

@ -1342,13 +1342,13 @@ ALTER TABLE `tmap` MODIFY COLUMN `id_user` varchar(250) NOT NULL DEFAULT '';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 39);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 40);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '747');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '748');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';

View File

@ -92,6 +92,12 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) {
$options_satellite = array_merge($options_satellite, $satellite_options);
}
$options_services = enterprise_hook('massive_services_options');
if ($options_services === ENTERPRISE_NOT_HOOK) {
$options_services = [];
}
if (in_array($option, array_keys($options_alerts))) {
$tab = 'massive_alerts';
} else if (in_array($option, array_keys($options_agents))) {
@ -108,6 +114,8 @@ if (in_array($option, array_keys($options_alerts))) {
$tab = 'massive_satellite';
} else if (in_array($option, array_keys($options_plugins))) {
$tab = 'massive_plugins';
} else if (in_array($option, array_keys($options_services))) {
$tab = 'massive_services';
}
if ($tab == 'massive_agents' && $option == '') {
@ -173,6 +181,10 @@ switch ($tab) {
$options = $options_plugins;
break;
case 'massive_services':
$options = $options_services;
break;
default:
// Default.
break;
@ -241,6 +253,11 @@ if ($satellitetab == ENTERPRISE_NOT_HOOK) {
$satellitetab = '';
}
$servicestab = enterprise_hook('massive_services_tab');
if ($servicestab == ENTERPRISE_NOT_HOOK) {
$servicestab = '';
}
$onheader = [];
$onheader['massive_agents'] = $agentstab;
@ -254,6 +271,7 @@ $onheader['massive_alerts'] = $alertstab;
$onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab;
$onheader['satellite'] = $satellitetab;
$onheader['services'] = $servicestab;
/*
Hello there! :)

View File

@ -189,6 +189,7 @@ if (check_acl($config['id_user'], 0, 'AW')) {
enterprise_hook('massivepolicies_submenu');
enterprise_hook('massivesnmp_submenu');
enterprise_hook('massivesatellite_submenu');
enterprise_hook('massiveservices_submenu');
$sub['gmassive']['sub2'] = $sub2;
}

View File

@ -13212,6 +13212,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3)
$id_group,
$critical,
$warning,
false,
SECONDS_5MINUTES,
$mode,
$id_agent,

View File

@ -794,7 +794,7 @@ function html_print_select_multiple_filtered(
}
// Main container.
$output .= '<div class="multi-select flex-row-vcenter '.$class.'">';
$output = '<div class="multi-select flex-row-vcenter '.$class.'">';
// Left box.
$output .= '<div class="multi-select-container flex-column">';
@ -941,7 +941,7 @@ function html_print_select_multiple_filtered(
$output .= '</div>';
// Left box.
// Right box.
$output .= '<div class="multi-select-container flex-column">';
// Filtering.
@ -1062,6 +1062,151 @@ function html_print_select_multiple_filtered(
}
/**
* Form multiple inputs for slect groups.
*
* @param array $data Data inputs.
*
* @return string Html output.
*/
function html_print_select_multiple_modules_filtered(array $data):string
{
if (is_ajax() === true) {
ui_require_javascript_file(
'multiselect_filtered',
'include/javascript/',
true
);
} else {
ui_require_javascript_file('multiselect_filtered');
}
$uniqId = $data['uniqId'];
// Group.
$output = '<div>';
$output .= html_print_input(
[
'label' => __('Group'),
'name' => 'filtered-module-group-'.$uniqId,
'returnAllGroup' => true,
'privilege' => 'AR',
'type' => 'select_groups',
'return' => true,
'script' => 'fmAgentChange(\''.$uniqId.'\')',
'selected' => $data['mGroup'],
]
);
// Recursion.
$output .= html_print_input(
[
'label' => __('Recursion'),
'type' => 'switch',
'name' => 'filtered-module-recursion-'.$uniqId,
'value' => (empty($data['mRecursion']) === true) ? false : true,
'checked' => (empty($data['mRecursion']) === true) ? false : true,
'return' => true,
'id' => 'filtered-module-recursion-'.$uniqId,
'onchange' => 'fmAgentChange(\''.$uniqId.'\')',
]
);
// Groups module.
$module_groups = db_get_all_rows_sql(
'SELECT * FROM tmodule_group ORDER BY name'
);
$module_groups = array_reduce(
$module_groups,
function ($carry, $item) {
$carry[$item['id_mg']] = $item['name'];
return $carry;
}
);
$output .= html_print_input(
[
'label' => __('Module group'),
'type' => 'select',
'fields' => $module_groups,
'name' => 'filtered-module-module-group-'.$uniqId,
'selected' => $data['mModuleGroup'],
'return' => true,
'nothing' => __('All'),
'nothing_value' => 0,
'script' => 'fmModuleChange(\''.$uniqId.'\')',
]
);
$output .= '</div>';
$output .= '<div>';
// Agent.
$agents = agents_get_group_agents($data['mGroup']);
if ((empty($agents)) === true || $agents == -1) {
$agents = [];
}
$output .= html_print_input(
[
'label' => __('Agents'),
'type' => 'select',
'fields' => $agents,
'name' => 'filtered-module-agents-'.$uniqId,
'selected' => explode(',', $data['mAgents']),
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\')',
]
);
// Show common modules.
$selection = [
0 => __('Show common modules'),
1 => __('Show all modules'),
];
$output .= html_print_input(
[
'label' => __('Show common modules'),
'type' => 'select',
'fields' => $selection,
'name' => 'filtered-module-show-common-modules-'.$uniqId,
'selected' => $data['mShowCommonModules'],
'return' => true,
'script' => 'fmModuleChange(\''.$uniqId.'\')',
]
);
$all_modules = select_modules_for_agent_group(
$data['mModuleGroup'],
explode(',', $data['mAgents']),
$data['mShowCommonModules'],
false
);
$output .= html_print_input(
[
'label' => __('Modules'),
'type' => 'select',
'fields' => $all_modules,
'name' => 'filtered-module-modules-'.$uniqId,
'selected' => explode(',', $data['mModules']),
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
]
);
$output .= '</div>';
if ($data['return'] === false) {
echo $output;
}
return $output;
}
/**
* Prints an array of fields in a popup menu of a form based on a SQL query.
* The first and second columns of the query will be used.
@ -4339,7 +4484,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
0 => __('Select an Agent first'),
];
} else {
$string_filter .= '';
$string_filter = '';
if ($data['get_only_string_modules'] === true) {
$string_filter = 'AND id_tipo_modulo IN (17,23,3,10,33,36)';
}
@ -4425,6 +4570,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
);
break;
case 'select_multiple_modules_filtered':
$output .= html_print_select_multiple_modules_filtered($data);
break;
default:
// Ignore.
break;

View File

@ -1,8 +1,9 @@
/* global $ */
/* global $, jQuery*/
/**
* Add modules from available to selected.
*/
// eslint-disable-next-line no-unused-vars
function addItems(id, noneStr) {
$("#available-select-" + id + " :selected")
.toArray()
@ -17,6 +18,7 @@ function addItems(id, noneStr) {
/**
* Mark all options for given id.
*/
// eslint-disable-next-line no-unused-vars
function markAll(id) {
$("#" + id + " option").prop("selected", true);
}
@ -24,6 +26,7 @@ function markAll(id) {
/**
* Remove modules from selected back to available.
*/
// eslint-disable-next-line no-unused-vars
function removeItems(id, noneStr) {
$("#selected-select-" + id + " :selected")
.toArray()
@ -69,16 +72,19 @@ function filterItems(id, str) {
});
}
// eslint-disable-next-line no-unused-vars
function filterAvailableItems(txt, id, noneStr) {
filterItems("available-select-" + id, txt);
keepSelectClean("available-select-" + id, noneStr);
}
// eslint-disable-next-line no-unused-vars
function filterSelectedItems(txt, id, noneStr) {
filterItems("selected-select-" + id, txt);
keepSelectClean("selected-select-" + id, noneStr);
}
// eslint-disable-next-line no-unused-vars
function disableFilters(id) {
$("#id-group-selected-select-" + id).prop("disabled", true);
$("#checkbox-id-group-recursion-selected-select-" + id).prop(
@ -87,6 +93,7 @@ function disableFilters(id) {
);
}
// eslint-disable-next-line no-unused-vars
function reloadContent(id, url, options, side, noneStr) {
var current;
var opposite;
@ -155,3 +162,65 @@ $(document).submit(function() {
.keyup();
$("[id^=selected-select-] option").prop("selected", true);
});
// eslint-disable-next-line no-unused-vars
function fmAgentChange(uniqId) {
var idGroup = $("#filtered-module-group-" + uniqId).val();
var recursion = $("#filtered-module-recursion-" + uniqId).is(":checked");
jQuery.post(
"ajax.php",
{
page: "operation/agentes/ver_agente",
get_agents_group_json: 1,
id_group: idGroup,
privilege: "AW",
keys_prefix: "_",
recursion: recursion
},
function(data) {
$("#filtered-module-agents-" + uniqId).html("");
$("#filtered-module-modules-" + uniqId).html("");
jQuery.each(data, function(id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
var option = $("<option></option>")
.attr("value", value["id_agente"])
.html(value["alias"]);
$("#filtered-module-agents-" + uniqId).append(option);
});
},
"json"
);
}
// eslint-disable-next-line no-unused-vars
function fmModuleChange(uniqId) {
var idModuleGroup = $("#filtered-module-module-group-" + uniqId).val();
var idAgents = $("#filtered-module-agents-" + uniqId).val();
var showCommonModules = $(
"#filtered-module-show-common-modules-" + uniqId
).val();
jQuery.post(
"ajax.php",
{
page: "operation/agentes/ver_agente",
get_modules_group_json: 1,
id_module_group: idModuleGroup,
id_agents: idAgents,
selection: showCommonModules
},
function(data) {
$("#filtered-module-modules-" + uniqId).html("");
if (data) {
jQuery.each(data, function(id, value) {
var option = $("<option></option>")
.attr("value", value["id_agente_modulo"])
.html(value["nombre"]);
$("#filtered-module-modules-" + uniqId).append(option);
});
}
},
"json"
);
}

View File

@ -285,6 +285,11 @@ class Module extends Entity
return $this->{$methodName}($params);
}
if (is_array($this->fields) === false) {
// Element deleted.
return null;
}
if (array_key_exists($methodName, $this->fields) === true) {
if (empty($params) === false) {
if ($this->is_local() === true) {

View File

@ -716,6 +716,23 @@ p.center {
text-align: center;
}
.center {
text-align: center;
}
.margin-top-10 {
margin-top: 10px;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
.margin-tb-10 {
margin-top: 10px;
margin-bottom: 10px;
}
.img_help {
cursor: help;
}

View File

@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 39),
('MR', 40),
('identification_reminder', 1),
('identification_reminder_timestamp', 0),
('current_package_enterprise', '747'),
('current_package_enterprise', '748'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),