mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
info about database connection error
This commit is contained in:
parent
71832cbb5e
commit
18370cbd97
@ -7,7 +7,7 @@ const { DatabaseAnalyser } = require('dbgate-tools');
|
||||
module.exports = {
|
||||
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
||||
opened: [],
|
||||
closed: [],
|
||||
closed: {},
|
||||
requests: {},
|
||||
|
||||
handle_structure(conid, database, { structure }) {
|
||||
@ -39,7 +39,7 @@ module.exports = {
|
||||
if (existing) return existing;
|
||||
const connection = await connections.get({ conid });
|
||||
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 = {
|
||||
conid,
|
||||
database,
|
||||
@ -89,6 +89,8 @@ module.exports = {
|
||||
async status({ conid, database }) {
|
||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
||||
if (existing) return existing.status;
|
||||
const lastClosed = this.closed[`${conid}/${database}`];
|
||||
if (lastClosed) return lastClosed.status;
|
||||
return {
|
||||
name: 'error',
|
||||
message: 'Not connected',
|
||||
@ -118,7 +120,7 @@ module.exports = {
|
||||
existing.disconnected = true;
|
||||
if (kill) existing.subprocess.kill();
|
||||
this.opened = this.opened.filter((x) => x.conid != conid || x.database != database);
|
||||
this.closed[conid] = {
|
||||
this.closed[`${conid}/${database}`] = {
|
||||
status: {
|
||||
...existing.status,
|
||||
name: 'error',
|
||||
|
@ -108,6 +108,15 @@ function SqlObjectList({ conid, database }) {
|
||||
|
||||
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') {
|
||||
return (
|
||||
<WidgetsInnerContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user