Skip to content

Commit

Permalink
refactor-datastudio-layout
Browse files Browse the repository at this point in the history
Signed-off-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 committed Sep 26, 2024
1 parent 7abe338 commit fe4f38c
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dinky-web/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ export default [
footerRender: false,
component: './DataStudio'
},
{
path: '/datastudio-new',
name: 'datastudio',
icon: 'CodeOutlined',
footerRender: false,
component: './DataStudioNew'
},
{
path: '/devops',
name: 'devops',
Expand Down
1 change: 1 addition & 0 deletions dinky-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"monaco-editor": "^0.51.0",
"omit.js": "^2.0.2",
"path-to-regexp": "^6.2.2",
"rc-dock": "^3.3.0",
"rc-menu": "^9.14.0",
"rc-util": "^5.43.0",
"re-resizable": "^6.10.0",
Expand Down
159 changes: 159 additions & 0 deletions dinky-web/src/pages/DataStudioNew/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import DockLayout, {LayoutData, PanelBase, PanelData} from "rc-dock";
import React from "react";
import {TabBase, TabData} from "rc-dock/src/DockData";
import {PageContainer} from "@ant-design/pro-layout";
import 'rc-dock/dist/rc-dock.css';

const DataStudioNew: React.FC = (props: any) => {

const mainLayout: LayoutData = {
dockbox: {
mode: 'horizontal',
children: [
{
id: 'dock1',
mode: 'horizontal',
size: 200,
tabs: [
{
id: 'tab1-1',
title: 'tab1-1',
content: <div>Hello World</div>
}
]
},
{
id: 'dock2',
size: 400,
tabs: [
{
id: 'tab2-1',
title: 'tab2-1',

content: <div>Hello World111</div>
},
{
id: 'tab2-2',
title: 'tab2-2',
content: <div>Hello World22222</div>
}
],
},
{
id: 'dock3',
size: 200,
panelLock: {
panelStyle: 'main'
},
tabs: [
{
id: 'tab3-1',
title: 'tab3-1',
content: <div>Hello World111</div>
},
{
id: 'tab3-2',
title: 'tab3-2',
content: <div>Hello World22222</div>
}
],
},
]
}
};


const footerLayout: LayoutData = {
dockbox: {
mode: 'vertical',
children: [
{
id: 'dock1',
mode: 'vertical',
size: 200,
tabs: [
{
id: 'tab1-1',
title: 'tab1-1',
content: <div>Hello World</div>
}
]
},
]
}
};


const saveTab = (tab: TabData): TabBase => {
console.log('saveTab', tab)
return {id: tab.id}
};

const loadTab = (tab: TabBase) : TabData => {
console.log('loadTab', tab);
return {id: tab.id, title: 'tab1', content: <div>Hello World</div> , group: 'allowWindow'};
};

// add tab0 to the main panel
const afterPanelLoaded = (savedPanel: PanelBase, loadedPanel: PanelData) => {
console.log('afterPanelLoaded', savedPanel, loadedPanel);
};

return <PageContainer breadcrumb={undefined} title={false} >
<DockLayout
dockId="dock1"
layout={mainLayout}
saveTab={(tab: TabData) => saveTab(tab)}
loadTab={(tab: TabBase) => loadTab(tab)}
groups={{
allowWindow: {
floatable: true,
newWindow: true,
maximizable: true,
}
}}
afterPanelLoaded={afterPanelLoaded}
afterPanelSaved={(savedPanel: PanelBase, panel: PanelData) => {
console.log('afterPanelSaved', savedPanel);
}}
onLayoutChange={(layout) => {
console.log('onLayoutChange', layout);
}}
style={{
position: "relative", width: "98vw", height: "65vh",
left: 10,
top: 10,
right: 10,
bottom: 10,
}}
/>
<DockLayout
dockId="dock2"
layout={footerLayout}
saveTab={(tab: TabData) => saveTab(tab)}
loadTab={(tab: TabBase) => loadTab(tab)}
groups={{
allowWindow: {
floatable: true,
newWindow: true,
maximizable: true,
}
}}
afterPanelLoaded={afterPanelLoaded}
afterPanelSaved={(savedPanel: PanelBase, panel: PanelData) => {
console.log('afterPanelSaved', savedPanel);
}}
onLayoutChange={(layout) => {
console.log('onLayoutChange', layout);
}}
style={{
position: "relative", width: "98vw", height: "25vh",
left: 10,
top: 10,
right: 10,
}}
/>
</PageContainer>
};

export default DataStudioNew;

0 comments on commit fe4f38c

Please sign in to comment.