progress task list

Former-commit-id: 5b8a10cdc792e74538784ae27367bc1ca2c7bed0
This commit is contained in:
daniel 2019-03-07 14:45:26 +01:00
parent 3d09f81b7b
commit 00283a5c6a
4 changed files with 181 additions and 4 deletions

View File

@ -33,6 +33,8 @@ require_once $config['homedir'].'/include/functions_cron.php';
enterprise_include_once('include/functions_tasklist.php');
enterprise_include_once('include/functions_cron.php');
ui_require_css_file('task_list');
/**
* Defined as wizard to guide user to explore running tasks.
*/
@ -346,6 +348,8 @@ class DiscoveryTaskList extends Wizard
$recon_tasks = [];
}
$url_ajax = $config['homeurl'].'ajax.php';
$table = new StdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
@ -425,7 +429,16 @@ class DiscoveryTaskList extends Wizard
$data[0] = '';
}
$data[1] = '<b>'.$task['name'].'</b>';
// Name task.
$data[1] = '';
if ($task['disabled'] != 2) {
$data[1] .= '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\',\''.$url_ajax.'\')">';
}
$data[1] .= '<b>'.$task['name'].'</b>';
if ($task['disabled'] != 2) {
$data[1] .= '</a>';
}
$data[2] = $server_name;
@ -489,6 +502,15 @@ class DiscoveryTaskList extends Wizard
$data[8] = __('Not executed yet');
}
if ($task['disabled'] != 2) {
$data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\',\''.$url_ajax.'\')">';
$data[9] .= html_print_image(
'images/eye.png',
true
);
$data[9] .= '</a>';
}
if (check_acl(
$config['id_user'],
$task['id_group'],
@ -496,7 +518,7 @@ class DiscoveryTaskList extends Wizard
)
) {
if ($ipam === true) {
$data[9] = '<a href="'.ui_get_full_url(
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
$tipam_task_id
@ -513,7 +535,7 @@ class DiscoveryTaskList extends Wizard
).'</a>';
} else {
// Check if is a H&D, Cloud or Application or IPAM.
$data[9] = '<a href="'.ui_get_full_url(
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
$this->getTargetWiz($task),
@ -545,7 +567,12 @@ class DiscoveryTaskList extends Wizard
html_print_table($table);
}
// Div neccesary for modal progress task.
echo '<div id="progress_task" style="display:none"></div>';
unset($table);
ui_require_javascript_file('pandora_taskList');
}
return true;
@ -589,6 +616,7 @@ class DiscoveryTaskList extends Wizard
} else {
return 'wiz=hd&mode=customnetscan';
}
break;
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Ajax
* @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 $config['homedir'].'/include/graphs/functions_d3.php';
$progress_task_discovery = (bool) get_parameter('progress_task_discovery', 0);
if ($progress_task_discovery) {
$id_task = get_parameter('id', 0);
if ($id_task !== 0) {
$result = '';
$result .= '<ul class="progress_task_discovery">';
$result .= '<li><h1>'._('Overall Progress').'</h1></li>';
$result .= '<li>';
$result .= d3_progress_bar(
$id_task,
90,
460,
50,
'#EA5434'
);
$result .= '</li>';
$result .= '<li><h1>'.__('Searching devices in').' red a scanear</h1></li>';
$result .= '<li>';
$result .= d3_progress_bar(
$id_task.'_2',
30,
460,
50,
'#2751E1'
);
$result .= '</li>';
$result .= '<li><h1>'.__('Summary').'</h1></li>';
$result .= '<li><span><b>'.__('Estimated').'</b>: total de host</span></li>';
$result .= '<li><span><b>'.__('Discovered').'</b>: total de agentes</span></li>';
$result .= '<li><span><b>'.__('Not alive/Not found').'</b>: total de agentes 1-2</span></li>';
$result .= '</ul>';
echo $result;
} else {
// Error.
ui_print_error_message(
__('Please, select task')
);
}
return;
}

View File

@ -0,0 +1,33 @@
/**
*
* @param {*} id
* @param {*} name
*/
function progress_task_list(id, name, url) {
var params = [];
params.push("page=include/ajax/task_list.ajax");
params.push("progress_task_discovery=1");
params.push("id=" + id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: (action = url),
dataType: "html",
success: function(data) {
$("#progress_task")
.hide()
.empty()
.append(data)
.dialog({
title: "Task: " + name,
resizable: true,
draggable: true,
modal: false,
width: 600,
height: 400
})
.show();
}
});
}

View File

@ -0,0 +1,42 @@
/**
*
* Name: Default theme
*
* Extension to manage a list of gateways and the node address where they should
* point to.
*
* @category css
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
ul.progress_task_discovery {
width: 80%;
margin: 0 auto;
display: flex;
flex-direction: column;
}
ul.progress_task_discovery li span {
font-size: 9pt;
margin-left: 20px;
}