#10598 New wizard welcome

This commit is contained in:
Jonathan 2023-05-23 16:54:40 +02:00
parent 4f5315db98
commit ae526d5df0
16 changed files with 2082 additions and 288 deletions

View File

@ -34,6 +34,22 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$notifications_numbers['notifications'],
$notifications_numbers['last_id']
).'</div>';
$header_welcome = '';
if (check_acl($config['id_user'], $group, 'AW')) {
$header_welcome .= '<div id="welcome-icon-header">';
$header_welcome .= html_print_image(
'images/computer@groups.svg',
true,
[
'class' => 'main_menu_icon invert_filter',
'title' => __('Welcome dialog'),
'id' => 'Welcome-dialog',
'alt' => __('Welcome dialog'),
'style' => 'cursor: pointer;',
]
);
$header_welcome .= '</div>';
}
// ======= Servers List ===============================================
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
@ -461,7 +477,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
} else {
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div>
<div class="header_center">'.$header_searchbar.'</div>
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
}
?>
</div> <!-- Closes #table_header_inner -->
@ -904,6 +920,44 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$("#agent_access").css("display","");
});
$("#welcome-icon-header").click(function () {
if (!$('#welcome_modal_window').length){
$(document.body).append('<div id="welcome_modal_window"></div>');
$(document.body).append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'include/styles/new_installation_welcome_window.css') );
}
// Clean DOM.
load_modal({
target: $('#welcome_modal_window'),
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>'
},
onshow: {
page: 'include/ajax/welcome_window',
method: 'loadWelcomeWindow',
},
oncancel: {
page: 'include/ajax/welcome_window',
title: "<?php echo __('Cancel Configuration Window'); ?>",
method: 'cancelWelcome',
confirm: function (fn) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want to cancel this tutorial?'); ?>',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Continue execution.
fn();
}
})
}
}
});
});
<?php if (enterprise_installed()) { ?>
// Feedback.
$("#feedback-header").click(function () {

View File

@ -100,21 +100,23 @@ if ($initial && users_is_admin()) {
);
}
$welcome = !$initial;
try {
$welcome_window = new WelcomeWindow($welcome);
if ($welcome_window !== null) {
$welcome_window->run();
if (check_acl($config['id_user'], 0, 'AW')) {
$welcome = !$initial;
try {
$welcome_window = new WelcomeWindow($welcome);
if ($welcome_window !== null) {
$welcome_window->run();
}
} catch (Exception $e) {
$welcome = false;
}
} catch (Exception $e) {
$welcome = false;
}
try {
if (isset($_SESSION['showed_tips_window']) === false) {
$tips_window = new TipsWindow();
if ($tips_window !== null) {
$tips_window->run();
$tips_window->run();
}
}
} catch (Exception $e) {

View File

@ -1071,16 +1071,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
function () {
$(".actions", this).css ("visibility", "hidden");
});
$("#ag_group").click (
function () {
$(this).css ("width", "auto");
$(this).css ("min-width", "100px");
});
$("#ag_group").blur (function () {
$(this).css ("width", "100px");
});
var show_deploy_agent = "<?php echo get_parameter('show_deploy_agent', 0); ?>";
if (show_deploy_agent !== '0'){
$('#button-modal_deploy_agent').click();
}
});
</script>

View File

@ -168,6 +168,22 @@ if ($access_console_node === true) {
}
$sub = [];
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
$sub['wizard']['text'] = __('Configuration wizard');
$sub['wizard']['id'] = 'conf_wizard';
$sub['wizard']['type'] = 'direct';
$sub['wizard']['subtype'] = 'nolink';
$sub2 = [];
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$sub2['godmode/wizards/mini_diagnosis']['text'] = __('Mini-diagnosis');
$sub2['godmode/wizards/mini_diagnosis']['id'] = 'mini_diagnosis';
}
$sub2['godmode/wizards/task_to_perform']['text'] = __('Tasks to perform');
$sub2['godmode/wizards/task_to_perform']['id'] = 'task_to_perform';
$sub['wizard']['sub2'] = $sub2;
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$sub['templates']['text'] = __('Templates');
$sub['templates']['id'] = 'Templates';

View File

@ -0,0 +1,132 @@
<?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-2023 PandoraFMS S.L.
* 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.
* ============================================================================
*/
// Begin.
global $config;
$status_um = false;
$status_su = false;
$status_cm = false;
$status_lv = false;
// Header.
ui_print_standard_header(
__('Mini-Diagnosis'),
'images/op_snmp.png',
false,
false,
false,
[],
[
[
'link' => '',
'label' => __('Configuration'),
],
[
'link' => '',
'label' => __('Configuration wizard'),
],
]
);
if (empty($config['pandora_uid']) === 'ONLINE') {
$status_um = true;
}
require_once 'include/functions_servers.php';
if (check_all_servers_up() === true) {
$status_su = true;
}
if (empty($config['welcome_mail_configured']) === false) {
$status_cm = true;
}
if (enterprise_installed()) {
$license_valid = true;
enterprise_include_once('include/functions_license.php');
$license = enterprise_hook('license_get_info');
$days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24));
if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) {
$license_valid = false;
}
if ($license_valid === true) {
$status_lv = true;
}
}
ui_require_css_file('mini_diagnosis');
$table = new stdClass();
$table->width = '60%';
$table->class = 'filter-table-adv databox';
$table->size = [];
$table->data = [];
$table->size[0] = '30%';
$table->size[1] = '30%';
$table->data[0][0] = html_print_wizard_diagnosis(__('Verification update manager register'), 'update_manager', __('Verification update manager register'), $status_um, true);
$table->data[0][1] = html_print_wizard_diagnosis(__('Please ensure mail configuration matches your needs'), 'configure_email', __('Please ensure mail configuration matches your needs'), $status_cm, true);
$table->data[1][0] = html_print_wizard_diagnosis(__('All servers up'), 'servers_up', __('All servers up'), $status_su, true);
$table->data[1][1] = html_print_wizard_diagnosis(__('Valid license verification and expiration greater than 30 days'), 'license_valid', __('Valid license verification and expiration greater than 30 days'), $status_lv, true);
html_print_table($table);
?>
<script type="text/javascript">
document.getElementById("update_manager").setAttribute(
'onclick',
'configureUpdateManager()'
);
document.getElementById("configure_email").setAttribute(
'onclick',
'configureEmail()'
);
document.getElementById("servers_up").setAttribute(
'onclick',
'serversUp()'
);
document.getElementById("license_valid").setAttribute(
'onclick',
'messageLicense()'
);
function configureUpdateManager() {
window.location = '<?php echo ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'); ?>';
}
function configureEmail() {
window.location = '<?php echo ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general#table3'); ?>';
}
function serversUp() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'); ?>';
}
function messageLicense() {
window.location = '<?php echo ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_list'); ?>';
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="12px" viewBox="0 0 12 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>EB094270-FB38-4A58-BE94-D40EA44EA568</title>
<g id="Agentes" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="1.a1-Agentes---Listado" transform="translate(-362.500000, -268.000000)" fill="#C1CCDC">
<g id="Contenido" transform="translate(310.000000, 188.000000)">
<g transform="translate(20.000000, 20.000000)" id="Agentes">
<g id="Content" transform="translate(29.308511, 20.000000)">
<g id="Top" transform="translate(0.191489, 0.000000)">
<g id="Icons/Light/24/example" transform="translate(3.000000, 40.000000)">
<circle id="Oval" cx="6" cy="6" r="6"></circle>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -35,6 +35,13 @@ if (is_ajax() === false) {
}
$ajaxPage = 'include/ajax/welcome_window';
// Ajax controller.
$method = get_parameter('method', '');
if ($method === 'loadWelcomeWindow') {
unset($config['welcome_state']);
}
// Control call flow.
try {
@ -44,9 +51,6 @@ try {
exit;
}
// Ajax controller.
$method = get_parameter('method', '');
if (method_exists($welcome_actions, $method) === true) {
if ($welcome_actions->ajaxMethod($method) === true) {
$welcome_actions->{$method}();

View File

@ -336,54 +336,7 @@ class WelcomeWindow extends Wizard
public function loadWelcomeWindow()
{
global $config;
$btn_configure_mail_class = 'pending';
$btn_create_agent_class = 'pending';
$btn_create_module_class = '';
$btn_create_alert_class = '';
$btn_create_discovery_class = 'pending';
$li_configure_mail_class = 'row_green';
$li_create_agent_class = 'row_green';
$li_create_module_class = 'row_grey';
$li_create_alert_class = 'row_grey';
$li_create_discovery_class = 'row_green';
if (empty($config['welcome_mail_configured']) === false) {
$btn_configure_mail_class = ' completed';
}
if (empty($config['welcome_id_agent']) === false) {
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' pending';
$li_create_module_class = 'row_green';
}
if (empty($config['welcome_module']) === false) {
$btn_create_module_class = ' completed';
$btn_create_alert_class = ' pending';
$li_create_module_class = 'row_green';
}
if (empty($config['welcome_alert']) === false) {
$btn_create_alert_class = ' completed';
$li_create_alert_class = 'row_green';
}
if (empty($config['welcome_task']) === false) {
$btn_create_discovery_class = ' completed';
}
if ((int) $config['welcome_state'] === WELCOME_FINISHED) {
// Nothing left to do.
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' completed';
$btn_create_alert_class = ' completed';
$btn_create_discovery_class = ' completed';
$li_create_module_class = 'row_green';
$li_create_alert_class = 'row_green';
}
$flag_task = false;
$form = [
'action' => '#',
@ -413,187 +366,389 @@ class WelcomeWindow extends Wizard
],
],
],
[
];
if (check_acl($config['id_user'], 0, 'PM')) {
$flag_um = false;
$flag_cm = false;
$flag_su = false;
$flag_lv = false;
$btn_update_manager_class = ' pending';
$btn_configure_mail_class = ' pending';
$btn_servers_up_class = ' pending';
$btn_license_valid_class = ' pending';
$li_update_manager_class = 'row_grey';
$li_configure_mail_class = 'row_grey';
$li_servers_up_class = 'row_grey';
$li_license_valid_class = 'row_grey';
if ($config['pandora_uid'] === 'ONLINE') {
$btn_update_manager_class = ' completed';
$li_update_manager_class = 'row_green';
$flag_um = true;
}
if (empty($config['welcome_mail_configured']) === false) {
$btn_configure_mail_class = ' completed';
$flag_cm = true;
}
include_once 'include/functions_servers.php';
if (check_all_servers_up() === true) {
$btn_servers_up_class = ' completed';
$li_servers_up_class = 'row_green';
$flag_su = true;
}
if (enterprise_installed()) {
$license_valid = true;
enterprise_include_once('include/functions_license.php');
$license = enterprise_hook('license_get_info');
$days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24));
if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) {
$license_valid = false;
}
if ($license_valid === true) {
$btn_license_valid_class = ' completed';
$li_license_valid_class = 'row_green';
$flag_lv = true;
}
}
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_configure_mail',
'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class,
'block_id' => 'div_diagnosis',
'class' => 'flex-row flex-items-center w98p ',
'direct' => 1,
'block_content' => [
[
'label' => __('Please ensure mail configuration matches your needs'),
'label' => __('Mini-diagnosis'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
'id' => 'lbl_create_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important',
'mode' => 'onlyIcon',
],
'name' => 'btn_email_conf',
'id' => 'btn_email_conf',
'name' => 'lbl_diagnosis',
'id' => 'lbl_diagnosis',
],
],
],
],
[
'label' => 'Learn to monitor',
'class' => 'extra',
'arguments' => [
'class' => 'class="lbl_learn"',
'name' => 'lbl_learn',
'id' => 'lbl_learn',
],
],
[
'wrapper' => 'div',
'block_id' => 'div_create_agent',
'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_agent_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Create an agent'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
'id' => 'lbl_create_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_create_agent_class) === false) ? $btn_create_agent_class : 'invisible_important',
'mode' => 'onlyIcon',
];
if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) {
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_update_manager',
'class' => 'hole flex-row flex-items-center w98p '.$li_update_manager_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Verification update manager register'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_update_manager',
'id' => 'lbl_update_manager',
],
'name' => 'btn_create_agent',
'id' => 'btn_create_agent',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_monitor_actions',
'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_module_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Create a module to check if an agent is online'),
'arguments' => [
'class' => 'second_lbl',
'name' => 'lbl_check_agent',
'id' => 'lbl_check_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_create_module_class) === false) ? $btn_create_module_class : 'invisible_important',
'mode' => 'onlyIcon',
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_update_manager_class) === false) ? $btn_update_manager_class : 'invisible_important',
'mode' => 'onlyIcon',
],
'name' => 'btn_update_manager_conf',
'id' => 'btn_update_manager_conf',
],
'name' => 'btn_create_module',
'id' => 'btn_create_module',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_monitor_actions',
'class' => 'hole learn_content_indented flex-row flex-items-center w98p '.$li_create_alert_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Be warned if something is wrong, create an alert on the module'),
'arguments' => [
'class' => 'second_lbl',
'name' => 'lbl_create_alert',
'id' => 'lbl_create_alert',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_create_alert_class) === false) ? $btn_create_alert_class : 'invisible_important',
'mode' => 'onlyIcon',
];
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_configure_mail',
'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Please ensure mail configuration matches your needs'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
'id' => 'lbl_create_agent',
],
'name' => 'btn_create_alert',
'id' => 'btn_create_alert',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_discover',
'class' => 'hole flex-row flex-items-center w98p '.$li_create_discovery_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Discover hosts and devices in your network'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_discover_devices',
'id' => 'lbl_discover_devices',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_create_discovery_class) === false) ? $btn_create_discovery_class : 'invisible_important',
'mode' => 'onlyIcon',
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important',
'mode' => 'onlyIcon',
],
'name' => 'btn_email_conf',
'id' => 'btn_email_conf',
],
'name' => 'btn_discover_devices',
'id' => 'btn_discover_devices',
],
],
];
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_servers_up',
'class' => 'hole flex-row flex-items-center w98p '.$li_servers_up_class,
'direct' => 1,
'block_content' => [
[
'label' => __('All servers up'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_servers_up',
'id' => 'lbl_servers_up',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_servers_up_class) === false) ? $btn_servers_up_class : 'invisible_important',
'mode' => 'onlyIcon',
],
'name' => 'btn_servers_up_conf',
'id' => 'btn_servers_up_conf',
],
],
],
];
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_license_valid',
'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class,
'direct' => 1,
'block_content' => [
[
'label' => __('Valid license verification and expiration greater than 30 days'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_license_valid',
'id' => 'lbl_license_valid',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important',
'mode' => 'onlyIcon',
],
'name' => 'btn_license_valid_conf',
'id' => 'btn_license_valid_conf',
],
],
],
];
} else {
$key = db_get_value_sql('SELECT `value` FROM tupdate_settings WHERE `key` = "customer_key"');
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_all_correct',
'class' => 'hole flex-row flex-items-center w98p',
'direct' => 1,
'block_content' => [
[
'label' => __('It seems that your Pandora FMS is working correctly and registered with ID:<br> #'.$key.'.<br>For more information use the self-diagnosis tool.'),
'arguments' => [
'class' => 'first_lbl w98p',
'name' => 'lbl_all_correct',
'id' => 'lbl_all_correct',
],
],
],
];
}
if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) {
$flag_task = true;
}
}
// Task to do.
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_task_todo',
'class' => 'flex-row flex-items-center w98p',
'direct' => 1,
'block_content' => [
[
'label' => __('Task to perform'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_task_todo',
'id' => 'lbl_task_todo',
],
],
],
];
if (enterprise_installed() === true) {
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_not_working',
'class' => 'hole flex-row flex-items-center w98p',
'direct' => 1,
'block_content' => [
[
'label' => __('If something is not working as expected, look for this icon and report!'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_not_working',
'id' => 'lbl_not_working',
],
],
[
'label' => html_print_image(
'images/feedback-header.png',
true,
[
'onclick' => '$(\'#feedback-header\').click()',
'style' => 'cursor: pointer;',
]
),
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_wizard_agent',
'class' => 'hole flex-row flex-items-center w98p row_grey',
'direct' => 1,
'block_content' => [
[
'label' => __('Wizard install agent'),
'arguments' => [
'class' => 'first_lbl row_grey',
'name' => 'lbl_wizard_agent',
'id' => 'lbl_wizard_agent',
],
],
];
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => 'completed',
'mode' => 'onlyIcon',
],
'name' => 'btn_wizard_agent_conf',
'id' => 'btn_wizard_agent_conf',
],
],
],
];
$status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status'];
$check_web_color = 'row_grey';
if ($status_webserver === '1') {
$check_web_color = 'row_green';
}
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_check_web',
'class' => 'hole flex-row flex-items-center w98p '.$check_web_color,
'direct' => 1,
'block_content' => [
[
'label' => __('Create check web'),
'arguments' => [
'class' => 'first_lbl row_grey',
'name' => 'lbl_check_web',
'id' => 'lbl_check_web',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => 'completed',
'mode' => 'onlyIcon',
],
'name' => 'btn_check_web_conf',
'id' => 'btn_check_web_conf',
],
],
],
];
$status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status'];
$status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status'];
$check_connectivity = 'row_grey';
if ($status_newtwork === '1' && $status_pluggin === '1') {
$check_connectivity = 'row_green';
}
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_check_connectivity',
'class' => 'hole flex-row flex-items-center w98p '.$check_connectivity,
'direct' => 1,
'block_content' => [
[
'label' => __('Create basic connectivity'),
'arguments' => [
'class' => 'first_lbl row_grey',
'name' => 'lbl_check_connectivity',
'id' => 'lbl_check_connectivity',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => 'completed',
'mode' => 'onlyIcon',
],
'name' => 'btn_check_connectivity_conf',
'id' => 'btn_check_connectivity_conf',
],
],
],
];
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_check_net',
'class' => 'hole flex-row flex-items-center w98p row_green',
'direct' => 1,
'block_content' => [
[
'label' => __('Create basic net'),
'arguments' => [
'class' => 'first_lbl row_grey',
'name' => 'lbl_check_net',
'id' => 'lbl_check_net',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => 'completed',
'mode' => 'onlyIcon',
],
'name' => 'btn_check_net_conf',
'id' => 'btn_check_net_conf',
],
],
],
];
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_check_mail_alert',
'class' => 'hole flex-row flex-items-center w98p row_green',
'direct' => 1,
'block_content' => [
[
'label' => __('Create Alert Mail'),
'arguments' => [
'class' => 'first_lbl row_grey',
'name' => 'lbl_check_mail_alert',
'id' => 'lbl_check_mail_alert',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => [
'class' => 'completed',
'mode' => 'onlyIcon',
],
'name' => 'btn_check_mail_alert_conf',
'id' => 'btn_check_mail_alert_conf',
],
],
],
];
$output = $this->printForm(
[
'form' => $form,
@ -602,7 +757,7 @@ class WelcomeWindow extends Wizard
true
);
$output .= $this->loadJS();
$output .= $this->loadJS($flag_task);
echo $output;
// Ajax methods does not continue.
@ -830,82 +985,96 @@ class WelcomeWindow extends Wizard
*
* @return string HTML code for javascript functionality.
*/
public function loadJS()
public function loadJS($flag_task=false)
{
ob_start();
?>
<script type="text/javascript">
<?php
if ($this->step > W_CREATE_AGENT) {
switch ($this->step) {
case W_CREATE_MODULE:
?>
document.getElementById("button-btn_create_module").setAttribute(
'onclick',
'checkAgentOnline()'
);
<?php
break;
$('#div_all_correct').children().attr('class','w100p').attr('style', 'overflow-wrap: break-word;');
<?php if ($flag_task === true) { ?>
document.getElementById("button-btn_update_manager_conf").setAttribute(
'onclick',
'configureUpdateManager()'
);
document.getElementById("button-btn_email_conf").setAttribute(
'onclick',
'configureEmail()'
);
document.getElementById("button-btn_servers_up_conf").setAttribute(
'onclick',
'serversUp()'
);
document.getElementById("button-btn_license_valid_conf").setAttribute(
'onclick',
'messageLicense()'
);
<?php } ?>
case W_CREATE_ALERT:
?>
document.getElementById("button-btn_create_alert").setAttribute(
'onclick',
'createAlertModule()'
);
<?php
break;
// Task to do buttons.
document.getElementById("button-btn_wizard_agent_conf").setAttribute(
'onclick',
'deployAgent()'
);
default:
// Ignore.
break;
}
document.getElementById("button-btn_check_web_conf").setAttribute(
'onclick',
'openCreateModulesDialog()'
);
document.getElementById("button-btn_check_connectivity_conf").setAttribute(
'onclick',
'openCreateConnectivityDialog()'
);
document.getElementById("button-btn_check_net_conf").setAttribute(
'onclick',
'openCreateBasicNetDialog()'
);
document.getElementById("button-btn_check_mail_alert_conf").setAttribute(
'onclick',
'openCreateAlertMailDialog()'
);
function configureUpdateManager() {
window.location = '<?php echo ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'); ?>';
}
?>
document.getElementById("button-btn_email_conf").setAttribute(
'onclick',
'configureEmail()'
);
document.getElementById("button-btn_create_agent").setAttribute(
'onclick',
'createNewAgent()'
);
document.getElementById("button-btn_discover_devices").setAttribute(
'onclick',
'discoverDevicesNetwork()'
);
function configureEmail() {
window.location = '<?php echo ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general#table3'); ?>';
}
function configureEmail() {
window.location = '<?php echo ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general#table3'); ?>';
}
function serversUp() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'); ?>';
}
function createNewAgent() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&new_agent=1&crt-2=Create+agent'); ?>';
}
function messageLicense() {
window.location = '<?php echo ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_list'); ?>';
}
function checkAgentOnline() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$this->getWelcomeAgent().''); ?>';
}
function deployAgent() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&show_deploy_agent=1'); ?>';
}
function createAlertModule() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$this->getWelcomeAgent().''); ?>';
}
function openCreateModulesDialog() {
window.location = '<?php echo ui_get_full_url('index.php?sec=wizard&sec2=godmode/wizards/task_to_perform&create_modules_dialog=1'); ?>';
}
function monitorRemoteCommands() {
window.location = '<?php echo ui_get_full_url(''); ?>';
}
function openCreateConnectivityDialog() {
window.location = '<?php echo ui_get_full_url('index.php?sec=wizard&sec2=godmode/wizards/task_to_perform&create_connectivity_dialog=1'); ?>';
}
function discoverDevicesNetwork() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan'); ?>';
}
function openCreateBasicNetDialog() {
window.location = '<?php echo ui_get_full_url('index.php?sec=wizard&sec2=godmode/wizards/task_to_perform&create_net_scan_dialog=1'); ?>';
}
function reportIsNotWorking() {
}
function openCreateAlertMailDialog() {
window.location = '<?php echo ui_get_full_url('index.php?sec=wizard&sec2=godmode/wizards/task_to_perform&create_alert_mail_dialog=1'); ?>';
}
function cierre_dialog(){
this.dialog("close");
}
function cierre_dialog(){
this.dialog("close");
}
</script>
<?php
return ob_get_clean();

View File

@ -455,7 +455,7 @@ function alerts_delete_alert_action($id_alert_action)
*
* @return mixed Id of the cloned action or false in case of fail.
*/
function alerts_clone_alert_action($id_alert_action, $id_group)
function alerts_clone_alert_action($id_alert_action, $id_group, $copy_name='')
{
$id_alert_action = safe_int($id_alert_action, 1);
if (empty($id_alert_action)) {
@ -474,7 +474,13 @@ function alerts_clone_alert_action($id_alert_action, $id_group)
unset($action['id']);
return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action);
if ($copy_name !== '') {
$copy_name = $copy_name;
} else {
$copy_name = $action['name'].' '.__('copy');
}
return alerts_create_alert_action($copy_name, $action['id_alert_command'], $action);
}

View File

@ -1916,7 +1916,7 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
*
* @param $thrash3 Don't use.
*/
function api_set_new_agent($id_node, $thrash2, $other, $trhash3)
function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false)
{
global $config;
@ -2038,13 +2038,17 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3)
}
}
returnData(
'string',
[
'type' => 'string',
'data' => $id_agente,
]
);
if ($return === false) {
returnData(
'string',
[
'type' => 'string',
'data' => $id_agente,
]
);
} else {
return $id_agente;
}
} catch (\Exception $e) {
returnError($e->getMessage());
return;

View File

@ -6977,3 +6977,44 @@ function html_print_code_picker(
echo $output;
}
}
function html_print_wizard_diagnosis(
$title,
$id_button,
$description='',
$status=true,
$return=false,
) {
$button = '';
if ($status === true) {
$status = 'Connected';
$img = '/images/configuration@svg.svg';
} else {
$status = 'Disconnected';
$img = '/images/change-active.svg';
}
$button = html_print_image(
$img,
true,
[
'class' => 'main_menu_icon invert_filter float-right mrgn_right_10px',
'id' => $id_button,
]
);
$output = '<div class="rectangle rectangle_'.$status.'">
<span class="status '.$status.'">'.__($status).$button.'</span>
<div class="title">'.html_print_image('/images/circle_title.svg', true, ['class' => 'invert_filter']).'<span>'.$title.'</span></div>
<div class="description">
<span>'.$description.'</span>
</div>
</div>';
if ($return === true) {
return $output;
} else {
echo $output;
}
}

View File

@ -1317,3 +1317,24 @@ function servers_get_master()
return $result;
}
/**
* Return true if all servers are up.
*
* @return boolean
*/
function check_all_servers_up()
{
$status = true;
$servers = servers_get_info();
foreach ($servers as $server) {
if ($server['status'] !== '1') {
return false;
}
}
return $status;
}

View File

@ -3078,6 +3078,32 @@ function ui_print_module_status(
}
/**
* Returns html code to print a shape for a module.
*
* @param integer $color Hex color.
* @param boolean $return True or false.
* @param string $class Custom class or use defined.
* @param string $div_content Content.
*
* @return string HTML code for shape.
*/
function ui_print_diagnosis_status(
$color,
$return=false,
$class='status_rounded_rectangles',
$div_content=''
) {
$output = '<div style="background: '.$color.'" class="'.$class.'">'.$div_content.'</div>';
if ($return === false) {
echo $output;
}
return $output;
}
/**
* Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status.
*

View File

@ -0,0 +1,83 @@
.rectangle {
background-color: #ffffff;
border: 2px solid #e5e9ed;
border-radius: 6px;
max-width: 475px;
width: 475px;
height: 161px;
display: contents;
justify-content: flex-start;
}
.rectangle:hover {
background-color: #f3f5f7;
}
.rectangle_Connected {
border-left: 4px solid #82b92e;
}
.rectangle_Disconnected {
border-left: 4px solid #8a96a6;
}
.status {
font-weight: bold;
margin-top: -10px;
margin-left: 20px;
}
.Connected {
color: #82b92e;
font-family: Lato;
font-size: 15px;
line-height: 24px;
}
.Disconnected {
color: #8a96a6;
font-family: Lato;
font-size: 15px;
line-height: 24px;
}
.title {
margin-top: 20px;
margin-left: 20px;
}
.title > img {
margin-top: 5px;
}
.title > span {
color: #14524f;
font-family: Lato;
font-size: 18px;
line-height: 24px;
text-align: left;
margin-left: 10px;
margin-right: 10px;
display: inline-block;
margin-left: 20px;
margin-top: -20px;
}
.description {
margin-top: 20px;
margin-left: 10px;
color: #454545;
font-family: Lato;
font-size: 15px;
line-height: 24px;
width: 430px;
text-align: left;
}
.button {
text-align: right;
}
span > img:hover {
cursor: pointer;
}

View File

@ -86,3 +86,13 @@
#welcome_form li.extra {
padding-bottom: 2.5em;
}
#li-div_diagnosis,
#li-div_task_todo {
border-left: unset !important;
}
#div_diagnosis > label,
#div_task_todo > label {
font-weight: bold;
}