Merge branch 'ent-10340-gotty-quickshell-no-funciona' into 'develop'

Fix gotty host missing on ws.php

See merge request artica/pandorafms!5812
This commit is contained in:
Rafael Ameijeiras 2023-05-08 06:05:31 +00:00
commit 37d0cff221
5 changed files with 105 additions and 5 deletions

View File

@ -80,6 +80,30 @@ $t->data[1][] = html_print_label_input_block(
);
html_print_input_hidden('update_config', 1);
// Test.
$row = [];
$test_start = '<span id="test-gotty-spinner" class="invisible">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$test_start .= '&nbsp;<span id="test-gotty-message" class="invisible"></span>';
$row['gotty_test'] = html_print_label_input_block(
__('Test'),
html_print_button(
__('Start'),
'test-gotty',
false,
'handleTest()',
[
'icon' => 'cog',
'mode' => 'secondary mini',
'style' => 'width: 115px;',
],
true
).$test_start,
['div_class' => 'inline_flex row']
);
$t->data['gotty_test'] = $row;
html_print_table($t);
echo '</fieldset>';
@ -99,3 +123,73 @@ html_print_action_buttons(
);
echo '</form>';
echo '<script>';
echo 'var server_addr = "'.$_SERVER['SERVER_ADDR'].'";';
$handle_test_js = "var handleTest = function (event) {
var ws_proxy_url = $('input#text-ws_proxy_url').val();
var ws_port = $('input#text-ws_port').val();
var httpsEnabled = window.location.protocol == 'https' ? true : false;
if (ws_proxy_url == '') {
ws_url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + ':' + ws_port;
} else {
ws_url = ws_proxy_url;
}
var showLoadingImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon cog rotation secondary mini');
}
var showSuccessImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon tick secondary mini');
}
var showFailureImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon fail secondary mini');
}
var hideMessage = function () {
$('span#test-gotty-message').hide();
}
var showMessage = function () {
$('span#test-gotty-message').show();
}
var changeTestMessage = function (message) {
$('span#test-gotty-message').text(message);
}
var errorMessage = '".__('WebService engine has not been started, please check documentation.')."';
hideMessage();
showLoadingImage();
var ws = new WebSocket(ws_url);
// Catch errors.
ws.onerror = () => {
showFailureImage();
changeTestMessage(errorMessage);
showMessage();
ws.close();
};
ws.onopen = () => {
showSuccessImage();
hideMessage();
ws.close();
};
ws.onclose = (event) => {
changeTestMessage(errorMessage);
hideLoadingImage();
showMessage();
};
}
$('#button-test-ehorus').click(handleTest);";
echo $handle_test_js;
echo '</script>';

View File

@ -301,7 +301,7 @@ class WSManager extends WebSocketServer
\db_pandora_audit(
AUDIT_LOG_WEB_SOCKETS,
'WebSocket connection started',
$user->account->idUser
'N/A'
);
$this->stderr('ONLINE '.$user->address.'('.$user->account->idUser.')');
@ -424,7 +424,7 @@ class WSManager extends WebSocketServer
\db_pandora_audit(
AUDIT_LOG_WEB_SOCKETS,
'WebSocket connection finished',
$user->account->idUser
'N/A'
);
$this->stderr('OFFLINE '.$user->address.'('.$user->account->idUser.')');

View File

@ -472,7 +472,7 @@ abstract class WebSocketServer
} else if ($numBytes == 0) {
$this->disconnect($socket);
$this->stderr(
'Client disconnected. TCP connection lost: '.$socket
'Client disconnected. TCP connection lost'
);
} else {
$user = $this->getUserBySocket($socket);
@ -521,7 +521,7 @@ abstract class WebSocketServer
} else if ($numBytes == 0) {
$this->disconnect($socket);
$this->stderr(
'Client disconnected. TCP connection lost: '.$socket
'Client disconnected. TCP connection lost.'
);
} else {
$user = $this->getUserBySocket($socket);
@ -581,6 +581,7 @@ abstract class WebSocketServer
$sockErrNo=null
) {
$user = $this->getUserBySocket($socket);
if ($user !== null) {
if (array_key_exists($user->id, $this->users)) {
unset($this->users[$user->id]);

View File

@ -10616,6 +10616,11 @@ button div.cog {
contain;
}
button div.tick {
mask: url(../../images/input_tick.png) no-repeat center / contain;
-webkit-mask: url(../../images/input_tick.png) no-repeat center / contain;
}
button div.info {
mask: url(../../images/info@svg.svg) no-repeat center / contain;
-webkit-mask: url(../../images/info@svg.svg) no-repeat center / contain;

View File

@ -116,7 +116,7 @@ if (substr($os, 0, 3) !== 'win') {
// Common.
$base_cmd = 'nohup "'.$config['gotty'].'" '.$gotty_creds;
$base_cmd .= ' --permit-arguments -a 127.0.0.1 -w ';
$base_cmd .= ' --permit-arguments -a '.$config['gotty_host'].' -w ';
// Launch gotty - SSH.
$cmd = $base_cmd.' --port '.$config['gotty_ssh_port'];