mirror of
https://github.com/Fabio286/antares.git
synced 2025-03-08 23:48:05 +01:00
feat(PostgreSQL): database in connection parameters
This commit is contained in:
parent
8a6c59f7ce
commit
964570247f
@ -1,5 +1,10 @@
|
||||
module.exports = {
|
||||
// Defaults
|
||||
defaultPort: null,
|
||||
defaultUser: null,
|
||||
defaultDatabase: null,
|
||||
// Core
|
||||
database: false,
|
||||
collations: false,
|
||||
engines: false,
|
||||
// Tools
|
||||
@ -7,7 +12,7 @@ module.exports = {
|
||||
usersManagement: false,
|
||||
variables: false,
|
||||
// Structure
|
||||
databases: true,
|
||||
schemas: false,
|
||||
tables: false,
|
||||
views: false,
|
||||
triggers: false,
|
||||
|
5
src/common/customizations/index.js
Normal file
5
src/common/customizations/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
maria: require('./mysql'),
|
||||
mysql: require('./mysql'),
|
||||
pg: require('./postgresql')
|
||||
};
|
@ -2,6 +2,10 @@ const defaults = require('./defaults');
|
||||
|
||||
module.exports = {
|
||||
...defaults,
|
||||
// Defaults
|
||||
defaultPort: 3306,
|
||||
defaultUser: 'root',
|
||||
defaultDatabase: null,
|
||||
// Core
|
||||
collations: true,
|
||||
engines: true,
|
||||
|
@ -2,17 +2,20 @@ const defaults = require('./defaults');
|
||||
|
||||
module.exports = {
|
||||
...defaults,
|
||||
// Defaults
|
||||
defaultPort: 5432,
|
||||
defaultUser: 'postgres',
|
||||
defaultDatabase: 'postgres',
|
||||
// Core
|
||||
collations: false,
|
||||
engines: false,
|
||||
database: true,
|
||||
// Tools
|
||||
processesList: true,
|
||||
// Structure
|
||||
tables: true,
|
||||
views: true,
|
||||
triggers: true,
|
||||
routines: true,
|
||||
functions: true,
|
||||
views: false,
|
||||
triggers: false,
|
||||
routines: false,
|
||||
functions: false,
|
||||
schedulers: false,
|
||||
// Settings
|
||||
databaseEdit: false,
|
||||
|
@ -11,6 +11,9 @@ export default connections => {
|
||||
password: conn.password
|
||||
};
|
||||
|
||||
if (conn.database)
|
||||
params.database = conn.database;
|
||||
|
||||
if (conn.ssl) {
|
||||
params.ssl = {
|
||||
key: conn.key ? fs.readFileSync(conn.key) : null,
|
||||
@ -50,6 +53,9 @@ export default connections => {
|
||||
password: conn.password
|
||||
};
|
||||
|
||||
if (conn.database)
|
||||
params.database = conn.database;
|
||||
|
||||
if (conn.ssl) {
|
||||
params.ssl = {
|
||||
key: conn.key ? fs.readFileSync(conn.key) : null,
|
||||
|
@ -75,7 +75,8 @@ export class PostgreSQLClient extends AntaresCore {
|
||||
async connect () {
|
||||
if (!this._poolSize) {
|
||||
const client = new Client(this._params);
|
||||
this._connection = client.connect();
|
||||
await client.connect();
|
||||
this._connection = client;
|
||||
}
|
||||
else {
|
||||
const pool = new Pool({ ...this._params, max: this._poolSize });
|
||||
|
@ -63,11 +63,11 @@
|
||||
PostgreSQL
|
||||
</option>
|
||||
<!-- <option value="mssql">
|
||||
Microsoft SQL
|
||||
</option>
|
||||
<option value="oracledb">
|
||||
Oracle DB
|
||||
</option> -->
|
||||
Microsoft SQL
|
||||
</option>
|
||||
<option value="oracledb">
|
||||
Oracle DB
|
||||
</option> -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -97,6 +97,18 @@
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="customizations.database" class="form-group">
|
||||
<div class="col-4 col-sm-12">
|
||||
<label class="form-label">{{ $t('word.database') }}</label>
|
||||
</div>
|
||||
<div class="col-8 col-sm-12">
|
||||
<input
|
||||
v-model="localConnection.database"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-4 col-sm-12">
|
||||
<label class="form-label">{{ $t('word.user') }}</label>
|
||||
@ -247,6 +259,7 @@
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import customizations from 'common/customizations';
|
||||
import Connection from '@/ipc-api/Connection';
|
||||
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
||||
import BaseToast from '@/components/BaseToast';
|
||||
@ -274,6 +287,11 @@ export default {
|
||||
selectedTab: 'general'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
customizations () {
|
||||
return customizations[this.connection.client];
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.localConnection = Object.assign({}, this.connection);
|
||||
window.addEventListener('keydown', this.onKey);
|
||||
|
@ -101,6 +101,18 @@
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="customizations.database" class="form-group">
|
||||
<div class="col-4 col-sm-12">
|
||||
<label class="form-label">{{ $t('word.database') }}</label>
|
||||
</div>
|
||||
<div class="col-8 col-sm-12">
|
||||
<input
|
||||
v-model="connection.database"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-4 col-sm-12">
|
||||
<label class="form-label">{{ $t('word.user') }}</label>
|
||||
@ -251,6 +263,7 @@
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import customizations from 'common/customizations';
|
||||
import Connection from '@/ipc-api/Connection';
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
||||
@ -270,8 +283,9 @@ export default {
|
||||
name: '',
|
||||
client: 'mysql',
|
||||
host: '127.0.0.1',
|
||||
port: '3306',
|
||||
user: 'root',
|
||||
database: null,
|
||||
port: null,
|
||||
user: null,
|
||||
password: '',
|
||||
ask: false,
|
||||
uid: uidGen('C'),
|
||||
@ -291,7 +305,13 @@ export default {
|
||||
selectedTab: 'general'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
customizations () {
|
||||
return customizations[this.connection.client];
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.setDefaults();
|
||||
window.addEventListener('keydown', this.onKey);
|
||||
|
||||
setTimeout(() => {
|
||||
@ -307,21 +327,9 @@ export default {
|
||||
addConnection: 'connections/addConnection'
|
||||
}),
|
||||
setDefaults () {
|
||||
switch (this.connection.client) {
|
||||
case 'mysql':
|
||||
this.connection.port = '3306';
|
||||
break;
|
||||
case 'mssql':
|
||||
this.connection.port = '1433';
|
||||
break;
|
||||
case 'pg':
|
||||
this.connection.user = 'postgres';
|
||||
this.connection.port = '5432';
|
||||
break;
|
||||
case 'oracledb':
|
||||
this.connection.port = '1521';
|
||||
break;
|
||||
}
|
||||
this.connection.user = this.customizations.defaultUser;
|
||||
this.connection.port = this.customizations.defaultPort;
|
||||
this.connection.database = this.customizations.defaultDatabase;
|
||||
},
|
||||
async startTest () {
|
||||
this.isTesting = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user