Wip command center, alerts SNMP broken

This commit is contained in:
Daniel Barbero Martin 2021-06-04 11:34:12 +02:00
parent ca59034cf3
commit da6c75f5b0
2 changed files with 31 additions and 66 deletions

View File

@ -48,7 +48,11 @@ if (is_ajax()) {
$id = (int) get_parameter('id', 0);
$get_recovery_fields = (int) get_parameter('get_recovery_fields', 1);
$is_management_allowed = !is_management_allowed();
// Snmp alerts are not in the metaconsole so they cannot be centralized.
$is_management_allowed = false;
if ($get_recovery_fields !== 0) {
$is_management_allowed = !is_management_allowed();
}
// If command ID is not provided, check for action id.
if ($id == 0) {

View File

@ -987,42 +987,21 @@ if ($create_alert || $update_alert) {
echo '</td></tr>';
// Alert type (e-mail, event etc.)
echo '<tr><td class="datos">'.__('Alert action').'</td><td class="datos">';
echo '<tr><td class="datos">'.__('Alert commands').'</td><td class="datos">';
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
html_print_select_from_sql(
'SELECT id, name
FROM talert_actions
ORDER BY name',
'alert_type',
$alert_type,
'',
'',
0,
false,
false,
false
);
break;
case 'oracle':
html_print_select_from_sql(
'SELECT id, dbms_lob.substr(name,4000,1) as name
FROM talert_actions
ORDER BY dbms_lob.substr(name,4000,1)',
'alert_type',
$alert_type,
'',
'',
0,
false,
false,
false
);
break;
}
html_print_select_from_sql(
'SELECT id, name
FROM talert_commands
ORDER BY name',
'alert_type',
$alert_type,
'',
'',
0,
false,
false,
false
);
echo '</td></tr>';
echo '<tr><td class="datos">'.__('Position').'</td><td class="datos">';
@ -1482,7 +1461,6 @@ function time_changed () {
$(document).ready (function () {
$('#time_threshold').change (time_changed);
$("input[name=all_delete_box]").change (function() {
if ($(this).is(":checked")) {
$("input[name='delete_ids[]']").check();
@ -1503,10 +1481,9 @@ $(document).ready (function () {
value: "1"
});
values.push ({
name: "id_action",
name: "id",
value: this.value
});
values.push ({
name: "get_recovery_fields",
value: "0"
@ -1515,13 +1492,11 @@ $(document).ready (function () {
values,
function (data, status) {
var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');
original_command = js_html_entity_decode (data["command"]);
command_description = js_html_entity_decode (data["description"]);
for (i = 1; i <= max_fields; i++) {
var old_value = '';
// Only keep the value if is provided from hidden (first time)
// Only keep the value if is provided from hidden (first time).
var id_field = $("[name=field" + i + "_value]").attr('id');
if (id_field == "hidden-field" + i + "_value") {
@ -1535,24 +1510,10 @@ $(document).ready (function () {
else {
$('#table_macros-field' + i).replaceWith(data["fields_rows"][i]);
// The row provided has a predefined class. We delete it
// The row provided has a predefined class. We delete it.
$('#table_macros-field' + i)
.removeAttr('class');
//Remove this to put the help message in alert commands, to do it more general
// Add help hint only in first field
/*if (i == 1) {
var td_content =
$('#table_macros-field' + i)
.find('td').eq(0);
td_content
.html(
td_content.html() +
$('#help_snmp_alert_hint').html()
);
}*/
$("[name=field" + i + "_value]").val(old_value);
$('#table_macros-field').show();
}
@ -1562,7 +1523,7 @@ $(document).ready (function () {
);
});
// Charge the fields of the action
// Charge the fields of the action.
$("#alert_type").trigger('change');
$("#submit-delete_button").click (function () {