From 9ffd443a66303f88fc4529896f6d1d7917454f7a Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Mon, 19 Apr 2021 19:15:06 +0200 Subject: [PATCH] feat(UI): format and clear queries --- package.json | 2 +- src/main/index.js | 14 ----- src/main/ipc-handlers/application.js | 10 +--- src/main/libs/clients/PostgreSQLClient.js | 13 ++-- src/renderer/components/WorkspaceQueryTab.vue | 59 +++++++++++++++++-- src/renderer/i18n/en-US.js | 3 +- src/renderer/scss/main.scss | 4 ++ .../store/modules/connections.store.js | 3 +- 8 files changed, 69 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 9d6725e7..72cea1ca 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,6 @@ "electron-store": "^7.0.0", "electron-updater": "^4.3.5", "faker": "^5.3.1", - "keytar": "^7.3.0", "marked": "^2.0.2", "moment": "^2.29.1", "mssql": "^6.2.3", @@ -83,6 +82,7 @@ "pgsql-ast-parser": "^7.0.2", "source-map-support": "^0.5.16", "spectre.css": "^0.5.9", + "sql-formatter": "^4.0.2", "v-mask": "^2.2.4", "vue-i18n": "^8.22.4", "vuedraggable": "^2.24.3", diff --git a/src/main/index.js b/src/main/index.js index de6b8714..90400c28 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -2,9 +2,7 @@ import { app, BrowserWindow, nativeImage } from 'electron'; import * as path from 'path'; -import crypto from 'crypto'; import { format as formatUrl } from 'url'; -import keytar from 'keytar'; import Store from 'electron-store'; import ipcHandlers from './ipc-handlers'; @@ -96,18 +94,6 @@ else { // create main BrowserWindow when electron is ready app.on('ready', async () => { - try { - let key = await keytar.getPassword('antares', 'user'); - - if (!key) { - key = crypto.randomBytes(16).toString('hex'); - keytar.setPassword('antares', 'user', key); - } - } - catch (err) { - console.log(err); - } - mainWindow = createMainWindow(); }); } diff --git a/src/main/ipc-handlers/application.js b/src/main/ipc-handlers/application.js index c4130020..31a3fe0d 100644 --- a/src/main/ipc-handlers/application.js +++ b/src/main/ipc-handlers/application.js @@ -1,4 +1,3 @@ -import keytar from 'keytar'; import { app, ipcMain } from 'electron'; export default () => { @@ -7,14 +6,7 @@ export default () => { }); ipcMain.on('get-key', async event => { - let key = false; - - try { - key = await keytar.getPassword('antares', 'user'); - } - catch (err) { - console.log(err); - } + const key = false; event.returnValue = key; }); }; diff --git a/src/main/libs/clients/PostgreSQLClient.js b/src/main/libs/clients/PostgreSQLClient.js index f19af90f..1313c727 100644 --- a/src/main/libs/clients/PostgreSQLClient.js +++ b/src/main/libs/clients/PostgreSQLClient.js @@ -77,7 +77,8 @@ export class PostgreSQLClient extends AntaresCore { */ use (schema) { this._schema = schema; - return this.raw(`SET search_path TO ${schema}`); + if (schema) + return this.raw(`SET search_path TO ${schema}`); } /** @@ -274,7 +275,7 @@ export class PostgreSQLClient extends AntaresCore { */ async getTableIndexes ({ schema, table }) { if (schema !== 'public') - this.use(schema); + await this.use(schema); const { rows } = await this.raw(`WITH ndx_list AS ( SELECT pg_index.indexrelid, pg_class.oid @@ -670,7 +671,7 @@ export class PostgreSQLClient extends AntaresCore { : ''; if (this._schema !== 'public') - this.use(this._schema); + await this.use(this._schema); const sql = `CREATE PROCEDURE ${this._schema}.${routine.name}(${parameters}) LANGUAGE ${routine.language} @@ -799,7 +800,7 @@ export class PostgreSQLClient extends AntaresCore { : ''; if (this._schema !== 'public') - this.use(this._schema); + await this.use(this._schema); const body = func.returns ? func.sql : '$BODY$\n$BODY$'; @@ -1018,7 +1019,7 @@ export class PostgreSQLClient extends AntaresCore { } = params; if (this._schema !== 'public') - this.use(this._schema); + await this.use(this._schema); let sql = ''; const alterColumns = []; @@ -1247,7 +1248,7 @@ export class PostgreSQLClient extends AntaresCore { }; if (args.nest && this._schema !== 'public') - this.use(this._schema); + await this.use(this._schema); const resultsArr = []; let paramsArr = []; diff --git a/src/renderer/components/WorkspaceQueryTab.vue b/src/renderer/components/WorkspaceQueryTab.vue index 64af2859..6b22ceb5 100644 --- a/src/renderer/components/WorkspaceQueryTab.vue +++ b/src/renderer/components/WorkspaceQueryTab.vue @@ -1,5 +1,12 @@