diff --git a/src/main/ipc-handlers/connection.js b/src/main/ipc-handlers/connection.js index 558e2d6d..b75964fe 100644 --- a/src/main/ipc-handlers/connection.js +++ b/src/main/ipc-handlers/connection.js @@ -2,6 +2,7 @@ import { ipcMain } from 'electron'; import knex from 'knex'; import InformationSchema from '../models/InformationSchema'; +import { RawQuery } from '../models/RawQuery'; const connections = {}; @@ -74,4 +75,19 @@ export default () => { return { status: 'error', response: err.toString() }; } }); + + ipcMain.on('runQuery', async (event, { connection, query, database }) => { + const knexIstance = connections[connection.uid]; + const Query = new RawQuery({ knexIstance, database }); + try { + Query.runQuery(query); + + Query.on('row', row => { + event.sender.send('row', row); + }); + } + catch (err) { + return { status: 'error', response: err.toString() }; + } + }); }; diff --git a/src/main/models/RawQuery.js b/src/main/models/RawQuery.js new file mode 100644 index 00000000..7bb11397 --- /dev/null +++ b/src/main/models/RawQuery.js @@ -0,0 +1,22 @@ +'use strict'; +import { EventEmitter } from 'events'; + +export class RawQuery extends EventEmitter { + constructor ({ knexIstance, database }) { + super(); + this.conn = knexIstance; + this.database = database; + } + + async runQuery (query) { + if (this.database) await this.conn.raw(`USE \`${this.database}\``); + const stream = this.conn.raw(query).stream(); + stream.on('data', row => { + this.emit('row', row); + }); + + stream.on('error', err => { + this.emit('error', err); + }); + } +} diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 6970b3a4..f47f9f1a 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -89,6 +89,7 @@ export default { padding: 0; justify-content: flex-start; height: calc(100vh - #{$excluding-size}); + width: calc(100% - #{$settingbar-width}); > .columns{ height: calc(100vh - #{$footer-height}); diff --git a/src/renderer/components/BaseNotification.vue b/src/renderer/components/BaseNotification.vue index fb8f0260..56fa25f6 100644 --- a/src/renderer/components/BaseNotification.vue +++ b/src/renderer/components/BaseNotification.vue @@ -85,7 +85,7 @@ export default { overflow: hidden; text-overflow: ellipsis; display: inline-block; - max-width: 25rem; + max-width: 30rem; user-select: none; } diff --git a/src/renderer/components/Workspace.vue b/src/renderer/components/Workspace.vue index 6b20e653..f62b06c1 100644 --- a/src/renderer/components/Workspace.vue +++ b/src/renderer/components/Workspace.vue @@ -1,18 +1,18 @@ @@ -21,22 +21,17 @@ import { mapGetters, mapActions } from 'vuex'; import Connection from '@/ipc-api/Connection'; import WorkspaceExploreBar from '@/components/WorkspaceExploreBar'; -import QueryEditor from '@/components/QueryEditor'; +import WorkspaceQueryTab from '@/components/WorkspaceQueryTab'; export default { name: 'Workspace', components: { WorkspaceExploreBar, - QueryEditor + WorkspaceQueryTab }, props: { connection: Object }, - data () { - return { - query: '' - }; - }, computed: { ...mapGetters({ selectedWorkspace: 'workspaces/getSelected', diff --git a/src/renderer/components/WorkspaceExploreBar.vue b/src/renderer/components/WorkspaceExploreBar.vue index 928a6788..20c37b90 100644 --- a/src/renderer/components/WorkspaceExploreBar.vue +++ b/src/renderer/components/WorkspaceExploreBar.vue @@ -1,5 +1,5 @@ + + + +