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