mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 20:16:00 +00:00
master/detail header
This commit is contained in:
43
packages/web/src/datagrid/ReferenceHeader.js
Normal file
43
packages/web/src/datagrid/ReferenceHeader.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ToolbarButton from '../widgets/ToolbarButton';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { ReferenceIcon } from '../icons';
|
||||||
|
import theme from '../theme';
|
||||||
|
|
||||||
|
const Container = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
background: #ddeeee;
|
||||||
|
height: ${theme.toolBar.height}px;
|
||||||
|
overflow: hidden;
|
||||||
|
border-top: 1px solid #ccc;
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Header = styled.div`
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 10px;
|
||||||
|
display: flex;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const HeaderText = styled.div`
|
||||||
|
margin-left: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default function ReferenceHeader({ reference, onClose }) {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Header>
|
||||||
|
<ReferenceIcon />
|
||||||
|
<HeaderText>
|
||||||
|
{reference.pureName} [{reference.columns.map((x) => x.refName).join(', ')}] = master [
|
||||||
|
{reference.columns.map((x) => x.baseName).join(', ')}]
|
||||||
|
</HeaderText>
|
||||||
|
</Header>
|
||||||
|
<ToolbarButton icon="fas fa-times" onClick={onClose} patchY={6}>
|
||||||
|
Close
|
||||||
|
</ToolbarButton>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import DataGrid from './DataGrid';
|
import DataGrid from './DataGrid';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { TableGridDisplay, createGridConfig, createGridCache } from '@dbgate/datalib';
|
import { TableGridDisplay, createGridConfig, createGridCache } from '@dbgate/datalib';
|
||||||
import { getFilterValueExpression } from '@dbgate/filterparser';
|
import { getFilterValueExpression } from '@dbgate/filterparser';
|
||||||
import { useConnectionInfo, getTableInfo } from '../utility/metadataLoaders';
|
import { useConnectionInfo, getTableInfo } from '../utility/metadataLoaders';
|
||||||
@@ -8,6 +9,23 @@ import engines from '@dbgate/engines';
|
|||||||
import useSocket from '../utility/SocketProvider';
|
import useSocket from '../utility/SocketProvider';
|
||||||
import { VerticalSplitter } from '../widgets/Splitter';
|
import { VerticalSplitter } from '../widgets/Splitter';
|
||||||
import stableStringify from 'json-stable-stringify';
|
import stableStringify from 'json-stable-stringify';
|
||||||
|
import ReferenceHeader from './ReferenceHeader';
|
||||||
|
|
||||||
|
const ReferenceContainer = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ReferenceGridWrapper = styled.div`
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
`;
|
||||||
|
|
||||||
export default function TableDataGrid({
|
export default function TableDataGrid({
|
||||||
conid,
|
conid,
|
||||||
@@ -98,6 +116,10 @@ export default function TableDataGrid({
|
|||||||
[config || childConfig, reference]
|
[config || childConfig, reference]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleCloseReference = () => {
|
||||||
|
setReference(null);
|
||||||
|
};
|
||||||
|
|
||||||
if (!display) return null;
|
if (!display) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -118,22 +140,27 @@ export default function TableDataGrid({
|
|||||||
masterLoadedTime={masterLoadedTime}
|
masterLoadedTime={masterLoadedTime}
|
||||||
/>
|
/>
|
||||||
{reference && (
|
{reference && (
|
||||||
<TableDataGrid
|
<ReferenceContainer>
|
||||||
key={`${reference.schemaName}.${reference.pureName}`}
|
<ReferenceHeader reference={reference} onClose={handleCloseReference} />
|
||||||
conid={conid}
|
<ReferenceGridWrapper>
|
||||||
database={database}
|
<TableDataGrid
|
||||||
pureName={reference.pureName}
|
key={`${reference.schemaName}.${reference.pureName}`}
|
||||||
schemaName={reference.schemaName}
|
conid={conid}
|
||||||
changeSetState={changeSetState}
|
database={database}
|
||||||
dispatchChangeSet={dispatchChangeSet}
|
pureName={reference.pureName}
|
||||||
toolbarPortalRef={toolbarPortalRef}
|
schemaName={reference.schemaName}
|
||||||
tabVisible={false}
|
changeSetState={changeSetState}
|
||||||
config={childConfig}
|
dispatchChangeSet={dispatchChangeSet}
|
||||||
setConfig={setChildConfig}
|
toolbarPortalRef={toolbarPortalRef}
|
||||||
cache={childCache}
|
tabVisible={false}
|
||||||
setCache={setChildCache}
|
config={childConfig}
|
||||||
masterLoadedTime={myLoadedTime}
|
setConfig={setChildConfig}
|
||||||
/>
|
cache={childCache}
|
||||||
|
setCache={setChildCache}
|
||||||
|
masterLoadedTime={myLoadedTime}
|
||||||
|
/>
|
||||||
|
</ReferenceGridWrapper>
|
||||||
|
</ReferenceContainer>
|
||||||
)}
|
)}
|
||||||
</VerticalSplitter>
|
</VerticalSplitter>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ const StyledIconSpan = styled.span`
|
|||||||
|
|
||||||
const ButtonDivInner = styled.div`
|
const ButtonDivInner = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: ${(props) => props.patchY}px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default function ToolbarButton({ children, onClick, icon = undefined, disabled = undefined }) {
|
export default function ToolbarButton({ children, onClick, icon = undefined, disabled = undefined, patchY = 2 }) {
|
||||||
const Icon = icon;
|
const Icon = icon;
|
||||||
return (
|
return (
|
||||||
<ButtonDiv
|
<ButtonDiv
|
||||||
@@ -49,7 +49,7 @@ export default function ToolbarButton({ children, onClick, icon = undefined, dis
|
|||||||
}}
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<ButtonDivInner>
|
<ButtonDivInner patchY={patchY}>
|
||||||
{Icon && (
|
{Icon && (
|
||||||
<StyledIconSpan disabled={disabled}>
|
<StyledIconSpan disabled={disabled}>
|
||||||
<i className={icon} />
|
<i className={icon} />
|
||||||
|
|||||||
Reference in New Issue
Block a user