Minor fixes Wiz.Discovery
Former-commit-id: 750cd3ab1902ed3eda9806aa9b505d5e4a1175be
This commit is contained in:
parent
6a43536b33
commit
ad3e2b88bf
|
@ -19,10 +19,11 @@ ui_print_page_header(__('Discover'), '', false, '', true);
|
|||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* Mask class names.
|
||||
*
|
||||
* @param [type] $str
|
||||
* @return void
|
||||
* @param string $str Wiz parameter.
|
||||
*
|
||||
* @return string Classname.
|
||||
*/
|
||||
function get_wiz_class($str)
|
||||
{
|
||||
|
@ -39,6 +40,9 @@ function get_wiz_class($str)
|
|||
case 'app':
|
||||
return 'Applications';
|
||||
|
||||
case 'ctask':
|
||||
return 'ConsoleTasks';
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
return null;
|
||||
|
@ -46,6 +50,31 @@ function get_wiz_class($str)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aux. function to compare classpath names.
|
||||
*
|
||||
* @param string $a Classpath A.
|
||||
* @param string $b Classpath B.
|
||||
*
|
||||
* @return string Matching one.
|
||||
*/
|
||||
function cl_load_cmp($a, $b)
|
||||
{
|
||||
$str_a = basename($a, '.class.php');
|
||||
$str_b = basename($b, '.class.php');
|
||||
if ($str_a == $str_b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($str_a < $str_b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CLASS LOADER.
|
||||
*/
|
||||
|
@ -79,8 +108,13 @@ if (enterprise_installed() === true) {
|
|||
}
|
||||
}
|
||||
|
||||
// Combine class paths.
|
||||
$classes = array_merge($classes, $enterprise_classes);
|
||||
|
||||
// Sort output.
|
||||
uasort($classes, 'cl_load_cmp');
|
||||
|
||||
// Check user action.
|
||||
$wiz_in_use = get_parameter('wiz', null);
|
||||
$page = get_parameter('page', 0);
|
||||
|
||||
|
@ -110,8 +144,14 @@ if ($classname_selected === null) {
|
|||
foreach ($classes as $classpath) {
|
||||
$classname = basename($classpath, '.class.php');
|
||||
$obj = new $classname();
|
||||
|
||||
// DiscoveryTaskList must be first button.
|
||||
if ($classname == 'DiscoveryTaskList') {
|
||||
array_unshift($wiz_data, $obj->load());
|
||||
} else {
|
||||
$wiz_data[] = $obj->load();
|
||||
}
|
||||
}
|
||||
|
||||
Wizard::printBigButtonsList($wiz_data);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to schedule tasks on Pandora FMS Console
|
||||
*
|
||||
* @category Wizard
|
||||
* @package Pandora FMS
|
||||
* @subpackage Host&Devices
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/Wizard.main.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
/**
|
||||
* Defined as wizard to guide user to explore running tasks.
|
||||
*/
|
||||
class ConsoleTasks extends Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
* Number of pages to control breadcrum.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $MAXPAGES = 1;
|
||||
|
||||
/**
|
||||
* Labels for breadcrum.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $pageLabels = ['Base'];
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param integer $page Start page, by default 0.
|
||||
* @param string $msg Custom default mesage.
|
||||
* @param string $icon Custom icon.
|
||||
* @param string $label Custom label.
|
||||
*
|
||||
* @return class HostDevices
|
||||
*/
|
||||
public function __construct(
|
||||
int $page=0,
|
||||
string $msg='Default message. Not set.',
|
||||
string $icon='images/wizard/csv_image.svg',
|
||||
string $label='Console Tasks'
|
||||
) {
|
||||
$this->setBreadcrum([]);
|
||||
|
||||
$this->task = [];
|
||||
$this->msg = $msg;
|
||||
$this->icon = $icon;
|
||||
$this->label = __($label);
|
||||
$this->page = $page;
|
||||
$this->url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=ctask'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements run method.
|
||||
*
|
||||
* @return mixed Returns null if wizard is ongoing. Result if done.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Load styles.
|
||||
parent::run();
|
||||
echo 'hola';
|
||||
|
||||
for ($i = 0; $i < $this->MAXPAGES; $i++) {
|
||||
$breadcrum[] = [
|
||||
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=app&mode=vmware&page='.$i.'&task='.$this->task['id_rt'],
|
||||
'label' => $this->label.' '.$this->pageLabels[$i],
|
||||
'selected' => (($i == $this->page) ? 1 : 0),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->page < $this->MAXPAGES) {
|
||||
// Avoid to print header out of wizard.
|
||||
$this->prepareBreadcrum($breadcrum);
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
$this->printGoBackButton();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements load method.
|
||||
*
|
||||
* @return mixed Skeleton for button.
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->label,
|
||||
'url' => $this->url,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -38,6 +38,24 @@ enterprise_include('include/class/CSVImportAgents.class.php');
|
|||
class HostDevices extends Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
* Number of pages to control breadcrum.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $maxPagesNetScan = 2;
|
||||
|
||||
/**
|
||||
* Labels for breadcrum.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $pageLabelsNetScan = [
|
||||
'NetScan definition',
|
||||
'NetScan features',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Stores all needed parameters to create a recon task.
|
||||
*
|
||||
|
@ -92,16 +110,6 @@ class HostDevices extends Wizard
|
|||
$mode = get_parameter('mode', null);
|
||||
|
||||
if ($mode === null) {
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd',
|
||||
'label' => __('    Host & devices'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->printHeader();
|
||||
$this->printBigButtonsList(
|
||||
[
|
||||
[
|
||||
|
@ -123,62 +131,12 @@ class HostDevices extends Wizard
|
|||
|
||||
if (enterprise_installed()) {
|
||||
if ($mode == 'importcsv') {
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd',
|
||||
'label' => __('    Host & devices'),
|
||||
],
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd&mode=importcsv',
|
||||
'label' => __('      Import CSV'),
|
||||
],
|
||||
]
|
||||
);
|
||||
$this->printHeader();
|
||||
$csv_importer = new CSVImportAgents($this->page, $this->breadcrum);
|
||||
return $csv_importer->runCSV();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == 'netscan') {
|
||||
if ($this->page != 2) {
|
||||
// Do not paint breadcrum in last page. Redirected.
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd',
|
||||
'label' => __('    Host & devices'),
|
||||
],
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd&mode=netscan',
|
||||
'label' => __('      Net scan definition'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->page == 1) {
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd',
|
||||
'label' => __('    Host & devices'),
|
||||
],
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd&mode=netscan',
|
||||
'label' => __('      Net scan definition'),
|
||||
],
|
||||
[
|
||||
'link' => $this->url.'&wiz=hd&mode=netscan&page=1',
|
||||
'label' => __('      Net scan features'),
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
return $this->runNetScan();
|
||||
}
|
||||
|
||||
|
@ -257,6 +215,29 @@ class HostDevices extends Wizard
|
|||
}
|
||||
}
|
||||
|
||||
if ($task_id !== null
|
||||
&& $taskname == null
|
||||
&& $server_id == null
|
||||
&& $id_group == null
|
||||
&& $server == null
|
||||
&& $datacenter == ''
|
||||
&& $user == ''
|
||||
&& $pass == ''
|
||||
&& $encrypt == null
|
||||
&& $interval == 0
|
||||
) {
|
||||
// Default values, no data received.
|
||||
// User is accesing directly to this page.
|
||||
if (users_is_admin() !== true && check_acl(
|
||||
$config['id_usuario'],
|
||||
$this->task['id_group'],
|
||||
'PM'
|
||||
) !== true
|
||||
) {
|
||||
$this->msg = __('You have no access to edit this task.');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (isset($this->task['id_rt']) === false) {
|
||||
// Disabled 2 Implies wizard non finished.
|
||||
$this->task['disabled'] = 2;
|
||||
|
@ -305,6 +286,7 @@ class HostDevices extends Wizard
|
|||
['id_rt' => $this->task['id_rt']]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -408,7 +390,6 @@ class HostDevices extends Wizard
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -478,6 +459,25 @@ class HostDevices extends Wizard
|
|||
return null;
|
||||
}
|
||||
|
||||
$task_url = '';
|
||||
if (isset($this->task['id_rt'])) {
|
||||
$task_url = '&task='.$this->task['id_rt'];
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $this->maxPagesNetScan; $i++) {
|
||||
$breadcrum[] = [
|
||||
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page='.$i.$task_url,
|
||||
'label' => $this->pageLabelsNetScan[$i],
|
||||
'selected' => (($i == $this->page) ? 1 : 0),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->page < $this->maxPagesNetScan) {
|
||||
// Avoid to print header out of wizard.
|
||||
$this->prepareBreadcrum($breadcrum);
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
if (isset($this->page) === true
|
||||
&& $this->page != 0
|
||||
&& isset($this->task['id_rt']) === false
|
||||
|
@ -698,7 +698,9 @@ $("select#interval_manual_defined").change(function() {
|
|||
// XXX: Could be improved validating inputs before continue (JS)
|
||||
// Print NetScan page 0.
|
||||
$this->printForm($form);
|
||||
$this->printGoBackButton();
|
||||
$this->printGoBackButton(
|
||||
$this->url.'&page='.($this->page - 1).$task_url
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,3 +94,11 @@ div.data_container:hover {
|
|||
.arrow_box.selected:before {
|
||||
border-left-color: #82b92e;
|
||||
}
|
||||
.arrow_box {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
padding: 14px;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
* TODO: This may be at hostdevices.css
|
||||
*/
|
Loading…
Reference in New Issue