diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
index 2cedd211d4..d5d970a502 100644
--- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
+++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
@@ -432,7 +432,7 @@ class DiscoveryTaskList extends Wizard
// Name task.
$data[1] = '';
if ($task['disabled'] != 2) {
- $data[1] .= '';
+ $data[1] .= '';
}
$data[1] .= ''.$task['name'].'';
@@ -503,7 +503,7 @@ class DiscoveryTaskList extends Wizard
}
if ($task['disabled'] != 2) {
- $data[9] = '';
+ $data[9] = '';
$data[9] .= html_print_image(
'images/eye.png',
true
@@ -512,7 +512,7 @@ class DiscoveryTaskList extends Wizard
}
if ($task['disabled'] != 2 && $task['utimestamp'] > 0) {
- $data[9] .= '';
+ $data[9] .= '';
$data[9] .= html_print_image(
'images/dynamic_network_icon.png',
true
@@ -565,6 +565,9 @@ class DiscoveryTaskList extends Wizard
$data[9] = '';
}
+ // Div neccesary for modal progress task.
+ echo '';
+
array_push($table->data, $data);
}
@@ -576,8 +579,8 @@ class DiscoveryTaskList extends Wizard
html_print_table($table);
}
- // Div neccesary for modal progress task.
- echo '';
+ // Div neccesary for modal map task.
+ echo '';
unset($table);
diff --git a/pandora_console/include/ajax/task_list.ajax.php b/pandora_console/include/ajax/task_list.ajax.php
index 46c8340a98..353083390a 100644
--- a/pandora_console/include/ajax/task_list.ajax.php
+++ b/pandora_console/include/ajax/task_list.ajax.php
@@ -43,7 +43,7 @@ if ($progress_task_discovery) {
$global_progress = $task['status'];
$summary = json_decode($task['summary'], true);
- $result = '';
+ $result = '';
$result .= '
';
$result .= ''._('Overall Progress').'
';
$result .= '- ';
@@ -57,6 +57,7 @@ if ($progress_task_discovery) {
'',
'#FFFFFF',
0,
+ 0,
0
);
@@ -98,6 +99,7 @@ if ($progress_task_discovery) {
'',
'#FFFFFF',
0,
+ 0,
0
);
$result .= '
';
@@ -139,10 +141,12 @@ if ($progress_task_discovery) {
$table->data[$i][1] .= $summary['summary']['WMI'];
$table->data[$i++][1] .= '';
- $result .= html_print_table($table, true);
+ $result .= html_print_table($table, true).'
';
- echo $result;
+ $result_array['status'] = $global_progress;
+ $result_array['html'] = $result;
+ echo json_encode($result_array);
return;
}
diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php
index cc8ffea667..5ce06e982f 100644
--- a/pandora_console/include/graphs/functions_d3.php
+++ b/pandora_console/include/graphs/functions_d3.php
@@ -364,7 +364,8 @@ function d3_progress_bar(
$text='',
$fill_color='#FFFFFF',
$radiusx=10,
- $radiusy=10
+ $radiusy=10,
+ $transition=1
) {
global $config;
@@ -387,6 +388,7 @@ function d3_progress_bar(
'".$fill_color."',
".(int) $radiusx.',
'.(int) $radiusy.',
+ '.(int) $transition.'
);
';
diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js
index 5501d92f6f..51dae061ec 100644
--- a/pandora_console/include/graphs/pandora.d3.js
+++ b/pandora_console/include/graphs/pandora.d3.js
@@ -1784,7 +1784,8 @@ function progress_bar_d3(
label,
label_color,
radiusx,
- radiusy
+ radiusy,
+ transition
) {
var startPercent = 0;
var endPercent = parseInt(percentile) / 100;
@@ -1844,17 +1845,21 @@ function progress_bar_d3(
progress_front.attr("width", width * bar_progress);
}
- var bar_progress = startPercent;
-
- (function loops() {
+ if (transition == 0) {
+ var bar_progress = endPercent;
updateProgress(bar_progress);
+ } else {
+ var bar_progress = startPercent;
+ (function loops() {
+ updateProgress(bar_progress);
- if (count > 0) {
- count--;
- bar_progress += step;
- setTimeout(loops, 30);
- }
- })();
+ if (count > 0) {
+ count--;
+ bar_progress += step;
+ setTimeout(loops, 30);
+ }
+ })();
+ }
}
function progress_bubble_d3(
diff --git a/pandora_console/include/javascript/pandora_taskList.js b/pandora_console/include/javascript/pandora_taskList.js
index dc6fd13208..270fec67a0 100644
--- a/pandora_console/include/javascript/pandora_taskList.js
+++ b/pandora_console/include/javascript/pandora_taskList.js
@@ -1,44 +1,82 @@
-/**
- *
- * @param {*} id
- * @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);
+/*
+ global $
+ global jQuery
+*/
- jQuery.ajax({
- data: params.join("&"),
+/**
+ * Function for create modal with progress task
+ * and recalculate 3 second.
+ * @param {int} id
+ * @param {string} name
+ */
+function progress_task_list(id, title) {
+ var timeoutRef = null;
+ var xhr = null;
+ var $elem = $("#progress_task_" + id);
+
+ $elem
+ .hide()
+ .empty()
+ .dialog({
+ title: title,
+ draggable: true,
+ modal: false,
+ width: 600,
+ height: 420,
+ close: function() {
+ 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: (action = url),
- dataType: "html",
+ url: "ajax.php",
+ dataType: "json",
success: function(data) {
- $("#progress_task")
- .hide()
- .empty()
- .append(data)
- .dialog({
- title: "Task: " + name,
- resizable: true,
- draggable: true,
- modal: false,
- width: 600,
- height: 400
- })
- .show();
+ callback(null, data);
+ },
+ error: function() {
+ callback(new Error("cannot fetch the list"));
}
});
}
-function show_map(id, name, url) {
- var params = [];
- params.push("page=include/ajax/task_list.ajax");
- params.push("showmap=1");
- params.push("id=" + id);
-
- $("#progress_task")
+function show_map(id, name) {
+ $("#map_task")
.empty()
.hide()
.append("Loading map
")
@@ -53,12 +91,16 @@ function show_map(id, name, url) {
.show();
jQuery.ajax({
- data: params.join("&"),
+ data: {
+ page: "include/ajax/task_list.ajax",
+ showmap: 1,
+ id: id
+ },
type: "POST",
- url: (action = url),
+ url: "ajax.php",
dataType: "html",
success: function(data) {
- $("#progress_task")
+ $("#map_task")
.empty()
.append(data);
}