diff --git a/pandora_console/include/ajax/visual_console.ajax.php b/pandora_console/include/ajax/visual_console.ajax.php index 59d08a92c8..cb7e016283 100644 --- a/pandora_console/include/ajax/visual_console.ajax.php +++ b/pandora_console/include/ajax/visual_console.ajax.php @@ -36,6 +36,7 @@ $ajax = true; $render_map = (bool) get_parameter('render_map', false); $graph_javascript = (bool) get_parameter('graph_javascript', false); +$force_remote_check = (bool) get_parameter('force_remote_check', false); if ($render_map) { $width = (int) get_parameter('width', '400'); @@ -55,3 +56,36 @@ if ($render_map) { ); return; } + +if ($force_remote_check) { + $id_layout = (int) get_parameter('id_layout', false); + $data = db_get_all_rows_sql( + sprintf( + 'SELECT id_agent FROM tlayout_data WHERE id_layout = %d AND id_agent <> 0', + $id_layout + ) + ); + + if (empty($data)) { + echo '0'; + } else { + $ids = []; + foreach ($data as $key => $value) { + $ids[] = $value['id_agent']; + } + + $sql = sprintf( + 'UPDATE `tagente_modulo` SET flag = 1 WHERE `id_agente` IN (%s)', + implode(',', $ids) + ); + + $result = db_process_sql($sql); + if ($result) { + echo true; + } else { + echo '0'; + } + } + + return; +} diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 33a860ef22..8b51d0a8f6 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -398,6 +398,17 @@ if ($pure === false) { echo ''; if ($aclWrite === true || $aclManage === true) { + if (!is_metaconsole()) { + echo ''.html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force remote checks'), + 'class' => 'invert_filter', + ] + ).''; + } + echo html_print_checkbox_switch('edit-mode', 1, false, true); } @@ -671,12 +682,14 @@ if ($edit_capable === true) { if ($(this).prop('checked')) { visualConsoleManager.visualConsole.enableEditMode(); visualConsoleManager.changeUpdateInterval(0); + $('#force_check').hide(); $('#edit-controls').css('visibility', ''); } else { visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.unSelectItems(); visualConsoleManager.changeUpdateInterval(); // To ms. $('#edit-controls').css('visibility', 'hidden'); + $('#force_check').show(); } }); '; + $.ajax({ + type: "GET", + url: "ajax.php", + dataType: "json", + data: { + page: "include/ajax/visual_console.ajax", + force_remote_check: true, + id_layout: id_layout + }, + success: function (data) { + if (data == 1) { + visualConsoleManager.changeUpdateInterval(5000); + setTimeout(resetInterval, 6000); + } else { + resetInterval(); + } + }, + error: function (data) { + resetInterval(); + } + }); + }); + + function resetInterval() { + visualConsoleManager.changeUpdateInterval(); + } + /** * Process ajax responses and shows a dialog with results. */