Unverified Commit 8956a2d3 authored by ZackYoung's avatar ZackYoung Committed by GitHub

[Feature] [Web] add data-studio web layout (#2123)

* add data-studio web * fix login layout by resolution * add data-studio web * modify icon * modify icon * fix bottomContainer height * add dva storage * add dva storage * add dva storage * optimize web layout * optimize web layout * modify code * fix * optimize web tabs change * fix * optimize web tabs change * optimize init metadata * optimize leftBottom side * modify code * fix tabs key type * modify code * add bottomContainer * 添加树节点选中的 dva 事件 * modify tree * 实现 tag 的右键菜单 * fix error * fix error * modify CODE * 优化代码 * modify CODE * added search * 调整代码 * 调整 header 样式 * added some 组件 * added icon * 调整代码 * fix layout * fix layout * fix layout * fix layout --------- Co-authored-by: 's avatarzhu-mingye <934230207@qq.com>
parent f94dc38c
...@@ -22,7 +22,6 @@ package org.dinky.controller; ...@@ -22,7 +22,6 @@ package org.dinky.controller;
import org.dinky.data.dto.CatalogueTaskDTO; import org.dinky.data.dto.CatalogueTaskDTO;
import org.dinky.data.enums.Status; import org.dinky.data.enums.Status;
import org.dinky.data.model.Catalogue; import org.dinky.data.model.Catalogue;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.function.constant.PathConstant; import org.dinky.function.constant.PathConstant;
import org.dinky.service.CatalogueService; import org.dinky.service.CatalogueService;
...@@ -31,11 +30,9 @@ import java.io.BufferedReader; ...@@ -31,11 +30,9 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
...@@ -44,8 +41,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -44,8 +41,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.JsonNode;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -174,35 +169,6 @@ public class CatalogueController { ...@@ -174,35 +169,6 @@ public class CatalogueController {
} }
} }
/** 动态查询列表 */
@PostMapping
public ProTableResult<Catalogue> listCatalogues(@RequestBody JsonNode para) {
return catalogueService.selectForProTable(para);
}
/** 批量删除 */
@DeleteMapping
public Result<Void> deleteMul(@RequestBody JsonNode para) {
if (para.size() > 0) {
boolean isAdmin = false;
List<String> error = new ArrayList<>();
for (final JsonNode item : para) {
Integer id = item.asInt();
List<String> ids = catalogueService.removeCatalogueAndTaskById(id);
if (!ids.isEmpty()) {
error.addAll(ids);
}
}
if (error.size() == 0 && !isAdmin) {
return Result.succeed("删除成功");
} else {
return Result.succeed("删除失败,请检查作业" + error + "状态。");
}
} else {
return Result.failed("请选择要删除的记录");
}
}
/** 获取指定ID的信息 */ /** 获取指定ID的信息 */
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result<Catalogue> getOneById(@RequestBody Catalogue catalogue) throws Exception { public Result<Catalogue> getOneById(@RequestBody Catalogue catalogue) throws Exception {
......
...@@ -192,6 +192,6 @@ export default defineConfig({ ...@@ -192,6 +192,6 @@ export default defineConfig({
mfsu: { mfsu: {
strategy: 'normal', strategy: 'normal',
}, },
requestRecord: {}, // requestRecord: {},
dva: {}, dva: {},
}); });
...@@ -60,8 +60,8 @@ const Settings: ProLayoutProps & { ...@@ -60,8 +60,8 @@ const Settings: ProLayoutProps & {
colorBgMenuItemSelected: '#3399FF', colorBgMenuItemSelected: '#3399FF',
}, },
pageContainer: { pageContainer: {
paddingBlockPageContainerContent: 5, paddingBlockPageContainerContent: 0,
paddingInlinePageContainerContent: 10, paddingInlinePageContainerContent: 0,
} }
}, },
}; };
......
...@@ -47,27 +47,30 @@ ...@@ -47,27 +47,30 @@
"dependencies": { "dependencies": {
"@ant-design/charts": "^1.4.2", "@ant-design/charts": "^1.4.2",
"@ant-design/icons": "^5.0.1", "@ant-design/icons": "^5.0.1",
"@ant-design/pro-components": "^2.5.5", "@ant-design/pro-components": "^2.6.3",
"@ant-design/pro-layout": "^7.13.3", "@ant-design/pro-layout": "^7.13.3",
"@ant-design/pro-table": "^3.6.9", "@ant-design/pro-table": "^3.6.9",
"@ant-design/use-emotion-css": "^1.0.4", "@ant-design/use-emotion-css": "^1.0.4",
"@monaco-editor/react": "^4.5.1",
"@umijs/route-utils": "^4.0.1", "@umijs/route-utils": "^4.0.1",
"antd": "^5.6.1", "antd": "^5.6.1",
"classnames": "^2.3.2", "classnames": "^2.3.2",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"million": "^2.5.1-beta.3",
"moment": "^2.29.4", "moment": "^2.29.4",
"omit.js": "^2.0.2", "omit.js": "^2.0.2",
"rc-menu": "^9.8.4", "rc-menu": "^9.8.4",
"rc-util": "^5.33.0", "rc-util": "^5.33.0",
"re-resizable": "6.9.9",
"react": "^18.2.0", "react": "^18.2.0",
"react-countup": "^6.4.2", "react-countup": "^6.4.2",
"react-dev-inspector": "^1.8.1", "react-dev-inspector": "^1.8.1",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-helmet-async": "^1.3.0", "react-helmet-async": "^1.3.0",
"react-monaco-editor": "^0.52.0",
"react-spring": "^9.7.1", "react-spring": "^9.7.1",
"react-use-cookie": "^1.4.0", "react-use-cookie": "^1.4.0",
"redux-persist": "^6.0.0",
"screenfull": "^6.0.2", "screenfull": "^6.0.2",
"styled-components": "^6.0.0-rc.3", "styled-components": "^6.0.0-rc.3",
"use-sse": "^2.0.1" "use-sse": "^2.0.1"
......
...@@ -28,6 +28,9 @@ import {API_CONSTANTS} from "@/services/constants"; ...@@ -28,6 +28,9 @@ import {API_CONSTANTS} from "@/services/constants";
import {THEME} from "@/types/Public/data"; import {THEME} from "@/types/Public/data";
import {UnAccessible} from "@/pages/Other/403"; import {UnAccessible} from "@/pages/Other/403";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import {persistStore, persistReducer} from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import {Reducer, StoreEnhancer} from 'redux';
// const isDev = process.env.NODE_ENV === "development"; // const isDev = process.env.NODE_ENV === "development";
const loginPath = API_CONSTANTS.LOGIN_PATH; const loginPath = API_CONSTANTS.LOGIN_PATH;
...@@ -138,3 +141,24 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) => ...@@ -138,3 +141,24 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
export const request = { export const request = {
...errorConfig, ...errorConfig,
}; };
// 这个是redux-persist 的配置
const persistConfig = {
key: 'root', // 自动框架生产的根目录id 是root。不变
storage, // 这个是选择用什么存储,session 还是 storage
};
const persistEnhancer: StoreEnhancer = (next) =>
(reducer: Reducer<any, any>) => {
const store = next(persistReducer(persistConfig, reducer));
const persist = persistStore(store);
return {...store, persist};
}
export const dva = {
config: {
extraEnhancers: [persistEnhancer],
},
};
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import {monaco} from "react-monaco-editor"; import * as monaco from 'monaco-editor';
import keyWordJsonData from "./keyword.json"; import keyWordJsonData from "./keyword.json";
import {Document, GlobalVar} from "@/types/RegCenter/data.d"; import {Document, GlobalVar} from "@/types/RegCenter/data.d";
import {Column, ISuggestions, MetaData} from "@/components/CustomEditor/CodeEdit/data"; import {Column, ISuggestions, MetaData} from "@/components/CustomEditor/CodeEdit/data";
......
...@@ -17,19 +17,21 @@ ...@@ -17,19 +17,21 @@
* *
*/ */
import MonacoEditor, {monaco} from "react-monaco-editor"; import * as monaco from 'monaco-editor';
import {MonacoEditorOptions} from "@/types/Public/data"; import {MonacoEditorOptions} from "@/types/Public/data";
import {convertCodeEditTheme} from "@/utils/function"; import {convertCodeEditTheme} from "@/utils/function";
import React, {useState} from "react"; import React, {useState} from "react";
import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn"; import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn";
import {editor} from "monaco-editor"; import {editor} from "monaco-editor";
import {Editor, OnChange} from "@monaco-editor/react";
type CodeEditFormProps = { type CodeEditFormProps = {
height?: string; height?: string;
width?: string; width?: string;
language?: string; language?: string;
options?: any; options?: any;
onChange?: (val: string) => void; onChange?: OnChange;
code: string; code: string;
readOnly?: boolean; readOnly?: boolean;
lineNumbers?: string; lineNumbers?: string;
...@@ -126,7 +128,7 @@ const CodeEdit = (props: CodeEditFormProps) => { ...@@ -126,7 +128,7 @@ const CodeEdit = (props: CodeEditFormProps) => {
return (<> return (<>
<div className={"monaco-float"}> <div className={"monaco-float"}>
<MonacoEditor <Editor
width={width} width={width}
height={height} height={height}
value={code} value={code}
...@@ -138,7 +140,7 @@ const CodeEdit = (props: CodeEditFormProps) => { ...@@ -138,7 +140,7 @@ const CodeEdit = (props: CodeEditFormProps) => {
autoDetectHighContrast: true, autoDetectHighContrast: true,
lineNumbers, lineNumbers,
}} }}
editorDidMount={editorDidMount} onMount={editorDidMount}
onChange={onChange} onChange={onChange}
theme={theme ? theme : convertCodeEditTheme()} theme={theme ? theme : convertCodeEditTheme()}
/> />
......
...@@ -17,14 +17,18 @@ ...@@ -17,14 +17,18 @@
* *
*/ */
import MonacoEditor, {monaco} from "react-monaco-editor"; import {Editor } from "@monaco-editor/react";
import {convertCodeEditTheme} from "@/utils/function"; import {convertCodeEditTheme} from "@/utils/function";
import {MonacoEditorOptions} from "@/types/Public/data"; import {MonacoEditorOptions} from "@/types/Public/data";
import React, {useState} from "react"; import React, {useState} from "react";
import {editor} from "monaco-editor"; import {editor} from "monaco-editor";
import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn"; import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn";
import FullscreenBtn from "../FullscreenBtn"; import FullscreenBtn from "../FullscreenBtn";
import * as monaco from 'monaco-editor';
import { loader } from '@monaco-editor/react';
import {EditorLanguage} from "monaco-editor/esm/metadata";
loader.config({ monaco });
/** /**
* props * props
* todo: * todo:
...@@ -33,9 +37,9 @@ import FullscreenBtn from "../FullscreenBtn"; ...@@ -33,9 +37,9 @@ import FullscreenBtn from "../FullscreenBtn";
* 2. Callback for right-clicking to clear logs (optional, not required) * 2. Callback for right-clicking to clear logs (optional, not required)
*/ */
export type CodeShowFormProps = { export type CodeShowFormProps = {
height?: string; height?: string|number;
width?: string; width?: string;
language?: string; language?: EditorLanguage;
options?: any; options?: any;
code: string; code: string;
lineNumbers?: string; lineNumbers?: string;
...@@ -86,10 +90,10 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -86,10 +90,10 @@ const CodeShow = (props: CodeShowFormProps) => {
const [editorRef, setEditorRef] = useState<any>(); const [editorRef, setEditorRef] = useState<any>();
const [timer, setTimer] = useState<NodeJS.Timer>(); const [timer, setTimer] = useState<NodeJS.Timer>();
// register TypeScript language service, if language is not set default value is typescript! // // register TypeScript language service, if language is not set default value is typescript!
monaco.languages.register({ // monaco.languages.register({
id: language || "typescript", // id: language || "typescript",
}); // });
/** /**
* handle sync log * handle sync log
...@@ -202,7 +206,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -202,7 +206,7 @@ const CodeShow = (props: CodeShowFormProps) => {
{fullScreenBtn && <FullscreenBtn isFullscreen={fullScreen} fullScreenCallBack={() => setFullScreen(!fullScreen)}/>} {fullScreenBtn && <FullscreenBtn isFullscreen={fullScreen} fullScreenCallBack={() => setFullScreen(!fullScreen)}/>}
{/* editor */} {/* editor */}
<MonacoEditor <Editor
width={width} width={width}
height={height} height={height}
value={loading ? "loading..." : code} value={loading ? "loading..." : code}
...@@ -218,7 +222,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -218,7 +222,7 @@ const CodeShow = (props: CodeShowFormProps) => {
lineNumbers, lineNumbers,
}} }}
editorDidMount={editorDidMount} onMount={editorDidMount}
theme={theme ? theme : convertCodeEditTheme()} theme={theme ? theme : convertCodeEditTheme()}
/> />
......
...@@ -24,7 +24,7 @@ const Footer: React.FC = () => { ...@@ -24,7 +24,7 @@ const Footer: React.FC = () => {
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
return ( return (
<DefaultFooter <DefaultFooter
style={{background: 'none', bottom: 0 }} style={{background: 'url(/icons/footer-bg.svg) 100% 100% no-repeat', backgroundSize: "cover", bottom: 0}}
copyright={`${currentYear} ` + l('app.copyright.produced')} copyright={`${currentYear} ` + l('app.copyright.produced')}
links={[ links={[
{ {
......
...@@ -20,7 +20,8 @@ import React from "react"; ...@@ -20,7 +20,8 @@ import React from "react";
const defaultSvgSize = "100%"; const defaultSvgSize = "100%";
const style = {overflow: "hidden",width: "100%",height: "100%"}; // const style = {overflow: "hidden",width: "100%",height: "100%"};
const style = {overflow: "hidden"};
export const MysqlIcons = (props: any) => { export const MysqlIcons = (props: any) => {
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import Icon from "@ant-design/icons";
import React from "react";
const defaultSvgSize = "100%";
const style = {overflow: "hidden"};
export const SaveIcon = (props: any) => {
const {size: sizeProps , style : styleProps} = props;
const size = sizeProps || defaultSvgSize;
return <>
<Icon style={{...style,...styleProps}} component={() => (
<svg className="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" width={size} height={size}>
<path
d="M523.73504 319.29344h-204.8c-16.896 0-30.72-13.824-30.72-30.72s13.824-30.72 30.72-30.72h204.8c16.896 0 30.72 13.824 30.72 30.72s-13.824 30.72-30.72 30.72zM605.65504 452.41344h-286.72c-16.896 0-30.72-13.824-30.72-30.72s13.824-30.72 30.72-30.72h286.72c16.896 0 30.72 13.824 30.72 30.72s-13.824 30.72-30.72 30.72z"
fill="#FFFFFF" ></path>
<path
d="M658.176 146.57536H267.8784c-40.07936 0-72.58112 32.13312-72.58112 71.7824v587.29472c0 39.63904 32.49152 71.7824 72.58112 71.7824h488.2432c40.07936 0 72.58112-32.13312 72.58112-71.7824V303.18592L658.176 146.57536z"
fill="#3889FF" ></path>
<path
d="M317.10208 195.29728h341.06368v146.176H317.10208zM268.38016 633.8048h487.23968v243.61984H268.38016z"
fill="#FFFFFF"></path>
<path
d="M598.71232 317.10208a25.6 25.6 0 0 1-25.6-25.6v-46.24384a25.6 25.6 0 1 1 51.2 0v46.24384a25.6 25.6 0 0 1-25.6 25.6zM640 736.2048h-256a25.6 25.6 0 1 1 0-51.2h256a25.6 25.6 0 1 1 0 51.2zM643.0208 829.17376h-256a25.6 25.6 0 1 1 0-51.2h256a25.6 25.6 0 0 1 0 51.2z"
fill="#3889FF"></path>
</svg>
)}/>
</>;
};
export const MaxIcon = (props: any) => {
const {size: sizeProps , style : styleProps} = props;
const size = sizeProps || defaultSvgSize;
return <>
<Icon {...props} style={{...style,...styleProps}} component={() => (
<svg className="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg"width={size} height={size} >
<path
d="M0 0m341.333333 0l341.333334 0q341.333333 0 341.333333 341.333333l0 341.333334q0 341.333333-341.333333 341.333333l-341.333334 0q-341.333333 0-341.333333-341.333333l0-341.333334q0-341.333333 341.333333-341.333333Z"
fill="#3D7FFF"></path>
<path
d="M483.242667 761.813333H293.162667l155.861333-154.026666c7.594667-7.509333 7.594667-22.528 0-30.037334-7.594667-11.264-22.784-11.264-34.218667 0L258.986667 731.733333v-202.88c0-11.264-11.392-22.528-22.784-22.528-11.434667 0-22.826667 11.264-22.826667 22.528v214.186667C213.333333 773.034667 236.16 810.666667 270.336 810.666667h212.906667c11.392 0 22.826667-11.264 22.826666-22.528 0-15.061333-11.434667-26.325333-22.826666-26.325334zM768.426667 213.333333h-224.298667c-11.434667 0-22.826667 11.264-22.826667 22.528s11.392 22.570667 22.826667 22.570667h190.08l-159.701333 154.026667c-7.594667 7.509333-7.594667 22.528 0 33.792 11.434667 7.509333 26.624 7.509333 34.218666 0l155.861334-154.026667v187.861333c0 11.264 11.434667 22.528 22.826666 22.528s22.826667-11.264 22.826667-22.528V273.450667c3.797333-37.546667-15.232-60.117333-41.813333-60.117334z"
fill="#FFFFFF" ></path>
</svg>
)}/>
</>;
};
export const MinIcon = (props: any) => {
const {size: sizeProps , style : styleProps} = props;
const size = sizeProps || defaultSvgSize;
return <>
<Icon {...props} style={{...style,...styleProps}} component={() => (
<svg className="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" width={size} height={size}>
<path
d="M0 0m204.8 0l614.4 0q204.8 0 204.8 204.8l0 614.4q0 204.8-204.8 204.8l-614.4 0q-204.8 0-204.8-204.8l0-614.4q0-204.8 204.8-204.8Z"
fill="#008AFF" ></path>
<path
d="M217.6 448m40.96 0l506.88 0q40.96 0 40.96 40.96l0 20.48q0 40.96-40.96 40.96l-506.88 0q-40.96 0-40.96-40.96l0-20.48q0-40.96 40.96-40.96Z"
fill="#FFFFFF" ></path>
</svg>
)}/>
</>;
};
import React from "react";
export type ContentScrollProps = {
height:number|string
children?: React.ReactNode;
}
const ContentScroll: React.FC<ContentScrollProps> = (props) => {
const {height,children}=props
return (
<div className="content-scroll" style={{height:height,display:height<1?"none":"block"}}>
{children}
</div>
)
}
export default ContentScroll;
import React from "react";
import {MinusOutlined, MinusSquareOutlined, PlusSquareOutlined} from "@ant-design/icons";
import {Enable, Resizable, ResizeCallback, Size} from "re-resizable";
import {PageContainer} from "@ant-design/pro-components";
import {l} from "@/utils/intl";
import {Button, TabPaneProps} from "antd";
import {MaxIcon, MinIcon} from "@/components/Icons/StudioIcon";
export type MovableSidebarProps = {
title?: React.ReactNode;
enable?: Enable;
minWidth?: string | number;
minHeight?: string | number;
maxWidth?: string | number;
maxHeight?: string | number;
contentHeight?: number;
defaultSize?: Size;
visible?: boolean;
children?: React.ReactNode;
handlerMinimize?: () => void;
handlerMaxsize?: () => void;
onResize?: ResizeCallback;
style?: React.CSSProperties;
tagList?: TabPaneProps[];
};
const MovableSidebar: React.FC<MovableSidebarProps> = (props) => {
const {style, visible,onResize,defaultSize,
minWidth,maxWidth,minHeight,maxHeight,enable
,children, title,contentHeight,handlerMinimize, handlerMaxsize,tagList
} = props;
return (
<Resizable
className={'container'}
style={{...style, display: visible ? 'block' : 'none',borderRadius: 5}}
onResize={onResize}
defaultSize={defaultSize}
minWidth={minWidth}
maxWidth={maxWidth}
minHeight={minHeight}
maxHeight={maxHeight}
enable={enable}
>
<PageContainer
title={title}
tabProps={{
type: "editable-card",
hideAdd: true,
size: "small",
animated: true,
tabBarStyle: {margin: 0, padding: 0},
}}
tabList={tagList}
extra={[
<Button title={l('global.mini')} key={"minimize"} icon={<MinusOutlined/>} block type={"text"} shape={"circle"}
onClick={props.handlerMinimize}/>
// <MinusSquareOutlined size={15} title={l('global.mini')} key={"minimize"} onClick={handlerMinimize}/>,
// <MinusOutlined size={35} title={l('global.mini')} key={"minimize"} onClick={handlerMinimize}/>,
// <PlusSquareOutlined size={15} title={l('global.max')} key={"maximize"} onClick={handlerMaxsize}/>
]}
fixedHeader
>
<div style={{height: contentHeight}}>{children}</div>
</PageContainer>
</Resizable>
);
};
export default MovableSidebar;
...@@ -49,4 +49,20 @@ export const TagAlignCenter = styled.div` ...@@ -49,4 +49,20 @@ export const TagAlignCenter = styled.div`
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100%; height: 100%;
`; `;
\ No newline at end of file export const TagAlignLeft = styled.div`
display: flex;
height: 100%;
justify-content: left;
align-items: center;
`;
export const FlexCenterDiv = styled.div`
display: flex;
height: 100%;
justify-content: left;
align-items: center;
`;
export const Title = styled.div`
font-size: 16px;
`;
...@@ -40,7 +40,7 @@ body, ...@@ -40,7 +40,7 @@ body,
.header { .header {
height: 100px; height: 100px;
line-height: 144px; line-height: 10vh;
position: relative; position: relative;
font-weight: 600; font-weight: 600;
font-size: 4rem; font-size: 4rem;
...@@ -60,10 +60,10 @@ body, ...@@ -60,10 +60,10 @@ body,
.desc { .desc {
margin-bottom: 2rem; margin-bottom: 1rem;
margin-top: 2rem; margin-top: 2rem;
color: @text-color-secondary; //color: @text-color-secondary;
font-size: @font-size-base; //font-size: @font-size-base;
} }
...@@ -71,7 +71,7 @@ body, ...@@ -71,7 +71,7 @@ body,
display: flex; display: flex;
flex: auto; flex: auto;
max-height: max-content; max-height: max-content;
padding: 0vh 6vh 30vh 2vh; padding: 0 6vh 30vh 2vh;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
...@@ -82,7 +82,7 @@ body, ...@@ -82,7 +82,7 @@ body,
.form { .form {
position: relative; position: relative;
height: 100%; height: 100 * 100vw / 320;
box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.4); box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.4);
margin-left: 60vw; margin-left: 60vw;
margin-bottom: -15vh; margin-bottom: -15vh;
...@@ -211,6 +211,23 @@ ol { ...@@ -211,6 +211,23 @@ ol {
border-bottom-color: red; border-bottom-color: red;
} }
.treeList {
height: 100%;
overflow-x: auto;
overflow-y: auto;
.ant-tree-list-holder-inner {
min-width: max-content;
z-index: auto;
}
.tree-search-value {
//color: #00EE76;
color: #c00b26;
background-color: rgba(3, 102, 214, 0.5);
font-size: 15px;
}
}
.siderTree { .siderTree {
height: 100%; height: 100%;
overflow-x: auto; overflow-x: auto;
...@@ -232,12 +249,12 @@ ol { ...@@ -232,12 +249,12 @@ ol {
} }
} }
.gitCodeTree{ .gitCodeTree {
max-height: 70vh; max-height: 70vh;
min-height: 70vh; min-height: 70vh;
} }
.schemaTree{ .schemaTree {
max-height: 89vh; max-height: 89vh;
min-height: 89vh; min-height: 89vh;
} }
...@@ -287,20 +304,20 @@ ol { ...@@ -287,20 +304,20 @@ ol {
align-content: center; align-content: center;
} }
.query-form{ .query-form {
width: max-content; width: max-content;
left: 0; left: 0;
position: absolute; position: absolute;
} }
.tiny-charts{ .tiny-charts {
position: absolute; position: absolute;
top: 15px; top: 15px;
right: 12px; right: 12px;
} }
.radio-group-chart{ .radio-group-chart {
position: absolute; position: absolute;
right: 0; right: 0;
top: 7px; top: 7px;
...@@ -309,4 +326,51 @@ ol { ...@@ -309,4 +326,51 @@ ol {
.tag-content { .tag-content {
align-items: center; align-items: center;
align-content: center; align-content: center;
} }
\ No newline at end of file
h5{
margin-left: 0.5rem;
margin-bottom: 0;
}
// theme
// light
.side{
background-color: #fafaf9
}
.container{
background-color: #ffffff;
}
.ant-page-header{
border-block: 1px solid #E0E2E5;
}
// 滚动条
.content-scroll {
background-color: #ffffff;
overflow-y: auto;
direction: ltr;
scrollbar-color: #d4aa70 #e4e4e4;
scrollbar-width: thin;
}
.content-scroll::-webkit-scrollbar {
width: 5px;
}
.content-scroll::-webkit-scrollbar-track {
background-color: #ffffff;
border-radius: 100px;
}
.content-scroll::-webkit-scrollbar-thumb {
border-radius: 100px;
border: 6px solid rgba(0, 0, 0, 0.18);
border-left: 0;
border-right: 0;
background-color: #1890ff;
}
...@@ -21,6 +21,7 @@ import pages from './en-US/pages'; ...@@ -21,6 +21,7 @@ import pages from './en-US/pages';
import pwa from './en-US/pwa'; import pwa from './en-US/pwa';
import request from './en-US/request'; import request from './en-US/request';
import response from './en-US/response'; import response from './en-US/response';
import shortcutKey from './en-US/shortcutKey';
export default { export default {
'navBar.lang': 'Languages', 'navBar.lang': 'Languages',
...@@ -34,4 +35,5 @@ export default { ...@@ -34,4 +35,5 @@ export default {
...pages, ...pages,
...request, ...request,
...response, ...response,
...shortcutKey,
}; };
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
export default { export default {
'global.max':'max',
'button.create': 'Create', 'button.create': 'Create',
'button.close': 'Close', 'button.close': 'Close',
'button.confirm': 'Confirm', 'button.confirm': 'Confirm',
...@@ -104,6 +105,7 @@ export default { ...@@ -104,6 +105,7 @@ export default {
'global.time.millisecond': 'ms ', 'global.time.millisecond': 'ms ',
'global.stay.tuned': 'Stay tuned', 'global.stay.tuned': 'Stay tuned',
'global.mini': 'Mini Size',
'global.table.operate': 'Operation', 'global.table.operate': 'Operation',
'global.table.config': 'Config', 'global.table.config': 'Config',
......
...@@ -69,4 +69,22 @@ export default { ...@@ -69,4 +69,22 @@ export default {
'menu.metrics': 'Metrics', 'menu.metrics': 'Metrics',
'menu.about': 'About', 'menu.about': 'About',
'menu.version': 'Version: {version}', 'menu.version': 'Version: {version}',
'menu.datastudio.project': 'Project',
'menu.datastudio.structure': 'Structure',
'menu.datastudio.metadata': 'Metadata',
'menu.datastudio.console': 'Console',
'menu.datastudio.jobConfig': 'Job Config',
'menu.datastudio.executeConfig': 'Execute Config',
'menu.datastudio.savePoint': 'Save Point',
'menu.datastudio.historyVision': 'History Vision',
'menu.datastudio.jobInfo': 'Job Info',
'menu.datastudio.tool':'Tool',
'menu.datastudio.result':'Result',
'menu.datastudio.bi':'BI',
'menu.datastudio.lineage':'Lineage',
'menu.datastudio.process':'Process',
'menu.datastudio.history':'History',
'menu.datastudio.table-data':'Table Data',
}; };
...@@ -783,4 +783,16 @@ export default { ...@@ -783,4 +783,16 @@ export default {
'metrics.flink.metrics.name': 'Metric Name', 'metrics.flink.metrics.name': 'Metric Name',
'metrics.flink.metrics.placeholder': 'Please select the Metric Name (multiple choices)', 'metrics.flink.metrics.placeholder': 'Please select the Metric Name (multiple choices)',
// metadata
'pages.metadata.NoDatabaseSelected': 'No database selected',
'pages.metadata.Application': 'Application',
'pages.metadata.TableInfo': 'Table Info',
'pages.metadata.Description': 'Description',
'pages.metadata.DataSearch': 'Data Search',
'pages.metadata.GenerateSQL': 'Generate SQL',
'pages.metadata.FieldInformation': 'Field Info',
'pages.metadata.catalogSelect': 'Select Catalog & Database',
'pages.metadata.catalogRefresh': 'Refresh Catalog',
'pages.metadata.catalogRefreshSuccess': 'Refresh Catalog Success',
'pages.metadata.selectDatabase': 'Select Database',
}; };
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export default {
'shortcut.title': 'Shortcut key',
'shortcut.key.save': 'Save',
'shortcut.key.check': 'Check',
'shortcut.key.beautify': 'Beautify',
'shortcut.key.fullscreen': 'Full Screen',
'shortcut.key.fullscreenClose': 'Close the popup and full screen',
'shortcut.key.more': 'More shortcut keys',
'shortcut.key.search': 'Search',
'shortcut.key.replace': 'Replace',
'shortcut.key.revoke': 'Revoke',
'shortcut.key.redo': 'Redo',
'shortcut.key.notes': 'Notes',
'shortcut.key.indent': 'Indent',
'shortcut.key.removeIndent': 'Remove indent',
'shortcut.key.selectToEnd': 'Select subsequent',
'shortcut.key.format': 'Format',
'shortcut.key.editMultiline': 'Edit multiple lines',
'shortcut.key.copyRow': 'Copy a row',
'shortcut.key.deleteRow': 'Delete a row',
'shortcut.key.matchNext': 'Match Next',
'shortcut.key.matchPrevious': 'Match Previous',
'shortcut.key.goNextHighlight': 'Go to Next Highlight',
'shortcut.key.goPreviousHighlight': 'Go to Previous Highlight',
'shortcut.key.appendLineBefore': 'Append a Newline Before',
'shortcut.key.appendLine': 'Append Newline',
'shortcut.key.transpositionUpAndDown': 'Transposition up and down',
'shortcut.key.collapseOrExpand': 'Collapse/Expand',
'shortcut.key.checked': 'Checked',
}
...@@ -21,6 +21,7 @@ import pages from './zh-CN/pages'; ...@@ -21,6 +21,7 @@ import pages from './zh-CN/pages';
import pwa from './zh-CN/pwa'; import pwa from './zh-CN/pwa';
import request from './zh-CN/request'; import request from './zh-CN/request';
import response from './zh-CN/response'; import response from './zh-CN/response';
import shortcutKey from './zh-CN/shortcutKey';
export default { export default {
'navBar.lang': '语言', 'navBar.lang': '语言',
...@@ -34,4 +35,5 @@ export default { ...@@ -34,4 +35,5 @@ export default {
...pwa, ...pwa,
...request, ...request,
...response, ...response,
...shortcutKey,
}; };
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
*/ */
export default { export default {
'global.max':'max',
'button.check':'检查',
'button.graph':'图',
'button.create': '新建', 'button.create': '新建',
'button.close': '关闭', 'button.close': '关闭',
'button.confirm': '确定', 'button.confirm': '确定',
...@@ -105,6 +108,7 @@ export default { ...@@ -105,6 +108,7 @@ export default {
'global.time.millisecond': '毫秒 ', 'global.time.millisecond': '毫秒 ',
'global.stay.tuned': '敬请期待', 'global.stay.tuned': '敬请期待',
'global.mini': '最小化',
'global.table.operate': '操作', 'global.table.operate': '操作',
'global.table.updateTime': '更新时间', 'global.table.updateTime': '更新时间',
......
...@@ -69,4 +69,21 @@ export default { ...@@ -69,4 +69,21 @@ export default {
'menu.metrics': '监控', 'menu.metrics': '监控',
'menu.about': '关于', 'menu.about': '关于',
'menu.version': '版本:{version}', 'menu.version': '版本:{version}',
'menu.datastudio.project': '项目',
'menu.datastudio.structure': '结构',
'menu.datastudio.metadata': '元数据',
'menu.datastudio.console': '控制台',
'menu.datastudio.jobConfig': '作业配置',
'menu.datastudio.executeConfig': '执行配置',
'menu.datastudio.savePoint': '保存点',
'menu.datastudio.historyVision': '历史版本',
'menu.datastudio.jobInfo': '作业信息',
'menu.datastudio.tool':'工具',
'menu.datastudio.result':'结果',
'menu.datastudio.bi':'BI',
'menu.datastudio.lineage':'血缘',
'menu.datastudio.process':'进程',
'menu.datastudio.history':'历史',
'menu.datastudio.table-data':'表数据',
}; };
...@@ -789,4 +789,24 @@ export default { ...@@ -789,4 +789,24 @@ export default {
'metrics.flink.metrics.placeholder': '请选择指标名称(可多选)', 'metrics.flink.metrics.placeholder': '请选择指标名称(可多选)',
// metadata
'pages.metadata.NoDatabaseSelected': '未选择数据源',
'pages.metadata.Application': 'Application',
'pages.metadata.TableInfo': '表信息',
'pages.metadata.Description': '描述',
'pages.metadata.DataSearch': '数据查询',
'pages.metadata.GenerateSQL': 'SQL 生成',
'pages.metadata.FieldInformation': '字段信息',
'pages.metadata.catalogSelect': '选择 Catalog & Database',
'pages.metadata.catalogRefresh': '刷新 Catalog',
'pages.metadata.catalogRefreshSuccess': '刷新 Catalog 成功',
'pages.metadata.selectDatabase': '选择数据源',
'pages.metadata.Console': '控制台',
'pages.metadata.help.noSqlSelect': '未选择任何sql!',
'pages.metadata.help.selectSql': '请在编辑器内选择你要执行的sql',
'pages.metadata.help.exec': '执行选中sql',
'pages.metadata.exec.result.msg': '执行时间: {time} 秒, 总行数: {rowCount}',
'pages.metadata.exec.result.msghelp': '行数超过500,仅显示前500',
}; };
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export default {
'shortcut.title': '快捷键',
'shortcut.key.save': '保存',
'shortcut.key.check': '校验',
'shortcut.key.beautify': '美化',
'shortcut.key.fullscreen': '全屏',
'shortcut.key.fullscreenClose': '关闭弹框及全屏',
'shortcut.key.more': '更多快捷键',
'shortcut.key.search': '搜索',
'shortcut.key.replace': '替换',
'shortcut.key.revoke': '撤销',
'shortcut.key.redo': '重做',
'shortcut.key.notes': '注释',
'shortcut.key.indent': '缩进',
'shortcut.key.removeIndent': '取消缩进',
'shortcut.key.selectToEnd': '选中后续',
'shortcut.key.format': '格式化',
'shortcut.key.editMultiline': '编辑多行',
'shortcut.key.copyRow': '复制一行',
'shortcut.key.deleteRow': '删除一行',
'shortcut.key.matchNext': '匹配下一个',
'shortcut.key.matchPrevious': '匹配上一个',
'shortcut.key.goNextHighlight': '前往下一个高亮',
'shortcut.key.goPreviousHighlight': '前往上一个高亮',
'shortcut.key.appendLineBefore': '前面追加换行',
'shortcut.key.appendLine': '追加换行',
'shortcut.key.transpositionUpAndDown': '上下换位',
'shortcut.key.collapseOrExpand': '折叠/展开',
'shortcut.key.checked': '选中',
}
import React, {useEffect} from "react";
import CodeShow from "@/components/CustomEditor/CodeShow";
import {connect} from "@@/exports";
import {StateType} from "@/pages/DataStudio/model";
const Console: React.FC= (props:any) => {
useEffect(() => {
},[])
return <CodeShow code={props.console} height={(props.height-53)} theme={"vs-dark"} language={"kotlin"}/>
// return <MonacoEditor width={"100%"} height={props.height-53} theme={"dark"} value={props.console} />
};
export default connect(({Studio}: { Studio: StateType }) => ({
height: Studio.bottomContainer.height,
console: Studio.bottomContainerContent.console,
}))(Console);
import {queryDataByParams} from "@/services/BusinessCrud";
export function getConsoleData() {
return queryDataByParams('api/process/getConsoleByUserId');
}
import React from "react";
import MovableSidebar from "@/components/Sidebar/MovableSidebar";
import {l} from "@/utils/intl";
import {StateType, VIEW} from "@/pages/DataStudio/model";
import {ConfigProvider, Space, Tabs} from "antd";
import {LeftBottomMoreTabs, LeftBottomSide} from "@/pages/DataStudio/route";
import {connect} from "@@/exports";
import {Title} from "@/components/StyledComponents";
import ContentScroll from "@/components/Scroll/ContentScroll";
export type BottomContainerProps = {
size: number
}
const BottomContainer: React.FC<BottomContainerProps> = (props: any) => {
const {dispatch, size,bottomContainer} = props;
/**
* 侧边栏最小化
*/
const handleMinimize = () => {
dispatch({
type: 'Studio/updateSelectBottomKey',
payload: "",
})
}
/**
* 更新底部高度
* @param {number} height
*/
const updateBottomHeight = (height: number) => {
dispatch({
type: "Studio/updateBottomHeight",
payload: height,
})
}
/**
* 更新中间内容高度
* @param {number} height
*/
const updateCenterContentHeight = (height: number) => {
dispatch({
type: "Studio/updateCenterContentHeight",
payload: height,
})
}
const updateSelectBottomSubKey = (key: string) => {
dispatch({
type: "Studio/updateSelectBottomSubKey",
payload: key,
})
}
/**
* 更新工具栏内容高度
* @param {number} height
*/
const updateToolContentHeight = (height: number) => {
dispatch({
type: "Studio/updateToolContentHeight",
payload: height,
})
}
const getSubTabs = () => {
// @ts-ignore
return Object.values(Object.keys(LeftBottomMoreTabs).map(x=>LeftBottomMoreTabs[x].map(y=>{return{...y,key:x+"/"+y.key}}))).flatMap(x=>x)
}
/**
* 拖动回调
* @param event
* @param direction
* @param {{offsetHeight: any}} elementRef
*/
const resizeCallback = (event: any, direction: any, elementRef: { offsetHeight: any; }) => {
updateBottomHeight(elementRef.offsetHeight)
const centerContentHeight = document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight - bottomContainer.height;
updateCenterContentHeight(centerContentHeight)
updateToolContentHeight(centerContentHeight - VIEW.midMargin)
}
// export interface TabPaneProps {
// tab?: React.ReactNode;
// className?: string;
// style?: React.CSSProperties;
// disabled?: boolean;
// children?: React.ReactNode;
// forceRender?: boolean;
// closable?: boolean;
// closeIcon?: React.ReactNode;
// prefixCls?: string;
// tabKey?: string;
// id?: string;
// animated?: boolean;
// active?: boolean;
// destroyInactiveTabPane?: boolean;
// }
const renderTabPane = () => {
// @ts-ignore
const leftBottomMoreTab = LeftBottomMoreTabs[bottomContainer.selectKey];
if (leftBottomMoreTab) {
const items=leftBottomMoreTab.map((item: any) => {
return {
key: bottomContainer.selectKey+"/"+item.key,
label: <span>{item.icon}{item.label}</span>
}
})
// updateSelectBottomSubKey(items[0].key.split("/")[1])
return (<Tabs
style={{height:"32px",display:"-webkit-box"}}
items={items}
type="card"
onChange={(key: string) => {
updateSelectBottomSubKey(key.split("/")[1])
}}
activeKey={bottomContainer.selectKey+"/"+bottomContainer.selectSubKey[bottomContainer.selectKey]}
size="small" tabPosition="top" />
)
}
return <></>
}
const renderItems = () => {
return [...LeftBottomSide.map(x=>{return{...x,key:x.key+"/"}})
,...getSubTabs()].map((item) =>{
return {...item,children:
<ContentScroll height={props.bottomContainer.height - 53} >
{item.children}
</ContentScroll>
}
})
}
// @ts-ignore
return (
<MovableSidebar
title={
<ConfigProvider
theme={{
components:{
Tabs:{
horizontalMargin:"0",
cardPaddingSM:"6px",
horizontalItemPadding:"0",
}
}
}}
>
<Space>
<Title >{l(bottomContainer.selectKey)}</Title>
{renderTabPane()}
</Space>
</ConfigProvider>
}
visible={bottomContainer.selectKey !== ""}
style={{zIndex: 999 ,height: bottomContainer.height ,marginTop: 0,backgroundColor:"#fff"}}
defaultSize={{width: "100%", height: bottomContainer.height}}
minHeight={VIEW.midMargin}
maxHeight={size.contentHeight - 40}
onResize={(event: any, direction: any, elementRef: { offsetHeight: any; }) => resizeCallback(event, direction, elementRef)}
enable={{top: true}}
handlerMinimize={handleMinimize}
>
<Tabs activeKey={bottomContainer.selectKey+"/"+(bottomContainer.selectSubKey[bottomContainer.selectKey]?bottomContainer.selectSubKey[bottomContainer.selectKey]:"")}
items={renderItems()}
tabBarStyle={{display: "none"}}/>
</MovableSidebar>
)
}
export default connect(({Studio}: { Studio: StateType }) => ({
leftContainer: Studio.leftContainer,
bottomContainer: Studio.bottomContainer,
centerContentHeight: Studio.centerContentHeight,
}))(BottomContainer);
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {HomeOutlined} from "@ant-design/icons";
import React from "react";
/**
* @description: 生成面包屑
* @type {({title: JSX.Element} | {title: string})[]}
*/
export const buildBreadcrumbItems = (breadcrumb :string) => {
const items = [
{title: <HomeOutlined/>,}
];
// 如果有 activeBreadcrumbTitle, 则切割 activeBreadcrumbTitle, 生成面包屑数组, 并映射
const activeBreadcrumbTitleList = Array.from(breadcrumb.split("/") ).map(title => ( {title: <>{title}</>}));
items.push(...activeBreadcrumbTitleList);
return items;
};
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {FlexCenterDiv} from "@/components/StyledComponents";
import {VIEW} from "@/pages/DataStudio/model";
import {Breadcrumb, Descriptions, Space} from "antd";
import {
ApiTwoTone,
EnvironmentOutlined,
FlagTwoTone,
PauseCircleTwoTone,
PlayCircleTwoTone,
RocketTwoTone,
SafetyCertificateTwoTone,
SaveTwoTone,
SendOutlined
} from "@ant-design/icons";
import React from "react";
import {l} from "@/utils/intl";
import {buildBreadcrumbItems} from "@/pages/DataStudio/HeaderContainer/function";
const headerStyle: React.CSSProperties = {
display: "inline-flex",
lineHeight: '32px',
height: "32px",
fontStyle: "normal",
fontWeight: "bold",
fontSize: "16px",
padding: "4px 10px",
};
const HeaderContainer = (props: any) => {
const {size, activeBreadcrumbTitle} = props;
/**
* @description: 生成面包屑
* @type {({title: JSX.Element} | {title: string})[]}
*/
const renderBreadcrumbItems = () => {
if (!activeBreadcrumbTitle) {
return <Space><EnvironmentOutlined/><span>Guide Page</span></Space>
}
return <>
<FlexCenterDiv style={{width: (size.width - 2 * VIEW.paddingInline) / 2}}>
<Breadcrumb separator={">"} items={buildBreadcrumbItems(activeBreadcrumbTitle)}/>
</FlexCenterDiv>
</>
};
/**
* @description: 渲染右侧按钮
* @returns {JSX.Element}
*/
const renderRightButtons = () => {
return <>
<Space size={'middle'} align={"center"} direction={"horizontal"} wrap>
{/*保存按钮 icon*/}
<SaveTwoTone title={l('button.save')} onClick={() => {
}}/>
{/*检查 sql按钮*/}
<SafetyCertificateTwoTone title={l('button.check')} onClick={() => {
}}/>
{/* 执行图按钮*/}
<FlagTwoTone title={l('button.graph')} onClick={() => {
}}/>
{/* 执行按钮*/}
<PlayCircleTwoTone title={l('button.execute')} onClick={() => {
}}/>
{/* 异步提交按钮*/}
<RocketTwoTone title={l('button.async')} onClick={() => {
}}/>
{/* 推送海豚, 此处需要将系统设置中的 ds 的配置拿出来做判断 启用才展示 */}
<SendOutlined title={l('button.push')} onClick={() => {
}}/>
{/* 发布按钮*/}
<PauseCircleTwoTone title={l('button.publish')} onClick={() => {
}}/>
{/* api 按钮*/}
<ApiTwoTone title={l('button.api')} onClick={() => {
}}/>
</Space>
</>
};
/**
* render
*/
return <>
<Descriptions column={2} size={'middle'} layout={'horizontal'} key={"h"} style={headerStyle}>
<Descriptions.Item>
{renderBreadcrumbItems()}
</Descriptions.Item>
<Descriptions.Item>
{/*{renderRightButtons()}*/}
</Descriptions.Item>
</Descriptions>
</>
}
export default HeaderContainer
import {connect} from "@umijs/max";
import { StateType} from "../../model";
import {Select, Space, Spin, Tag} from "antd";
import React, {useEffect, useState} from "react";
import {
DatabaseOutlined, ReloadOutlined,
TableOutlined
} from "@ant-design/icons";
import {clearMetaDataTable, showMetaDataTable} from "./service";
import {l} from "@/utils/intl";
import {Key, ProForm, ProFormSelect} from "@ant-design/pro-components";
import {TagAlignLeft} from "@/components/StyledComponents";
import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree";
import {DataSources} from "@/types/RegCenter/data";
import ContentScroll from "@/components/Scroll/ContentScroll";
const MetaData = (props: any) => {
const {dispatch ,toolContentHeight,leftContainer, database: { dbData , selectDatabaseId , expandKeys, selectKeys} } = props;
const [treeData, setTreeData] = useState<[]>([]);
const [loadingDatabase, setLoadingDatabase] = useState(false);
const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0]
/**
* @description: 刷新树数据
* @param {number} databaseId
*/
const onRefreshTreeData = (databaseId: number) => {
if (!databaseId) {
setLoadingDatabase(false);
return;
}
setLoadingDatabase(true);
const res = showMetaDataTable(databaseId);
res.then((tables) => {
setLoadingDatabase(false);
if (tables) {
for (let i = 0; i < tables.length; i++) {
tables[i].title = tables[i].name;
tables[i].key = tables[i].name;
tables[i].icon = <DatabaseOutlined/>;
tables[i].children = tables[i].tables;
for (let j = 0; j < tables[i].children.length; j++) {
tables[i].children[j].title = tables[i].children[j].name;
tables[i].children[j].key = tables[i].name + '.' + tables[i].children[j].name;
tables[i].children[j].icon = <TableOutlined/>;
tables[i].children[j].isLeaf = true;
tables[i].children[j].schema = tables[i].name;
tables[i].children[j].table = tables[i].children[j].name;
}
}
setTreeData(tables);
} else {
setTreeData([]);
}
});
};
useEffect(()=>{
if (selectDatabaseId){
onRefreshTreeData(selectDatabaseId)
}
},[])
/**
* 数据库选择改变时间时 刷新树数据
* @param {number} value
*/
const onChangeDataBase = (value: number) => {
onRefreshTreeData(value);
};
/**
* 刷新数据库列表
*/
const refreshDataBase = () => {
if (!selectDatabaseId) return;
setLoadingDatabase(true);
clearMetaDataTable(selectDatabaseId).then(() => {
onChangeDataBase(selectDatabaseId);
})
};
/**
* 构建数据库列表 下拉框
* @returns {{label: JSX.Element, value: number, key: number}[]}
*/
const getDataBaseOptions = () => {
return dbData.map(({id, name, type, enabled,status}: DataSources.DataSource) => (
{
key: id,
value: id,
label: <TagAlignLeft><Tag key={id} color={enabled ? "processing" : "error"}>{type}</Tag>{name}</TagAlignLeft>,
disabled: !enabled || !status
}
))
};
/**
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
* @returns {Promise<void>}
*/
const handleTreeNodeClick = async (keys: Key[] ,info: any) => {
// 选中的key
dispatch({
type: "Studio/updateDatabaseSelectKey",
payload: keys
})
const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info;
if (isLeaf) {
const queryParams = {id: selectDatabaseId , schemaName, tableName};
dispatch({
type: "Studio/addTab",
payload: {
icon: selectDb.type,
id: selectDatabaseId + schemaName + tableName,
breadcrumbLabel: [selectDb.type,selectDb.name].join("/"),
label: schemaName + '.' + tableName ,
params:{ queryParams: queryParams, tableInfo: fullInfo},
type: "metadata"
}
})
}
};
/**
* 数据库选择改变事件
* @param {number} databaseId
*/
const handleSelectDataBaseId = (databaseId: number) => {
dispatch({
type: "Studio/updateSelectDatabaseId",
payload: databaseId
})
onChangeDataBase(databaseId);
}
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const handleTreeExpand = (expandedKeys: Key[]) => {
dispatch({
type: "Studio/updateDatabaseExpandKey",
payload: expandedKeys
})
}
return (
<Spin spinning={loadingDatabase} delay={500}>
<ProForm style={{height: 40}} initialValues={{selectDb:selectDatabaseId}} submitter={false}>
<ProFormSelect
width={leftContainer.width - 45 }
addonAfter={<ReloadOutlined spin={loadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear={false}
name={"selectDb"}
placeholder={l('pages.metadata.selectDatabase')}
options={getDataBaseOptions()}
fieldProps={{onSelect: (selectId) => handleSelectDataBaseId(selectId)}}
/>
</ProForm>
<SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} style={{height: (toolContentHeight - 64 - 20 )}} onNodeClick={handleTreeNodeClick} treeData={treeData} onExpand={handleTreeExpand}/>
</Spin>
);
};
export default connect(({Studio}: { Studio: StateType }) => ({
toolContentHeight:Studio.toolContentHeight,
leftContainer: Studio.leftContainer,
database: Studio.database,
}))(MetaData);
import {queryDataByParams} from "@/services/BusinessCrud";
/*--- 刷新 元数据表 ---*/
export function showMetaDataTable(id: number) {
return queryDataByParams('api/database/getSchemasAndTables', {id: id});
}
/*--- 清理 元数据表缓存 ---*/
export function clearMetaDataTable(id: number) {
return queryDataByParams('api/database/unCacheSchemasAndTables', {id: id});
}
export function getDataBase() {
return queryDataByParams('api/database/listEnabledAll');
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {buildSchemaTree} from "@/pages/RegCenter/DataSource/components/DataSourceDetail/function";
import React from "react";
import {Empty, Tree} from "antd";
const {DirectoryTree} = Tree;
/**
* props
*/
type TreeProps = {
treeData: Partial<any>[];
onNodeClick: (info: any) => void
style?: React.CSSProperties
}
const JobTree: React.FC<TreeProps> = (props) => {
const {treeData, onNodeClick, style} = props;
return <>
{
(treeData.length > 0) ?
<DirectoryTree
style={style}
className={'treeList'}
onSelect={(_, info) => onNodeClick(info)}
treeData={buildSchemaTree(treeData)}
/> : <Empty className={'code-content-empty'} description={"暂无作业,请点击左上角新建目录"}/>
}
</>;
};
export default JobTree;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React, {useEffect} from "react";
import JobTree from "@/pages/DataStudio/LeftContainer/Project/JobTree";
const Project: React.FC= (props) => {
useEffect(() => {
},[])
return <>
<JobTree onNodeClick={()=>{}} treeData={[]} />
</>;
};
export default Project;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Tabs} from "antd";
import MovableSidebar, {MovableSidebarProps} from "@/components/Sidebar/MovableSidebar";
import React from "react";
import {connect} from "@@/exports";
import {StateType, VIEW} from "@/pages/DataStudio/model";
import {LeftSide} from "@/pages/DataStudio/route";
import {l} from "@/utils/intl";
export type LeftContainerProps = {
size:number
}
const LeftContainer:React.FC<LeftContainerProps> = (props:any) => {
const {dispatch,size} = props;
const {toolContentHeight ,leftContainer , rightContainer} = props
/**
* 侧边栏大小变化
* @param width
*/
const handleReSizeChange = (width: any) => {
dispatch({
type: 'Studio/updateLeftWidth',
payload: width,
})
}
/**
* 侧边栏最小化
*/
const handleMinimize = () => {
dispatch({
type: 'Studio/updateSelectLeftKey',
payload: "",
})
}
/**
* 侧边栏最大化
*/
const handleMaxsize = (widthChangeValue: number) => {
handleReSizeChange(widthChangeValue)
}
/**
* 侧边栏属性
* @type {{onResize: (event: any, direction: any, elementRef: {offsetWidth: any}) => void, visible: boolean, defaultSize: {width: any, height: any}, enable: {right: boolean}, minWidth: number, title: string, handlerMinimize: () => void, contentHeight: any, maxWidth: number}}
*/
const restMovableSidebarProps : MovableSidebarProps = {
contentHeight: toolContentHeight,
onResize: (event: any, direction: any, elementRef: { offsetWidth: any; }) => handleReSizeChange(elementRef.offsetWidth),
title: <h5>{l(leftContainer.selectKey)}</h5>,
handlerMinimize: ()=> handleMinimize(),
handlerMaxsize: () => handleMaxsize(size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700),
visible: leftContainer.selectKey !== "",
defaultSize: {width: leftContainer.width, height: leftContainer.height},
minWidth: 260,
maxWidth: size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700, //
enable: {right: true},
style:{borderInlineEnd: "1px solid #E0E2E5"}
}
return(
<MovableSidebar {...restMovableSidebarProps}>
<Tabs activeKey={leftContainer.selectKey} items={LeftSide} tabBarStyle={{display: "none"}}/>
</MovableSidebar>
)
}
export default connect(({Studio}: { Studio: StateType }) => ({
leftContainer: Studio.leftContainer,
rightContainer: Studio.rightContainer,
toolContentHeight: Studio.toolContentHeight,
}))(LeftContainer);
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {l} from "@/utils/intl";
export const KEY_BOARD = [
{
key: 'ctrls',
label: 'Ctrl + S',
description: l('shortcut.key.save'),
},
{
key: 'alt2',
label: 'Alt + 2',
description: l('shortcut.key.check'),
},
{
key: 'alt3',
label: 'Alt + 3',
description: l('shortcut.key.beautify'),
},
{
key: 'f2',
label: 'F2',
description: l('shortcut.key.fullscreen'),
},
{
key: 'esc',
label: 'Esc',
description: l('shortcut.key.fullscreenClose'),
},
{
key: 'f1',
label: 'F1',
description: l('shortcut.key.more'),
},
{
key: 'ctrlf',
label: 'Ctrl + F',
description: l('shortcut.key.search'),
},
{
key: 'ctrlh',
label: 'Ctrl + H',
description: l('shortcut.key.replace'),
},
{
key: 'ctrlz',
label: 'Ctrl + Z',
description: l('shortcut.key.revoke'),
},
{
key: 'ctrlY',
label: 'Ctrl + Y',
description: l('shortcut.key.redo'),
},
{
key: 'ctrl/',
label: 'Ctrl + /',
description: l('shortcut.key.notes'),
},
{
key: 'ctrl+alt+right',
label: 'Shift + Alt + Right',
description: l('shortcut.key.selectToEnd'),
},
{
key: 'ctrl+alt+f',
label: 'Shift + Alt + F',
description: l('shortcut.key.format'),
},
{
key: 'ctrl+shift+up',
label: 'Ctrl + Shift + Up/Down',
description: l('shortcut.key.editMultiline'),
},
{
key: 'ctrl+alt+up',
label: 'Ctrl + Alt + Up/Down',
description: l('shortcut.key.copyRow'),
},
{
key: 'ctrl+shift+k',
label: 'Ctrl + Shift + K',
description: l('shortcut.key.deleteRow'),
},
{
key: 'ctrl+f3',
label: 'Ctrl + F3',
description: l('shortcut.key.matchNext'),
},
{
key: 'ctrl+shift+f3',
label: 'Ctrl + Shift + F3',
description: l('shortcut.key.matchPrevious'),
},
{
key: 'f7',
label: 'F7',
description: l('shortcut.key.goNextHighlight'),
},
{
key: 'shift+f7',
label: 'Shift +F7',
description: l('shortcut.key.goPreviousHighlight'),
},
{
key: 'ctrl+shift+end',
label: 'Ctrl + Shift + End',
description: l('shortcut.key.appendLineBefore'),
},
{
key: 'ctrl+end',
label: 'Ctrl + End',
description: l('shortcut.key.appendLine'),
},
{
key: 'alt+up/down',
label: 'Alt + Up/Down',
description: l('shortcut.key.transpositionUpAndDown'),
},
{
key: 'ctrl+shift+[/]',
label: 'Ctrl + Shift + [/]',
description: l('shortcut.key.collapseOrExpand'),
},
]
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Divider, Typography} from "antd";
import {KEY_BOARD} from "@/pages/DataStudio/MiddleContainer/KeyBoard/constant";
import {l} from "@/utils/intl";
import React from "react";
const {Title, Paragraph, Text} = Typography;
const KeyBoard = () => {
const buildKeyBoard = () => {
return KEY_BOARD.map((item,index) => {
return <>
{index % 6 === 0 ? <Divider plain orientationMargin={0}/> : <>
<Text keyboard>{item.label}</Text>{item.description}<Divider type="vertical"/>
</>}
</>
});
}
return <>
<Typography style={{padding: '2px', textAlign: 'center', border: 'salmon'}}>
<br/>
<Title level={4}>{l('shortcut.title')}</Title>
<Paragraph style={{padding: 0, margin: 0, textAlign: 'center', border: 'salmon'}} >
{buildKeyBoard()}
</Paragraph>
</Typography>
</>;
};
export default KeyBoard;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export const QUICK_GUIDE = [
{
key: 'registcluster',
label: '注册 Session 集群',
link: '/registration/cluster/instance'
},{
key: 'registcluster',
label: '注册 Session 集群',
link: '/registration/cluster/instance'
}
];
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Divider, Typography} from "antd";
import React from "react";
import {QUICK_GUIDE} from "@/pages/DataStudio/MiddleContainer/QuickGuide/constant";
const {Title, Paragraph, Link} = Typography;
const QuickGuide = () => {
const buildQuickGuide = () => {
return QUICK_GUIDE.map((item,index) => {
return <>
{index % 7 === 0 ? <Divider plain orientationMargin={0}/> : <>
<Link href={item.link} key={item.key}>{item.label}</Link>
<Divider type="vertical"/>
</>}
</>
});
}
return <>
<Typography style={{padding: '2px', textAlign: 'center', border: 'salmon'}}>
<Title level={4}>快捷引导</Title>
todo: buildQuickGuide
{/*<Paragraph style={{padding: 0, margin: 0, textAlign: 'center', border: 'salmon'}} >*/}
{/* {buildQuickGuide()}*/}
{/*</Paragraph>*/}
</Typography>
</>
};
export default QuickGuide;
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {ConfigProvider, Divider, Dropdown, Menu, Space, Tabs} from "antd";
import React, {useState} from "react";
import {connect} from "@@/exports";
import {MetadataParams, StateType, TabsItemType, TabsPageType} from "@/pages/DataStudio/model";
import RightTagsRouter from "@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter";
import {renderDBIcon} from "@/pages/RegCenter/DataSource/components/function";
import KeyBoard from "@/pages/DataStudio/MiddleContainer/KeyBoard";
import {MenuInfo} from "rc-menu/es/interface";
import {STUDIO_TAG_RIGHT_CONTEXT_MENU} from "@/pages/DataStudio/constants";
import QuickGuide from "@/pages/DataStudio/MiddleContainer/QuickGuide";
import ContentScroll from "@/components/Scroll/ContentScroll";
type TargetKey = React.MouseEvent | React.KeyboardEvent | string;
const MiddleContainer = (props: any) => {
const {tabs: {panes, activeKey}, dispatch} = props;
const [contextMenuPosition, setContextMenuPosition] = useState({});
const [contextMenuVisible, setContextMenuVisible] = useState(false);
const [includeTab, setIncludeTab] = useState({});
/**
* 更新当前激活的tab
* @param {string} key
* @param eInfo
*/
const updateActiveKey = (key: string, eInfo: any) => {
const {target: {innerText}} = eInfo;
const replaceLabel = innerText.toString().replace('.', '/') // 替换掉 . 为 /, 因为再 tree 里选中的 key 是 / 分割的
setContextMenuVisible(false)
dispatch({
type: 'Studio/updateTabsActiveKey',
payload: key,
})
dispatch({
type: 'Studio/updateDatabaseSelectKey',
payload: [replaceLabel],
})
};
/**
* 关闭所有标签
*/
const handleCloseAllTabs = () => {
dispatch({
type: 'Studio/closeAllTabs',
});
setContextMenuVisible(false)
}
/**
* 关闭其他标签
*/
const handleCloseOtherTabs = () => {
dispatch({
type: 'Studio/closeOtherTabs',
payload: includeTab,
});
setContextMenuVisible(false)
}
/**
* the right click event
* @param info
* @param item
*/
const handleRightClick = (info: any, item: any) => {
info.preventDefault(); // 阻止默认右键事件
const {key, label} = item;
const replaceLabel = label.toString().replace('.', '/') // 替换掉 . 为 /, 因为再 tree 里选中的 key 是 / 分割的
updateActiveKey(key, info);
dispatch({
type: 'Studio/updateDatabaseSelectKey',
payload: [replaceLabel],
})
// 获取 选中的值
setIncludeTab(item);
// 获取右键点击的位置
const {clientX, clientY} = info;
setContextMenuVisible(true)
setContextMenuPosition({
position: 'fixed', cursor: 'context-menu', width: '10vw', zIndex: 9999,
left: clientX + 10, // + 10 是为了让鼠标不至于在选中的节点上 && 不遮住当前鼠标位置
top: clientY + 10, // + 10 是为了让鼠标不至于在选中的节点上 && 不遮住当前鼠标位置
});
};
/**
* 右键菜单的点击事件
* @param {MenuInfo} node
*/
const handleMenuClick = (node: MenuInfo) => {
switch (node.key) {
case 'closeAll':
handleCloseAllTabs();
break;
case 'closeOther':
handleCloseOtherTabs();
break;
default:
break;
}
};
/**
* 右键菜单
* @returns {JSX.Element}
*/
const renderRightClickMenu = () => {
const menuList = <Menu onClick={handleMenuClick} items={STUDIO_TAG_RIGHT_CONTEXT_MENU}/>
return <>
<Dropdown
arrow
trigger={['contextMenu']}
overlayStyle={{...contextMenuPosition}}
overlay={menuList}
open={contextMenuVisible}
onVisibleChange={setContextMenuVisible}
>
{/*占位*/}
<div style={{...contextMenuPosition}}/>
</Dropdown>
</>
}
/**
* render tabs
*/
const tabItems = (panes).map((item: TabsItemType) => {
const renderContent = () => {
const params = item.params as MetadataParams
console.log(item.type==TabsPageType.metadata)
switch (item.type) {
case TabsPageType.metadata:
return <RightTagsRouter tableInfo={params.tableInfo} queryParams={params.queryParams}/>
default:
return <></>
}
}
return {
key: item.key,
label: <Space onContextMenu={(e) => handleRightClick(e, item)}
key={item.key}>{renderDBIcon(item.icon, 20)}{item.label}</Space>,
children:
<ContentScroll height={ activeKey === item.key ? props.centerContentHeight - 40 : 0}>
{renderContent()}
</ContentScroll>
}
})
/**
* 关闭tab
* @param {TargetKey} targetKey
*/
const closeTab = (targetKey: TargetKey) => {
dispatch({
type: 'Studio/closeTab',
payload: targetKey,
})
};
/**
* render middle content
* @returns {JSX.Element}
*/
const renderMiddleContent = () => {
if (tabItems?.length === 0) {
return <>
<KeyBoard/>
<Divider/>
<QuickGuide/>
</>
} else {
return <>
<ConfigProvider theme={{
components:{
Tabs:{
margin:0,
borderRadiusLG:0
}
}
}}>
<Tabs
// tabBarStyle={{border: '1px solid black',borderRadius: 0}}
hideAdd
onTabClick={(active, e) => updateActiveKey(active, e)}
activeKey={activeKey}
type="editable-card"
onEdit={closeTab}
items={tabItems}
/>
{renderRightClickMenu()}
</ConfigProvider>
</>
}
}
return <>
{renderMiddleContent()}
</>
}
export default connect(({Studio}: { Studio: StateType }) => ({
tabs: Studio.tabs,
centerContentHeight: Studio.centerContentHeight
}))(MiddleContainer);
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const ExecuteConfig = () => {
return <div>ExecuteConfig</div>;
};
export default ExecuteConfig;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const HistoryVersion = () => {
return <div>HistoryVersion</div>;
};
export default HistoryVersion;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const JobConfig = () => {
return <div>JobConfig</div>;
};
export default JobConfig;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const JobInfo = () => {
return <div>JobInfo</div>;
};
export default JobInfo;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const SavePoints = () => {
return <div>SavePoints</div>;
};
export default SavePoints;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {StateType, VIEW} from "@/pages/DataStudio/model";
import MovableSidebar from "@/components/Sidebar/MovableSidebar";
import {l} from "@/utils/intl";
import {Button, Space, Tabs} from "antd";
import {CloseSquareOutlined, CopyOutlined, QuestionOutlined} from "@ant-design/icons";
import React from "react";
import {connect} from "@@/exports";
import {mapDispatchToProps} from "@/pages/DataStudio/function";
import {LeftSide, RightSide} from "@/pages/DataStudio/route";
export type RightContainerProps = {
size:number
bottomHeight:number
}
const RightContainer:React.FC<RightContainerProps> = (prop:any) => {
const {size,leftContainer,rightContainer,bottomHeight,updateRightWidth,updateSelectRightKey}=prop
const maxWidth= size.width - 2 * VIEW.leftToolWidth - leftContainer.width - 600
return (
<MovableSidebar
contentHeight={size.contentHeight - VIEW.midMargin - bottomHeight}
onResize={(event: any, direction: any, elementRef: {
offsetWidth: any;
}) => updateRightWidth(elementRef.offsetWidth)}
title={<h5>{l(rightContainer.selectKey)}</h5>}
handlerMinimize={() => updateSelectRightKey("")}
handlerMaxsize={() => updateRightWidth(maxWidth)}
visible={rightContainer.selectKey !== ""}
defaultSize={{width: rightContainer.width, height: rightContainer.height}}
minWidth={300}
maxWidth={maxWidth}
enable={{left: true}}
style={{borderInlineStart: "1px solid #E0E2E5"}}
>
<Tabs activeKey={rightContainer.selectKey} items={RightSide} tabBarStyle={{display: "none"}}/>
</MovableSidebar>
)
};
export default connect(({Studio}: { Studio: StateType }) => ({
leftContainer: Studio.leftContainer,
rightContainer: Studio.rightContainer,
bottomContainer: Studio.bottomContainer,
activeBreadcrumbTitle: Studio.tabs.activeBreadcrumbTitle,
tabs: Studio.tabs,
}), mapDispatchToProps)(RightContainer);
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {MenuItemType} from "rc-menu/lib/interface";
import {l} from "@/utils/intl";
export const STUDIO_TAG_RIGHT_CONTEXT_MENU: MenuItemType[] = [
{
key: "closeAll",
label: l('right.menu.closeAll'),
},
{
key: "closeOther",
label: l('right.menu.closeOther'),
}
]
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Dispatch} from "@@/plugin-dva/types";
import {DataSources} from "@/types/RegCenter/data";
export const mapDispatchToProps = (dispatch: Dispatch) => ({
updateToolContentHeight: (key: number) => dispatch({
type: "Studio/updateToolContentHeight",
payload: key,
}),
updateCenterContentHeight: (key: number) => dispatch({
type: "Studio/updateCenterContentHeight",
payload: key,
}),
updateSelectLeftKey: (key: string) => dispatch({
type: "Studio/updateSelectLeftKey",
payload: key,
}),
updateLeftWidth: (width: number) => dispatch({
type: "Studio/updateLeftWidth",
payload: width,
}), updateSelectRightKey: (key: string) => dispatch({
type: "Studio/updateSelectRightKey",
payload: key,
}),
updateRightWidth: (width: number) => dispatch({
type: "Studio/updateRightWidth",
payload: width,
}), updateSelectBottomKey: (key: string) => dispatch({
type: "Studio/updateSelectBottomKey",
payload: key,
}), updateSelectBottomSubKey: (key: string) => dispatch({
type: "Studio/updateSelectBottomSubKey",
payload: key,
}),
updateBottomHeight: (height: number) => dispatch({
type: "Studio/updateBottomHeight",
payload: height,
}),
saveDataBase: (data: DataSources.DataSource[]) => dispatch({
type: "Studio/saveDataBase",
payload: data,
}),
updateBottomConsole: (data: string) => dispatch({
type: "Studio/updateBottomConsole",
payload: data,
}),
});
...@@ -15,15 +15,208 @@ ...@@ -15,15 +15,208 @@
* limitations under the License. * limitations under the License.
*/ */
import { Card } from 'antd'; import {Button, Layout, Menu, Space} from 'antd';
import {connect, getDvaApp} from "umi";
import {
CloseSquareOutlined,
CopyOutlined,
QuestionOutlined,
} from "@ant-design/icons";
import React, {Fragment, useCallback, useEffect, useState} from "react";
import {StateType, TabsItemType, TabsPageType, VIEW} from "@/pages/DataStudio/model";
import MovableSidebar from "@/components/Sidebar/MovableSidebar";
import {PersistGate} from 'redux-persist/integration/react';
import {getDataBase} from "@/pages/DataStudio/LeftContainer/MetaData/service";
import MiddleContainer from "@/pages/DataStudio/MiddleContainer";
import LeftContainer from "@/pages/DataStudio/LeftContainer";
import {LeftBottomMoreTabs, LeftBottomSide, LeftSide, RightSide} from "@/pages/DataStudio/route";
import {l} from '@/utils/intl';
import {mapDispatchToProps} from "@/pages/DataStudio/function";
import BottomContainer from "@/pages/DataStudio/BottomContainer";
import HeaderContainer from "@/pages/DataStudio/HeaderContainer";
import RightContainer from "@/pages/DataStudio/RightContainer";
import {getConsoleData} from "@/pages/DataStudio/BottomContainer/Console/service";
const {Sider, Content} = Layout;
const DataStudio = (props: any) => { const DataStudio = (props: any) => {
const {
bottomContainer, leftContainer, rightContainer, saveDataBase, updateToolContentHeight,updateBottomConsole
, updateCenterContentHeight, updateSelectLeftKey, updateLeftWidth, updateSelectRightKey
, updateRightWidth, updateSelectBottomKey, updateBottomHeight, activeBreadcrumbTitle, updateSelectBottomSubKey, tabs
} = props
const getActiveTabType: () => (TabsPageType) = () => {
if (parseInt(tabs.activeKey) < 0) {
return TabsPageType.None
}
return (tabs.panes as TabsItemType[]).find(item => item.key === tabs.activeKey)?.type || TabsPageType.None
}
const app = getDvaApp(); // 获取dva的实例
const persistor = app._store.persist;
const bottomHeight = bottomContainer.selectKey === "" ? 0 : bottomContainer.height;
const [size, setSize] = useState({
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
contentHeight: document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight,
});
const onResize = useCallback(() => {
setSize({
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
contentHeight: document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight,
})
const centerContentHeight = document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight - bottomHeight;
updateCenterContentHeight(centerContentHeight)
updateToolContentHeight(centerContentHeight - VIEW.midMargin)
}, []);
useEffect(() => {
window.addEventListener('resize', onResize);
onResize();
return () => {
window.removeEventListener('resize', onResize);
};
}, [onResize]);
useEffect(() => {
getDataBase().then(res => saveDataBase(res))
getConsoleData().then(res => updateBottomConsole(res))
onResize();
}, []);
/**
* 渲染头部
* @returns {JSX.Element}
*/
const renderHeaderContainer = () => {
return <HeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle}/>
}
/**
* 渲染左侧侧边栏
* @returns {JSX.Element}
*/
const renderLeftContainer = () => {
return <LeftContainer size={size}/>
}
/**
* 渲染右侧侧边栏
* @returns {JSX.Element}
*/
const renderRightContainer = () => {
return <RightContainer size={size} bottomHeight={bottomHeight}/>
}
return ( return (
<div style={{ margin: '-24px' }}> <PersistGate loading={null} persistor={persistor}>
<Card bordered={false} size="small" id="studio_card" style={{ marginBottom: 0 }}></Card> <Fragment>
</div> <Layout style={{minHeight: "60vh"}}>
{/* 渲染 header */}
{renderHeaderContainer()}
<Layout hasSider style={{minHeight: size.contentHeight}}>
{/*渲染左侧侧边栏*/}
<Sider collapsed collapsedWidth={40}>
<Menu
className={'side'}
mode="inline"
selectedKeys={[leftContainer.selectKey]}
items={LeftSide.map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
style={{height: '50%'}}
onClick={(item) => {
updateSelectLeftKey(item.key === leftContainer.selectKey ? '' : item.key)
}}
/>
{/*底部菜单*/}
<Menu
className={'side'}
mode="inline"
selectedKeys={[bottomContainer.selectKey]}
items={LeftBottomSide.map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
style={{
display: 'flex',
height: '50%',
flexDirection: "column-reverse"
}}
onClick={(item) => {
updateSelectBottomKey(item.key === bottomContainer.selectKey ? '' : item.key)
if (bottomContainer.selectKey !== '' && (!bottomContainer.selectSubKey[item.key] && LeftBottomMoreTabs[item.key])) {
updateSelectBottomSubKey(LeftBottomMoreTabs[item.key][0].key)
}
}}
/>
</Sider>
<Content style={{
flexDirection: "column-reverse",
display: "flex",
height: size.contentHeight,
}}>
{/*渲染底部内容*/}
{<BottomContainer size={size}/>}
<div style={{
display: "flex",
position: "absolute",
top: VIEW.headerHeight,
width: size.width - VIEW.sideWidth * 2
}}>
{renderLeftContainer()}
<Content
style={{width: size.width - 2 * VIEW.sideWidth - leftContainer.width - rightContainer.width}}>
<MiddleContainer/>
</Content>
{renderRightContainer()}
</div>
</Content>
{/* 渲染右侧侧边栏 */}
<Sider collapsed collapsedWidth={40}>
<Menu
className={'side'}
selectedKeys={[rightContainer.selectKey]}
mode="inline"
style={{height: '100%', borderInlineStart: "1px solid rgba(5, 5, 5, 0.06)"}}
items={RightSide.filter(x => {
if (!x.isShow) {
return true
}
return x.isShow(getActiveTabType())
}).map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
onClick={(item) => {
updateSelectRightKey(item.key === rightContainer.selectKey ? '' : item.key)
}}
/>
</Sider>
</Layout>
</Layout>
</Fragment>
</PersistGate>
); );
}; };
export default DataStudio;
export default connect(({Studio}: { Studio: StateType }) => ({
leftContainer: Studio.leftContainer,
rightContainer: Studio.rightContainer,
bottomContainer: Studio.bottomContainer,
activeBreadcrumbTitle: Studio.tabs.activeBreadcrumbTitle,
tabs: Studio.tabs,
}), mapDispatchToProps)(DataStudio);
This diff is collapsed.
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {
ApartmentOutlined,
BarChartOutlined,
CalendarOutlined,
ConsoleSqlOutlined,
DatabaseOutlined,
DesktopOutlined,
FolderOutlined,
HistoryOutlined,
InfoCircleOutlined,
MonitorOutlined,
PlayCircleOutlined,
RightSquareOutlined,
SettingOutlined,
TableOutlined,
ToolOutlined
} from "@ant-design/icons";
import React, {ReactNode} from "react";
import MetaData from "@/pages/DataStudio/LeftContainer/MetaData";
import Project from "@/pages/DataStudio/LeftContainer/Project";
import Console from "@/pages/DataStudio/BottomContainer/Console";
import JobConfig from "@/pages/DataStudio/RightContainer/JobConfig";
import ExecuteConfig from "@/pages/DataStudio/RightContainer/ExecuteConfig";
import SavePoints from "@/pages/DataStudio/RightContainer/SavePoints";
import HistoryVersion from "@/pages/DataStudio/RightContainer/HistoryVersion";
import JobInfo from "@/pages/DataStudio/RightContainer/JobInfo";
import {l} from "@/utils/intl";
import {TabsPageType} from "@/pages/DataStudio/model";
export const LeftSide = [
{
key: 'menu.datastudio.project',
icon: <ConsoleSqlOutlined />,
label: l('menu.datastudio.project'),
children: <Project/>
},
{
key: 'menu.datastudio.structure',
icon: <TableOutlined/>,
label: l('menu.datastudio.structure'),
children: <div>structure</div>
},
{
key: 'menu.datastudio.metadata',
icon: <DatabaseOutlined/>,
label: l('menu.datastudio.metadata'),
children: <MetaData/>
}
];
export const RightSide:TabProp[] = [
{
key: 'menu.datastudio.jobConfig',
icon: <SettingOutlined/>,
label: l('menu.datastudio.jobConfig'),
children: <JobConfig/>,
// isShow: type => type === TabsPageType.flinkSql,
},
{
key: 'menu.datastudio.executeConfig',
icon: <PlayCircleOutlined/>,
label: l('menu.datastudio.executeConfig'),
children: <ExecuteConfig/>,
isShow: type => type === TabsPageType.flinkSql,
},
{
key: 'menu.datastudio.savePoint',
icon: <FolderOutlined/>,
label: l('menu.datastudio.savePoint'),
children: <SavePoints/>,
isShow: type => type === TabsPageType.flinkSql,
},
{
key: 'menu.datastudio.historyVision',
icon: <HistoryOutlined/>,
label: l('menu.datastudio.historyVision'),
children: <HistoryVersion/>,
isShow: type => type === TabsPageType.flinkSql,
}, {
key: 'menu.datastudio.jobInfo',
icon: <InfoCircleOutlined/>,
label: l('menu.datastudio.jobInfo'),
children: <JobInfo/>,
isShow: type => type !== TabsPageType.None,
}
];
export const LeftBottomSide = [
{
key: 'menu.datastudio.console',
icon: <RightSquareOutlined/>,
label: l('menu.datastudio.console'),
children: <Console/>
},
{
key: 'menu.datastudio.result',
icon: <MonitorOutlined />,
label: l('menu.datastudio.result'),
},
{
key: 'menu.datastudio.bi',
icon: <BarChartOutlined />,
label: l('menu.datastudio.bi'),
},
{
key: 'menu.datastudio.lineage',
icon: <ApartmentOutlined />,
label: l('menu.datastudio.lineage'),
},
{
key: 'menu.datastudio.process',
icon: <DesktopOutlined />,
label: l('menu.datastudio.process'),
},
{
key: 'menu.datastudio.history',
icon: <CalendarOutlined/>,
label: l('menu.datastudio.history'),
},
{
key: 'menu.datastudio.table-data',
icon: <TableOutlined />,
label: l('menu.datastudio.table-data'),
},
{
key: 'menu.datastudio.tool',
icon: <ToolOutlined />,
label: l('menu.datastudio.tool'),
}
]
export const LeftBottomMoreTabs:{[c:string]:TabProp[]} = {
'menu.datastudio.tool':[
{
key: 'menu.datastudio.tool.datax',
icon: <ToolOutlined />,
label: ('menu.datastudio.tool.datax'),
children: <div>datax</div>
},{
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined />,
label: ('menu.datastudio.tool.datax2'),
children: <div>datax2</div>
},
] , 'menu.datastudio.tool2':[
{
key: 'menu.datastudio.tool.datax',
icon: <ToolOutlined />,
label: ('menu.datastudio.tool.datax'),
children: <div>datax</div>
},{
key: 'menu.datastudio.tool.datax2',
icon: <ToolOutlined />,
label: ('menu.datastudio.tool.datax2'),
children: <div>datax2</div>
},
]
}
export type TabProp ={
key:string;
icon: ReactNode;
label: string;
children: ReactNode;
isShow?:(type:TabsPageType)=>boolean;
}
...@@ -43,13 +43,8 @@ const Login: React.FC = () => { ...@@ -43,13 +43,8 @@ const Login: React.FC = () => {
const containerClassName = useEmotionCss(() => { const containerClassName = useEmotionCss(() => {
return { return {
display: "flex", display: "flex",
width: "100%",
flexDirection: "column", flexDirection: "column",
height: "100%", height: "100%",
position: "relative",
backgroundImage: "url(/icons/footer-bg.svg)",
backgroundPosition: "bottom center",
backgroundRepeat: "no-repeat",
}; };
}); });
......
...@@ -20,7 +20,7 @@ import {l} from '@/utils/intl'; ...@@ -20,7 +20,7 @@ import {l} from '@/utils/intl';
import { import {
BookOutlined, ConsoleSqlOutlined, HighlightOutlined, BookOutlined, ConsoleSqlOutlined, HighlightOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import React, {useState} from 'react'; import React, {useEffect, useState} from 'react';
import {DataSources} from '@/types/RegCenter/data'; import {DataSources} from '@/types/RegCenter/data';
import SchemaDesc from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc'; import SchemaDesc from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc';
import GenSQL from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/GenSQL'; import GenSQL from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/GenSQL';
...@@ -29,6 +29,9 @@ import SQLQuery from '@/pages/RegCenter/DataSource/components/DataSourceDetail/R ...@@ -29,6 +29,9 @@ import SQLQuery from '@/pages/RegCenter/DataSource/components/DataSourceDetail/R
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data'; import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import SQLConsole from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole'; import SQLConsole from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole';
import {SearchOutline} from 'antd-mobile-icons'; import {SearchOutline} from 'antd-mobile-icons';
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
import {ProCardTabsProps} from "@ant-design/pro-card/es/typing";
/** /**
...@@ -36,16 +39,25 @@ import {SearchOutline} from 'antd-mobile-icons'; ...@@ -36,16 +39,25 @@ import {SearchOutline} from 'antd-mobile-icons';
*/ */
type RightTagsRouterProps = { type RightTagsRouterProps = {
tableInfo: Partial<DataSources.Table>, tableInfo: Partial<DataSources.Table>,
tableColumns: Partial<DataSources.Column[]>, rightButtons?: React.ReactNode,
rightButtons: React.ReactNode,
queryParams: QueryParams queryParams: QueryParams
tagDisabled: boolean tagDisabled?: boolean
} }
const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
const {tableColumns, tableInfo, queryParams, tagDisabled, rightButtons} = props; const { tableInfo, queryParams, tagDisabled=false, rightButtons} = props;
const [tableColumns,setTableColumns] = useState<Partial<DataSources.Column[]>>([]);
useEffect(() => {
const fetchData = async () => {
const result = await queryDataByParams(API_CONSTANTS.DATASOURCE_GET_COLUMNS_BY_TABLE, queryParams);
setTableColumns(result);
};
if (queryParams.id !== 0) {
fetchData();
}
}, [queryParams]);
// state // state
const [activeKey, setActiveKey] = useState('desc'); const [activeKey, setActiveKey] = useState('desc');
...@@ -77,7 +89,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { ...@@ -77,7 +89,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
]; ];
// tab props // tab props
const restTabProps = { const restTabProps : ProCardTabsProps = {
activeKey: activeKey, activeKey: activeKey,
type: 'card', type: 'card',
tabBarExtraContent: rightButtons, tabBarExtraContent: rightButtons,
......
...@@ -16,36 +16,64 @@ ...@@ -16,36 +16,64 @@
*/ */
import {Empty, Tree} from 'antd'; import {Empty, Input, Space, Tree} from 'antd';
import React from 'react'; import React, {useCallback, useState} from 'react';
import {buildSchemaTree} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/function'; import {buildSchemaTree} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/function';
import {Key} from '@ant-design/pro-components';
const {DirectoryTree} = Tree; const {DirectoryTree} = Tree;
/** /**
* props * props
*/ */
type SchemaTreeProps = { type SchemaTreeProps = {
treeData: Partial<any>[]; treeData: Partial<any>[];
onNodeClick: (info: any) => void onNodeClick: (keys: Key[], info: any) => void
style?: React.CSSProperties
expandKeys: Key[]
onExpand: (keys: Key[]) => void
selectKeys: Key[]
} }
const SchemaTree: React.FC<SchemaTreeProps> = (props) => { const SchemaTree: React.FC<SchemaTreeProps> = (props) => {
const {treeData, onNodeClick} = props; const {treeData, onNodeClick, style, expandKeys, onExpand, selectKeys} = props;
/** const [searchValue, setSearchValue] = useState('');
* render
*/ /**
return <> * search tree node
{ * @type {(e: {target: {value: React.SetStateAction<string>}}) => void}
(treeData.length > 0) ? */
<DirectoryTree const onSearchChange = useCallback((e: { target: { value: React.SetStateAction<string>; }; }) => {
onSelect={(_, info) => onNodeClick(info)} setSearchValue(e.target.value)
treeData={buildSchemaTree(treeData)} },[searchValue])
/> : <Empty className={'code-content-empty'}/>
} /**
</>; * render
*/
return <>
{
(treeData.length > 0) ?
<>
<Input
placeholder="请输入关键字搜索"
allowClear
style={{marginBottom: 8}}
value={searchValue}
onChange={onSearchChange}
/>
<DirectoryTree
expandedKeys={expandKeys}
selectedKeys={selectKeys}
onExpand={(keys) => onExpand(keys)}
style={style}
className={'treeList'}
onSelect={onNodeClick}
treeData={buildSchemaTree(treeData, searchValue)}
/>
</> : <Empty className={'code-content-empty'}/>
}
</>;
}; };
export default SchemaTree; export default SchemaTree;
...@@ -16,13 +16,16 @@ ...@@ -16,13 +16,16 @@
*/ */
import {DatabaseTwoTone, TableOutlined} from '@ant-design/icons'; import {DatabaseTwoTone, TableOutlined} from '@ant-design/icons';
import {folderSeparator} from '@/utils/function'; import {folderSeparator, searchTreeNode} from '@/utils/function';
/** /**
* build schema tree * build schema tree
* @param data * @param data
* @param searchValue
*/ */
export const buildSchemaTree = (data: any): any => data.map((item: any) => { export const buildSchemaTree = (data: any,searchValue = ''): any => data.map((item: any) => {
return { return {
isLeaf: false, isLeaf: false,
name: item.name, name: item.name,
...@@ -33,7 +36,10 @@ export const buildSchemaTree = (data: any): any => data.map((item: any) => { ...@@ -33,7 +36,10 @@ export const buildSchemaTree = (data: any): any => data.map((item: any) => {
title: item.name, title: item.name,
fullInfo: item, fullInfo: item,
key: item.name, key: item.name,
children: item.tables.map((table: any) => { children: item.tables
// filter table by search value and map table to tree node
.filter((table: any)=> (table.name.indexOf(searchValue) > -1))
.map((table: any) => {
return { return {
isLeaf: true, isLeaf: true,
name: table.name, name: table.name,
...@@ -41,7 +47,7 @@ export const buildSchemaTree = (data: any): any => data.map((item: any) => { ...@@ -41,7 +47,7 @@ export const buildSchemaTree = (data: any): any => data.map((item: any) => {
icon: <TableOutlined/>, icon: <TableOutlined/>,
content: table.name, content: table.name,
path: item.name + folderSeparator() + table.name, path: item.name + folderSeparator() + table.name,
title: table.name, title: searchTreeNode(table.name,searchValue),
key: item.name + folderSeparator() + table.name, key: item.name + folderSeparator() + table.name,
fullInfo: table, fullInfo: table,
}; };
......
...@@ -41,7 +41,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -41,7 +41,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [disabled, setDisabled] = useState<boolean>(true); const [disabled, setDisabled] = useState<boolean>(true);
const [treeData, setTreeData] = useState<Partial<any>[]>([]); const [treeData, setTreeData] = useState<Partial<any>[]>([]);
const [tableColumns, setTableColumns] = useState<Partial<DataSources.Column[]>>([]);
const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({}); const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({});
const [params, setParams] = useState<QueryParams>({id: 0, schemaName: '', tableName: ''}); const [params, setParams] = useState<QueryParams>({id: 0, schemaName: '', tableName: ''});
...@@ -54,7 +53,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -54,7 +53,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const clearState = () => { const clearState = () => {
setDisabled(true); setDisabled(true);
setTableColumns([]);
setTableInfo({}); setTableInfo({});
setParams({ setParams({
id: 0, id: 0,
...@@ -87,7 +85,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -87,7 +85,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info; const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info;
if (isLeaf) { if (isLeaf) {
setParams({ setParams({
id: dataSource.id || 0, id: dataSource.id as number,
schemaName, schemaName,
tableName tableName
}); });
...@@ -95,12 +93,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -95,12 +93,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
/** /**
* get table columns * get table columns
*/ */
const columnsData = await queryDataByParams(API_CONSTANTS.DATASOURCE_GET_COLUMNS_BY_TABLE, {
id: dataSource.id,
schemaName,
tableName
});
setTableColumns(columnsData);
setTableInfo(fullInfo); setTableInfo(fullInfo);
} else { } else {
clearState(); clearState();
...@@ -137,7 +130,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -137,7 +130,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
{/* tags */} {/* tags */}
<RightTagsRouter <RightTagsRouter
tableInfo={tableInfo} tableInfo={tableInfo}
tableColumns={tableColumns}
queryParams={params} queryParams={params}
rightButtons={renderBackButton()} rightButtons={renderBackButton()}
tagDisabled={disabled} tagDisabled={disabled}
......
...@@ -60,7 +60,7 @@ const DataSourceTable = () => { ...@@ -60,7 +60,7 @@ const DataSourceTable = () => {
* execute query list * execute query list
* set list * set list
*/ */
const querDataSourceList = async () => { const queryDataSourceList = async () => {
await queryList(API_CONSTANTS.DATASOURCE).then(res => { await queryList(API_CONSTANTS.DATASOURCE).then(res => {
setDataSource(res.data); setDataSource(res.data);
}); });
...@@ -73,7 +73,7 @@ const DataSourceTable = () => { ...@@ -73,7 +73,7 @@ const DataSourceTable = () => {
const executeAndCallbackRefresh = async (callback: () => void) => { const executeAndCallbackRefresh = async (callback: () => void) => {
await setLoading(true); await setLoading(true);
await callback(); await callback();
await querDataSourceList(); await queryDataSourceList();
await setLoading(false); await setLoading(false);
}; };
...@@ -146,7 +146,7 @@ const DataSourceTable = () => { ...@@ -146,7 +146,7 @@ const DataSourceTable = () => {
* query list * query list
*/ */
useEffect(() => { useEffect(() => {
querDataSourceList(); queryDataSourceList();
}, []); }, []);
/** /**
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
import React, {useCallback, useEffect, useRef, useState} from "react"; import React, {useCallback, useEffect, useState} from "react";
import {ProCard} from "@ant-design/pro-components"; import {ProCard} from "@ant-design/pro-components";
import FileTree from "@/pages/RegCenter/Resource/components/FileTree"; import FileTree from "@/pages/RegCenter/Resource/components/FileTree";
import FileShow from "@/pages/RegCenter/Resource/components/FileShow"; import FileShow from "@/pages/RegCenter/Resource/components/FileShow";
...@@ -52,6 +52,35 @@ const ResourceOverView: React.FC = () => { ...@@ -52,6 +52,35 @@ const ResourceOverView: React.FC = () => {
const [formValue, setFormValue] = useState<Resource>({id: 0, fileName: '', description: ''}); const [formValue, setFormValue] = useState<Resource>({id: 0, fileName: '', description: ''});
const [uploadValue] = useState({url: API_CONSTANTS.RESOURCE_UPLOAD, pid: '', description: ''}); const [uploadValue] = useState({url: API_CONSTANTS.RESOURCE_UPLOAD, pid: '', description: ''});
const updateTreeData = (list: any[], key: React.Key, children: any[]): any[] =>
list.map((node) => {
if (node.path === key) {
return {
...node,
children,
};
}
if (node.children) {
return {
...node,
children: updateTreeData(node.children, key, children),
};
}
return node;
});
const refreshTreeData = async (pid: number, path: string) => {
const data = await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, {pid: pid});
setTreeData((origin) =>
updateTreeData(origin, path, data)
);
}
const refreshTree = async () => {
await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, {pid: -1}).then(res => setTreeData(res))
}
useEffect(() => { useEffect(() => {
refreshTree() refreshTree()
}, []) }, [])
...@@ -64,9 +93,6 @@ const ResourceOverView: React.FC = () => { ...@@ -64,9 +93,6 @@ const ResourceOverView: React.FC = () => {
const queryContent = useCallback(async (id: number) => { const queryContent = useCallback(async (id: number) => {
await queryDataByParams(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {id}).then(res => setContent(res)) await queryDataByParams(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {id}).then(res => setContent(res))
}, [clickedNode]) }, [clickedNode])
const refreshTree = async () => {
await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, {pid: -1}).then(res => setTreeData(res))
}
/** /**
* the node click event * the node click event
...@@ -74,7 +100,7 @@ const ResourceOverView: React.FC = () => { ...@@ -74,7 +100,7 @@ const ResourceOverView: React.FC = () => {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const handleNodeClick = async (info: any) => { const handleNodeClick = async (info: any) => {
const {node: {id, isLeaf, key, pos}, node} = info; const {node: {id, isLeaf, key,}, node} = info;
setSelectedKeys([key] as any); setSelectedKeys([key] as any);
setClickedNode(node); setClickedNode(node);
if (isLeaf) { if (isLeaf) {
...@@ -83,6 +109,18 @@ const ResourceOverView: React.FC = () => { ...@@ -83,6 +109,18 @@ const ResourceOverView: React.FC = () => {
setContent(''); setContent('');
} }
}; };
const getSelectedNode = () => {
const indexes = (rightClickedNode.pos.split("-") as string[]).map(x => parseInt(x));
if (indexes.length === 1) {
return treeData[indexes[0]]
} else {
let temp = treeData[indexes[0]]
for (let i = 1; i < indexes.length - 1; i++) {
temp = temp.children[indexes[i]]
}
return temp
}
}
/** /**
* the node right click event OF upload, * the node right click event OF upload,
...@@ -90,7 +128,7 @@ const ResourceOverView: React.FC = () => { ...@@ -90,7 +128,7 @@ const ResourceOverView: React.FC = () => {
const handleCreateFolder = () => { const handleCreateFolder = () => {
if (rightClickedNode) { if (rightClickedNode) {
setEditModal("createFolder") setEditModal("createFolder")
const {id, name, desc} = rightClickedNode; const {id} = rightClickedNode;
setShowEditModal(true) setShowEditModal(true)
setFormValue({id, fileName: "", description: ""}) setFormValue({id, fileName: "", description: ""})
setContextMenuVisible(false) setContextMenuVisible(false)
...@@ -104,6 +142,15 @@ const ResourceOverView: React.FC = () => { ...@@ -104,6 +142,15 @@ const ResourceOverView: React.FC = () => {
} }
}; };
const getSelectedParentNode = () => {
const indexes = (rightClickedNode.pos.split("-") as string[]).map(x => parseInt(x));
let temp = treeData[indexes[0]]
for (let i = 1; i < indexes.length - 2; i++) {
temp = temp.children[indexes[i]]
}
return {node: temp, index: indexes[indexes.length - 2]}
}
/** /**
* the node right click event OF delete, * the node right click event OF delete,
*/ */
...@@ -131,7 +178,7 @@ const ResourceOverView: React.FC = () => { ...@@ -131,7 +178,7 @@ const ResourceOverView: React.FC = () => {
} }
const handleRefresh = async () => { const handleRefresh = async () => {
if (rightClickedNode) { if (rightClickedNode) {
const {id, name, desc, path} = rightClickedNode; // const {id, name, desc, path} = rightClickedNode;
//todo refresh //todo refresh
} }
...@@ -199,7 +246,7 @@ const ResourceOverView: React.FC = () => { ...@@ -199,7 +246,7 @@ const ResourceOverView: React.FC = () => {
getSelectedNode().children = [d] getSelectedNode().children = [d]
} }
setShowEditModal(false) setShowEditModal(false)
} else if (editModal == "rename") { } else if (editModal === "rename") {
await handleOption(API_CONSTANTS.RESOURCE_RENAME, "重命名", {...value}) await handleOption(API_CONSTANTS.RESOURCE_RENAME, "重命名", {...value})
getSelectedNode().fileName = value.fileName getSelectedNode().fileName = value.fileName
getSelectedNode().name = value.fileName getSelectedNode().name = value.fileName
...@@ -208,26 +255,8 @@ const ResourceOverView: React.FC = () => { ...@@ -208,26 +255,8 @@ const ResourceOverView: React.FC = () => {
const handleUploadCancel = () => { const handleUploadCancel = () => {
setShowUpload(false) setShowUpload(false)
} }
const getSelectedNode = () => {
const indexes = (rightClickedNode.pos.split("-") as string[]).map(x => parseInt(x));
if (indexes.length == 1) {
return treeData[indexes[0]]
} else {
let temp = treeData[indexes[0]]
for (let i = 1; i < indexes.length - 1; i++) {
temp = temp.children[indexes[i]]
}
return temp
}
}
const getSelectedParentNode = () => {
const indexes = (rightClickedNode.pos.split("-") as string[]).map(x => parseInt(x));
let temp = treeData[indexes[0]]
for (let i = 1; i < indexes.length - 2; i++) {
temp = temp.children[indexes[i]]
}
return {node: temp, index: indexes[indexes.length - 2]}
}
/** /**
...@@ -260,34 +289,14 @@ const ResourceOverView: React.FC = () => { ...@@ -260,34 +289,14 @@ const ResourceOverView: React.FC = () => {
setContent(value); setContent(value);
// todo: save content // todo: save content
} }
const updateTreeData = (list: any[], key: React.Key, children: any[]): any[] =>
list.map((node) => { const asyncLoadData = async ({ children, path, id}: any) => {
if (node.path === key) {
return {
...node,
children,
};
}
if (node.children) {
return {
...node,
children: updateTreeData(node.children, key, children),
};
}
return node;
});
const asyncLoadData = async ({key, children, path, id}: any) => {
if (children.length > 0) { if (children.length > 0) {
return; return;
} }
await refreshTreeData(id, path) await refreshTreeData(id, path)
} }
const refreshTreeData = async (pid: number, path: string) => {
const data = await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, {pid: pid});
setTreeData((origin) =>
updateTreeData(origin, path, data)
);
}
/** /**
......
This diff is collapsed.
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
import { getIntl } from '@umijs/max'; import { getIntl } from '@umijs/max';
export const l = (id: string, defaultMessage?: string, value?: {}) : string => { export const l = (id: string, defaultMessage?: string, value?: {}) : string => {
if (id.trim()===""){
return "";
}
return getIntl().formatMessage({ id, defaultMessage }, value); return getIntl().formatMessage({ id, defaultMessage }, value);
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment