From da6c75f5b0a70fa909a786da88911d940cce892b Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Fri, 4 Jun 2021 11:34:12 +0200 Subject: [PATCH] Wip command center, alerts SNMP broken --- .../godmode/alerts/alert_commands.php | 6 +- .../godmode/snmpconsole/snmp_alert.php | 91 ++++++------------- 2 files changed, 31 insertions(+), 66 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 73cdafdad7..3446658987 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -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) { diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 0dc5f20a8e..32379d665c 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -987,42 +987,21 @@ if ($create_alert || $update_alert) { echo ''; // Alert type (e-mail, event etc.) - echo ''.__('Alert action').''; + echo ''.__('Alert commands').''; - 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 ''; echo ''.__('Position').''; @@ -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(); @@ -1491,9 +1469,9 @@ $(document).ready (function () { $("input[name='delete_ids[]']").uncheck(); } }); - + $("#alert_type").change (function () { - values = Array (); + values = Array (); values.push ({ name: "page", value: "godmode/alerts/alert_commands" @@ -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,44 +1492,28 @@ $(document).ready (function () { values, function (data, status) { var max_fields = parseInt(''); - 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") { old_value = $("[name=field" + i + "_value]").val(); } - + // If the row is empty, hide de row if (data["fields_rows"][i] == '') { $('#table_macros-field' + i).hide(); } 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(); } @@ -1561,17 +1522,17 @@ $(document).ready (function () { "json" ); }); - - // Charge the fields of the action + + // Charge the fields of the action. $("#alert_type").trigger('change'); - + $("#submit-delete_button").click (function () { confirmation = confirm(""); if (!confirmation) { return; } }); - + var added_config = { "selector": "textarea.tiny-mce-editor", "plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",