mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat(PostgreSQL): database in connection parameters
This commit is contained in:
@ -1,5 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
// Defaults
|
||||||
|
defaultPort: null,
|
||||||
|
defaultUser: null,
|
||||||
|
defaultDatabase: null,
|
||||||
// Core
|
// Core
|
||||||
|
database: false,
|
||||||
collations: false,
|
collations: false,
|
||||||
engines: false,
|
engines: false,
|
||||||
// Tools
|
// Tools
|
||||||
@ -7,7 +12,7 @@ module.exports = {
|
|||||||
usersManagement: false,
|
usersManagement: false,
|
||||||
variables: false,
|
variables: false,
|
||||||
// Structure
|
// Structure
|
||||||
databases: true,
|
schemas: false,
|
||||||
tables: false,
|
tables: false,
|
||||||
views: false,
|
views: false,
|
||||||
triggers: 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 = {
|
module.exports = {
|
||||||
...defaults,
|
...defaults,
|
||||||
|
// Defaults
|
||||||
|
defaultPort: 3306,
|
||||||
|
defaultUser: 'root',
|
||||||
|
defaultDatabase: null,
|
||||||
// Core
|
// Core
|
||||||
collations: true,
|
collations: true,
|
||||||
engines: true,
|
engines: true,
|
||||||
|
@ -2,17 +2,20 @@ const defaults = require('./defaults');
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...defaults,
|
...defaults,
|
||||||
|
// Defaults
|
||||||
|
defaultPort: 5432,
|
||||||
|
defaultUser: 'postgres',
|
||||||
|
defaultDatabase: 'postgres',
|
||||||
// Core
|
// Core
|
||||||
collations: false,
|
database: true,
|
||||||
engines: false,
|
|
||||||
// Tools
|
// Tools
|
||||||
processesList: true,
|
processesList: true,
|
||||||
// Structure
|
// Structure
|
||||||
tables: true,
|
tables: true,
|
||||||
views: true,
|
views: false,
|
||||||
triggers: true,
|
triggers: false,
|
||||||
routines: true,
|
routines: false,
|
||||||
functions: true,
|
functions: false,
|
||||||
schedulers: false,
|
schedulers: false,
|
||||||
// Settings
|
// Settings
|
||||||
databaseEdit: false,
|
databaseEdit: false,
|
||||||
|
@ -11,6 +11,9 @@ export default connections => {
|
|||||||
password: conn.password
|
password: conn.password
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (conn.database)
|
||||||
|
params.database = conn.database;
|
||||||
|
|
||||||
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,
|
||||||
@ -50,6 +53,9 @@ export default connections => {
|
|||||||
password: conn.password
|
password: conn.password
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (conn.database)
|
||||||
|
params.database = conn.database;
|
||||||
|
|
||||||
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,
|
||||||
|
@ -75,7 +75,8 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
async connect () {
|
async connect () {
|
||||||
if (!this._poolSize) {
|
if (!this._poolSize) {
|
||||||
const client = new Client(this._params);
|
const client = new Client(this._params);
|
||||||
this._connection = client.connect();
|
await client.connect();
|
||||||
|
this._connection = client;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const pool = new Pool({ ...this._params, max: this._poolSize });
|
const pool = new Pool({ ...this._params, max: this._poolSize });
|
||||||
|
@ -97,6 +97,18 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</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="form-group">
|
||||||
<div class="col-4 col-sm-12">
|
<div class="col-4 col-sm-12">
|
||||||
<label class="form-label">{{ $t('word.user') }}</label>
|
<label class="form-label">{{ $t('word.user') }}</label>
|
||||||
@ -247,6 +259,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions } from 'vuex';
|
import { mapActions } from 'vuex';
|
||||||
|
import customizations from 'common/customizations';
|
||||||
import Connection from '@/ipc-api/Connection';
|
import Connection from '@/ipc-api/Connection';
|
||||||
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
||||||
import BaseToast from '@/components/BaseToast';
|
import BaseToast from '@/components/BaseToast';
|
||||||
@ -274,6 +287,11 @@ export default {
|
|||||||
selectedTab: 'general'
|
selectedTab: 'general'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
customizations () {
|
||||||
|
return customizations[this.connection.client];
|
||||||
|
}
|
||||||
|
},
|
||||||
created () {
|
created () {
|
||||||
this.localConnection = Object.assign({}, this.connection);
|
this.localConnection = Object.assign({}, this.connection);
|
||||||
window.addEventListener('keydown', this.onKey);
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
@ -101,6 +101,18 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</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="form-group">
|
||||||
<div class="col-4 col-sm-12">
|
<div class="col-4 col-sm-12">
|
||||||
<label class="form-label">{{ $t('word.user') }}</label>
|
<label class="form-label">{{ $t('word.user') }}</label>
|
||||||
@ -251,6 +263,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions } from 'vuex';
|
import { mapActions } from 'vuex';
|
||||||
|
import customizations from 'common/customizations';
|
||||||
import Connection from '@/ipc-api/Connection';
|
import Connection from '@/ipc-api/Connection';
|
||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
||||||
@ -270,8 +283,9 @@ export default {
|
|||||||
name: '',
|
name: '',
|
||||||
client: 'mysql',
|
client: 'mysql',
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: '3306',
|
database: null,
|
||||||
user: 'root',
|
port: null,
|
||||||
|
user: null,
|
||||||
password: '',
|
password: '',
|
||||||
ask: false,
|
ask: false,
|
||||||
uid: uidGen('C'),
|
uid: uidGen('C'),
|
||||||
@ -291,7 +305,13 @@ export default {
|
|||||||
selectedTab: 'general'
|
selectedTab: 'general'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
customizations () {
|
||||||
|
return customizations[this.connection.client];
|
||||||
|
}
|
||||||
|
},
|
||||||
created () {
|
created () {
|
||||||
|
this.setDefaults();
|
||||||
window.addEventListener('keydown', this.onKey);
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -307,21 +327,9 @@ export default {
|
|||||||
addConnection: 'connections/addConnection'
|
addConnection: 'connections/addConnection'
|
||||||
}),
|
}),
|
||||||
setDefaults () {
|
setDefaults () {
|
||||||
switch (this.connection.client) {
|
this.connection.user = this.customizations.defaultUser;
|
||||||
case 'mysql':
|
this.connection.port = this.customizations.defaultPort;
|
||||||
this.connection.port = '3306';
|
this.connection.database = this.customizations.defaultDatabase;
|
||||||
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;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async startTest () {
|
async startTest () {
|
||||||
this.isTesting = true;
|
this.isTesting = true;
|
||||||
|
Reference in New Issue
Block a user