From 1b82a970b1a55b6e7eb5d9101ebdbd94023e34e0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 14:36:16 +0100 Subject: [PATCH 1/4] WIP: App wiz Former-commit-id: aa969dc2fead693977959374c747f046676c5fed --- pandora_console/godmode/servers/discovery.php | 16 ++++++++++++++++ .../godmode/wizards/HostDevices.class.php | 18 ------------------ .../godmode/wizards/Wizard.main.php | 14 +++++++++++--- .../include/class/ConsoleSupervisor.php | 8 ++++++++ pandora_console/include/functions_messages.php | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 97b9b8a884..e7922c881a 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -33,6 +33,9 @@ function get_wiz_class($str) case 'tasklist': return 'DiscoveryTaskList'; + case 'app': + return 'Applications'; + default: // Ignore. return null; @@ -50,6 +53,19 @@ foreach ($classes as $classpath) { include_once $classpath; } +// Load enterprise wizards. +if (enterprise_installed() === true) { + $enterprise_classes = glob( + $config['homedir'].'/'.ENTERPRISE_DIR.'/wizards/*.class.php' + ); + foreach ($enterprise_classes as $classpath) { + $r = enterprise_include_once( + 'wizards/'.basename($classpath) + ); + } +} + +$classes = array_merge($classes, $enterprise_classes); $wiz_in_use = get_parameter('wiz', null); $page = get_parameter('page', 0); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 8dcf6d9a1e..88b9a2fa7e 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -156,24 +156,6 @@ class HostDevices extends Wizard } - /** - * Checks if environment is ready, - * returns array - * icon: icon to be displayed - * label: label to be displayed - * - * @return array With data. - **/ - public function load() - { - return [ - 'icon' => $this->icon, - 'label' => $this->label, - 'url' => $this->url, - ]; - } - - // Extra methods. diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 2f58bea91e..3a7fea7cf0 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -92,12 +92,20 @@ class Wizard /** - * To be overwritten. + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed * - * @return void - */ + * @return array With data. + **/ public function load() { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; } diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 88dbf0f11f..95a5ff1086 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -340,6 +340,14 @@ class ConsoleSupervisor enterprise_hook('cron_supervisor_release_lock'); } + /* + * Check if CRON is running. + * NOTIF.CRON.CONFIGURED + */ + if (enterprise_installed()) { + $this->checkCronRunning(); + } + } diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 3fb907ab06..5374fb7b1e 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -375,7 +375,7 @@ function messages_get_count( tnotification_source ns LEFT JOIN tnotification_source_user nsu ON ns.id=nsu.id_source - AND nsu.id_user="test") + AND nsu.id_user="%s") ON tm.id_source=ns.id', $user ); From e7abe4ad4372158206e47b628c9f17f8cfea2ac4 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 17:59:02 +0100 Subject: [PATCH 2/4] Wiz.Applications SQL updates Former-commit-id: e0f547a0f35b338705a14df6477bf3a5461d8e49 --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/pandoradb.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index c86c9bf7d6..2352cf2a66 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1409,6 +1409,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; +ALTER TABLE trecon_task ADD `task_type` tinyint(2) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index ae780a5470..34d843bb44 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -785,6 +785,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `wmi_enabled` tinyint(1) unsigned DEFAULT '0', `auth_strings` text, `autoconfiguration_enabled` tinyint(1) unsigned default '0', + `task_type` tinyint(2) NOT NULL default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 422708c04a59af4bcf118dab6a9b42f02239d54a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 18:33:17 +0100 Subject: [PATCH 3/4] Revert "Wiz.Applications SQL updates" Identification using recon_script This reverts commit e7abe4ad4372158206e47b628c9f17f8cfea2ac4 [formerly e0f547a0f35b338705a14df6477bf3a5461d8e49]. Former-commit-id: 5b112c7d889d98c2040514556849ce4e408ab444 --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 - pandora_console/pandoradb.sql | 1 - 2 files changed, 2 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2352cf2a66..c86c9bf7d6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1409,7 +1409,6 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -ALTER TABLE trecon_task ADD `task_type` tinyint(2) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 34d843bb44..ae780a5470 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -785,7 +785,6 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `wmi_enabled` tinyint(1) unsigned DEFAULT '0', `auth_strings` text, `autoconfiguration_enabled` tinyint(1) unsigned default '0', - `task_type` tinyint(2) NOT NULL default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 4834561e873d6117197ef697eaa7c683f30a2359 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 14:38:00 +0100 Subject: [PATCH 4/4] Wiz. minor fixes Former-commit-id: b3963bf5994a8f9829922e0a1b0be3a20fc54fba --- .../godmode/wizards/HostDevices.class.php | 12 ++++- .../godmode/wizards/Wizard.main.php | 44 ++++++++++++++++++- pandora_console/include/styles/discovery.css | 10 ++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 83f5d21b4c..b5f635eb40 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -690,6 +690,14 @@ class HostDevices extends Wizard 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url, ]; + // Default. + $interval = 600; + $unit = 60; + if (isset($this->task['interval_sweep']) === true) { + $interval = $this->task['interval_sweep']; + $unit = $this->getTimeUnit($interval); + } + $form['js'] = ' $("select#interval_manual_defined").change(function() { if ($("#interval_manual_defined").val() == 1) { @@ -700,8 +708,8 @@ $("select#interval_manual_defined").change(function() { else { $("#interval_manual_container").show(); $("#text-interval_text").val(10); - $("#hidden-interval").val(600); - $("#interval_units").val(60); + $("#hidden-interval").val('.$interval.'); + $("#interval_units").val('.$unit.'); } }).change();'; diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 65a526cc58..638228c365 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -104,6 +104,40 @@ class Wizard } + /** + * Return units associated to target interval (in seconds). + * + * @param integer $interval Target interval. + * + * @return integer Unit. + */ + public function getTimeUnit($interval) + { + $units = [ + 1, + 60, + 3600, + 86400, + 604800, + 2592000, + 31104000, + ]; + + $size = count($units); + for ($i = 0; $i < $size; $i++) { + if ($interval < $units[$i]) { + if (($i - 1) < 0) { + return 1; + } + + return $units[($i - 1)]; + } + } + + return $units[-1]; + } + + /** * Builder for breadcrum * @@ -116,9 +150,15 @@ class Wizard $bc = []; $i = 0; foreach ($urls as $url) { + if ($url['selected'] == 1) { + $class = 'selected'; + } else { + $class = ''; + } + $bc[$i] = ''; - $bc[$i] .= '
'.$url['label'].'
'; - $bc[$i++] .= '
'; + $bc[$i] .= '
'.$url['label']; + $bc[$i++] .= '
'; } $this->setBreadcrum($bc); diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 7c5933aba9..aebb0a3d0d 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -60,7 +60,7 @@ div.data_container:hover { .arrow_box { display: inline-block; position: relative; - background: #82b92e; + background: #ccc; padding: 14px; margin-left: 20px; margin-bottom: 10px; @@ -75,6 +75,9 @@ div.data_container:hover { position: absolute; pointer-events: none; } +.arrow_box.selected { + background: #82b92e; +} .arrow_box:after { left: 0%; @@ -84,7 +87,10 @@ div.data_container:hover { } .arrow_box:before { left: 100%; - border-left-color: #82b92e; + border-left-color: #ccc; border-width: 20px; margin-top: -20px; } +.arrow_box.selected:before { + border-left-color: #82b92e; +}