From 049143d143d8187bfcb6377f2bf374c471c28046 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Wed, 3 Mar 2021 19:31:05 +0100 Subject: [PATCH] feat: processes list tool --- src/main/ipc-handlers/database.js | 11 + src/main/libs/clients/MySQLClient.js | 19 ++ src/renderer/components/BaseConfirmModal.vue | 2 +- .../components/ModalProcessesList.vue | 307 ++++++++++++++++++ src/renderer/components/ProcessesListRow.vue | 148 +++++++++ src/renderer/components/Workspace.vue | 90 ++++- .../components/WorkspaceQueryTable.vue | 8 +- src/renderer/i18n/en-US.js | 8 +- src/renderer/ipc-api/Database.js | 4 + src/renderer/scss/_data-types.scss | 1 + src/renderer/scss/main.scss | 4 + 11 files changed, 589 insertions(+), 13 deletions(-) create mode 100644 src/renderer/components/ModalProcessesList.vue create mode 100644 src/renderer/components/ProcessesListRow.vue diff --git a/src/main/ipc-handlers/database.js b/src/main/ipc-handlers/database.js index dd42183c..acbe8630 100644 --- a/src/main/ipc-handlers/database.js +++ b/src/main/ipc-handlers/database.js @@ -105,6 +105,17 @@ export default connections => { } }); + ipcMain.handle('get-processes', async (event, uid) => { + try { + const result = await connections[uid].getProcesses(); + + 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 6f93c5f7..5c47ab98 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -956,6 +956,25 @@ export class MySQLClient extends AntaresCore { }, {}); } + async getProcesses () { + const sql = 'SELECT `ID`, `USER`, `HOST`, `DB`, `COMMAND`, `TIME`, `STATE`, LEFT(`INFO`, 51200) AS `INFO` FROM `information_schema`.`PROCESSLIST`'; + + const { rows } = await this.raw(sql); + + return rows.map(row => { + return { + id: row.ID, + user: row.USER, + host: row.HOST, + db: row.DB, + command: row.COMMAND, + time: row.TIME, + state: row.STATE, + info: row.INFO + }; + }); + } + /** * CREATE TABLE * diff --git a/src/renderer/components/BaseConfirmModal.vue b/src/renderer/components/BaseConfirmModal.vue index f7c2e569..96ed5486 100644 --- a/src/renderer/components/BaseConfirmModal.vue +++ b/src/renderer/components/BaseConfirmModal.vue @@ -24,7 +24,7 @@ - +
+
+ {{ $t('word.results') }}: {{ sortedResults.length.toLocaleString() }} +
+
+ + + + + + + + + + diff --git a/src/renderer/components/ProcessesListRow.vue b/src/renderer/components/ProcessesListRow.vue new file mode 100644 index 00000000..07d71c26 --- /dev/null +++ b/src/renderer/components/ProcessesListRow.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/src/renderer/components/Workspace.vue b/src/renderer/components/Workspace.vue index 5d5199ff..64ac7d7f 100644 --- a/src/renderer/components/Workspace.vue +++ b/src/renderer/components/Workspace.vue @@ -7,10 +7,34 @@ ref="tabWrap" class="tab tab-block column col-12" > -
  • - +