Skip to content

Commit 3d58789

Browse files
authored
Merge pull request #253 from qianmoQ/1.22.0-SNAPSHOT
New Feature
2 parents eb0ec92 + 681b012 commit 3d58789

32 files changed

Lines changed: 471 additions & 97 deletions

src/renderer/app/layout/layout.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import { PluginFactory } from "@renderer/factory/plugin.factory";
2121
import { PluginToken } from "@renderer/token/plugin.token";
2222
import { ClickHousePlugin } from "@renderer/plugin/clickhouse.plugin";
2323
import { ElasticsearchPlugin } from "@renderer/plugin/elasticsearch.plugin";
24+
import { MysqlPlugin } from "@renderer/plugin/mysql.plugin";
25+
import { ConfigFactory } from "@renderer/factory/config.factory";
26+
import { ConfigToken } from "@renderer/token/config.token";
27+
import { MysqlConfig } from "@renderer/config/mysql.config";
2428

2529
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader =>
2630
new TranslateHttpLoader(http, './renderer/assets/i18n/', '.json');
@@ -55,7 +59,11 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader =>
5559
PostgresqlService,
5660
PluginFactory,
5761
{provide: PluginToken, useClass: ClickHousePlugin, multi: true},
58-
{provide: PluginToken, useClass: ElasticsearchPlugin, multi: true}
62+
{provide: PluginToken, useClass: ElasticsearchPlugin, multi: true},
63+
{provide: PluginToken, useClass: MysqlPlugin, multi: true},
64+
/* Config */
65+
ConfigFactory,
66+
{provide: ConfigToken, useClass: MysqlConfig, multi: true}
5967
]
6068
})
6169
export class LayoutModule {

src/renderer/app/pages/management/metadata/metadata.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class MetadataComponent extends BaseComponent implements OnInit {
2424
selectNode: any;
2525
selectMenu: MenuModel;
2626
rootNode: any;
27+
selectDatabase: string;
28+
selectTable: string;
2729
switchType = TypeEnum.disk;
2830
outerHeight: number;
2931
contextMenus: MenuModel[];
@@ -185,6 +187,9 @@ export class MetadataComponent extends BaseComponent implements OnInit {
185187
const dataSource = await this.dataSourceService.getByAliasAsync(this.rootNode.value);
186188
this.rootNode['sourceType'] = dataSource.type;
187189
request.config = dataSource;
190+
if (dataSource.type === DatabaseEnum.postgresql) {
191+
request.config.database = this.selectDatabase;
192+
}
188193
if (dataSource.type === DatabaseEnum.trino || dataSource.type === DatabaseEnum.presto) {
189194
this.items = [];
190195
this.loading.button = false;
@@ -215,6 +220,12 @@ export class MetadataComponent extends BaseComponent implements OnInit {
215220
if (node?.getChildren().length === 0 && node?.isExpanded) {
216221
const request = new RequestModel();
217222
request.config = await this.dataSourceService.getByAliasAsync(this.rootNode.value);
223+
224+
if (request.config.type === DatabaseEnum.postgresql) {
225+
request.config.database = this.selectDatabase;
226+
originNode.database = this.selectTable;
227+
}
228+
218229
this.metadataService.getChild(request, originNode).then(response => {
219230
if (response.status) {
220231
node.addChildren(TreeUtils.builderTreeNode(response.data.columns, originNode.type));
@@ -235,12 +246,16 @@ export class MetadataComponent extends BaseComponent implements OnInit {
235246
switch (node.level) {
236247
case 0:
237248
this.rootNode = node.origin;
249+
this.selectDatabase = '';
250+
this.selectTable = '';
238251
break;
239252
case 1:
240253
node.origin.type = TypeEnum.database;
254+
this.selectDatabase = node.origin.key;
241255
break;
242256
case 2:
243257
node.origin.type = TypeEnum.table;
258+
this.selectTable = node.origin.key;
244259
break;
245260
case 3:
246261
node.origin.type = TypeEnum.column;

src/renderer/app/pages/management/metadata/metadata.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { ColumnCreateComponent } from '@renderer/components/column/create/column
4242
import { CommentColumnComponent } from '@renderer/components/column/comment/column.comment.component';
4343
import { DatabaseFilterComponent } from '@renderer/components/database/filter/database.filter.component';
4444
import { TableFilterComponent } from '@renderer/components/table/filter/table.filter.component';
45+
import { CollationService } from "@renderer/services/management/collation.service";
4546

4647
const MANAGEMENT_METADATA_ROUTES: Routes = [
4748
{path: '', component: MetadataComponent}
@@ -96,7 +97,8 @@ const MANAGEMENT_METADATA_ROUTES: Routes = [
9697
EditorService,
9798
TableService,
9899
ColumnService,
99-
DatabaseService
100+
DatabaseService,
101+
CollationService
100102
]
101103
})
102104
export class MetadataModule {

src/renderer/assets/i18n/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@
167167
"failed": "Failed",
168168
"druid": "Druid",
169169
"materialized_postgresql": "MaterializePostgreSQL",
170-
"elasticsearch": "ElasticSearch"
170+
"elasticsearch": "ElasticSearch",
171+
"character": "Character",
172+
"collation": "Collation"
171173
},
172174
"language": {
173175
"english": "English",

src/renderer/assets/i18n/zh.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@
166166
"failed": "失败",
167167
"druid": "Druid",
168168
"materialized_postgresql": "MaterializePostgreSQL",
169-
"elasticsearch": "ElasticSearch"
169+
"elasticsearch": "ElasticSearch",
170+
"character": "字符集",
171+
"collation": "排序规则"
170172
},
171173
"language": {
172174
"english": "英语",

src/renderer/components/database/basic/database.basic.component.html

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,65 @@
4141
</div>
4242
<div [nzSpan]="24" class="gutter-row" nz-col>
4343
<form nz-form>
44-
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.basic'|translate}}"></nz-divider>
45-
<nz-form-item>
46-
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.engine'|translate}}</nz-form-label>
47-
<nz-form-control [nzSm]="14" [nzXs]="24">
48-
<nz-tag [nzColor]="'#2db7f5'">{{configure.type}}</nz-tag>
49-
</nz-form-control>
50-
</nz-form-item>
51-
<nz-form-item>
52-
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.name'|translate}}</nz-form-label>
53-
<nz-form-control [nzSm]="14" [nzXs]="24">
54-
<input (change)="handlerValidate()" [(ngModel)]="configure.name" name="name" nz-input type="text"/>
55-
</nz-form-control>
56-
</nz-form-item>
57-
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.property'|translate}}"></nz-divider>
58-
<app-component-database-engine-lazy *ngIf="configure.type === databaseType.lazy"
59-
(emitter)="handlerComponentEmitter($event)">
60-
</app-component-database-engine-lazy>
61-
<app-component-property [properties]="properties"
62-
[experimental]="configure.experimental"
63-
(emitter)="handlerComponentEmitter($event)">
64-
</app-component-property>
44+
<nz-tabset nzAnimated="false">
45+
<!-- Basic Settings -->
46+
<nz-tab [nzTitle]="basicSettingTemplate">
47+
<ng-template #basicSettingTemplate>
48+
<i nz-icon nzType="build"></i>
49+
{{'common.basic'|translate}}
50+
</ng-template>
51+
<nz-form-item>
52+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.engine'|translate}}</nz-form-label>
53+
<nz-form-control [nzSm]="14" [nzXs]="24">
54+
<nz-tag [nzColor]="'#2db7f5'">{{configure.type}}</nz-tag>
55+
</nz-form-control>
56+
</nz-form-item>
57+
<nz-form-item>
58+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.name'|translate}}</nz-form-label>
59+
<nz-form-control [nzSm]="14" [nzXs]="24">
60+
<input (change)="handlerValidate()" [(ngModel)]="configure.name" name="name" nz-input type="text"/>
61+
</nz-form-control>
62+
</nz-form-item>
63+
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.property'|translate}}"></nz-divider>
64+
<app-component-database-engine-lazy *ngIf="configure.type === databaseType.lazy"
65+
(emitter)="handlerComponentEmitter($event)">
66+
</app-component-database-engine-lazy>
67+
<app-component-property [properties]="properties"
68+
[experimental]="configure.experimental"
69+
(emitter)="handlerComponentEmitter($event)">
70+
</app-component-property>
71+
</nz-tab>
72+
<!-- CharacterSet and Collation Settings -->
73+
<nz-tab *ngIf="configure.characterAndCollationConfigure.enable"
74+
[nzTitle]="characterSetAndCollationSettingTemplate"
75+
(nzClick)="handlerLoadCharacterAndCollation()">
76+
<ng-template #characterSetAndCollationSettingTemplate>
77+
<i nz-icon nzType="block"></i>
78+
{{'common.character'|translate}} & {{'common.collation'|translate}}
79+
</ng-template>
80+
<nz-form-item *ngIf="configure.characterAndCollationConfigure.characterSetConfigure.enable">
81+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.character'|translate}}</nz-form-label>
82+
<nz-form-control [nzSm]="14" [nzXs]="24">
83+
<nz-select name="characterValue" nzShowSearch
84+
[(ngModel)]="configure.characterAndCollationConfigure.characterSetConfigure.value"
85+
(ngModelChange)="handlerChangeCharacter($event)">
86+
<nz-option *ngFor="let character of collationConfigure.characters" [nzValue]="character"
87+
[nzLabel]="character"></nz-option>
88+
</nz-select>
89+
</nz-form-control>
90+
</nz-form-item>
91+
<nz-form-item *ngIf="configure.characterAndCollationConfigure.collationConfigure.enable">
92+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.collation'|translate}}</nz-form-label>
93+
<nz-form-control [nzSm]="14" [nzXs]="24">
94+
<nz-select name="collationValue" nzShowSearch
95+
[(ngModel)]="configure.characterAndCollationConfigure.collationConfigure.value">
96+
<nz-option *ngFor="let collation of collationConfigure.collations" [nzValue]="collation"
97+
[nzLabel]="collation"></nz-option>
98+
</nz-select>
99+
</nz-form-control>
100+
</nz-form-item>
101+
</nz-tab>
102+
</nz-tabset>
65103
</form>
66104
</div>
67105
</div>

src/renderer/components/database/basic/database.basic.component.ts

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as cloneDeep from 'lodash/cloneDeep';
1313
import { PropertyModel } from '@renderer/model/property.model';
1414
import { NzTreeNode } from 'ng-zorro-antd/core/tree/nz-tree-base-node';
1515
import { MenuModel } from '@renderer/model/menu.model';
16+
import { CollationService } from "@renderer/services/management/collation.service";
1617

1718
@Component({
1819
selector: 'app-component-database',
@@ -35,9 +36,15 @@ export class DatabaseBasicComponent extends BaseComponent implements AfterViewIn
3536
configure: DatabaseModel;
3637
databaseType = DatabaseEnum;
3738
properties: PropertyModel[];
39+
collationConfigure = {
40+
elements: [],
41+
characters: [],
42+
collations: []
43+
};
3844

3945
constructor(private dataSourceService: DatasourceService,
4046
private metadataService: MetadataService,
47+
private collationService: CollationService,
4148
private messageService: NzMessageService) {
4249
super();
4350
this.configure = new DatabaseModel();
@@ -97,19 +104,53 @@ export class DatabaseBasicComponent extends BaseComponent implements AfterViewIn
97104
this.handlerValidate();
98105
}
99106

100-
async handlerComplete() {
101-
const request = new RequestModel();
102-
request.config = await this.dataSourceService.getByAliasAsync(this.config.value);
103-
this.metadataService.createDatabase(request, this.configure).then(response => {
104-
if (response.status) {
105-
this.messageService.success(response.message);
106-
this.config.status = true;
107-
this.config.menu = this.menu;
108-
this.config.currentNode = this.node;
109-
this.emitter.emit(this.config);
110-
} else {
111-
this.messageService.error(response.message);
112-
}
113-
});
107+
handlerComplete() {
108+
this.dataSourceService.getByAliasAsync(this.config.value)
109+
.then(dataSource => {
110+
const request = new RequestModel();
111+
request.config = dataSource;
112+
this.metadataService.createDatabase(request, this.configure)
113+
.then(response => {
114+
if (response.status) {
115+
this.messageService.success(response.message);
116+
this.config.status = true;
117+
this.config.menu = this.menu;
118+
this.config.currentNode = this.node;
119+
this.emitter.emit(this.config);
120+
} else {
121+
this.messageService.error(response.message);
122+
}
123+
});
124+
});
125+
126+
}
127+
128+
handlerLoadCharacterAndCollation() {
129+
if (this.collationConfigure.characters.length <= 0) {
130+
this.dataSourceService.getByAliasAsync(this.config.value)
131+
.then(dataSource => {
132+
const request = new RequestModel();
133+
request.config = dataSource;
134+
this.collationService.getCharacterAndCollation(request)
135+
.then(response => {
136+
response.data.columns.forEach(v => {
137+
const collation = {
138+
name: v['name'],
139+
values: v['values'].split(',')
140+
};
141+
this.collationConfigure.characters.push(v['name']);
142+
this.collationConfigure.elements.push(collation);
143+
});
144+
})
145+
});
146+
}
147+
}
148+
149+
handlerChangeCharacter(value: string) {
150+
this.configure.characterAndCollationConfigure.collationConfigure.value = null;
151+
if (this.configure.characterAndCollationConfigure.collationConfigure.enable) {
152+
this.collationConfigure.collations = this.collationConfigure.elements
153+
.filter(item => item.name === value)[0].values;
154+
}
114155
}
115156
}

src/renderer/components/table/basic/basic.table.component.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
<button nz-button nzType="primary" (click)="handlerDialog(true)" style="margin-top: -22px; float: right;">
33
<i class="fa fa-external-link-square"></i>&nbsp;{{'common.export'|translate}}
44
</button>
5-
<!-- <nz-dropdown-menu #export="nzDropdownMenu">-->
6-
<!-- <ul nz-menu>-->
7-
<!-- <li nz-menu-item >{{'common.csv'|translate}}</li>-->
8-
<!-- </ul>-->
9-
<!-- </nz-dropdown-menu>-->
10-
<ngx-table [id]="id" [data]="value.columns"
11-
[configuration]="configuration" [columns]="headers">
5+
<ngx-table [id]="id" [data]="value.columns" [configuration]="configuration" [columns]="headers">
6+
<ng-template let-row let-index="index">
7+
<td *ngFor="let header of headers" style="max-width: 300px;"
8+
ellipsis [ellipsis-content]="row[header.key]"
9+
(ellipsis-click-more)="handlerShowMoreEllipsis(row[header.key])">
10+
{{row[header.key]}}
11+
</td>
12+
</ng-template>
1213
</ngx-table>
1314
</div>
1415
<ng-template #notHasValues>

src/renderer/components/table/basic/basic.table.component.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { ExportToCsv } from 'export-to-csv';
55
import { Md5 } from 'ts-md5';
66
import { TableExportModel } from "@renderer/components/table/basic/table.export.model";
77
import { StringUtils } from "@renderer/utils/string.utils";
8+
import { TranslateService } from "@ngx-translate/core";
9+
import { NzModalService } from "ng-zorro-antd/modal";
810

911
@Component({
1012
selector: 'app-component-basic-table',
@@ -18,7 +20,8 @@ export class BasicTableComponent extends BaseComponent implements AfterViewInit
1820
public id: string;
1921
exportInfo: TableExportModel;
2022

21-
constructor() {
23+
constructor(private translateService: TranslateService,
24+
private modalService: NzModalService) {
2225
super();
2326
this.configuration = {...DefaultConfig};
2427
this.configuration.horizontalScroll = true;
@@ -68,4 +71,14 @@ export class BasicTableComponent extends BaseComponent implements AfterViewInit
6871
const csvExporter = new ExportToCsv(options);
6972
csvExporter.generateCsv(this.value.columns);
7073
}
74+
75+
handlerShowMoreEllipsis(value: any): void {
76+
this.modalService.info({
77+
nzWidth: '80%',
78+
nzKeyboard: false,
79+
nzMaskClosable: false,
80+
nzOkText: this.translateService.instant('common.ok'),
81+
nzContent: value.toString()
82+
});
83+
}
7184
}

src/renderer/components/table/create/table.create.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export class CreateTableComponent extends BaseComponent implements AfterViewInit
151151
const request = new RequestModel();
152152
request.config = await this.dataSourceService.getByAliasAsync(this.config.value);
153153
this.configure.database = this.value;
154+
request.config.database = this.value;
154155
this.tableService.createTable(request, this.configure, this.columns).then(response => {
155156
if (response.status) {
156157
this.messageService.success(response.message);

0 commit comments

Comments
 (0)