From bd5e2102a659c2fee5f5aa214f3c078140a0c318 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 17 Mar 2022 10:08:09 +0800 Subject: [PATCH 1/5] [UI] Execute button to add shortcut key prompt --- electron-builder.yml | 1 + src/renderer/app/pages/query/query/query.component.html | 2 ++ src/renderer/assets/i18n/en.json | 1 + src/renderer/assets/i18n/zh.json | 1 + src/renderer/services/query/query.service.ts | 1 + 5 files changed, 6 insertions(+) diff --git a/electron-builder.yml b/electron-builder.yml index 74236620..7beff46c 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -37,6 +37,7 @@ releaseInfo: - New data source window layout - Add nine editor themes + - Execute button to add shortcut key prompt directories: output: ./release diff --git a/src/renderer/app/pages/query/query/query.component.html b/src/renderer/app/pages/query/query/query.component.html index e22efd6c..82a29dbe 100644 --- a/src/renderer/app/pages/query/query/query.component.html +++ b/src/renderer/app/pages/query/query/query.component.html @@ -25,12 +25,14 @@ nzValue="{{detail.alias}}" nzLabel="{{detail.alias}}"> + + + + + + + diff --git a/src/renderer/app/pages/query/query/query.component.ts b/src/renderer/app/pages/query/query/query.component.ts index e94c85d4..2d563780 100644 --- a/src/renderer/app/pages/query/query/query.component.ts +++ b/src/renderer/app/pages/query/query/query.component.ts @@ -14,6 +14,7 @@ import { StateEnum } from '@renderer/enum/state.enum'; import { SqlUtils } from '@renderer/utils/sql.utils'; import { ResponseDataModel } from '@renderer/model/response.model'; import { SystemEditorModel } from '@renderer/model/system.model'; +import { CommandModel } from '@renderer/model/command.model'; @Component({ selector: 'app-query', @@ -30,6 +31,7 @@ export class QueryComponent extends BaseComponent implements AfterViewInit { cancel: true }; responseTableData: ResponseDataModel[] = new Array(); + executeCommands: CommandModel[] = new Array(); editorContainers = []; resultContainers = []; loadingContainers = []; @@ -50,6 +52,7 @@ export class QueryComponent extends BaseComponent implements AfterViewInit { this.loadingContainers.push({loading: false}); this.responseTableData.push(new ResponseDataModel()); this.processorContainers.push({icon: 'tint', color: '#2db7f5'}); + this.executeCommands.push(new CommandModel('EXPLAIN ...', 'EXPLAIN {0}')); } ngAfterViewInit(): void { @@ -166,4 +169,13 @@ export class QueryComponent extends BaseComponent implements AfterViewInit { const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror']; codeMirror.setValue(sql); } + + handlerExecuteCommand(command: CommandModel) { + const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror']; + let sql = codeMirror.getValue(); + if (StringUtils.isNotEmpty(codeMirror.getSelection())) { + sql = codeMirror.getSelection(); + } + this.handlerExecute(StringUtils.format(command.format, [sql])); + } } diff --git a/src/renderer/model/command.model.ts b/src/renderer/model/command.model.ts new file mode 100644 index 00000000..d683f7a7 --- /dev/null +++ b/src/renderer/model/command.model.ts @@ -0,0 +1,9 @@ +export class CommandModel { + name: string; + format: string; + + constructor(name: string, format: string) { + this.name = name; + this.format = format; + } +} From 6f60c775504b2f17323f9b58864c0e9907313c43 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 17 Mar 2022 14:20:16 +0800 Subject: [PATCH 5/5] [Optimize] Merge Query Select the query & query function --- electron-builder.yml | 1 + .../pages/query/query/query.component.html | 7 ----- .../app/pages/query/query/query.component.ts | 30 +++++++------------ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 458def76..d8f3bcfc 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -27,6 +27,7 @@ releaseInfo: ---- - Optimized the display of metadata management disk usage + - Merge Query Select the query & query function #### Bug --- diff --git a/src/renderer/app/pages/query/query/query.component.html b/src/renderer/app/pages/query/query/query.component.html index 52d1965a..07add00d 100644 --- a/src/renderer/app/pages/query/query/query.component.html +++ b/src/renderer/app/pages/query/query/query.component.html @@ -39,13 +39,6 @@ -