Merge branch 'ent-3543-Cambio-visual-de-radio-buttons-y-checkbox-en-el-setup' into 'develop'

Changed radio buttons by checkbox switch

See merge request artica/pandorafms!2235

Former-commit-id: 23face1e62093414afb9be18a4353eeab073105f
This commit is contained in:
Alejandro Fraguas 2019-03-11 11:18:10 +01:00
commit 62c38173eb
6 changed files with 92 additions and 71 deletions

View File

@ -134,7 +134,6 @@ if (is_ajax()) {
set_unless_defined($config['double_auth_enabled'], false); set_unless_defined($config['double_auth_enabled'], false);
$row = []; $row = [];
$row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true); $row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true);
$row['control'] = html_print_input_hidden('double_auth_enabled', 0);
$row['control'] .= html_print_checkbox_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); $row['control'] .= html_print_checkbox_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true);
$table->data['double_auth_enabled'] = $row; $table->data['double_auth_enabled'] = $row;

View File

@ -1,18 +1,23 @@
<?php <?php
/**
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 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
global $config; global $config;
check_login(); check_login();
@ -23,7 +28,7 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
return; return;
} }
// Check custom field // Check custom field.
$custom_field = db_get_value('name', 'tagent_custom_fields', 'name', $config['ehorus_custom_field']); $custom_field = db_get_value('name', 'tagent_custom_fields', 'name', $config['ehorus_custom_field']);
$custom_field_exists = !empty($custom_field); $custom_field_exists = !empty($custom_field);
$custom_field_created = null; $custom_field_created = null;
@ -36,7 +41,7 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) {
$custom_field_exists = $custom_field_created = $result; $custom_field_exists = $custom_field_created = $result;
} }
// Enable table // Enable table.
$table_enable = new StdClass(); $table_enable = new StdClass();
$table_enable->data = []; $table_enable->data = [];
$table_enable->width = '100%'; $table_enable->width = '100%';
@ -45,15 +50,13 @@ $table_enable->class = 'databox filters';
$table_enable->size['name'] = '30%'; $table_enable->size['name'] = '30%';
$table_enable->style['name'] = 'font-weight: bold'; $table_enable->style['name'] = 'font-weight: bold';
// Enable eHorus // Enable eHorus.
$row = []; $row = [];
$row['name'] = __('Enable eHorus'); $row['name'] = __('Enable eHorus');
$row['control'] = __('Enabled').'&nbsp;'.html_print_radio_button('ehorus_enabled', 1, '', $config['ehorus_enabled'], true).'&nbsp;&nbsp;'; $row['control'] = html_print_checkbox_switch('ehorus_enabled', 1, $config['ehorus_enabled'], true);
$row['control'] .= __('Disabled').'&nbsp;'.html_print_radio_button('ehorus_enabled', 0, '', $config['ehorus_enabled'], true);
$row['button'] = html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"', true);
$table_enable->data['ehorus_enabled'] = $row; $table_enable->data['ehorus_enabled'] = $row;
// Remote config table // Remote config table.
$table_remote = new StdClass(); $table_remote = new StdClass();
$table_remote->data = []; $table_remote->data = [];
$table_remote->width = '100%'; $table_remote->width = '100%';
@ -63,40 +66,40 @@ $table_remote->class = 'databox filters';
$table_remote->size['name'] = '30%'; $table_remote->size['name'] = '30%';
$table_remote->style['name'] = 'font-weight: bold'; $table_remote->style['name'] = 'font-weight: bold';
// User // User.
$row = []; $row = [];
$row['name'] = __('User'); $row['name'] = __('User');
$row['control'] = html_print_input_text('ehorus_user', $config['ehorus_user'], '', 30, 100, true); $row['control'] = html_print_input_text('ehorus_user', $config['ehorus_user'], '', 30, 100, true);
$table_remote->data['ehorus_user'] = $row; $table_remote->data['ehorus_user'] = $row;
// Pass // Pass.
$row = []; $row = [];
$row['name'] = __('Password'); $row['name'] = __('Password');
$row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true); $row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true);
$table_remote->data['ehorus_pass'] = $row; $table_remote->data['ehorus_pass'] = $row;
// Directory hostname // Directory hostname.
$row = []; $row = [];
$row['name'] = __('API Hostname'); $row['name'] = __('API Hostname');
$row['control'] = html_print_input_text('ehorus_hostname', $config['ehorus_hostname'], '', 30, 100, true); $row['control'] = html_print_input_text('ehorus_hostname', $config['ehorus_hostname'], '', 30, 100, true);
$row['control'] .= ui_print_help_tip(__('Hostname of the eHorus API').'. '.__('Without protocol and port').'. '.__('e.g., portal.ehorus.com'), true); $row['control'] .= ui_print_help_tip(__('Hostname of the eHorus API').'. '.__('Without protocol and port').'. '.__('e.g., portal.ehorus.com'), true);
$table_remote->data['ehorus_hostname'] = $row; $table_remote->data['ehorus_hostname'] = $row;
// Directory port // Directory port.
$row = []; $row = [];
$row['name'] = __('API Port'); $row['name'] = __('API Port');
$row['control'] = html_print_input_text('ehorus_port', $config['ehorus_port'], '', 6, 100, true); $row['control'] = html_print_input_text('ehorus_port', $config['ehorus_port'], '', 6, 100, true);
$row['control'] .= ui_print_help_tip(__('e.g., 18080'), true); $row['control'] .= ui_print_help_tip(__('e.g., 18080'), true);
$table_remote->data['ehorus_port'] = $row; $table_remote->data['ehorus_port'] = $row;
// Request timeout // Request timeout.
$row = []; $row = [];
$row['name'] = __('Request timeout'); $row['name'] = __('Request timeout');
$row['control'] = html_print_input_text('ehorus_req_timeout', $config['ehorus_req_timeout'], '', 3, 10, true); $row['control'] = html_print_input_text('ehorus_req_timeout', $config['ehorus_req_timeout'], '', 3, 10, true);
$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the eHorus API').'. '.__('0 to disable'), true); $row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the eHorus API').'. '.__('0 to disable'), true);
$table_remote->data['ehorus_req_timeout'] = $row; $table_remote->data['ehorus_req_timeout'] = $row;
// Test // Test.
$row = []; $row = [];
$row['name'] = __('Test'); $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, '', 'class="sub next"', true);
@ -106,7 +109,7 @@ $row['control'] .= '<span id="test-ehorus-failure" style="display:none;">&nbsp;'
$row['control'] .= '&nbsp;<span id="test-ehorus-message" style="display:none;"></span>'; $row['control'] .= '&nbsp;<span id="test-ehorus-message" style="display:none;"></span>';
$table_remote->data['ehorus_test'] = $row; $table_remote->data['ehorus_test'] = $row;
// Print // Print.
echo '<div style="text-align: center; padding-bottom: 20px;">'; echo '<div style="text-align: center; padding-bottom: 20px;">';
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">'; echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
html_print_image('include/ehorus/images/ehorus-logo-grey.png'); html_print_image('include/ehorus/images/ehorus-logo-grey.png');
@ -136,13 +139,13 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) {
ui_print_error_message($error_message); ui_print_error_message($error_message);
} }
// Form enable // Form enable.
echo '<form id="form_enable" method="post">'; echo '<form id="form_enable" method="post">';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
html_print_table($table_enable); html_print_table($table_enable);
echo '</form>'; echo '</form>';
// Form remote // Form remote.
if ($config['ehorus_enabled']) { if ($config['ehorus_enabled']) {
echo '<form id="form_remote" method="post">'; echo '<form id="form_remote" method="post">';
echo '<fieldset>'; echo '<fieldset>';
@ -159,6 +162,9 @@ if ($config['ehorus_enabled']) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
$('form#form_remote').hide();
$('form#form_enable').css('margin-bottom','20px');
var showFields = function () { var showFields = function () {
$('form#form_remote').show(); $('form#form_remote').show();
} }
@ -166,10 +172,17 @@ if ($config['ehorus_enabled']) {
$('form#form_remote').hide(); $('form#form_remote').hide();
} }
var handleEnable = function (event) { var handleEnable = function (event) {
if (event.target.value == '1') showFields(); var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
else hideFields(); if (event.target.value == '1' && is_checked) {
showFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
}
else {
hideFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
};
} }
$('input:radio[name="ehorus_enabled"]').change(handleEnable); $('input:checkbox[name="ehorus_enabled"]').change(handleEnable);
var handleTest = function (event) { var handleTest = function (event) {
var user = $('input#text-ehorus_user').val(); var user = $('input#text-ehorus_user').val();

View File

@ -1,17 +1,23 @@
<?php <?php
/**
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -269,12 +275,10 @@ $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory
$table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); $table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true);
$table->data[38][0] = __('Set alias as name by default in agent creation'); $table->data[38][0] = __('Set alias as name by default in agent creation');
$table->data[38][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('alias_as_name', 1, '', $config['alias_as_name'], true).'&nbsp;&nbsp;'; $table->data[38][1] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true);
$table->data[38][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('alias_as_name', 0, '', $config['alias_as_name'], true);
$table->data[39][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); $table->data[39][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true);
$table->data[39][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('unique_ip', 1, '', $config['unique_ip'], true).'&nbsp;&nbsp;'; $table->data[39][1] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true);
$table->data[39][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('unique_ip', 0, '', $config['unique_ip'], true);
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">'; echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';

View File

@ -1,16 +1,23 @@
<?php <?php
/**
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
global $config; global $config;
require_once 'include/functions_ui.php'; require_once 'include/functions_ui.php';
@ -55,21 +62,19 @@ $table->data[5][0] = '<b>'.__('Maximum chart resolution').'</b>'.ui_print_help_t
$table->data[5][1] = html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true); $table->data[5][1] = html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true);
$table->data[6][0] = '<b>'.__('Disable custom live view filters').'</b>'.ui_print_help_tip(__('Disable the definition of custom filters in the live view. Only existing filters can be used.'), true); $table->data[6][0] = '<b>'.__('Disable custom live view filters').'</b>'.ui_print_help_tip(__('Disable the definition of custom filters in the live view. Only existing filters can be used.'), true);
$table->data[6][1] = __('Yes').'&nbsp;&nbsp;'.html_print_radio_button('netflow_disable_custom_lvfilters', 1, '', $config['netflow_disable_custom_lvfilters'], true).'&nbsp;&nbsp;&nbsp;'; $table->data[6][1] = html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true);
$table->data[6][1] .= __('No').'&nbsp;&nbsp;'.html_print_radio_button('netflow_disable_custom_lvfilters', 0, '', $config['netflow_disable_custom_lvfilters'], true);
$table->data[7][0] = '<b>'.__('Netflow max lifetime').'</b>'.ui_print_help_tip(__('Sets the maximum lifetime for netflow data in days.'), true); $table->data[7][0] = '<b>'.__('Netflow max lifetime').'</b>'.ui_print_help_tip(__('Sets the maximum lifetime for netflow data in days.'), true);
$table->data[7][1] = html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true); $table->data[7][1] = html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true);
$table->data[8][0] = '<b>'.__('Name resolution for IP address').'</b>'.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true); $table->data[8][0] = '<b>'.__('Name resolution for IP address').'</b>'.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true);
$onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;"; $onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;";
$table->data[8][1] = __('Yes').'&nbsp;&nbsp;'.html_print_radio_button_extended('netflow_get_ip_hostname', 1, '', $config['netflow_get_ip_hostname'], false, $onclick, '', true).'&nbsp;&nbsp;&nbsp;'; $table->data[8][1] = html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true);
$table->data[8][1] .= __('No').'&nbsp;&nbsp;'.html_print_radio_button('netflow_get_ip_hostname', 0, '', $config['netflow_get_ip_hostname'], true);
echo '<form id="netflow_setup" method="post">'; echo '<form id="netflow_setup" method="post">';
html_print_table($table); html_print_table($table);
// Update button // Update button.
echo '<div class="action-buttons" style="width:100%;">'; echo '<div class="action-buttons" style="width:100%;">';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
html_print_submit_button(__('Update'), 'upd_button', false, 'class="sub upd"'); html_print_submit_button(__('Update'), 'upd_button', false, 'class="sub upd"');

View File

@ -964,7 +964,7 @@ $row++;
__('Custom report front page. It will be applied to all reports and templates by default.'), __('Custom report front page. It will be applied to all reports and templates by default.'),
true true
); );
$table_other->data[$row][1] = html_print_checkbox( $table_other->data[$row][1] = html_print_checkbox_switch(
'custom_report_front', 'custom_report_front',
1, 1,
$config['custom_report_front'], $config['custom_report_front'],
@ -1438,12 +1438,12 @@ $(document).ready (function () {
// Juanma (06/05/2014) New feature: Custom front page for reports // Juanma (06/05/2014) New feature: Custom front page for reports
var custom_report = $('#checkbox-custom_report_front') var custom_report = $('#checkbox-custom_report_front')
.prop('checked'); .prop('checked');
display_custom_report_front(custom_report,$('#checkbox-custom_report_front').parent().parent().parent().parent().attr('id')); display_custom_report_front(custom_report,$('#checkbox-custom_report_front').parent().parent().parent().parent().parent().attr('id'));
$("#checkbox-custom_report_front").click( function() { $("#checkbox-custom_report_front").change( function() {
var custom_report = $('#checkbox-custom_report_front') var custom_report = $('#checkbox-custom_report_front')
.prop('checked'); .prop('checked');
display_custom_report_front(custom_report,$(this).parent().parent().parent().parent().attr('id')); display_custom_report_front(custom_report,$(this).parent().parent().parent().parent().parent().attr('id'));
}); });
$(".databox.filters").css('margin-bottom','-10px'); $(".databox.filters").css('margin-bottom','-10px');
}); });

View File

@ -128,8 +128,8 @@
</div> </div>
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.732'; $version = '7.0NG.732';
$build = '190311'; $build = '190311';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);