mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
info about database connection error
This commit is contained in:
@@ -7,7 +7,7 @@ const { DatabaseAnalyser } = require('dbgate-tools');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
||||||
opened: [],
|
opened: [],
|
||||||
closed: [],
|
closed: {},
|
||||||
requests: {},
|
requests: {},
|
||||||
|
|
||||||
handle_structure(conid, database, { structure }) {
|
handle_structure(conid, database, { structure }) {
|
||||||
@@ -39,7 +39,7 @@ module.exports = {
|
|||||||
if (existing) return existing;
|
if (existing) return existing;
|
||||||
const connection = await connections.get({ conid });
|
const connection = await connections.get({ conid });
|
||||||
const subprocess = fork(process.argv[1], ['databaseConnectionProcess']);
|
const subprocess = fork(process.argv[1], ['databaseConnectionProcess']);
|
||||||
const lastClosed = this.closed.find((x) => x.conid == conid && x.database == database);
|
const lastClosed = this.closed[`${conid}/${database}`];
|
||||||
const newOpened = {
|
const newOpened = {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
@@ -89,6 +89,8 @@ module.exports = {
|
|||||||
async status({ conid, database }) {
|
async status({ conid, database }) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
||||||
if (existing) return existing.status;
|
if (existing) return existing.status;
|
||||||
|
const lastClosed = this.closed[`${conid}/${database}`];
|
||||||
|
if (lastClosed) return lastClosed.status;
|
||||||
return {
|
return {
|
||||||
name: 'error',
|
name: 'error',
|
||||||
message: 'Not connected',
|
message: 'Not connected',
|
||||||
@@ -118,7 +120,7 @@ module.exports = {
|
|||||||
existing.disconnected = true;
|
existing.disconnected = true;
|
||||||
if (kill) existing.subprocess.kill();
|
if (kill) existing.subprocess.kill();
|
||||||
this.opened = this.opened.filter((x) => x.conid != conid || x.database != database);
|
this.opened = this.opened.filter((x) => x.conid != conid || x.database != database);
|
||||||
this.closed[conid] = {
|
this.closed[`${conid}/${database}`] = {
|
||||||
status: {
|
status: {
|
||||||
...existing.status,
|
...existing.status,
|
||||||
name: 'error',
|
name: 'error',
|
||||||
|
|||||||
@@ -108,6 +108,15 @@ function SqlObjectList({ conid, database }) {
|
|||||||
|
|
||||||
const inputRef = React.useRef(null);
|
const inputRef = React.useRef(null);
|
||||||
|
|
||||||
|
if (status && status.name == 'error') {
|
||||||
|
return (
|
||||||
|
<WidgetsInnerContainer>
|
||||||
|
<ErrorInfo message={status.message} icon="img error" />
|
||||||
|
<InlineButton onClick={handleRefreshDatabase}>Refresh</InlineButton>
|
||||||
|
</WidgetsInnerContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectList.length == 0 && (status && status.name) != 'pending') {
|
if (objectList.length == 0 && (status && status.name) != 'pending') {
|
||||||
return (
|
return (
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user