info about database connection error

This commit is contained in:
Jan Prochazka 2021-01-05 17:52:18 +01:00
parent 71832cbb5e
commit 18370cbd97
2 changed files with 14 additions and 3 deletions

View File

@ -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',

View File

@ -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>