Setup Websocket engine, unified

This commit is contained in:
fbsanchez 2019-12-13 13:11:38 +01:00
parent 5f32bfdb64
commit bd1954ce38
8 changed files with 198 additions and 147 deletions

View File

@ -309,7 +309,7 @@ function quickShellSettings()
}
// Parser.
if (get_parameter('qs_update', false) !== false) {
if (get_parameter('update_config', false) !== false) {
// Gotty settings. Internal communication (WS).
$gotty = get_parameter(
'gotty',
@ -389,100 +389,104 @@ function quickShellSettings()
ui_print_success_message($msg);
}
// Form.
$wiz = new Wizard();
// Form. Using old style.
echo '<fieldset>';
echo '<legend>'.__('Quickshell').'</legend>';
$wiz->printForm(
[
'form' => [
'action' => '#',
'class' => 'wizard',
'method' => 'post',
],
'inputs' => [
[
'label' => __('Gotty path').ui_print_help_tip(
__('Leave blank if using an external Gotty service'),
true
),
'arguments' => [
'type' => 'text',
'name' => 'gotty',
'value' => $config['gotty'],
],
],
[
'label' => __('Gotty host'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_host',
'value' => $config['gotty_host'],
],
],
[
'label' => __('Gotty ssh port'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_ssh_port',
'value' => $config['gotty_ssh_port'],
],
],
[
'label' => __('Gotty telnet port'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_telnet_port',
'value' => $config['gotty_telnet_port'],
],
],
[
'toggle' => true,
'toggle_name' => 'Advanced',
'block_content' => [
[
'label' => __('Gotty user').ui_print_help_tip(
__('Optional, set a user to access gotty service'),
true
),
'arguments' => [
'type' => 'text',
'name' => 'gotty_user',
'value' => $config['gotty_user'],
],
],
[
'label' => __('Gotty password').ui_print_help_tip(
__('Optional, set a password to access gotty service'),
true
),
'arguments' => [
'type' => 'password',
'name' => 'gotty_pass',
'value' => io_output_password($config['gotty_pass']),
],
],
],
],
[
'arguments' => [
'type' => 'hidden',
'name' => 'qs_update',
'value' => 1,
],
],
[
'arguments' => [
'type' => 'submit',
'label' => __('Update'),
'attributes' => 'class="sub next"',
],
],
],
],
false,
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Gotty path');
$t->data[0][1] = html_print_input_text(
'gotty',
$config['gotty'],
'',
30,
100,
true
);
$t->data[1][0] = __('Gotty host');
$t->data[1][1] = html_print_input_text(
'gotty_host',
$config['gotty_host'],
'',
30,
100,
true
);
$t->data[2][0] = __('Gotty ssh port');
$t->data[2][1] = html_print_input_text(
'gotty_ssh_port',
$config['gotty_ssh_port'],
'',
30,
100,
true
);
$t->data[3][0] = __('Gotty telnet port');
$t->data[3][1] = html_print_input_text(
'gotty_telnet_port',
$config['gotty_telnet_port'],
'',
30,
100,
true
);
$hidden = new StdClass();
$hidden->data = [];
$hidden->width = '100%';
$hidden->class = 'databox filters';
$hidden->data = [];
$hidden->style[0] = 'font-weight: bold';
$hidden->data[0][0] = __('Gotty user').ui_print_help_tip(
__('Optional, set a user to access gotty service'),
true
);
$hidden->data[0][1] = html_print_input_text(
'gotty_user',
$config['gotty_user'],
'',
30,
100,
true
);
$hidden->data[1][0] = __('Gotty password').ui_print_help_tip(
__('Optional, set a password to access gotty service'),
true
);
$hidden->data[1][1] = html_print_input_password(
'gotty_pass',
io_output_password($config['gotty_pass']),
'',
30,
100,
true
);
html_print_table($t);
ui_print_toggle(
[
'content' => html_print_table($hidden, true),
'name' => __('Advanced options'),
'clean' => false,
'main_class' => 'no-border-imp',
'container_class' => 'no-border-imp',
]
);
echo '</fieldset>';
}

View File

@ -129,6 +129,7 @@ if ($disabled != '') {
$extensions = extensions_get_extension_info();
$table = new StdClass;
$table->width = '98%';
$table->head = [];

View File

@ -133,13 +133,10 @@ $buttons['notifications'] = [
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=notifications').'">'.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'</a>',
];
// Enable only if quickshell is enabled.
if (function_exists('quickShellSettings') === true) {
$buttons['quickshell'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=quickshell').'">'.html_print_image('images/ehorus/terminal.png', true, ['title' => __('Quickshell')]).'</a>',
];
}
$buttons['websocket_engine'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=websocket_engine').'">'.html_print_image('images/websocket_small.png', true, ['title' => __('Websocket engine')]).'</a>',
];
$help_header = '';
if (enterprise_installed()) {
@ -191,9 +188,9 @@ switch ($section) {
$subpage = ' &raquo '.__('Notifications');
break;
case 'quickshell':
$buttons['quickshell']['active'] = true;
$subpage = ' &raquo '.__('QuickShell');
case 'websocket_engine':
$buttons['websocket_engine']['active'] = true;
$subpage = ' &raquo '.__('Pandora Websocket Engine');
$help_header = 'quickshell_settings';
break;
@ -261,8 +258,8 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
break;
case 'quickshell':
quickShellSettings();
case 'websocket_engine':
include_once $config['homedir'].'/godmode/setup/setup_websocket_engine.php';
break;
default:

View File

@ -403,50 +403,6 @@ html_print_table($table_mail_conf);
echo '</fieldset>';
echo '<fieldset>';
echo '<legend>'.__('WebSocket settings').'</legend>';
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Bind address');
$t->data[0][1] = html_print_input_text(
'ws_bind_address',
$config['ws_bind_address'],
'',
30,
100,
true
);
$t->data[1][0] = __('Bind port');
$t->data[1][2] = html_print_input_text(
'ws_port',
$config['ws_port'],
'',
30,
100,
true
);
$t->data[2][0] = __('WebSocket proxy url').ui_print_help_tip(__('If you had configured a wsproxy set here target URL (for instance ws://your.public.fqdn/ws).'), true);
$t->data[2][2] = html_print_input_text(
'ws_proxy_url',
$config['ws_proxy_url'],
'',
30,
100,
true
);
html_print_input_hidden('update_config', 1);
html_print_table($t);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');

View File

@ -0,0 +1,89 @@
<?php
/**
* Settings for Pandora Websocket engine.
*
* @category UI file
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
global $config;
$url = ui_get_full_url(
'index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=websocket_engine&amp;pure='.$config['pure']
);
echo '<form id="form_setup" method="post" action="'.$url.'">';
echo '<fieldset>';
echo '<legend>'.__('WebSocket settings').'</legend>';
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Bind address');
$t->data[0][1] = html_print_input_text(
'ws_bind_address',
$config['ws_bind_address'],
'',
30,
100,
true
);
$t->data[1][0] = __('Bind port');
$t->data[1][2] = html_print_input_text(
'ws_port',
$config['ws_port'],
'',
30,
100,
true
);
$t->data[2][0] = __('WebSocket proxy url').ui_print_help_tip(__('If you had configured a wsproxy set here target URL (for instance ws://your.public.fqdn/ws).'), true);
$t->data[2][2] = html_print_input_text(
'ws_proxy_url',
$config['ws_proxy_url'],
'',
30,
100,
true
);
html_print_input_hidden('update_config', 1);
html_print_table($t);
echo '</fieldset>';
quickShellSettings();
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
echo '</form>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -590,6 +590,10 @@ select:-internal-list-box {
.no-border {
border: none;
}
.no-border-imp,
.no-border-imp > div {
border: none !important;
}
.no-padding {
padding: 0;
}