From 6a6f43a718561e0abd2cb89048b7fe45d08736ae Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 16 Jul 2022 12:01:37 +0200 Subject: [PATCH] feat: initial console implementation --- src/common/interfaces/antares.ts | 2 +- src/common/shortcuts.ts | 5 + src/main/libs/AntaresCore.ts | 2 +- src/main/main.ts | 8 +- src/renderer/App.vue | 8 +- src/renderer/components/TheFooter.vue | 27 +++- src/renderer/components/Workspace.vue | 11 +- .../components/WorkspaceQueryConsole.vue | 147 ++++++++++++++++++ src/renderer/components/WorkspaceTabQuery.vue | 6 +- .../components/WorkspaceTabQueryTable.vue | 15 +- src/renderer/i18n/en-US.ts | 6 +- src/renderer/index.ts | 6 + src/renderer/scss/themes/dark-theme.scss | 5 + src/renderer/stores/console.ts | 50 ++++++ 14 files changed, 278 insertions(+), 20 deletions(-) create mode 100644 src/renderer/components/WorkspaceQueryConsole.vue create mode 100644 src/renderer/stores/console.ts diff --git a/src/common/interfaces/antares.ts b/src/common/interfaces/antares.ts index 8614443d..b98ee5ef 100644 --- a/src/common/interfaces/antares.ts +++ b/src/common/interfaces/antares.ts @@ -25,7 +25,7 @@ export interface IpcResponse { */ export interface ClientParams { client: ClientCode; - uid: string; + uid?: string; params: mysql.ConnectionOptions & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean} | pg.ClientConfig & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean} diff --git a/src/common/shortcuts.ts b/src/common/shortcuts.ts index 8a035110..720fe923 100644 --- a/src/common/shortcuts.ts +++ b/src/common/shortcuts.ts @@ -29,6 +29,11 @@ const shortcuts: ShortcutRecord[] = [ event: 'open-connections-modal', keys: ['Shift+CommandOrControl+Space'], description: 'Show all connections' + }, + { + event: 'toggle-console', + keys: ['CommandOrControl+F12', 'CommandOrControl+`'], + description: 'Toggle console' } ]; diff --git a/src/main/libs/AntaresCore.ts b/src/main/libs/AntaresCore.ts index e8106513..b7b34828 100644 --- a/src/main/libs/AntaresCore.ts +++ b/src/main/libs/AntaresCore.ts @@ -8,7 +8,7 @@ const queryLogger = ({ sql, cUid }: {sql: string; cUid: string}) => { // Remove comments, newlines and multiple spaces const escapedSql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' '); const mainWindow = webContents.fromId(1); - mainWindow.send('query-log', { cUid, sql: escapedSql }); + mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() }); console.log(escapedSql); }; diff --git a/src/main/main.ts b/src/main/main.ts index 36ad7260..a69ccf2d 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -155,9 +155,11 @@ else { } } - // Main process shortcuts - if (isDevelopment) { - globalShortcut.register('CommandOrControl+F12', () => { + if (isDevelopment) { // Dev shortcuts + globalShortcut.register('Shift+CommandOrControl+F5', () => { + mainWindow.reload(); + }); + globalShortcut.register('Shift+CommandOrControl+F12', () => { mainWindow.webContents.openDevTools(); }); } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 08eb2928..04788339 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -71,10 +71,6 @@ ipcRenderer.on('open-connections-modal', () => { isAllConnectionsModal.value = true; }); -ipcRenderer.on('query-log', (e, sql: string) => { - console.log(sql); -}); - document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { changeApplicationTheme(applicationTheme.value);// Forces persistentStore to save on file and mail process @@ -155,10 +151,10 @@ onMounted(() => { .connection-panel-wrapper { height: calc(100vh - #{$excluding-size}); width: 100%; - padding-top: 15vh; + padding-top: 2rem; display: flex; justify-content: center; - align-items: flex-start; + align-items: center; overflow: auto; } } diff --git a/src/renderer/components/TheFooter.vue b/src/renderer/components/TheFooter.vue index 0401d723..be78e8c7 100644 --- a/src/renderer/components/TheFooter.vue +++ b/src/renderer/components/TheFooter.vue @@ -11,14 +11,30 @@