Adapt views

This commit is contained in:
jose.gonzalez@pandorafms.com 2022-10-26 10:51:12 +02:00
parent ffa0d24083
commit c7aa456d60
6 changed files with 197 additions and 105 deletions

@ -725,15 +725,19 @@ echo '<fieldset>';
html_print_table($table_other);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('update_config', 1);
html_print_submit_button(
__('Update'),
'update_button',
false,
'class="sub upd"'
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
[ 'icon' => 'update' ],
true
),
]
);
echo '</div>';
echo '</form>';
?>

@ -1,30 +1,30 @@
<?php
/**
* Extension to self monitor Pandora FMS Console
* Authentication setup.
*
* @package Pandora FMS
* @version 1.0.0
* @license See below
* Pandora FMS - http://pandorafms.com
* * ==================================================
* * Copyright (c) 2005-2021 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.
* * Warning: This file may be required into the metaconsole's setup
* * Load global vars
* @category Setup
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2022 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
if ((bool) check_acl($config['id_user'], 0, 'PM') === true && is_user_admin($config['id_user']) === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Setup Management'
@ -36,10 +36,10 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
// Load enterprise extensions.
enterprise_include('godmode/setup/setup_auth.php');
if (is_ajax()) {
if (is_ajax() === true) {
$change_auth_metod = (bool) get_parameter('change_auth_metod');
if ($change_auth_metod) {
if ($change_auth_metod === true) {
$table = new StdClass();
$table->data = [];
$table->width = '100%';
@ -62,7 +62,7 @@ if (is_ajax()) {
);
$table->data['fallback_local_auth'] = $row;
if (enterprise_installed()) {
if (enterprise_installed() === true) {
$is_management_allowed = is_management_allowed();
// Autocreate remote users.
$row = [];
@ -83,9 +83,6 @@ if (is_ajax()) {
}
switch ($type_auth) {
case 'mysql':
break;
case 'ldap':
// LDAP server.
$row = [];
@ -335,11 +332,12 @@ if (is_ajax()) {
case 'saml':
case 'integria':
// Add enterprise authentication options.
if (enterprise_installed()) {
if (enterprise_installed() === true) {
add_enterprise_auth_options($table, $type_auth);
}
break;
case 'mysql':
default:
// Default case.
break;
@ -373,7 +371,7 @@ if (is_ajax()) {
true
);
if (!$config['double_auth_enabled']) {
if ((bool) $config['double_auth_enabled'] === false) {
$table->rowclass['2FA_all_users'] = 'invisible';
} else {
$table->rowclass['2FA_all_users'] = '';
@ -432,7 +430,7 @@ $auth_methods = [
'mysql' => __('Local %s', get_product_name()),
'ldap' => __('ldap'),
];
if (enterprise_installed()) {
if (enterprise_installed() === true) {
add_enterprise_auth_methods($auth_methods);
}
@ -452,7 +450,7 @@ $table->data['auth'] = $row;
// Form.
echo '<form id="form_setup" method="post">';
if (!is_metaconsole()) {
if (is_metaconsole() === false) {
html_print_input_hidden('update_config', 1);
} else {
// To use it in the metasetup.
@ -461,15 +459,20 @@ if (!is_metaconsole()) {
}
html_print_table($table);
echo '<div id="table_auth_result"></div>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
__('Update'),
'update_button',
false,
'class="sub upd"'
html_print_div([ 'id' => 'table_auth_result' ]);
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
[ 'icon' => 'update' ],
true
),
]
);
echo '</div>';
echo '</form>';
?>

@ -1,12 +1,20 @@
<?php
/**
* View eHorus setup.
*
* @category Setup
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Copyright (c) 2005-2022 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
@ -18,6 +26,7 @@
* ============================================================================
*/
// Load globals.
global $config;
check_login();
@ -109,7 +118,17 @@ $table_remote->data['ehorus_req_timeout'] = $row;
// Test.
$row = [];
$row['name'] = __('Test');
$row['control'] = html_print_button(__('Start'), 'test-ehorus', false, '', 'class="sub next"', true);
$row['control'] = html_print_button(
__('Start'),
'test-ehorus',
false,
'',
[
'icon' => 'cog',
'mode' => 'secondary mini',
],
true
);
$row['control'] .= '<span id="test-ehorus-spinner" class="invisible">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-ehorus-success" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-ehorus-failure" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
@ -119,7 +138,7 @@ $table_remote->data['ehorus_test'] = $row;
// Print.
echo '<div class="center pdd_b_20px">';
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
if ($config['style'] === 'pandora_black' && is_metaconsole() === true) {
html_print_image(
'include/ehorus/images/ehorus-logo.png',
false,
@ -175,12 +194,21 @@ echo '</div>';
echo '</fieldset>';
echo '</div>';
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
['icon' => 'update'],
true
),
]
);
echo '</form>';
?>
?>
<script type="text/javascript">
@ -229,7 +257,7 @@ if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
var handleUserLevel = function(event) {
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
var is_checked_userlevel = $('input:checkbox[name="ehorus_user_level_conf"]').is(':checked');
if (event.target.value == '1' && is_checked && !is_checked_userlevel) {
showUserPass();
$('input:checkbox[name="ehorus_user_level_conf"]').attr('checked', true);
@ -283,12 +311,12 @@ if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
var changeTestMessage = function (message) {
$('span#test-ehorus-message').text(message);
}
hideSuccessImage();
hideFailureImage();
hideMessage();
showLoadingImage();
$.ajax({
url: 'https://' + host + ':' + port + '/login',
type: 'POST',
@ -322,7 +350,7 @@ if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
else {
changeTestMessage(errorThrown);
}
showFailureImage();
showMessage();
})
@ -330,8 +358,6 @@ if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
hideLoadingImage();
});
}
$('input#button-test-ehorus').click(handleTest);
$('#button-test-ehorus').click(handleTest);
</script>

@ -620,7 +620,7 @@ echo '<legend>'.__('Mail configuration').'</legend>';
'email_test_dialog',
false,
"show_email_test('".$uniqid."');",
'class="sub next"',
[ 'icon' => 'next' ],
true
);
@ -634,9 +634,19 @@ echo '<legend>'.__('Mail configuration').'</legend>';
echo '<fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
['icon' => 'update'],
true
),
]
);
echo '</form>';
@ -667,17 +677,26 @@ echo '<legend>'.__('Mail configuration').'</legend>';
true
);
$table_mail_test->data[1][0] = html_print_button(
__('Send'),
'email_test',
false,
'',
'class="sub next"',
$table_mail_test->data[1][0] = '&nbsp&nbsp<span id="email_test_sent_message" class="invisible"><b>Email sent</b></span><span id="email_test_failure_message" class=invisible"><b>Email could not be sent</b></span>';
$table_mail_test->data[1][1] = html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_button(
__('Send'),
'email_test',
false,
'',
[
'icon' => 'cog',
'mode' => 'mini',
],
true
),
],
true
);
$table_mail_test->data[1][1] = '&nbsp&nbsp<span id="email_test_sent_message" class="invisible"><b>Email sent</b></span><span id="email_test_failure_message" class=invisible"><b>Email could not be sent</b></span>';
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" class="invisible">'.html_print_table($table_mail_test, true).'</div>';
}
@ -814,6 +833,6 @@ $(document).ready (function () {
}
})
$('input#button-email_test').click(perform_email_test);
$('#button-email_test').click(perform_email_test);
});
</script>

@ -1,12 +1,20 @@
<?php
/**
* Integria setup.
*
* @category Setup
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Copyright (c) 2005-2022 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
@ -18,6 +26,7 @@
* ============================================================================
*/
// Load globals.
global $config;
check_login();
@ -33,27 +42,19 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
require_once $config['homedir'].'/include/functions_integriaims.php';
if (is_ajax()) {
if (is_ajax() === true) {
$operation = (string) get_parameter('operation', '');
if ($operation === 'check_api_access') {
} else if ($operation === 'sync_inventory') {
}
$integria_user = get_parameter('integria_user', '');
$integria_pass = get_parameter('integria_pass', '');
$integria_api_hostname = get_parameter('api_hostname', '');
$integria_api_pass = get_parameter('api_pass', '');
$user_level_conf = get_parameter('user_level_conf', 0);
$user_level_conf_bool = $user_level_conf === 'true' ? true : false;
$user_level_conf_bool = ((bool) $user_level_conf === true);
$login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', [], false, '', '', $user_level_conf_bool);
if ($login_result != false) {
echo json_encode(['login' => 1]);
} else {
echo json_encode(['login' => 0]);
}
echo json_encode(['login' => ($login_result !== false) ? 1 : 0]);
return;
}
@ -312,7 +313,17 @@ $table_remote->data['integria_req_timeout'] = $row;
$row = [];
$row['name'] = __('Inventory');
$row['control'] = html_print_button(__('Sync inventory'), 'sync-inventory', false, '', 'class="sub next"', true);
$row['control'] = html_print_button(
__('Sync inventory'),
'sync-inventory',
false,
'',
[
'icon' => 'cog',
'mode' => 'secondary mini',
],
true
);
$row['control'] .= '<span id="test-integria-spinner-sync" style="display:none;">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-integria-success-sync" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-integria-failure-sync" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
@ -564,7 +575,17 @@ $table_cr_settings->data['custom_response_incident_status'] = $row;
// Test.
$row = [];
$row['name'] = __('Test');
$row['control'] = html_print_button(__('Start'), 'test-integria', false, '', 'class="sub next"', true);
$row['control'] = html_print_button(
__('Start'),
'test-integria',
false,
'',
[
'icon' => 'cog',
'mode' => 'secondary mini',
],
true
);
$row['control'] .= '<span id="test-integria-spinner" class="invisible">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-integria-success" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-integria-failure" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
@ -628,13 +649,31 @@ if ($has_connection != false) {
echo '</fieldset>';
echo '</div>';
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
['icon' => 'update'],
true
),
]
);
} else {
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update and continue'), 'update_button', false, 'class="sub next"');
echo '</div>';
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update and continue'),
'update_button',
false,
['icon' => 'update'],
true
),
]
);
}
@ -653,7 +692,7 @@ echo '</form>';
var handleUserLevel = function(event) {
var is_checked = $('input:checkbox[name="integria_enabled"]').is(':checked');
var is_checked_userlevel = $('input:checkbox[name="integria_user_level_conf"]').is(':checked');
if (event.target.value == '1' && is_checked && !is_checked_userlevel) {
showUserPass();
$('input:checkbox[name="integria_user_level_conf"]').attr('checked', true);
@ -797,11 +836,11 @@ echo '</form>';
}
var handleInventorySync = function (event) {
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
var notFoundMessage = '<?php echo __('User not found'); ?>';
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
var hideLoadingImage = function () {
$('span#test-integria-spinner-sync').hide();
}
@ -821,7 +860,6 @@ echo '</form>';
$('span#test-integria-failure-sync').show();
}
hideSuccessImage();
hideFailureImage();
showLoadingImage();
@ -887,9 +925,7 @@ echo '</form>';
});
}
$('input#button-test-integria').click(handleTest);
$('input#button-sync-inventory').click(handleInventorySync);
$('#button-test-integria').click(handleTest);
$('#button-sync-inventory').click(handleInventorySync);
</script>

@ -84,12 +84,16 @@ if (function_exists('quickShellSettings') === true) {
quickShellSettings();
}
echo '<div class="action-buttons w100p">';
html_print_submit_button(
__('Update'),
'update_button',
false,
'class="sub upd"'
html_print_div(
[
'class' => 'action-buttons w100p',
'content' => html_print_submit_button(
__('Update'),
'update_button',
false,
[ 'icon' => 'update' ],
true
),
]
);
echo '</div>';
echo '</form>';