From 4f6a81dc5b2368be51581d496be0cdf027085177 Mon Sep 17 00:00:00 2001
From: alejandro-campos
Date: Mon, 22 Apr 2019 17:46:04 +0200
Subject: [PATCH 1/4] visual changes to discovery
Former-commit-id: fd606abb997aa4f3144d072f610915524b5358db
---
.../godmode/wizards/HostDevices.class.php | 264 +++++++++---------
.../godmode/wizards/Wizard.main.php | 23 +-
.../include/ajax/task_list.ajax.php | 51 ++--
.../include/class/CustomNetScan.class.php | 20 +-
pandora_console/include/functions_html.php | 21 +-
.../include/graphs/functions_d3.php | 4 +-
pandora_console/include/graphs/pandora.d3.js | 23 +-
pandora_console/include/styles/discovery.css | 117 +++++++-
8 files changed, 333 insertions(+), 190 deletions(-)
diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php
index e4e0e97fdc..1c20eb04e3 100755
--- a/pandora_console/godmode/wizards/HostDevices.class.php
+++ b/pandora_console/godmode/wizards/HostDevices.class.php
@@ -581,113 +581,83 @@ class HostDevices extends Wizard
if (isset($this->page) === false
|| $this->page == 0
) {
- $form = [];
- // Input task name.
- $form['inputs'][] = [
- 'label' => ''.__('Task name').'',
- 'arguments' => [
+ // Comment input
+ $comment_input ='';
+
+ $comment_input .= $this->printInput([
+ 'name' => 'comment',
+ 'rows' => 1,
+ 'columns' => 1,
+ 'value' => $this->task['description'],
+ 'type' => 'textarea',
+ 'size' => 25,
+ 'class' => 'discovery_textarea_input',
+ 'return' => true
+ ]);
+
+ // Task input
+ $taskname_input_label = '';
+
+ $taskname_input = $this->printInput([
'name' => 'taskname',
'value' => $this->task['name'],
'type' => 'text',
'size' => 25,
- ],
- ];
+ 'class' => 'discovery_full_width_input'
+ ]);
- if (isset($this->task['id_rt']) === true) {
- // Propagate id.
- $form['inputs'][] = [
- 'arguments' => [
- 'name' => 'task',
- 'value' => $this->task['id_rt'],
- 'type' => 'hidden',
- ],
- ];
- }
+ // Network input
+ $network_input_label .= ''.ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true).'
';
- // Input task name.
- $form['inputs'][] = [
- 'label' => ''.__('Comment').'',
- 'arguments' => [
- 'name' => 'comment',
- 'value' => $this->task['description'],
- 'type' => 'text',
- 'size' => 25,
- ],
- ];
-
- // Input Discovery Server.
- $form['inputs'][] = [
- 'label' => ''.__('Discovery server').''.ui_print_help_tip(
- __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
- true
- ),
- 'arguments' => [
- 'type' => 'select_from_sql',
- 'sql' => sprintf(
- 'SELECT id_server, name
- FROM tserver
- WHERE server_type = %d
- ORDER BY name',
- SERVER_TYPE_DISCOVERY
- ),
- 'name' => 'id_recon_server',
- 'selected' => $this->task['id_recon_server'],
- 'return' => true,
- ],
- ];
-
- // Input Network.
- $form['inputs'][] = [
-
- 'label' => ''.__('Network').''.ui_print_help_tip(
- __('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'),
- true
- ),
- 'arguments' => [
+ $network_input = $this->printInput([
'name' => 'network',
'value' => $this->task['subnet'],
'type' => 'text',
'size' => 25,
- ],
- ];
+ 'class' => 'discovery_full_width_input',
+ ]);
- // Input Group.
- $form['inputs'][] = [
- 'label' => ''.__('Group').'',
- 'arguments' => [
- 'name' => 'id_group',
- 'returnAllGroup' => false,
- 'privilege' => 'PM',
- 'type' => 'select_groups',
- 'selected' => $this->task['id_group'],
- 'return' => true,
- ],
- ];
- // Interval and schedules.
+ // Discovery server input
+ $discovery_server_select_label = ''.ui_print_help_tip(__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true).'
';
+
+ $discovery_server_select = $this->printInput([
+ 'type' => 'select_from_sql',
+ 'sql' => sprintf(
+ 'SELECT id_server, name
+ FROM tserver
+ WHERE server_type = %d
+ ORDER BY name',
+ SERVER_TYPE_DISCOVERY
+ ),
+ 'name' => 'id_recon_server',
+ 'selected' => $this->task['id_recon_server'],
+ 'return' => true,
+ 'style' => 'width: 100%',
+ ]);
+
+ // Interval input
$interv_manual = 0;
if ((int) $this->task['interval_sweep'] == 0) {
$interv_manual = 1;
}
- // Schedule.
- $form['inputs'][] = [
- 'label' => ''.__('Interval').''.ui_print_help_tip(
- __('Manual interval means that it will be executed only On-demand'),
- true
- ),
- 'arguments' => [
- 'type' => 'select',
- 'selected' => $interv_manual,
- 'fields' => [
- 0 => __('Defined'),
- 1 => __('Manual'),
- ],
- 'name' => 'interval_manual_defined',
- 'return' => true,
+ $interval_input_label = ''.ui_print_help_tip(__('Manual interval means that it will run only on demand.'), true).'
';
+
+ $interval_input = $this->printInput([
+ 'type' => 'select',
+ 'selected' => $interv_manual,
+ 'fields' => [
+ 0 => __('Defined'),
+ 1 => __('Manual'),
],
- 'extra' => ''.html_print_extended_select_for_time(
+ 'name' => 'interval_manual_defined',
+ 'return' => true,
+ 'style' => 'float: right;'
+ ]);
+
+ $interval_input_extra = ''.html_print_extended_select_for_time(
'interval',
$this->task['interval_sweep'],
'',
@@ -700,36 +670,37 @@ class HostDevices extends Wizard
).ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
- ).'',
- ];
+ ).'';
- $str = __('Next');
- if (isset($this->task['id_rt']) === true) {
- $str = __('Update and continue');
+ // Group select
+ $group_select = '';
+
+ $group_select .= $this->printInput([
+ 'name' => 'id_group',
+ 'returnAllGroup' => false,
+ 'privilege' => 'PM',
+ 'type' => 'select_groups',
+ 'selected' => $this->task['id_group'],
+ 'return' => true,
+ 'class' => 'discovery_list_input',
+ 'size' => 9,
+ ]);
+
+ if (isset($this->task['id_rt']) === true) {
+ //Propagate ID
+ $task_hidden = $this->printInput([
+ 'name' => 'task',
+ 'value' => $this->task['id_rt'],
+ 'type' => 'hidden'
+ ]);
}
- // Submit button.
- $form['inputs'][] = [
- 'arguments' => [
- 'name' => 'submit',
- 'label' => $str,
- 'type' => 'submit',
- 'attributes' => 'class="sub next"',
- 'return' => true,
- ],
- ];
-
$task_url = '';
if (isset($this->task['id_rt'])) {
$task_url = '&task='.$this->task['id_rt'];
}
- $form['form'] = [
- 'method' => 'POST',
- 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
- ];
-
// Default.
$interval = 600;
$unit = 60;
@@ -738,24 +709,62 @@ class HostDevices extends Wizard
$unit = $this->getTimeUnit($interval);
}
- $form['js'] = '
-$("select#interval_manual_defined").change(function() {
- if ($("#interval_manual_defined").val() == 1) {
- $("#interval_manual_container").hide();
- $("#text-interval_text").val(0);
- $("#hidden-interval").val(0);
- }
- else {
- $("#interval_manual_container").show();
- $("#text-interval_text").val(10);
- $("#hidden-interval").val('.$interval.');
- $("#interval_units").val('.$unit.');
- }
-}).change();';
-
// XXX: Could be improved validating inputs before continue (JS)
// Print NetScan page 0.
- $this->printForm($form);
+ //$this->printForm($form);
+
+ echo '';
+
+ echo '';
+
}
}
@@ -783,7 +792,7 @@ $("select#interval_manual_defined").change(function() {
];
$form['inputs'][] = [
- 'extra' => 'Please, configure task '.io_safe_output($this->task['name']).'
',
+ 'extra' => 'Please, configure task '.io_safe_output($this->task['name']).'
',
];
// Input: Module template.
@@ -799,7 +808,6 @@ $("select#interval_manual_defined").change(function() {
'selected' => $this->task['id_network_profile'],
'nothing_value' => 0,
'nothing' => __('None'),
-
],
];
@@ -850,7 +858,7 @@ $("select#interval_manual_defined").change(function() {
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'],
];
- $this->printForm($form);
+ $this->printForm($form, false, true);
}
if ($this->page == 2) {
diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php
index fde2b411c0..011e906cfa 100644
--- a/pandora_console/godmode/wizards/Wizard.main.php
+++ b/pandora_console/godmode/wizards/Wizard.main.php
@@ -479,7 +479,8 @@ class Wizard
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
- ((isset($data['include_groups']) === true) ? $data['include_groups'] : false)
+ ((isset($data['include_groups']) === true) ? $data['include_groups'] : false),
+ ((isset($data['size']) === true) ? $data['size'] : false)
);
case 'submit':
@@ -636,7 +637,7 @@ class Wizard
*
* @return string HTML code.
*/
- public function printForm(array $data, bool $return=false)
+ public function printForm(array $data, bool $return=false, bool $print_white_box=false)
{
$form = $data['form'];
$inputs = $data['inputs'];
@@ -662,13 +663,27 @@ class Wizard
error_log('Error executing wizard callback: ', $e->getMessage());
}
- $output = '