#7076 Added force remote check

This commit is contained in:
Daniel Maya 2021-12-21 09:33:55 +01:00
parent ed4e1e4be4
commit db72cba1d2
2 changed files with 78 additions and 0 deletions

View File

@ -36,6 +36,7 @@ $ajax = true;
$render_map = (bool) get_parameter('render_map', false); $render_map = (bool) get_parameter('render_map', false);
$graph_javascript = (bool) get_parameter('graph_javascript', false); $graph_javascript = (bool) get_parameter('graph_javascript', false);
$force_remote_check = (bool) get_parameter('force_remote_check', false);
if ($render_map) { if ($render_map) {
$width = (int) get_parameter('width', '400'); $width = (int) get_parameter('width', '400');
@ -55,3 +56,36 @@ if ($render_map) {
); );
return; 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;
}

View File

@ -398,6 +398,17 @@ if ($pure === false) {
echo '</div>'; echo '</div>';
if ($aclWrite === true || $aclManage === true) { if ($aclWrite === true || $aclManage === true) {
if (!is_metaconsole()) {
echo '<a id ="force_check" href="" style="margin-right: 25px;">'.html_print_image(
'images/target.png',
true,
[
'title' => __('Force remote checks'),
'class' => 'invert_filter',
]
).'</a>';
}
echo html_print_checkbox_switch('edit-mode', 1, false, true); echo html_print_checkbox_switch('edit-mode', 1, false, true);
} }
@ -671,12 +682,14 @@ if ($edit_capable === true) {
if ($(this).prop('checked')) { if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode(); visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0); visualConsoleManager.changeUpdateInterval(0);
$('#force_check').hide();
$('#edit-controls').css('visibility', ''); $('#edit-controls').css('visibility', '');
} else { } else {
visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems(); visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms. visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden'); $('#edit-controls').css('visibility', 'hidden');
$('#force_check').show();
} }
}); });
<?php <?php
@ -750,6 +763,37 @@ if ($edit_capable === true) {
}); });
$('#force_check').click(function (e) {
e.preventDefault();
visualConsoleManager.changeUpdateInterval(0);
const id_layout = '<?php echo $visualConsoleId; ?>';
$.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(<?php echo ($refr * 1000); ?>);
}
/** /**
* Process ajax responses and shows a dialog with results. * Process ajax responses and shows a dialog with results.
*/ */