Skip to content

Commit

Permalink
Merge pull request #106 from qianmoQ/1.12.0-SNAPSHOT
Browse files Browse the repository at this point in the history
1.12.0 snapshot
  • Loading branch information
qianmoQ authored Mar 17, 2022
2 parents c38fcd7 + 6f60c77 commit 98a6b25
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 35 deletions.
6 changes: 6 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ releaseInfo:
- Add ancillary information such as execution result and time
- SQL shortcut keys can be executed by Ctrl+Enter [#102](https://github.com/EdurtIO/dbm/issues/102)
- Support for data source maxTotal configuration (experimental) [#102](https://github.com/EdurtIO/dbm/issues/102)
- Add SHOW PARTITIONS quick query
- The EXPLAIN command is supported
#### Docs
---
Expand All @@ -24,6 +26,9 @@ releaseInfo:
#### Optimize
----
- Optimized the display of metadata management disk usage
- Merge Query Select the query & query function
#### Bug
---
Expand All @@ -37,6 +42,7 @@ releaseInfo:
- New data source window layout
- Add nine editor themes
- Execute button to add shortcut key prompt
directories:
output: ./release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<app-component-antd-empty *ngIf="items.length <= 0; else hasLoadTemplate">
</app-component-antd-empty>
<ng-template #hasLoadTemplate>
<div nz-row nzJustify="space-around" [nzGutter]="[16, 16]">
<div *ngFor="let item of items; let i = index" nz-col nzSpan="6">
<nz-table nzPageSize="20" #progressItemsTable [nzData]="items">
<tbody nz-row nzJustify="space-around" [nzGutter]="[16, 16]">
<tr *ngFor="let item of progressItemsTable.data; let i = index" nz-col nzSpan="6">
<nz-card nzTitle="{{ (i + 1) + ': ' + item.name }}">
<nz-progress nz-popover [nzPopoverContent]="progressPopoverContent" nzType="circle"
[nzPercent]="item.value"
Expand All @@ -42,8 +43,8 @@
</nz-descriptions>
</ng-template>
</nz-card>
</div>
</div>
</tr>
</nz-table>
</ng-template>
</ng-template>
</nz-card>
Expand Down
34 changes: 22 additions & 12 deletions src/renderer/app/pages/query/query/query.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@
<nz-option *ngFor="let detail of dataSources" [nzDisabled]="!detail.status"
nzValue="{{detail.alias}}" nzLabel="{{detail.alias}}"></nz-option>
</nz-select>
<button id="executeButton" nz-button nzType="primary" nzSize="small"
[disabled]="disabledButton.execute"
[nzLoading]="loading.button"
(click)="handlerExecute()">
<i class="fa fa-flash"></i>&nbsp;{{'common.execute'|translate}}
</button>
<button id="selectionExecuteButton" nz-button nzType="primary" nzSize="small"
[disabled]="disabledButton.execute"
[nzLoading]="loading.button"
(click)="handlerSelectionExecute()">
<i class="fa fa-flask"></i>&nbsp;{{'common.select'|translate}} {{'common.execute'|translate}}
</button>
<nz-button-group>
<button id="executeButton" nz-button nzType="primary" nzSize="small"
nzTooltipTitle="{{'tooltip.execute'|translate}}" nzTooltipPlacement="bottom" nz-tooltip
[disabled]="disabledButton.execute"
[nzLoading]="loading.button"
(click)="handlerExecute()">
<i class="fa fa-flash"></i>&nbsp;{{'common.execute'|translate}}
</button>
<button nz-button nz-dropdown nzType="primary" nzPlacement="bottomRight"
[disabled]="disabledButton.execute"
[nzDropdownMenu]="executeMenu"
style="margin-left: -10px;">
<i class="fa fa-ellipsis-h"></i>
</button>
</nz-button-group>
<button nz-button nzType="dashed" nzSize="small"
[disabled]="disabledButton.execute"
(click)="handlerFormatter()">
Expand All @@ -52,6 +55,13 @@
<button style="float: right;" nz-button nzType="primary" nzSize="small" (click)="handlerQuickQuery()">
<i class="fa fa-modx"></i>&nbsp;{{'common.quick' | translate}} {{'common.query' | translate}}
</button>
<nz-dropdown-menu #executeMenu="nzDropdownMenu">
<ul nz-menu>
<li nz-menu-item *ngFor="let command of executeCommands" (click)="handlerExecuteCommand(command)">
{{command.name}}
</li>
</ul>
</nz-dropdown-menu>
</ng-template>
<!-- Query result container -->
<nz-card style="margin-top: 10px;" nzTitle="{{'common.result'|translate}}">
Expand Down
30 changes: 17 additions & 13 deletions src/renderer/app/pages/query/query/query.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -30,6 +31,7 @@ export class QueryComponent extends BaseComponent implements AfterViewInit {
cancel: true
};
responseTableData: ResponseDataModel[] = new Array();
executeCommands: CommandModel[] = new Array();
editorContainers = [];
resultContainers = [];
loadingContainers = [];
Expand All @@ -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 {
Expand All @@ -60,12 +63,7 @@ export class QueryComponent extends BaseComponent implements AfterViewInit {
'Ctrl-Enter': function(cm) {
// queryInstance.handlerExecute(null);
// Call the click method with the fetch element tag
const selectionContext = cm.getSelection();
if (StringUtils.isNotEmpty(selectionContext)) {
document.getElementById('selectionExecuteButton').click();
} else {
document.getElementById('executeButton').click();
}
document.getElementById('executeButton').click();
}
});
}, 0);
Expand All @@ -77,18 +75,25 @@ export class QueryComponent extends BaseComponent implements AfterViewInit {
status === true ? this.disabledButton.execute = true : this.disabledButton.execute = false;
}

handlerExecute(sql?: string) {
handlerExecute(command?: CommandModel) {
this.disabledButton.execute = true;
this.disabledButton.cancel = false;
this.loading.button = true;
this.loadingContainers[this.containerSelected].loading = true;
const queryHistory = new QueryHistoryModel();
const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror'];
let sql = codeMirror.getValue();
if (StringUtils.isNotEmpty(codeMirror.getSelection())) {
sql = codeMirror.getSelection();
}
if (command?.name) {
sql = StringUtils.format(command.format, [sql]);
}
queryHistory.id = Md5.hashStr(sql + new Date());
queryHistory.startTime = Date.parse(new Date().toString());
const request = new RequestModel();
request.config = this.datasourceService.getAll(this.datasource)?.data?.columns[0];
queryHistory.server = this.datasource;
sql = StringUtils.isEmpty(sql) ? this.codeEditors.get(this.containerSelected)['codeMirror'].getValue() : sql;
queryHistory.query = sql;
this.processorContainers[this.containerSelected].icon = 'spinner fa-spin';
this.processorContainers[this.containerSelected].color = 'cyan';
Expand Down Expand Up @@ -119,11 +124,6 @@ export class QueryComponent extends BaseComponent implements AfterViewInit {
});
}

handlerSelectionExecute() {
const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror'];
this.handlerExecute(codeMirror.getSelection());
}

handlerFormatter() {
const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror'];
codeMirror.setValue(SqlUtils.formatter(codeMirror.getValue(), this.editorConfig));
Expand Down Expand Up @@ -166,4 +166,8 @@ export class QueryComponent extends BaseComponent implements AfterViewInit {
const codeMirror = this.codeEditors.get(this.containerSelected)['codeMirror'];
codeMirror.setValue(sql);
}

handlerExecuteCommand(command: CommandModel) {
this.handlerExecute(command);
}
}
1 change: 1 addition & 0 deletions src/renderer/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"elapsed": "Total Time (sec)",
"rowsRead": "The total number of rows of data read",
"bytesRead": "The total number of bytes of data read",
"execute": "Press Ctrl+Enter to execute the command",
"editor": {
"preview": "Real-time feedback on editor modification status",
"activeLine": "Highlight the current selection row shown with the mouse",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"elapsed": "耗时总时长(秒)",
"rowsRead": "读取数据的总行数",
"bytesRead": "读取数据的总字节数",
"execute": "Press Ctrl+Enter to execute the command",
"editor": {
"preview": "实时反馈编辑器修改状态",
"activeLine": "用鼠标高亮显示当前选择行",
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/query/quick/quick.query.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ export class QuickQueryComponent extends BaseComponent {
}

handlerQuickCommand(command: { name: string, value: string }) {
const dt = StringUtils.format('{0}.{1}', [this.database, this.table]);
const sql = StringUtils.format(command.value, [dt]);
const sql = StringUtils.format(command.value, [this.database, this.table]);
this.emitterValue.emit(sql);
this.handlerCancel();
}
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/model/command.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class CommandModel {
name: string;
format: string;

constructor(name: string, format: string) {
this.name = name;
this.format = format;
}
}
11 changes: 7 additions & 4 deletions src/renderer/services/query/query.quick.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ export class QueryQuickService {
getQuickAll() {
return [{
name: 'DESCRIBE ...',
value: 'DESCRIBE {0}'
value: 'DESCRIBE `{0}`.`{1}`'
}, {
name: 'SHOW CREATE TABLE ...',
value: 'SHOW CREATE TABLE {0}'
value: 'SHOW CREATE TABLE `{0}`.`{1}`'
}, {
name: 'SELECT ... LIMIT 100',
value: 'SELECT * FROM {0} LIMIT 100'
value: 'SELECT * FROM `{0}`.`{1}` LIMIT 100'
}, {
name: 'SELECT COUNT FROM ...',
value: 'SELECT COUNT(1) FROM {0}'
value: 'SELECT COUNT(1) FROM `{0}`.`{1}`'
}, {
name: 'SHOW PARTITIONS FROM ...',
value: 'SELECT `partition` FROM `system`.parts WHERE `database` = \'{0}\' AND `table` = \'{1}\''
}];
}
}
1 change: 1 addition & 0 deletions src/renderer/services/query/query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class QueryService implements BaseService {
sql += '\nLIMIT ' + limit;
}
} catch (err) {
console.log(err);
// The SQL tree fails to be parsed and no action is taken
}
}
Expand Down

0 comments on commit 98a6b25

Please sign in to comment.