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

Conflicts:
	pandora_console/godmode/wizards/Wizard.main.php

Former-commit-id: 570168ca638ea3403de5768b08c640a909aa27d2
This commit is contained in:
fermin831 2019-02-20 16:54:52 +01:00
commit 0ed6c6d620
6 changed files with 98 additions and 30 deletions

View File

@ -36,6 +36,9 @@ function get_wiz_class($str)
case 'tasklist':
return 'DiscoveryTaskList';
case 'app':
return 'Applications';
default:
// Ignore.
return null;
@ -56,6 +59,7 @@ if (enterprise_installed()) {
if ($ent_classes === false) {
$ent_classes = [];
}
$classes = array_merge($classes, $ent_classes);
}
@ -63,6 +67,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);

View File

@ -186,24 +186,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.
@ -690,6 +672,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 +690,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();';

View File

@ -121,6 +121,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
*
@ -135,10 +169,15 @@ class Wizard
$bc = [];
$i = 0;
foreach ($urls as $url) {
$href = (isset($url['link']) === true) ? 'href="'.$url['link'].'"' : '';
$bc[$i] = '<a '.$href.' class="text_color">';
$bc[$i] .= '<div class="arrow_box">'.$url['label'].'</div>';
$bc[$i++] .= '</a>';
if ($url['selected'] == 1) {
$class = 'selected';
} else {
$class = '';
}
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
$bc[$i] .= '<div class="arrow_box '.$class.'">'.$url['label'];
$bc[$i++] .= '</div></a>';
}
if ($add === true) {
@ -162,12 +201,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,
];
}

View File

@ -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();
}
}

View File

@ -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
);

View File

@ -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;
}