mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 02:36:00 +00:00
load database list
This commit is contained in:
@@ -6,21 +6,25 @@ module.exports = {
|
||||
opened: [],
|
||||
|
||||
handle_databases(id, { databases }) {
|
||||
const existing = this.opened.find(x => x.connection.id == id);
|
||||
const existing = this.opened.find(x => x.id == id);
|
||||
if (!existing) return;
|
||||
existing.databases = databases;
|
||||
socket.emit(`database-list-changed-${id}`);
|
||||
},
|
||||
handle_error(id, { error }) {
|
||||
console.log(error);
|
||||
},
|
||||
|
||||
async ensureOpened(id) {
|
||||
const existing = this.opened.find(x => x.connection.id == id);
|
||||
const existing = this.opened.find(x => x.id == id);
|
||||
if (existing) return existing;
|
||||
const connection = await connections.get(id);
|
||||
const connection = await connections.get({ id });
|
||||
const subprocess = fork(`${__dirname}/../proc/serverConnectionProcess.js`);
|
||||
const newOpened = {
|
||||
id,
|
||||
subprocess,
|
||||
databases: [],
|
||||
connection,
|
||||
};
|
||||
this.opened.push(newOpened);
|
||||
subprocess.on('message', ({ msgtype, ...message }) => {
|
||||
|
||||
@@ -6,6 +6,7 @@ const io = require('socket.io');
|
||||
|
||||
const useController = require('./utility/useController');
|
||||
const connections = require('./controllers/connections');
|
||||
const serverConnections = require('./controllers/serverConnections');
|
||||
const socket = require('./utility/socket');
|
||||
|
||||
const app = express();
|
||||
@@ -21,5 +22,6 @@ app.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
useController(app, '/connections', connections);
|
||||
useController(app, '/server-connections', serverConnections);
|
||||
|
||||
server.listen(3000);
|
||||
|
||||
@@ -11,9 +11,11 @@ async function handleRefreshDatabases() {
|
||||
|
||||
async function handleConnect(connection) {
|
||||
storedConnection = connection;
|
||||
const driver = require(`../engines/${storedConnection.engine}/index`);
|
||||
|
||||
const driver = engines(storedConnection);
|
||||
systemConnection = await driver.connect(storedConnection);
|
||||
setInterval(handleRefreshDatabases, 30 * 1000);
|
||||
handleRefreshDatabases();
|
||||
// setInterval(handleRefreshDatabases, 30 * 1000);
|
||||
}
|
||||
|
||||
const messageHandlers = {
|
||||
|
||||
Reference in New Issue
Block a user