Minor fixes

This commit is contained in:
fbsanchez 2020-03-19 14:26:01 +01:00
parent 7870114f6c
commit 32c6e7f30c
2 changed files with 14 additions and 11 deletions

View File

@ -2873,10 +2873,12 @@ function ui_progress(
$text = $progress.'%'; $text = $progress.'%';
} }
$id = uniqid();
ui_require_css_file('progress'); ui_require_css_file('progress');
$output .= '<span class="progress_main" data-label="'.$text; $output .= '<span id="'.$id.'" class="progress_main" data-label="'.$text;
$output .= '" style="width: '.$width.'; height: '.$height.'em; border: 1px solid '.$color.'">'; $output .= '" style="width: '.$width.'; height: '.$height.'em; border: 1px solid '.$color.'">';
$output .= '<span class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>'; $output .= '<span id="'.$id.'_progress" class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>';
$output .= '</span>'; $output .= '</span>';
if ($ajax !== false && is_array($ajax)) { if ($ajax !== false && is_array($ajax)) {
@ -2900,8 +2902,8 @@ function ui_progress(
success: function(data) { success: function(data) {
try { try {
val = JSON.parse(data); val = JSON.parse(data);
$(".progress_main").attr("data-label", val + " %"); $("#'.$id.'").attr("data-label", val + " %");
$(".progress").width(val+"%"); $("#'.$id.'_progress").width(val+"%");
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@ -2914,8 +2916,8 @@ function ui_progress(
$output .= '<script type="text/javascript"> $output .= '<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
setInterval(() => { setInterval(() => {
last = $(".progress_main").attr("data-label").split(" ")[0]*1; last = $("#'.$id.'").attr("data-label").split(" ")[0]*1;
width = $(".progress").width() / $(".progress").parent().width() * 100; width = $("#'.$id.'_progress").width() / $("#'.$id.'_progress").parent().width() * 100;
width_interval = '.$ajax['interval'].'; width_interval = '.$ajax['interval'].';
if (last % 10 == 0) { if (last % 10 == 0) {
$.post({ $.post({
@ -2934,21 +2936,21 @@ function ui_progress(
success: function(data) { success: function(data) {
try { try {
val = JSON.parse(data); val = JSON.parse(data);
$(".progress_main").attr("data-label", val["last_contact"]+" s"); $("#'.$id.'").attr("data-label", val["last_contact"]+" s");
$(".progress").width(val["progress"]+"%"); $("#'.$id.'_progress").width(val["progress"]+"%");
} catch (e) { } catch (e) {
console.error(e); console.error(e);
$(".progress_text").attr("data-label", (last -1) + " s"); $(".progress_text").attr("data-label", (last -1) + " s");
if (width < 100) { if (width < 100) {
$(".progress").width((width+width_interval) + "%"); $("#'.$id.'_progress").width((width+width_interval) + "%");
} }
} }
} }
}); });
} else { } else {
$(".progress_main").attr("data-label", (last -1) + " s"); $("#'.$id.'").attr("data-label", (last -1) + " s");
if (width < 100) { if (width < 100) {
$(".progress").width((width+width_interval) + "%"); $("#'.$id.'_progress").width((width+width_interval) + "%");
} }
} }
}, 1000); }, 1000);

View File

@ -732,6 +732,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
if (is_enabled($module->{'__module_component'})) { if (is_enabled($module->{'__module_component'})) {
# Module from network component. # Module from network component.
delete $module->{'__module_component'};
$agentmodule_id = pandora_create_module_from_network_component( $agentmodule_id = pandora_create_module_from_network_component(
$self->{'pa_config'}, $self->{'pa_config'},
$module, $module,