From e0cb9b7b626bf73a776184c42640d897d8aa3b05 Mon Sep 17 00:00:00 2001 From: ZackYoung Date: Fri, 22 Dec 2023 20:50:48 +0800 Subject: [PATCH] [Fix] [Web] Fix debug (#2720) * fix_debug * fix_debug * fix_debug --- .../DataStudio/HeaderContainer/index.tsx | 19 +++++++++--------- .../pages/DataStudio/LeftContainer/index.tsx | 2 +- .../MiddleContainer/StudioEditor/index.tsx | 6 ++++-- dinky-web/src/pages/DataStudio/model.ts | 4 ++-- .../JobDetail/JobOperator/JobOperator.tsx | 20 +++++++++++++++++-- dinky-web/src/services/endpoints.tsx | 1 + 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index a85bd8813a..6f2898448b 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -190,20 +190,21 @@ const HeaderContainer = (props: connect) => { const handlerDebug = async () => { if (!currentData) return; + // @ts-ignore + const editor = currentTab.monacoInstance.editor.getEditors().find((x:any)=>x["id"]===currentData.id); - let selectsql = null; - if (currentTab.editorInstance) { - selectsql = currentTab.editorInstance - .getModel() - .getValueInRange(currentTab.editorInstance.getSelection()); + // + let selectSql = ''; + if (editor) { + selectSql = editor.getModel().getValueInRange(editor.getSelection()); } - if (selectsql == null || selectsql == '') { - selectsql = currentData.statement; + if (selectSql == null || selectSql == '') { + selectSql = currentData.statement; } const res = await debugTask( l('pages.datastudio.editor.debugging', '', { jobName: currentData.name }), - { ...currentData, statement: selectsql } + { ...currentData, statement: selectSql } ); if (!res) return; @@ -402,7 +403,7 @@ const HeaderContainer = (props: connect) => { currentTab?.type == TabsPageType.project && !isRunning(currentData) && (currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL || - isSql(currentTab?.subType?.toLowerCase())), + isSql(currentTab?.subType?.toLowerCase()??"")), props: { style: { background: '#52c41a' }, type: 'primary' diff --git a/dinky-web/src/pages/DataStudio/LeftContainer/index.tsx b/dinky-web/src/pages/DataStudio/LeftContainer/index.tsx index 24949fb440..2389d1bab9 100644 --- a/dinky-web/src/pages/DataStudio/LeftContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/LeftContainer/index.tsx @@ -86,7 +86,7 @@ const LeftContainer: React.FC = (props: any) => { handlerMaxsize: handleMaxsize, visible: leftContainer.selectKey !== '', defaultSize: { width: leftContainer.width, height: leftContainer.height }, - minWidth: 160, + minWidth: 225, maxWidth: MAX_WIDTH, enable: { right: true }, btnGroup: btn[leftContainer.selectKey] diff --git a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx index cc6ea7c7ed..a82914977f 100644 --- a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx +++ b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx @@ -39,6 +39,7 @@ import { Monaco } from '@monaco-editor/react'; import { Button, Spin } from 'antd'; import { editor } from 'monaco-editor'; import React, { memo, useEffect, useRef, useState } from 'react'; +import {getCurrentData, getCurrentTab} from "@/pages/DataStudio/function"; export type EditorProps = { tabsItem: DataStudioTabsItemType; @@ -105,10 +106,12 @@ const StudioEditor: React.FC = (props) => { editor.layout(); editor.focus(); editorInstance.current = editor; + // @ts-ignore + editor['id']=getCurrentTab(tabs.panes,tabs.activeKey)?.params.taskId tabsItem.monacoInstance = monaco; - tabsItem.editorInstance = editor; editor.onDidChangeCursorPosition((e) => { + props.footContainer.codePosition = [e.position.lineNumber, e.position.column]; dispatch({ type: STUDIO_MODEL.saveFooterValue, @@ -144,7 +147,6 @@ const StudioEditor: React.FC = (props) => { /> ; - editorInstance: editor.IStandaloneCodeEditor | undefined; console: ConsoleType; isModified: boolean; } @@ -184,6 +183,7 @@ export interface DataStudioTabsItemType extends TabsItemType { export type TabsType = { activeKey: string; activeBreadcrumbTitle: string; + selectedStatement?: string; panes: TabsItemType[]; }; @@ -868,7 +868,7 @@ const Model: ModelType = { ...state, suggestions: payload }; - } + }, } }; diff --git a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx index fe2ae01c5c..e029c09ee3 100644 --- a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx +++ b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx @@ -32,7 +32,8 @@ const operatorType = { CANCEL_JOB: 'canceljob', SAVEPOINT_CANCEL: 'cancel', SAVEPOINT_TRIGGER: 'trigger', - SAVEPOINT_STOP: 'stop' + SAVEPOINT_STOP: 'stop', + AUTO_STOP: 'autostop' }; export type OperatorType = { jobDetail: Jobs.JobInfoDetail; @@ -59,6 +60,21 @@ const JobOperator = (props: OperatorType) => { id: jobDetail?.instance?.taskId, isOnLine: jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH }); + } else if (key == operatorType.SAVEPOINT_CANCEL) { + getData(API_CONSTANTS.SAVEPOINT, { + taskId: jobDetail?.instance?.taskId, + savePointType: "cancel" + }); + } else if (key == operatorType.SAVEPOINT_STOP) { + getData(API_CONSTANTS.SAVEPOINT, { + taskId: jobDetail?.instance?.taskId, + savePointType: "stop" + }); + } else if (key == operatorType.SAVEPOINT_TRIGGER) { + getData(API_CONSTANTS.SAVEPOINT, { + taskId: jobDetail?.instance?.taskId, + savePointType: "trigger" + }); } else { cancelTask('', jobDetail?.instance?.taskId); } @@ -91,7 +107,7 @@ const JobOperator = (props: OperatorType) => {