mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
running as portal
This commit is contained in:
parent
a682df9253
commit
a5cc7624ad
@ -10,5 +10,6 @@ TOOLBAR=home
|
|||||||
ICON_home=fas fa-home
|
ICON_home=fas fa-home
|
||||||
TITLE_home=Home
|
TITLE_home=Home
|
||||||
PAGE_home=home.html
|
PAGE_home=home.html
|
||||||
|
STARTUP_PAGES=home
|
||||||
|
|
||||||
PAGES_DIRECTORY=/home/jena/jenasoft/dbgate-web/pages
|
PAGES_DIRECTORY=/home/jena/jenasoft/dbgate-web/pages
|
||||||
|
@ -10,9 +10,11 @@ module.exports = {
|
|||||||
page: process.env[`PAGE_${name}`],
|
page: process.env[`PAGE_${name}`],
|
||||||
}))
|
}))
|
||||||
: null;
|
: null;
|
||||||
|
const startupPages = process.env.STARTUP_PAGES ? process.env.STARTUP_PAGES.split(',') : [];
|
||||||
return {
|
return {
|
||||||
runAsPortal: !!process.env.CONNECTIONS,
|
runAsPortal: !!process.env.CONNECTIONS,
|
||||||
toolbar,
|
toolbar,
|
||||||
|
startupPages,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import resolveApi from '../utility/resolveApi';
|
import resolveApi from '../utility/resolveApi';
|
||||||
|
|
||||||
|
const Frame = styled.iframe`
|
||||||
|
flex: 1;
|
||||||
|
border: 0px solid gray;
|
||||||
|
`;
|
||||||
|
|
||||||
export default function InfoPageTab({ page }) {
|
export default function InfoPageTab({ page }) {
|
||||||
return <iframe src={`${resolveApi()}/pages/${page}`} />;
|
return <Frame src={`${resolveApi()}/pages/${page}`} />;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
import axios from '../utility/axios';
|
import axios from '../utility/axios';
|
||||||
import LoadingInfo from './LoadingInfo';
|
import LoadingInfo from './LoadingInfo';
|
||||||
import SearchInput from './SearchInput';
|
import SearchInput from './SearchInput';
|
||||||
|
import ErrorInfo from './ErrorInfo';
|
||||||
|
|
||||||
function SubDatabaseList({ data }) {
|
function SubDatabaseList({ data }) {
|
||||||
const setDb = useSetCurrentDatabase();
|
const setDb = useSetCurrentDatabase();
|
||||||
@ -126,7 +127,14 @@ function SqlObjectList({ conid, database }) {
|
|||||||
function SqlObjectListWrapper() {
|
function SqlObjectListWrapper() {
|
||||||
const db = useCurrentDatabase();
|
const db = useCurrentDatabase();
|
||||||
|
|
||||||
if (!db) return <div>(Choose database)</div>;
|
if (!db) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<WidgetTitle>Tables, views, functions</WidgetTitle>
|
||||||
|
<ErrorInfo message="Database not selected" />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
const { name, connection } = db;
|
const { name, connection } = db;
|
||||||
|
|
||||||
return <SqlObjectList conid={connection._id} database={name} />;
|
return <SqlObjectList conid={connection._id} database={name} />;
|
||||||
|
@ -5,7 +5,7 @@ import styled from 'styled-components';
|
|||||||
import ToolbarButton from './ToolbarButton';
|
import ToolbarButton from './ToolbarButton';
|
||||||
import useNewQuery from '../query/useNewQuery';
|
import useNewQuery from '../query/useNewQuery';
|
||||||
import { useConfig } from '../utility/metadataLoaders';
|
import { useConfig } from '../utility/metadataLoaders';
|
||||||
import { useSetOpenedTabs } from '../utility/globalState';
|
import { useSetOpenedTabs, useOpenedTabs } from '../utility/globalState';
|
||||||
import { openNewTab } from '../utility/common';
|
import { openNewTab } from '../utility/common';
|
||||||
|
|
||||||
const ToolbarContainer = styled.div`
|
const ToolbarContainer = styled.div`
|
||||||
@ -19,25 +19,44 @@ export default function ToolBar({ toolbarPortalRef }) {
|
|||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const toolbar = config.toolbar || [];
|
const toolbar = config.toolbar || [];
|
||||||
const setOpenedTabs = useSetOpenedTabs();
|
const setOpenedTabs = useSetOpenedTabs();
|
||||||
|
const openedTabs = useOpenedTabs();
|
||||||
|
|
||||||
|
function openTabFromButton(button) {
|
||||||
|
if (openedTabs.find((x) => x.tabComponent == 'InfoPageTab' && x.props && x.props.page == button.page)) {
|
||||||
|
setOpenedTabs((tabs) =>
|
||||||
|
tabs.map((tab) => ({
|
||||||
|
...tab,
|
||||||
|
selected: tab.tabComponent == 'InfoPageTab' && tab.props && tab.props.page == button.page,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
openNewTab(setOpenedTabs, {
|
||||||
|
title: button.title,
|
||||||
|
tabComponent: 'InfoPageTab',
|
||||||
|
icon: button.icon,
|
||||||
|
props: {
|
||||||
|
page: button.page,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (config.startupPages) {
|
||||||
|
for (const page of config.startupPages) {
|
||||||
|
const button = toolbar.find((x) => x.name == page);
|
||||||
|
if (button) {
|
||||||
|
openTabFromButton(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, config && config.startupPages);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolbarContainer>
|
<ToolbarContainer>
|
||||||
<ConnectionModal modalState={modalState} />
|
<ConnectionModal modalState={modalState} />
|
||||||
{toolbar.map((button) => (
|
{toolbar.map((button) => (
|
||||||
<ToolbarButton
|
<ToolbarButton key={button.name} onClick={() => openTabFromButton(button)} icon={button.icon}>
|
||||||
key={button.name}
|
|
||||||
onClick={() => {
|
|
||||||
openNewTab(setOpenedTabs, {
|
|
||||||
title: button.title,
|
|
||||||
tabComponent: 'InfoPageTab',
|
|
||||||
icon: button.icon,
|
|
||||||
props: {
|
|
||||||
page: button.page,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
icon={button.icon}
|
|
||||||
>
|
|
||||||
{button.title}
|
{button.title}
|
||||||
</ToolbarButton>
|
</ToolbarButton>
|
||||||
))}
|
))}
|
||||||
|
Loading…
Reference in New Issue
Block a user