-
Notifications
You must be signed in to change notification settings - Fork 58
support search for table #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d3006b4
07a1112
8e214cc
3dc5143
9805aae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ import { InfoNode } from "./infoNode"; | |
| import { INode } from "./INode"; | ||
|
|
||
| export class ConnectionNode implements INode { | ||
| public keyword; | ||
|
|
||
| constructor(private readonly id: string, private readonly host: string, private readonly user: string, | ||
| private readonly password: string, private readonly port: string, | ||
| private readonly certPath: string) { | ||
|
|
@@ -23,7 +25,7 @@ export class ConnectionNode implements INode { | |
| label: this.host, | ||
| collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, | ||
| contextValue: "connection", | ||
| iconPath: path.join(__filename, "..", "..", "..", "resources", "server.png"), | ||
| iconPath: path.join(__filename, "..", "..", "..", "resources", this.keyword ? "b_search.png" : "server.png") , | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -36,7 +38,7 @@ export class ConnectionNode implements INode { | |
| certPath: this.certPath, | ||
| }); | ||
|
|
||
| return Utility.queryPromise<any[]>(connection, "SHOW DATABASES") | ||
| return Utility.queryPromise<any[]>(connection, "SHOW DATABASES" + (this.keyword ? ` LIKE '%${this.keyword}%'` : "")) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .then((databases) => { | ||
| return databases.map<DatabaseNode>((database) => { | ||
| return new DatabaseNode(this.host, this.user, this.password, this.port, database.Database, this.certPath); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,14 @@ import * as vscode from "vscode"; | |
| import { AppInsightsClient } from "../common/appInsightsClient"; | ||
| import { Global } from "../common/global"; | ||
| import { Utility } from "../common/utility"; | ||
| import { MySQLTreeDataProvider } from "../mysqlTreeDataProvider"; | ||
| import { InfoNode } from "./infoNode"; | ||
| import { INode } from "./INode"; | ||
| import { TableNode } from "./tableNode"; | ||
|
|
||
| export class DatabaseNode implements INode { | ||
| public keyword; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave a blank line after this |
||
|
|
||
| constructor(private readonly host: string, private readonly user: string, | ||
| private readonly password: string, private readonly port: string, private readonly database: string, | ||
| private readonly certPath: string) { | ||
|
|
@@ -20,7 +23,7 @@ export class DatabaseNode implements INode { | |
| label: this.database, | ||
| collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, | ||
| contextValue: "database", | ||
| iconPath: path.join(__filename, "..", "..", "..", "resources", "database.svg"), | ||
| iconPath: path.join(__filename, "..", "..", "..", "resources", this.keyword ? "b_search.png" : "database.svg"), | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -33,8 +36,8 @@ export class DatabaseNode implements INode { | |
| database: this.database, | ||
| certPath: this.certPath, | ||
| }); | ||
|
|
||
| return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`) | ||
| const filter = this.keyword ? `TABLE_NAME LIKE '%${this.keyword}%'` : ""; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Miss |
||
| return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' ${filter} LIMIT ${Utility.maxTableCount}`) | ||
| .then((tables) => { | ||
| return tables.map<TableNode>((table) => { | ||
| return new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { Constants } from "./common/constants"; | |
| import { Global } from "./common/global"; | ||
| import { IConnection } from "./model/connection"; | ||
| import { ConnectionNode } from "./model/connectionNode"; | ||
| import { DatabaseNode } from "./model/databaseNode"; | ||
| import { INode } from "./model/INode"; | ||
|
|
||
| export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> { | ||
|
|
@@ -76,6 +77,19 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> { | |
| AppInsightsClient.sendEvent("addConnection.end"); | ||
| } | ||
|
|
||
| public async keywordFilter(node: DatabaseNode | ConnectionNode) { | ||
| vscode.window.showInputBox({ | ||
| prompt: "" , placeHolder: "keyword", value: node.keyword, | ||
| validateInput: (keyword: string) => { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It this by design? It will trigger |
||
| if (node.keyword !== keyword) { | ||
| node.keyword = keyword; | ||
| this.refresh(node); | ||
| } | ||
| return ""; | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| public refresh(element?: INode): void { | ||
| this._onDidChangeTreeData.fire(element); | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a blank line after this