From 325356fbfb49a7271b6f6283d906280b4a6b5426 Mon Sep 17 00:00:00 2001 From: Mohammed Abed El Hay Abu Baker <30116323+mhmdkrmabd@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:23:44 +0300 Subject: [PATCH] New feature related to #533, updates for #532, changes and improvements (#534) --- custom_node_modules/main/pty.js | 6 +++--- renderer/js/axonops_agent_webview.js | 1 - renderer/js/events/clusters.js | 15 ++++++++++++++- renderer/js/events/common.js | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/custom_node_modules/main/pty.js b/custom_node_modules/main/pty.js index 99b42f05..a96a09ba 100755 --- a/custom_node_modules/main/pty.js +++ b/custom_node_modules/main/pty.js @@ -565,13 +565,13 @@ class Pty { * {string} `cqlshrcPath` The associated `cqlsh.rc` file's path */ async createCQLSHInstance(data) { - // By default, cqlsh `v6.0.0` will be used to connect with the cluster - let cqlsh = '407', + // By default, cqlsh `v6.1.0` will be used to connect with the cluster + let cqlsh = '410', // Define the Apache Cassandra's version version = this.cassandraVersion // Check Cassandra's version, and choose the suitable cqlsh version to be called - cqlsh = version.startsWith('4.1') ? '410' : cqlsh + cqlsh = version.startsWith('4.0') ? '407' : cqlsh // Run cqlsh instance with the given cqlsh file path let binCall = `./cqlsh-${cqlsh}` diff --git a/renderer/js/axonops_agent_webview.js b/renderer/js/axonops_agent_webview.js index cbbe7c14..9cc13ffe 100644 --- a/renderer/js/axonops_agent_webview.js +++ b/renderer/js/axonops_agent_webview.js @@ -74,7 +74,6 @@ document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { try { document.querySelector('div[data-id="reloadWebView"]').addEventListener('click', () => { - console.log("CLICKED"); IPCRenderer.sendToHost(`reload-webview`) }) } catch (e) {} diff --git a/renderer/js/events/clusters.js b/renderer/js/events/clusters.js index 8c99c9e7..e5caa95c 100755 --- a/renderer/js/events/clusters.js +++ b/renderer/js/events/clusters.js @@ -3300,6 +3300,18 @@ // Clear the statement's input field and make sure it's focused on it setTimeout(() => statementInputField.val('').trigger('input').focus().attr('style', null)) + try { + let isClearCommand = (['clear', 'cls']).some((command) => statement.startsWith(minifyText(command))) + + if (!isClearCommand) + throw 0 + + + sessionContainer.children('div.block').find('div.actions div.btn[action="delete"]').click() + + return + } catch (e) {} + try { if (!((['quit', 'exit']).some((command) => minifyText(statement).startsWith(minifyText(command))))) throw 0 @@ -3416,8 +3428,9 @@ isCQLSHCommand = Modules.Consts.CQLSHCommands.some((command) => minifiedStatement.startsWith(minifyText(command))), // Whether or not the statement is quitting the cqlsh session isQuitCommand = (['quit', 'exit']).some((command) => minifiedStatement.startsWith(minifyText(command))), + isClearCommand = (['clear', 'cls']).some((command) => minifiedStatement.startsWith(minifyText(command))), // Decide whether or not the execution button should be disabled - isExecutionButtonDisabled = minifiedStatement.length <= 0 || ((!isCQLSHCommand && !isQuitCommand) && !minifiedStatement.endsWith(';')) + isExecutionButtonDisabled = minifiedStatement.length <= 0 || ((!isCQLSHCommand && !isQuitCommand && !isClearCommand) && !minifiedStatement.endsWith(';')) // Disable/enable the execution button executeBtn.attr('disabled', isExecutionButtonDisabled ? '' : null) diff --git a/renderer/js/events/common.js b/renderer/js/events/common.js index 25a978e2..8d18ccff 100755 --- a/renderer/js/events/common.js +++ b/renderer/js/events/common.js @@ -673,6 +673,24 @@ actionButton.filter('[action="toggleFullscreen"]').click() }) + + $(document).on('keydown', function(e) { + // CTRL+L to clear the enhanced terminal + if (!e.ctrlKey || e.keyCode != 76) + return + + let interactiveTerminal = $(`div[content="workarea"] div.workarea[cluster-id="${activeClusterID}"] div.tab-content div.tab-pane[tab="cqlsh-session"] div.interactive-terminal-container div.session-content`) + + if (interactiveTerminal.length <= 0) + return + + try { + if (!interactiveTerminal.is(':visible')) + throw 0 + + interactiveTerminal.children('div.block').find('div.actions div.btn[action="delete"]').click() + } catch (e) {} + }) } }