Fix ws test button

This commit is contained in:
Calvo 2023-05-05 11:25:33 +02:00
parent fb7a94ddd4
commit 4f48fa4450
3 changed files with 16 additions and 22 deletions

View File

@ -84,8 +84,6 @@ 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 .= '<span id="test-gotty-success" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$test_start .= '<span id="test-gotty-failure" class="invisible">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
$test_start .= '&nbsp;<span id="test-gotty-message" class="invisible"></span>';
$row['gotty_test'] = html_print_label_input_block(
__('Test'),
@ -100,7 +98,8 @@ $row['gotty_test'] = html_print_label_input_block(
'style' => 'width: 115px;',
],
true
).$test_start
).$test_start,
['div_class' => 'inline_flex row']
);
$t->data['gotty_test'] = $row;
@ -138,24 +137,18 @@ $handle_test_js = "var handleTest = function (event) {
ws_url = ws_proxy_url;
}
var hideLoadingImage = function () {
$('span#test-gotty-spinner').hide();
}
var showLoadingImage = function () {
$('span#test-gotty-spinner').show();
}
var hideSuccessImage = function () {
$('span#test-gotty-success').hide();
$('#button-test-gotty').children('div').attr('class', 'subIcon cog rotation secondary mini');
}
var showSuccessImage = function () {
$('span#test-gotty-success').show();
}
var hideFailureImage = function () {
$('span#test-gotty-failure').hide();
$('#button-test-gotty').children('div').attr('class', 'subIcon tick secondary mini');
}
var showFailureImage = function () {
$('span#test-gotty-failure').show();
$('#button-test-gotty').children('div').attr('class', 'subIcon fail secondary mini');
}
var hideMessage = function () {
$('span#test-gotty-message').hide();
}
@ -168,26 +161,22 @@ $handle_test_js = "var handleTest = function (event) {
var errorMessage = '".__('WebService engine has not been started, please check documentation.')."';
hideSuccessImage();
hideFailureImage();
hideMessage();
showLoadingImage();
var ws = new WebSocket(ws_url);
// Catch errors.
ws.onerror = () => {
showFailureImage();
changeTestMessage(errorMessage);
hideLoadingImage();
showMessage();
ws.close();
};
ws.onopen = () => {
console.log('SSH connected');
showSuccessImage();
hideLoadingImage();
hideMessage();
ws.close();
};

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);

View File

@ -10595,6 +10595,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;