Unverified Commit 1cd2930d authored by ZackYoung's avatar ZackYoung Committed by GitHub

[Fix]fix_some_web_bug (#2448)

* fix_some_web_bug * fix_some_web_bug
parent 4d9e70dc
......@@ -193,5 +193,5 @@ export default defineConfig({
strategy: 'normal'
},
// requestRecord: {},
dva: {}
dva: {},
});
......@@ -18,16 +18,18 @@
*/
import EditorFloatBtn from '@/components/CustomEditor/EditorFloatBtn';
import { MonacoEditorOptions } from '@/types/Public/data';
import { convertCodeEditTheme } from '@/utils/function';
import { Editor, loader } from '@monaco-editor/react';
import {CODE_EDIT_THEME, MonacoEditorOptions, THEME} from '@/types/Public/data';
import {convertCodeEditTheme} from '@/utils/function';
import {Editor, loader} from '@monaco-editor/react';
import * as monaco from 'monaco-editor';
import { editor } from 'monaco-editor';
import { EditorLanguage } from 'monaco-editor/esm/metadata';
import { useState } from 'react';
import {editor} from 'monaco-editor';
import {EditorLanguage} from 'monaco-editor/esm/metadata';
import {useEffect, useState} from 'react';
import FullscreenBtn from '../FullscreenBtn';
import useThemeValue from "@/hooks/useThemeValue";
import {JavaLog} from "@/components/CustomEditor/languages/javalog";
loader.config({ monaco });
// loader.config({monaco});
/**
* props
* todo:
......@@ -38,15 +40,15 @@ loader.config({ monaco });
export type CodeShowFormProps = {
height?: string | number;
width?: string;
language?: EditorLanguage;
language?: EditorLanguage | string;
options?: any;
code: string;
lineNumbers?: string;
theme?: string;
autoWrap?: string;
showFloatButton?: boolean;
refreshLogCallback?: () => void;
fullScreenBtn?: boolean;
style?: React.CSSProperties;
};
const CodeShow = (props: CodeShowFormProps) => {
......@@ -70,14 +72,13 @@ const CodeShow = (props: CodeShowFormProps) => {
},
code, // content
lineNumbers, // show lineNumbers
theme, // edit theme
autoWrap = 'on', // auto wrap
showFloatButton = false,
refreshLogCallback,
fullScreenBtn = false
} = props;
const { ScrollType } = editor;
const {ScrollType} = editor;
const [scrollBeyondLastLine] = useState<boolean>(options.scrollBeyondLastLine);
......@@ -87,6 +88,10 @@ const CodeShow = (props: CodeShowFormProps) => {
const [fullScreen, setFullScreen] = useState<boolean>(false);
const [editorRef, setEditorRef] = useState<any>();
const [timer, setTimer] = useState<NodeJS.Timer>();
const themeValue = useThemeValue();
useEffect(() => {
JavaLog();
}, [])
// // register TypeScript language service, if language is not set default value is typescript!
// monaco.languages.register({
......@@ -146,14 +151,14 @@ const CodeShow = (props: CodeShowFormProps) => {
* handle scroll to down
*/
const handleDownScroll = () => {
editorRef.setScrollPosition({ scrollTop: editorRef.getScrollTop() + 500 }, ScrollType.Smooth);
editorRef.setScrollPosition({scrollTop: editorRef.getScrollTop() + 500}, ScrollType.Smooth);
};
/**
* handle scroll to up
*/
const handleUpScroll = () => {
editorRef?.setScrollPosition({ scrollTop: editorRef.getScrollTop() - 500 }, ScrollType.Smooth);
editorRef?.setScrollPosition({scrollTop: editorRef.getScrollTop() - 500}, ScrollType.Smooth);
};
/**
......@@ -194,7 +199,7 @@ const CodeShow = (props: CodeShowFormProps) => {
* render
*/
return (
<div className={'monaco-float'}>
<div className={'monaco-float'} style={props.style}>
{/* fullScreen button */}
{fullScreenBtn && (
<FullscreenBtn
......@@ -219,6 +224,7 @@ const CodeShow = (props: CodeShowFormProps) => {
fixedOverflowWidgets: true,
autoClosingDelete: 'always',
lineNumbers,
minimap: {enabled: false},
scrollbar: {
// Subtle shadows to the left & top. Defaults to true.
useShadows: false,
......@@ -251,7 +257,7 @@ const CodeShow = (props: CodeShowFormProps) => {
style={{
width: 35,
height: height,
backgroundColor: '#f4f4f4',
backgroundColor: themeValue.borderColor,
paddingBlock: 10
}}
>
......
import {editor} from "monaco-editor";
import {languages} from "monaco-editor";
// todo 自定义语言不生效
export const JavaLog = () => {
// Register a new language
languages.register({ id: "java-log" });
// Register a tokens provider for the language
languages.setMonarchTokensProvider("java-log", {
tokenizer: {
root: [
[/\[error.*/, "custom-error"],
[/\[notice.*/, "custom-notice"],
[/.*/, "custom-info"],
[/\[[a-zA-Z 0-9:]+\]/, "custom-date"],
],
},
});
}
\ No newline at end of file
......@@ -19,23 +19,26 @@
import CodeShow from '@/components/CustomEditor/CodeShow';
import MovableSidebar from '@/components/Sidebar/MovableSidebar';
import { SseData } from '@/models/Sse';
import { DataStudioTabsItemType, StateType } from '@/pages/DataStudio/model';
import { SSE_TOPIC } from '@/pages/DevOps/constants';
import { API_CONSTANTS } from '@/services/endpoints';
import { parseMilliSecondStr } from '@/utils/function';
import { connect, useModel, useRequest } from '@@/exports';
import { CheckOutlined, CloseCircleFilled, LoadingOutlined } from '@ant-design/icons';
import { Empty, Space, Typography } from 'antd';
import { DataNode } from 'antd/es/tree';
import {SseData} from '@/models/Sse';
import {DataStudioTabsItemType, StateType} from '@/pages/DataStudio/model';
import {SSE_TOPIC} from '@/pages/DevOps/constants';
import {API_CONSTANTS} from '@/services/endpoints';
import {parseMilliSecondStr} from '@/utils/function';
import {connect, useModel, useRequest} from '@@/exports';
import {CheckOutlined, CloseCircleFilled, LoadingOutlined} from '@ant-design/icons';
import {Empty, Space, Typography} from 'antd';
import {DataNode} from 'antd/es/tree';
import DirectoryTree from 'antd/es/tree/DirectoryTree';
import { Key, useEffect, useState } from 'react';
const { Text } = Typography;
import {Key, useEffect, useState} from 'react';
import useThemeValue from "@/hooks/useThemeValue";
const {Text} = Typography;
export type ConsoleProps = {
tab: DataStudioTabsItemType;
height: number;
};
export interface ProcessStep extends DataNode {
status: string;
type: string;
......@@ -59,7 +62,7 @@ const buildExpandKeys = (node: ProcessStep) => {
};
const ConsoleContent = (props: ConsoleProps) => {
const { tab } = props;
const {tab} = props;
const [selectNode, setSelectNode] = useState<ProcessStep>();
const [processNode, setProcessNode] = useState<ProcessStep>();
......@@ -67,9 +70,10 @@ const ConsoleContent = (props: ConsoleProps) => {
const process = `FlinkSubmit/${tab.params.taskId}`;
const topic = `${SSE_TOPIC.PROCESS_CONSOLE}/${process}`;
const { subscribeTopic } = useModel('Sse', (model: any) => ({
const {subscribeTopic} = useModel('Sse', (model: any) => ({
subscribeTopic: model.subscribeTopic
}));
const themeValue = useThemeValue();
const onUpdate = (data: ProcessStep) => {
setProcessNode((prevState: any) => {
......@@ -92,11 +96,13 @@ const ConsoleContent = (props: ConsoleProps) => {
};
useRequest(
{ url: API_CONSTANTS.PROCESS_LOG, params: { processName: process } },
{ onSuccess: async (res) => onUpdate(res) }
{url: API_CONSTANTS.PROCESS_LOG, params: {processName: process}},
{onSuccess: async (res) => onUpdate(res)}
);
useEffect(() => subscribeTopic([topic], (data: SseData) => onUpdate(data.data)), []);
const onSelect = (_selectedKeys: Key[], info: { node: ProcessStep }) => setSelectNode(info.node);
const onSelect = (_selectedKeys: Key[], info: {
node: ProcessStep
}) => setSelectNode(info.node);
const renderTitle = (node: any) => {
const startDate = new Date(node.startTime);
......@@ -104,15 +110,15 @@ const ConsoleContent = (props: ConsoleProps) => {
const duration = node.time ? node.time : endDate.getTime() - startDate.getTime();
return (
<Space size={5}>
{node.status == 'RUNNING' && <LoadingOutlined />}
{node.status == 'RUNNING' && <LoadingOutlined/>}
{node.status == 'FINISHED' && (
<CheckOutlined style={{ color: 'green', fontWeight: 'bold' }} />
<CheckOutlined style={{color: 'green', fontWeight: 'bold'}}/>
)}
{node.status == 'FAILED' && (
<CloseCircleFilled style={{ color: 'red', fontWeight: 'bold' }} />
<CloseCircleFilled style={{color: 'red', fontWeight: 'bold'}}/>
)}
<Text>{node.title}</Text>
<Text type={'secondary'} style={{ marginLeft: 'auto' }}>
<Text type={'secondary'} style={{marginLeft: 'auto'}}>
{parseMilliSecondStr(duration)}
</Text>
</Space>
......@@ -130,7 +136,7 @@ const ConsoleContent = (props: ConsoleProps) => {
};
return (
<div style={{ overflow: 'hidden' }}>
<div style={{overflow: 'hidden'}}>
<MovableSidebar
defaultSize={{
width: 300,
......@@ -138,14 +144,13 @@ const ConsoleContent = (props: ConsoleProps) => {
}}
minWidth={20}
visible={true}
enable={{ right: true }}
enable={{right: true}}
headerVisible={false}
style={{ borderInlineStart: `1px`, float: 'left' }}
style={{ float: 'left',borderInlineEnd:`1px solid ${themeValue.borderColor}`,paddingInline:10}}
>
{processNode ? (
<DirectoryTree
className={'treeList'}
style={{height:props.height}}
showIcon={false}
titleRender={renderTitle}
onSelect={onSelect}
......@@ -154,15 +159,16 @@ const ConsoleContent = (props: ConsoleProps) => {
onExpand={handleExpand}
/>
) : (
<Empty />
<Empty/>
)}
</MovableSidebar>
<div>
<div style={{display:"inline",width:1500}}>
<CodeShow
code={selectNode?.log ? selectNode.log : ''}
height={props.height - 53}
language={'kotlin'}
lineNumbers={'off'}
language={'java-log'}
lineNumbers={"off"}
autoWrap={"off"}
//TODO 按钮显示有问题,先注释
// showFloatButton
/>
......@@ -171,7 +177,9 @@ const ConsoleContent = (props: ConsoleProps) => {
);
};
export default connect(({ Studio }: { Studio: StateType }) => ({
export default connect(({Studio}: {
Studio: StateType
}) => ({
height: Studio.bottomContainer.height,
console: Studio.bottomContainerContent.console
}))(ConsoleContent);
......@@ -24,7 +24,7 @@ import { StateType } from '@/pages/DataStudio/model';
import { l } from '@/utils/intl';
import { ConsoleSqlOutlined } from '@ant-design/icons';
import ProList from '@ant-design/pro-list';
import { Space, Tag, Typography } from 'antd';
import {Button, Drawer, Space, Tag, Typography} from 'antd';
import React, { useEffect, useState } from 'react';
import { connect } from 'umi';
......@@ -48,6 +48,8 @@ export type ExplainProps = {
const Explain: React.FC<ExplainProps> = (props: any) => {
const [explainData, setExplainData] = useState([]);
const [result, setResult] = useState(<Text>{l('pages.datastudio.explain.validate')}</Text>);
const [showModal,setShowModal] = useState(false);
const [explainInfo,setExplainInfo] = useState("");
const {
tabs: { panes, activeKey }
} = props;
......@@ -103,7 +105,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
}
});
}, []);
const showPlanDrawer = (info:string) => {
setShowModal(true);
setExplainInfo(info)
};
const renderContent = () => {
return (
<>
......@@ -142,15 +147,18 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
return (
<>
{row.sql ? (
<>
<Paragraph ellipsis={{ rows: 2, expandable: true, symbol: 'more' }}>
{row.sql}
</Paragraph>
</>
) : null}
{row.error ? (
<Paragraph>
<CodeShow code={row.error} language='java' height='500px' />
</Paragraph>
) : null}
{row.explain ? <a onClick={()=>showPlanDrawer(row.explain)} style={{float:"right"}} type={"link"}>Show Plan</a> :<></>}
</>
);
}
......@@ -199,18 +207,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
<blockquote>{result}</blockquote>
</Paragraph>
{renderContent()}
<Drawer width={"50%"} title="Show Plan" placement="right" onClose={()=>setShowModal(false)} open={showModal}>
<CodeShow style={{alignItems:"inherit"}} code={explainInfo} language='java' height='500px' />
</Drawer>
</>
// <Modal
// width={'100%'}
// destroyOnClose
// centered
// title={l('pages.datastudio.explain.validate.msg')}
// open={modalVisible}
// footer={false}
// onCancel={onClose}
// >
//
// </Modal>
);
};
......
......@@ -146,27 +146,27 @@ export function convertCodeEditTheme() {
],
// colors is an object of color identifiers and their color values.
colors: {
'editor.background': '#2f2e2e', // editor background color
'editor.lineHighlightBackground': '#959cb6', // editor line highlight background color
'editorLineNumber.foreground': '#ffffff', // editor line number color
'editorCursor.foreground': '#ffffff', // editor cursor color
'editorIndentGuide.background': '#ffffff', // editor indent guide color
'editor.foreground': '#ffffff', // editor selection highlight border color
'editor.selectionBackground': '#4ba1ef', // editor selection highlight color
'editor.selectionHighlightBorder': '#4ba1ef', // editor selection highlight border color
'editor.findMatchBackground': '#4ba1ef', // editor find match highlight color
'editor.wordHighlightBackground': '#8bb2d2' // editor word highlight color
// 'editor.background': '#2f2e2e', // editor background color
// 'editor.lineHighlightBackground': '#959cb6', // editor line highlight background color
// 'editorLineNumber.foreground': '#ffffff', // editor line number color
// 'editorCursor.foreground': '#ffffff', // editor cursor color
// 'editorIndentGuide.background': '#ffffff', // editor indent guide color
// 'editor.foreground': '#ffffff', // editor selection highlight border color
// 'editor.selectionBackground': '#4ba1ef', // editor selection highlight color
// 'editor.selectionHighlightBorder': '#4ba1ef', // editor selection highlight border color
// 'editor.findMatchBackground': '#4ba1ef', // editor find match highlight color
// 'editor.wordHighlightBackground': '#8bb2d2' // editor word highlight color
}
});
const theme = getLocalTheme();
switch (theme) {
case THEME.dark:
return CODE_EDIT_THEME.VS_CUSTOME;
case THEME.light:
return CODE_EDIT_THEME.DARK;
case THEME.light:
return CODE_EDIT_THEME.VS_CUSTOME;
default:
return CODE_EDIT_THEME.HC_BLACK;
return CODE_EDIT_THEME.VS_CUSTOME;
}
}
......
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