Merge branch 'ent-12176-mejorar-la-captura-de-errores-en-nuevo-discovery-cuando-termine-con-errores' into 'develop'

Ent 12176 Mejorar la captura de errores en nuevo Discovery cuando termine con errores

See merge request artica/pandorafms!6705
This commit is contained in:
Daniel Rodriguez 2023-12-13 10:32:58 +00:00
commit 70d8b344b7
2 changed files with 36 additions and 8 deletions

View File

@ -1422,6 +1422,14 @@ class DiscoveryTaskList extends HTML
$table->rowid = []; $table->rowid = [];
$table->data = []; $table->data = [];
$countErrors = 1;
$tableErrors = new StdClasS();
$tableErrors->class = 'databox data';
$tableErrors->width = '75%';
$tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
$tableErrors->rowid = [];
$tableErrors->data = [];
if ($task['review_mode'] == DISCOVERY_RESULTS) { if ($task['review_mode'] == DISCOVERY_RESULTS) {
$agents_review = db_get_all_rows_filter( $agents_review = db_get_all_rows_filter(
'tdiscovery_tmp_agents', 'tdiscovery_tmp_agents',
@ -1476,11 +1484,11 @@ class DiscoveryTaskList extends HTML
$countSummary = 1; $countSummary = 1;
if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) { if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) {
foreach ($task['stats'] as $key => $summary) { foreach ($task['stats'] as $key => $summary) {
$table->data[$i][0] = '<b>'.__('Summary').' '.$countSummary.'</b>';
$table->data[$i][1] = '';
$countSummary++;
$i++;
if (is_array($summary) === true) { if (is_array($summary) === true) {
$table->data[$i][0] = '<b>'.__('Summary').' '.$countSummary.'</b>';
$table->data[$i][1] = '';
$countSummary++;
$i++;
if (empty($summary['summary']) === true && empty($summary['info']) === true) { if (empty($summary['summary']) === true && empty($summary['info']) === true) {
$table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT); $table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT);
$table->data[$i][1] = ''; $table->data[$i][1] = '';
@ -1517,8 +1525,12 @@ class DiscoveryTaskList extends HTML
$i++; $i++;
} }
} else { } else {
$table->data[$i][0] = $summary; $tableErrors->data[$i][0] = '<b>'.__('Error %s', $countErrors).'</b>';
$table->data[$i][1] = ''; $tableErrors->data[$i][1] = '';
$i++;
$tableErrors->data[$i][0] = $summary;
$tableErrors->data[$i][1] = '';
$countErrors++;
$i++; $i++;
} }
} }
@ -1560,12 +1572,26 @@ class DiscoveryTaskList extends HTML
$table->data[$i++][1] .= '</span>'; $table->data[$i++][1] .= '</span>';
} }
} else { } else {
$table->data[$i][0] = $task['stats']['summary']; $tableErrors->data[$i][0] = '<b>'.__('Error %s', $countErrors).'</b>';
$tableErrors->data[$i][1] = '';
$i++;
$tableErrors->data[$i][0] = $task['stats']['summary'];
$tableErrors->data[$i][1] = '';
$countErrors++;
$i++;
} }
} }
$output = '<div class="subtitle"><span>'.__('Summary').'</span></div>'; $output = '<div class="subtitle"><span>'.__('Summary').'</span></div>';
$output .= html_print_table($table, true).'</div>'; if (is_array($table->data) === true && count($table->data) > 0) {
$output .= html_print_table($table, true);
}
if (is_array($tableErrors->data) === true && count($tableErrors->data) > 0) {
$output .= html_print_table($tableErrors, true);
}
$output .= '</div>';
} }
return $output; return $output;

View File

@ -117,6 +117,8 @@ class NewsBoard extends Element
$output .= '</div>'; $output .= '</div>';
return $output; return $output;
} else {
return '';
} }
} }