From 85f625daf7026815dac6223a29c5a6479830edbb Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sun, 26 Sep 2021 11:19:48 +0200 Subject: [PATCH] feat: copy cell/row or kill connections on context menu from processes list --- src/main/ipc-handlers/schema.js | 11 +++ src/main/libs/clients/MySQLClient.js | 4 + src/main/libs/clients/PostgreSQLClient.js | 4 + .../components/ModalProcessesList.vue | 60 ++++++++++++++- .../components/ModalProcessesListContext.vue | 75 +++++++++++++++++++ .../components/ModalProcessesListRow.vue | 35 +++------ src/renderer/i18n/en-US.js | 3 +- src/renderer/ipc-api/Schema.js | 4 + 8 files changed, 168 insertions(+), 28 deletions(-) create mode 100644 src/renderer/components/ModalProcessesListContext.vue diff --git a/src/main/ipc-handlers/schema.js b/src/main/ipc-handlers/schema.js index 8087c68a..10d71447 100644 --- a/src/main/ipc-handlers/schema.js +++ b/src/main/ipc-handlers/schema.js @@ -112,6 +112,17 @@ export default connections => { } }); + ipcMain.handle('kill-process', async (event, { uid, pid }) => { + try { + const result = await connections[uid].killProcess(pid); + + return { status: 'success', response: result }; + } + catch (err) { + return { status: 'error', response: err.toString() }; + } + }); + ipcMain.handle('use-schema', async (event, { uid, schema }) => { if (!schema) return; diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index 8dba44e9..2eaf2a13 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -1176,6 +1176,10 @@ export class MySQLClient extends AntaresCore { }); } + async killProcess (id) { + return await this.raw(`KILL ${id}`); + } + /** * CREATE TABLE * diff --git a/src/main/libs/clients/PostgreSQLClient.js b/src/main/libs/clients/PostgreSQLClient.js index 6de867d6..10653ab5 100644 --- a/src/main/libs/clients/PostgreSQLClient.js +++ b/src/main/libs/clients/PostgreSQLClient.js @@ -1029,6 +1029,10 @@ export class PostgreSQLClient extends AntaresCore { }); } + async killProcess (id) { + return await this.raw(`SELECT pg_terminate_backend(${id})`); + } + /** * CREATE TABLE * diff --git a/src/renderer/components/ModalProcessesList.vue b/src/renderer/components/ModalProcessesList.vue index 8de12674..9de0f6db 100644 --- a/src/renderer/components/ModalProcessesList.vue +++ b/src/renderer/components/ModalProcessesList.vue @@ -1,5 +1,15 @@