Merge branch 'ent-3595-discovery-fase-2' of https://brutus.artica.lan:8081/artica/pandorafms into ent-3595-discovery-fase-2

Former-commit-id: a9ac8888641116a4e98fbe7ac2d99901e771f275
This commit is contained in:
alejandro-campos 2019-03-26 15:42:47 +01:00
commit 0d8322aeda
5 changed files with 112 additions and 56 deletions

View File

@ -433,7 +433,7 @@ class DiscoveryTaskList extends Wizard
// Name task. // Name task.
$data[1] = ''; $data[1] = '';
if ($task['disabled'] != 2) { if ($task['disabled'] != 2) {
$data[1] .= '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\',\''.$url_ajax.'\')">'; $data[1] .= '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
} }
$data[1] .= '<b>'.$task['name'].'</b>'; $data[1] .= '<b>'.$task['name'].'</b>';
@ -504,7 +504,7 @@ class DiscoveryTaskList extends Wizard
} }
if ($task['disabled'] != 2) { if ($task['disabled'] != 2) {
$data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\',\''.$url_ajax.'\')">'; $data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image( $data[9] .= html_print_image(
'images/eye.png', 'images/eye.png',
true true
@ -513,7 +513,7 @@ class DiscoveryTaskList extends Wizard
} }
if ($task['disabled'] != 2 && $task['utimestamp'] > 0) { if ($task['disabled'] != 2 && $task['utimestamp'] > 0) {
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\',\''.$url_ajax.'\')">'; $data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image( $data[9] .= html_print_image(
'images/dynamic_network_icon.png', 'images/dynamic_network_icon.png',
true true
@ -566,6 +566,9 @@ class DiscoveryTaskList extends Wizard
$data[9] = ''; $data[9] = '';
} }
// Div neccesary for modal progress task.
echo '<div id="progress_task_'.$task['id_rt'].'" style="display:none"></div>';
array_push($table->data, $data); array_push($table->data, $data);
} }
@ -577,8 +580,8 @@ class DiscoveryTaskList extends Wizard
html_print_table($table); html_print_table($table);
} }
// Div neccesary for modal progress task. // Div neccesary for modal map task.
echo '<div id="progress_task" style="display:none"></div>'; echo '<div id="map_task" style="display:none"></div>';
unset($table); unset($table);

View File

@ -43,7 +43,7 @@ if ($progress_task_discovery) {
$global_progress = $task['status']; $global_progress = $task['status'];
$summary = json_decode($task['summary'], true); $summary = json_decode($task['summary'], true);
$result = ''; $result = '<div id = progress_task_'.$id_task.'>';
$result .= '<ul class="progress_task_discovery">'; $result .= '<ul class="progress_task_discovery">';
$result .= '<li><h1>'._('Overall Progress').'</h1></li>'; $result .= '<li><h1>'._('Overall Progress').'</h1></li>';
$result .= '<li>'; $result .= '<li>';
@ -57,6 +57,7 @@ if ($progress_task_discovery) {
'', '',
'#FFFFFF', '#FFFFFF',
0, 0,
0,
0 0
); );
@ -98,6 +99,7 @@ if ($progress_task_discovery) {
'', '',
'#FFFFFF', '#FFFFFF',
0, 0,
0,
0 0
); );
$result .= '</li>'; $result .= '</li>';
@ -139,10 +141,12 @@ if ($progress_task_discovery) {
$table->data[$i][1] .= $summary['summary']['WMI']; $table->data[$i][1] .= $summary['summary']['WMI'];
$table->data[$i++][1] .= '</span>'; $table->data[$i++][1] .= '</span>';
$result .= html_print_table($table, true); $result .= html_print_table($table, true).'</div>';
echo $result; $result_array['status'] = $global_progress;
$result_array['html'] = $result;
echo json_encode($result_array);
return; return;
} }

View File

@ -364,7 +364,8 @@ function d3_progress_bar(
$text='', $text='',
$fill_color='#FFFFFF', $fill_color='#FFFFFF',
$radiusx=10, $radiusx=10,
$radiusy=10 $radiusy=10,
$transition=1
) { ) {
global $config; global $config;
@ -387,6 +388,7 @@ function d3_progress_bar(
'".$fill_color."', '".$fill_color."',
".(int) $radiusx.', ".(int) $radiusx.',
'.(int) $radiusy.', '.(int) $radiusy.',
'.(int) $transition.'
); );
</script>'; </script>';

View File

@ -1784,7 +1784,8 @@ function progress_bar_d3(
label, label,
label_color, label_color,
radiusx, radiusx,
radiusy radiusy,
transition
) { ) {
var startPercent = 0; var startPercent = 0;
var endPercent = parseInt(percentile) / 100; var endPercent = parseInt(percentile) / 100;
@ -1844,8 +1845,11 @@ function progress_bar_d3(
progress_front.attr("width", width * bar_progress); progress_front.attr("width", width * bar_progress);
} }
if (transition == 0) {
var bar_progress = endPercent;
updateProgress(bar_progress);
} else {
var bar_progress = startPercent; var bar_progress = startPercent;
(function loops() { (function loops() {
updateProgress(bar_progress); updateProgress(bar_progress);
@ -1856,6 +1860,7 @@ function progress_bar_d3(
} }
})(); })();
} }
}
function progress_bubble_d3( function progress_bubble_d3(
recipient, recipient,

View File

@ -1,44 +1,82 @@
/** /*
* global $
* @param {*} id global jQuery
* @param {*} name
*/ */
function progress_task_list(id, name, url) {
var params = [];
params.push("page=include/ajax/task_list.ajax");
params.push("progress_task_discovery=1");
params.push("id=" + id);
jQuery.ajax({ /**
data: params.join("&"), * Function for create modal with progress task
type: "POST", * and recalculate 3 second.
url: (action = url), * @param {int} id
dataType: "html", * @param {string} name
success: function(data) { */
$("#progress_task") function progress_task_list(id, title) {
var timeoutRef = null;
var xhr = null;
var $elem = $("#progress_task_" + id);
$elem
.hide() .hide()
.empty() .empty()
.append(data)
.dialog({ .dialog({
title: "Task: " + name, title: title,
resizable: true,
draggable: true, draggable: true,
modal: false, modal: false,
width: 600, width: 600,
height: 400 height: 420,
}) close: function() {
.show(); if (xhr != null) xhr.abort();
if (timeoutRef != null) clearTimeout(timeoutRef);
}
});
// Function var.
var handleFetchTaskList = function(err, data) {
if (err) {
// TODO: Show info about the problem.
}
if (data.status > 0) {
$elem.html(data.html);
if (!$elem.dialog("isOpen")) $elem.dialog("open");
}
if (data.status != -1) {
timeoutRef = setTimeout(function() {
xhr = fetchTaskList(id, handleFetchTaskList);
}, 3000);
}
};
xhr = fetchTaskList(id, handleFetchTaskList);
}
/**
* Function that performs ajax request to return
* the progress of the task.
* @param {int} id Id task.
* @param {function} callback Function callback.
*/
function fetchTaskList(id, callback) {
return jQuery.ajax({
data: {
page: "include/ajax/task_list.ajax",
progress_task_discovery: 1,
id: id
},
type: "POST",
url: "ajax.php",
dataType: "json",
success: function(data) {
callback(null, data);
},
error: function() {
callback(new Error("cannot fetch the list"));
} }
}); });
} }
function show_map(id, name, url) { function show_map(id, name) {
var params = []; $("#map_task")
params.push("page=include/ajax/task_list.ajax");
params.push("showmap=1");
params.push("id=" + id);
$("#progress_task")
.empty() .empty()
.hide() .hide()
.append("<p>Loading map</p>") .append("<p>Loading map</p>")
@ -53,12 +91,16 @@ function show_map(id, name, url) {
.show(); .show();
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: {
page: "include/ajax/task_list.ajax",
showmap: 1,
id: id
},
type: "POST", type: "POST",
url: (action = url), url: "ajax.php",
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
$("#progress_task") $("#map_task")
.empty() .empty()
.append(data); .append(data);
} }