mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat(MySQL): possibility to set a default schema in connection parameters
This commit is contained in:
@ -7,6 +7,7 @@ module.exports = {
|
|||||||
database: false,
|
database: false,
|
||||||
collations: false,
|
collations: false,
|
||||||
engines: false,
|
engines: false,
|
||||||
|
connectionSchema: false,
|
||||||
// Tools
|
// Tools
|
||||||
processesList: false,
|
processesList: false,
|
||||||
usersManagement: false,
|
usersManagement: false,
|
||||||
|
@ -7,6 +7,7 @@ module.exports = {
|
|||||||
defaultUser: 'root',
|
defaultUser: 'root',
|
||||||
defaultDatabase: null,
|
defaultDatabase: null,
|
||||||
// Core
|
// Core
|
||||||
|
connectionSchema: true,
|
||||||
collations: true,
|
collations: true,
|
||||||
engines: true,
|
engines: true,
|
||||||
// Tools
|
// Tools
|
||||||
|
@ -67,6 +67,9 @@ export default connections => {
|
|||||||
if (conn.database)
|
if (conn.database)
|
||||||
params.database = conn.database;
|
params.database = conn.database;
|
||||||
|
|
||||||
|
if (conn.schema)
|
||||||
|
params.schema = conn.schema;
|
||||||
|
|
||||||
if (conn.ssl) {
|
if (conn.ssl) {
|
||||||
params.ssl = {
|
params.ssl = {
|
||||||
key: conn.key ? fs.readFileSync(conn.key) : null,
|
key: conn.key ? fs.readFileSync(conn.key) : null,
|
||||||
|
@ -12,6 +12,8 @@ export class ClientsFactory {
|
|||||||
* @param {String} args.params.host
|
* @param {String} args.params.host
|
||||||
* @param {Number} args.params.port
|
* @param {Number} args.params.port
|
||||||
* @param {String} args.params.password
|
* @param {String} args.params.password
|
||||||
|
* @param {String=} args.params.database
|
||||||
|
* @param {String=} args.params.schema
|
||||||
* @param {String} args.params.ssh.host
|
* @param {String} args.params.ssh.host
|
||||||
* @param {String} args.params.ssh.username
|
* @param {String} args.params.ssh.username
|
||||||
* @param {String} args.params.ssh.password
|
* @param {String} args.params.ssh.password
|
||||||
|
@ -113,7 +113,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
ssl: null
|
ssl: null
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this._params.database?.length) dbConfig.database = this._params.database;
|
if (this._params.schema?.length) dbConfig.database = this._params.schema;
|
||||||
|
|
||||||
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
if (this._params.ssl) dbConfig.ssl = { ...this._params.ssl };
|
||||||
|
|
||||||
@ -127,7 +127,8 @@ export class MySQLClient extends AntaresCore {
|
|||||||
dbConfig.port = this._tunnel.localPort;
|
dbConfig.port = this._tunnel.localPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._poolSize) this._connection = await mysql.createConnection(dbConfig);
|
if (!this._poolSize)
|
||||||
|
this._connection = await mysql.createConnection(dbConfig);
|
||||||
else {
|
else {
|
||||||
this._connection = mysql.createPool({
|
this._connection = mysql.createPool({
|
||||||
...dbConfig,
|
...dbConfig,
|
||||||
@ -168,6 +169,12 @@ export class MySQLClient extends AntaresCore {
|
|||||||
*/
|
*/
|
||||||
async getStructure (schemas) {
|
async getStructure (schemas) {
|
||||||
const { rows: databases } = await this.raw('SHOW DATABASES');
|
const { rows: databases } = await this.raw('SHOW DATABASES');
|
||||||
|
|
||||||
|
let filteredDatabases = databases;
|
||||||
|
|
||||||
|
if (this._params.schema)
|
||||||
|
filteredDatabases = filteredDatabases.filter(db => db.Database === this._params.schema);
|
||||||
|
|
||||||
const { rows: functions } = await this.raw('SHOW FUNCTION STATUS');
|
const { rows: functions } = await this.raw('SHOW FUNCTION STATUS');
|
||||||
const { rows: procedures } = await this.raw('SHOW PROCEDURE STATUS');
|
const { rows: procedures } = await this.raw('SHOW PROCEDURE STATUS');
|
||||||
const { rows: schedulers } = await this.raw('SELECT *, EVENT_SCHEMA AS `Db`, EVENT_NAME AS `Name` FROM information_schema.`EVENTS`');
|
const { rows: schedulers } = await this.raw('SELECT *, EVENT_SCHEMA AS `Db`, EVENT_NAME AS `Name` FROM information_schema.`EVENTS`');
|
||||||
@ -175,7 +182,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
const tablesArr = [];
|
const tablesArr = [];
|
||||||
const triggersArr = [];
|
const triggersArr = [];
|
||||||
|
|
||||||
for (const db of databases) {
|
for (const db of filteredDatabases) {
|
||||||
if (!schemas.has(db.Database)) continue;
|
if (!schemas.has(db.Database)) continue;
|
||||||
|
|
||||||
let { rows: tables } = await this.raw(`SHOW TABLE STATUS FROM \`${db.Database}\``);
|
let { rows: tables } = await this.raw(`SHOW TABLE STATUS FROM \`${db.Database}\``);
|
||||||
@ -197,7 +204,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return databases.map(db => {
|
return filteredDatabases.map(db => {
|
||||||
if (schemas.has(db.Database)) {
|
if (schemas.has(db.Database)) {
|
||||||
// TABLES
|
// TABLES
|
||||||
const remappedTables = tablesArr.filter(table => table.Db === db.Database).map(table => {
|
const remappedTables = tablesArr.filter(table => table.Db === db.Database).map(table => {
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
<a class="tab-link">{{ $t('word.ssl') }}</a>
|
<a class="tab-link">{{ $t('word.ssl') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class="tab-item"
|
class="tab-item c-hand"
|
||||||
:class="{'active': selectedTab === 'ssh'}"
|
:class="{'active': selectedTab === 'ssh'}"
|
||||||
@click="selectTab('ssh')"
|
@click="selectTab('ssh')"
|
||||||
>
|
>
|
||||||
<a class="c-hand">{{ $t('word.sshTunnel') }}</a>
|
<a class="tab-link">{{ $t('word.sshTunnel') }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -131,6 +131,19 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="customizations.connectionSchema" class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.schema') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
v-model="connection.schema"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('word.all')"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group columns">
|
<div class="form-group columns">
|
||||||
<div class="column col-4 col-sm-12" />
|
<div class="column col-4 col-sm-12" />
|
||||||
<div class="column col-8 col-sm-12">
|
<div class="column col-8 col-sm-12">
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
<a class="tab-link">{{ $t('word.ssl') }}</a>
|
<a class="tab-link">{{ $t('word.ssl') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class="tab-item"
|
class="tab-item c-hand"
|
||||||
:class="{'active': selectedTab === 'ssh'}"
|
:class="{'active': selectedTab === 'ssh'}"
|
||||||
@click="selectTab('ssh')"
|
@click="selectTab('ssh')"
|
||||||
>
|
>
|
||||||
<a class="c-hand">{{ $t('word.sshTunnel') }}</a>
|
<a class="tab-link">{{ $t('word.sshTunnel') }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -58,12 +58,6 @@
|
|||||||
<option value="pg">
|
<option value="pg">
|
||||||
PostgreSQL
|
PostgreSQL
|
||||||
</option>
|
</option>
|
||||||
<!-- <option value="mssql">
|
|
||||||
Microsoft SQL
|
|
||||||
</option>
|
|
||||||
<option value="oracledb">
|
|
||||||
Oracle DB
|
|
||||||
</option> -->
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -131,6 +125,19 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="customizations.connectionSchema" class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.schema') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
v-model="localConnection.schema"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('word.all')"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group columns">
|
<div class="form-group columns">
|
||||||
<div class="column col-4 col-sm-12" />
|
<div class="column col-4 col-sm-12" />
|
||||||
<div class="column col-8 col-sm-12">
|
<div class="column col-8 col-sm-12">
|
||||||
|
@ -38,12 +38,7 @@
|
|||||||
<i class="form-icon mdi mdi-magnify mdi-18px" />
|
<i class="form-icon mdi mdi-magnify mdi-18px" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceConnectPanel
|
<div class="workspace-explorebar-body">
|
||||||
v-if="workspace.connection_status !== 'connected'"
|
|
||||||
class="workspace-explorebar-body"
|
|
||||||
:connection="connection"
|
|
||||||
/>
|
|
||||||
<div v-else class="workspace-explorebar-body">
|
|
||||||
<WorkspaceExploreBarSchema
|
<WorkspaceExploreBarSchema
|
||||||
v-for="db of workspace.structure"
|
v-for="db of workspace.structure"
|
||||||
:key="db.name"
|
:key="db.name"
|
||||||
@ -143,7 +138,6 @@ import Routines from '@/ipc-api/Routines';
|
|||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
import Schedulers from '@/ipc-api/Schedulers';
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
import WorkspaceConnectPanel from '@/components/WorkspaceConnectPanel';
|
|
||||||
import WorkspaceExploreBarSchema from '@/components/WorkspaceExploreBarSchema';
|
import WorkspaceExploreBarSchema from '@/components/WorkspaceExploreBarSchema';
|
||||||
import DatabaseContext from '@/components/WorkspaceExploreBarSchemaContext';
|
import DatabaseContext from '@/components/WorkspaceExploreBarSchemaContext';
|
||||||
import TableContext from '@/components/WorkspaceExploreBarTableContext';
|
import TableContext from '@/components/WorkspaceExploreBarTableContext';
|
||||||
@ -160,7 +154,6 @@ import ModalNewScheduler from '@/components/ModalNewScheduler';
|
|||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceExploreBar',
|
name: 'WorkspaceExploreBar',
|
||||||
components: {
|
components: {
|
||||||
WorkspaceConnectPanel,
|
|
||||||
WorkspaceExploreBarSchema,
|
WorkspaceExploreBarSchema,
|
||||||
DatabaseContext,
|
DatabaseContext,
|
||||||
TableContext,
|
TableContext,
|
||||||
|
@ -113,7 +113,8 @@ module.exports = {
|
|||||||
large: 'Large',
|
large: 'Large',
|
||||||
row: 'Row | Rows',
|
row: 'Row | Rows',
|
||||||
cell: 'Cell | Cells',
|
cell: 'Cell | Cells',
|
||||||
triggerFunction: 'Trigger function | Trigger functions'
|
triggerFunction: 'Trigger function | Trigger functions',
|
||||||
|
all: 'All'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
Reference in New Issue
Block a user