Merge branch 'ent-3924-eHorus-settings' into 'develop'
Ent 3924 e horus settings See merge request artica/pandorafms!2417
This commit is contained in:
commit
c0763b86d2
|
@ -16,4 +16,10 @@ INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `als
|
|||
UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System status' OR `description` = 'Official communication';
|
||||
UPDATE `tnotification_source` SET `icon`="icono_logo_pandora.png" WHERE `description` = 'Official communication';
|
||||
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1) DEFAULT '1';
|
||||
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1288,6 +1288,11 @@ alter table tusuario add autorefresh_white_list text not null default '';
|
|||
ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30';
|
||||
ALTER TABLE `tusuario` DROP COLUMN `flash_chart`;
|
||||
ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0';
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1);
|
||||
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagente_modulo`
|
||||
|
|
|
@ -66,6 +66,12 @@ $table_remote->class = 'databox filters';
|
|||
$table_remote->size['name'] = '30%';
|
||||
$table_remote->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Enable eHorus user configuration.
|
||||
$row = [];
|
||||
$row['name'] = ('eHorus configuration at user level');
|
||||
$row['control'] = html_print_checkbox_switch('ehorus_user_level_conf', 1, $config['ehorus_user_level_conf'], true);
|
||||
$table_remote->data['ehorus_user_level_conf'] = $row;
|
||||
|
||||
// User.
|
||||
$row = [];
|
||||
$row['name'] = __('User');
|
||||
|
@ -163,9 +169,19 @@ echo '</div>';
|
|||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
||||
$('#form_remote').hide();
|
||||
|
||||
if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked'))
|
||||
{
|
||||
$('#form_remote').hide();
|
||||
}
|
||||
|
||||
if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
|
||||
{
|
||||
$('#ehorus-remote-setup-ehorus_user').hide();
|
||||
$('#ehorus-remote-setup-ehorus_pass').hide()
|
||||
}
|
||||
|
||||
|
||||
$('#form_enable').css('margin-bottom','20px');
|
||||
var showFields = function () {
|
||||
$('#form_remote').show();
|
||||
|
@ -173,6 +189,17 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
var hideFields = function () {
|
||||
$('#form_remote').hide();
|
||||
}
|
||||
|
||||
var hideUserPass = function () {
|
||||
$('#ehorus-remote-setup-ehorus_user').hide();
|
||||
$('#ehorus-remote-setup-ehorus_pass').hide();
|
||||
}
|
||||
|
||||
var showUserPass = function () {
|
||||
$('#ehorus-remote-setup-ehorus_user').show();
|
||||
$('#ehorus-remote-setup-ehorus_pass').show();
|
||||
}
|
||||
|
||||
var handleEnable = function (event) {
|
||||
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
|
||||
if (event.target.value == '1' && is_checked) {
|
||||
|
@ -184,15 +211,32 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
hideUserPass();
|
||||
$('input:checkbox[name="ehorus_user_level_conf"]').attr('checked', false);
|
||||
};
|
||||
}
|
||||
|
||||
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable);
|
||||
|
||||
$('input:checkbox[name="ehorus_user_level_conf"]').change(handleUserLevel);
|
||||
|
||||
var handleTest = function (event) {
|
||||
var user = $('input#text-ehorus_user').val();
|
||||
var pass = $('input#password-ehorus_pass').val();
|
||||
var host = $('input#text-ehorus_hostname').val();
|
||||
var port = $('input#text-ehorus_port').val();
|
||||
var timeout = Number.parseInt($('input#text-ehorus_req_timeout').val(), 10);
|
||||
|
||||
var is_checked_user_level = $('input:checkbox[name="ehorus_user_level_conf"]').is(':checked');
|
||||
|
||||
var timeoutMessage = '<?php echo __('Connection timeout'); ?>';
|
||||
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||
|
@ -230,7 +274,7 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
hideFailureImage();
|
||||
hideMessage();
|
||||
showLoadingImage();
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: 'https://' + host + ':' + port + '/login',
|
||||
type: 'POST',
|
||||
|
@ -245,9 +289,11 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
showSuccessImage();
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
showFailureImage();
|
||||
|
||||
if (xhr.status === 400) {
|
||||
if((xhr.status === 400 || xhr.status === 403) && is_checked_user_level)
|
||||
{
|
||||
showSuccessImage();
|
||||
return;
|
||||
}else if (xhr.status === 400) {
|
||||
changeTestMessage(badRequestMessage);
|
||||
}
|
||||
else if (xhr.status === 401 || xhr.status === 403) {
|
||||
|
@ -262,6 +308,8 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
else {
|
||||
changeTestMessage(errorThrown);
|
||||
}
|
||||
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
})
|
||||
.always(function(xhr, textStatus) {
|
||||
|
@ -269,4 +317,7 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
|
|||
});
|
||||
}
|
||||
$('input#button-test-ehorus').click(handleTest);
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -151,6 +151,12 @@ if ($new_user && $config['admin_can_add_user']) {
|
|||
$user_info['metaconsole_assigned_server'] = '';
|
||||
$user_info['metaconsole_access_node'] = 0;
|
||||
}
|
||||
|
||||
if ($config['ehorus_user_level_conf']) {
|
||||
$user_info['ehorus_user_level_user'] = '';
|
||||
$user_info['ehorus_user_level_pass'] = '';
|
||||
$user_info['ehorus_user_level_enabled'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($create_user) {
|
||||
|
@ -215,6 +221,19 @@ if ($create_user) {
|
|||
$values['strict_acl'] = (bool) get_parameter('strict_acl', false);
|
||||
$values['session_time'] = (int) get_parameter('session_time', 0);
|
||||
|
||||
// eHorus user level conf
|
||||
if ($config['ehorus_user_level_conf']) {
|
||||
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
|
||||
if ($values['ehorus_user_level_enabled'] === true) {
|
||||
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
|
||||
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
|
||||
} else {
|
||||
$values['ehorus_user_level_user'] = null;
|
||||
$values['ehorus_user_level_pass'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($id == '') {
|
||||
ui_print_error_message(__('User ID cannot be empty'));
|
||||
$user_info = $values;
|
||||
|
@ -298,6 +317,13 @@ if ($update_user) {
|
|||
$values['timezone'] = (string) get_parameter('timezone');
|
||||
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
|
||||
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
|
||||
// eHorus user level conf
|
||||
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
|
||||
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
|
||||
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
|
||||
|
||||
|
||||
|
||||
$dashboard = get_parameter('dashboard', '');
|
||||
$visual_console = get_parameter('visual_console', '');
|
||||
|
||||
|
@ -760,6 +786,7 @@ if (enterprise_installed() && !is_metaconsole()) {
|
|||
$values['Dashboard'] = __('Dashboard');
|
||||
}
|
||||
|
||||
|
||||
$table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false);
|
||||
|
||||
if (enterprise_installed()) {
|
||||
|
@ -842,6 +869,16 @@ foreach ($event_filter_data as $filter) {
|
|||
$table->data[16][0] = __('Default event filter');
|
||||
$table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false);
|
||||
|
||||
if ($config['ehorus_user_level_conf']) {
|
||||
$table->data[17][0] = __('eHorus user acces enabled');
|
||||
$table->data[17][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true);
|
||||
$table->data[18][0] = __('eHorus user');
|
||||
$table->data[19][0] = __('eHorus password');
|
||||
$table->data[18][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true);
|
||||
$table->data[19][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true);
|
||||
}
|
||||
|
||||
|
||||
if ($meta) {
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
|
||||
|
@ -933,6 +970,11 @@ $(document).ready (function () {
|
|||
$('#checkbox-metaconsole_agents_manager').trigger('change');
|
||||
|
||||
show_data_section();
|
||||
$('#checkbox-ehorus_user_level_enabled').change(function () {
|
||||
switch_ehorus_conf();
|
||||
});
|
||||
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
||||
|
||||
});
|
||||
|
||||
function show_data_section () {
|
||||
|
@ -987,5 +1029,21 @@ function show_data_section () {
|
|||
}
|
||||
}
|
||||
|
||||
function switch_ehorus_conf()
|
||||
{
|
||||
if(!$('#checkbox-ehorus_user_level_enabled').prop('checked'))
|
||||
{
|
||||
$("#user_configuration_table-18").hide();
|
||||
$("#user_configuration_table-19").hide();
|
||||
|
||||
}else
|
||||
{
|
||||
$("#user_configuration_table-18").show();
|
||||
$("#user_configuration_table-19").show()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
|
|
@ -1353,6 +1353,10 @@ function config_update_config()
|
|||
$error_update[] = __('Enable eHorus');
|
||||
}
|
||||
|
||||
if (!config_update_value('ehorus_user_level_conf', (int) get_parameter('ehorus_user_level_conf', 0))) {
|
||||
$error_update[] = __('eHorus user login');
|
||||
}
|
||||
|
||||
if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) {
|
||||
$error_update[] = __('eHorus user');
|
||||
}
|
||||
|
|
|
@ -4896,7 +4896,8 @@ input:checked + .p-slider:before {
|
|||
}
|
||||
|
||||
.user_edit_first_row,
|
||||
.user_edit_second_row {
|
||||
.user_edit_second_row,
|
||||
.user_edit_third_row {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,12 @@ $curl_timeout = $config['ehorus_req_timeout'];
|
|||
|
||||
$base_url = 'https://'.$hostname.':'.$port;
|
||||
|
||||
// If user login is enabled, fetch user and pass from user info
|
||||
if ($config['ehorus_user_level_conf']) {
|
||||
$user = $user_info['ehorus_user_level_user'];
|
||||
$password = io_safe_output(io_output_password($user_info['ehorus_user_level_pass']));
|
||||
}
|
||||
|
||||
// Get the login auth token
|
||||
$login_path = '/api/login';
|
||||
$body = [
|
||||
|
|
|
@ -1260,38 +1260,47 @@ if (enterprise_installed() && $config['log_collector']) {
|
|||
|
||||
// EHorus tab.
|
||||
if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field'])
|
||||
&& (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || is_user_admin($config['id_user']))
|
||||
&& (check_acl_one_of_groups(
|
||||
$config['id_user'],
|
||||
$all_groups,
|
||||
'AW'
|
||||
) || is_user_admin($config['id_user']))
|
||||
) {
|
||||
$ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']);
|
||||
if (!empty($ehorus_agent_id)) {
|
||||
$tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente;
|
||||
$ehorus_tab['text'] = '<a href="'.$tab_url.'" class="ehorus_tab">'.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).'</a>';
|
||||
$user_info = users_get_user_by_id($config['id_user']);
|
||||
if ($config['ehorus_user_level_conf'] && !$user_info['ehorus_user_level_enabled']) {
|
||||
// If ehorus user configuration is enabled, and userr acces level is disabled do not show eHorus tab.
|
||||
} else {
|
||||
$ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']);
|
||||
if (!empty($ehorus_agent_id)) {
|
||||
$tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente;
|
||||
$ehorus_tab['text'] = '<a href="'.$tab_url.'" class="ehorus_tab">'.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).'</a>';
|
||||
|
||||
// Hidden subtab layer.
|
||||
$ehorus_tab['sub_menu'] = '<ul class="mn subsubmenu" style="float:none;">';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_terminal" href="'.$tab_url.'&client_tab=terminal">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/terminal.png', true, [ 'title' => __('Terminal')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_display" href="'.$tab_url.'&client_tab=display">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/vnc.png', true, [ 'title' => __('Display')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_processes" href="'.$tab_url.'&client_tab=processes">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/processes.png', true, [ 'title' => __('Processes')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_services" href="'.$tab_url.'&client_tab=services">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/services.png', true, [ 'title' => __('Services')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_files" href="'.$tab_url.'&client_tab=files">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/files.png', true, [ 'title' => __('Files')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '</ul>';
|
||||
// Hidden subtab layer.
|
||||
$ehorus_tab['sub_menu'] = '<ul class="mn subsubmenu" style="float:none;">';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_terminal" href="'.$tab_url.'&client_tab=terminal">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/terminal.png', true, [ 'title' => __('Terminal')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_display" href="'.$tab_url.'&client_tab=display">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/vnc.png', true, [ 'title' => __('Display')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_processes" href="'.$tab_url.'&client_tab=processes">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/processes.png', true, [ 'title' => __('Processes')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_services" href="'.$tab_url.'&client_tab=services">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/services.png', true, [ 'title' => __('Services')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '<a class="tab_files" href="'.$tab_url.'&client_tab=files">';
|
||||
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/files.png', true, [ 'title' => __('Files')]);
|
||||
$ehorus_tab['sub_menu'] .= '</li>';
|
||||
$ehorus_tab['sub_menu'] .= '</a>';
|
||||
$ehorus_tab['sub_menu'] .= '</ul>';
|
||||
|
||||
$ehorus_tab['active'] = $tab == 'ehorus';
|
||||
$ehorus_tab['active'] = $tab == 'ehorus';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||
$dashboard = get_parameter('dashboard', '');
|
||||
$visual_console = get_parameter('visual_console', '');
|
||||
|
||||
|
||||
// Save autorefresh list.
|
||||
$autorefresh_list = get_parameter_post('autorefresh_list');
|
||||
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
|
||||
|
@ -122,6 +123,11 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||
}
|
||||
|
||||
$upd_info['time_autorefresh'] = (int) get_parameter('time_autorefresh', 0);
|
||||
$upd_info['ehorus_user_level_user'] = get_parameter('ehorus_user_level_user');
|
||||
$upd_info['ehorus_user_level_pass'] = get_parameter('ehorus_user_level_pass');
|
||||
$upd_info['ehorus_user_level_enabled'] = get_parameter('ehorus_user_level_enabled', 0);
|
||||
|
||||
|
||||
|
||||
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $id);
|
||||
|
||||
|
@ -624,6 +630,8 @@ echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?s
|
|||
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$newsletter.$newsletter_reminder.$double_authentication.'</div>
|
||||
<div class="edit_user_timezone">'.$timezone;
|
||||
|
||||
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
echo '<div id="timezone-picker">
|
||||
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
|
||||
|
@ -639,7 +647,61 @@ if (!is_metaconsole()) {
|
|||
</div>
|
||||
</div>';
|
||||
|
||||
echo '<div class="edit_user_button">';
|
||||
if ($config['ehorus_enabled'] && $config['ehorus_user_level_conf']) {
|
||||
// eHorus user remote login
|
||||
$table_remote = new StdClass();
|
||||
$table_remote->data = [];
|
||||
$table_remote->width = '100%';
|
||||
$table_remote->id = 'ehorus-remote-setup';
|
||||
$table_remote->class = 'white_box';
|
||||
$table_remote->size['name'] = '30%';
|
||||
$table_remote->style['name'] = 'font-weight: bold';
|
||||
|
||||
|
||||
// Title
|
||||
$row = [];
|
||||
$row['control'] = '<p class="edit_user_labels">'.__('eHorus user configuration').': </p>';
|
||||
$table_remote->data['ehorus_user_level_conf'] = $row;
|
||||
|
||||
// Enable/disable eHorus for this user
|
||||
$row = [];
|
||||
$row['name'] = __('eHorus user acces enabled');
|
||||
$row['control'] = html_print_checkbox_switch('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true);
|
||||
$table_remote->data['ehorus_user_level_enabled'] = $row;
|
||||
|
||||
// User.
|
||||
$row = [];
|
||||
$row['name'] = __('User');
|
||||
$row['control'] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 30, 100, true);
|
||||
$table_remote->data['ehorus_user_level_user'] = $row;
|
||||
|
||||
// Pass.
|
||||
$row = [];
|
||||
$row['name'] = __('Password');
|
||||
$row['control'] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 30, 100, true);
|
||||
$table_remote->data['ehorus_user_level_pass'] = $row;
|
||||
|
||||
// Test.
|
||||
$ehorus_port = db_get_value('value', 'tconfig', 'token', 'ehorus_port');
|
||||
$ehorus_host = db_get_value('value', 'tconfig', 'token', 'ehorus_hostname');
|
||||
|
||||
$row = [];
|
||||
$row['name'] = __('Test');
|
||||
$row['control'] = html_print_button(__('Start'), 'test-ehorus', false, 'ehorus_connection_test("'.$ehorus_host.'",'.$ehorus_port.')', 'class="sub next"', true);
|
||||
$row['control'] .= ' <span id="test-ehorus-spinner" style="display:none;"> '.html_print_image('images/spinner.gif', true).'</span>';
|
||||
$row['control'] .= ' <span id="test-ehorus-success" style="display:none;"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
|
||||
$row['control'] .= ' <span id="test-ehorus-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||
$row['control'] .= '<span id="test-ehorus-message" style="display:none;"></span>';
|
||||
$table_remote->data['ehorus_test'] = $row;
|
||||
|
||||
echo '<div class="ehorus_user_conf">';
|
||||
|
||||
html_print_table($table_remote);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
echo '<div class="edit_user_button">';
|
||||
if (!$config['user_can_update_info']) {
|
||||
echo '<i>'.__('You can not change your user info under the current authentication scheme').'</i>';
|
||||
} else {
|
||||
|
@ -648,8 +710,7 @@ if (!$config['user_can_update_info']) {
|
|||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
echo '</form>';
|
||||
|
||||
echo '<div id="edit_user_profiles" class="white_box">';
|
||||
if (!defined('METACONSOLE')) {
|
||||
|
@ -748,13 +809,13 @@ if (!defined('METACONSOLE')) {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
// Include OpenLayers and timezone user map library.
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
|
||||
// Closes no meta condition.
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
@ -1079,4 +1140,83 @@ function show_double_auth_deactivation () {
|
|||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
function ehorus_connection_test(host, port) {
|
||||
var user = $('input#text-ehorus_user_level_user').val();
|
||||
var pass = $('input#password-ehorus_user_level_pass').val();
|
||||
|
||||
debugger;
|
||||
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
|
||||
|
||||
var hideLoadingImage = function () {
|
||||
$('#test-ehorus-spinner').hide();
|
||||
}
|
||||
var showLoadingImage = function () {
|
||||
$('#test-ehorus-spinner').show();
|
||||
}
|
||||
var hideSuccessImage = function () {
|
||||
$('#test-ehorus-success').hide();
|
||||
}
|
||||
var showSuccessImage = function () {
|
||||
$('#test-ehorus-success').show();
|
||||
}
|
||||
var hideFailureImage = function () {
|
||||
$('#test-ehorus-failure').hide();
|
||||
}
|
||||
var showFailureImage = function () {
|
||||
$('#test-ehorus-failure').show();
|
||||
}
|
||||
var hideMessage = function () {
|
||||
$('#test-ehorus-message').hide();
|
||||
}
|
||||
var showMessage = function () {
|
||||
$('#test-ehorus-message').show();
|
||||
}
|
||||
var changeTestMessage = function (message) {
|
||||
$('#test-ehorus-message').text(message);
|
||||
}
|
||||
|
||||
hideSuccessImage();
|
||||
hideFailureImage();
|
||||
hideMessage();
|
||||
showLoadingImage();
|
||||
|
||||
$.ajax({
|
||||
url: 'https://' + host + ':' + port + '/login',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
user: user,
|
||||
pass: pass
|
||||
}
|
||||
})
|
||||
.done(function(data, textStatus, xhr) {
|
||||
showSuccessImage();
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
showFailureImage();
|
||||
|
||||
if (xhr.status === 400) {
|
||||
changeTestMessage(badRequestMessage);
|
||||
}
|
||||
else if (xhr.status === 401 || xhr.status === 403) {
|
||||
changeTestMessage(invalidPassMessage);
|
||||
}
|
||||
else if (xhr.status === 404) {
|
||||
changeTestMessage(notFoundMessage);
|
||||
}
|
||||
else if (errorThrown === 'timeout') {
|
||||
changeTestMessage(timeoutMessage);
|
||||
}
|
||||
else {
|
||||
changeTestMessage(errorThrown);
|
||||
}
|
||||
showMessage();
|
||||
})
|
||||
.always(function(xhr, textStatus) {
|
||||
hideLoadingImage();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1146,6 +1146,9 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
|
|||
`autorefresh_white_list` text not null default '',
|
||||
`time_autorefresh` int(5) unsigned NOT NULL default '30',
|
||||
`default_custom_view` int(10) unsigned NULL default '0',
|
||||
`ehorus_user_level_user` VARCHAR(60),
|
||||
`ehorus_user_level_pass` VARCHAR(45),
|
||||
`ehorus_user_level_enabled` TINYINT(1),
|
||||
CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL,
|
||||
UNIQUE KEY `id_user` (`id_user`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue