Unverified Commit e0cb9b7b authored by ZackYoung's avatar ZackYoung Committed by GitHub

[Fix] [Web] Fix debug (#2720)

* fix_debug * fix_debug * fix_debug
parent e9c59e24
...@@ -190,20 +190,21 @@ const HeaderContainer = (props: connect) => { ...@@ -190,20 +190,21 @@ const HeaderContainer = (props: connect) => {
const handlerDebug = async () => { const handlerDebug = async () => {
if (!currentData) return; if (!currentData) return;
// @ts-ignore
const editor = currentTab.monacoInstance.editor.getEditors().find((x:any)=>x["id"]===currentData.id);
let selectsql = null; //
if (currentTab.editorInstance) { let selectSql = '';
selectsql = currentTab.editorInstance if (editor) {
.getModel() selectSql = editor.getModel().getValueInRange(editor.getSelection());
.getValueInRange(currentTab.editorInstance.getSelection());
} }
if (selectsql == null || selectsql == '') { if (selectSql == null || selectSql == '') {
selectsql = currentData.statement; selectSql = currentData.statement;
} }
const res = await debugTask( const res = await debugTask(
l('pages.datastudio.editor.debugging', '', { jobName: currentData.name }), l('pages.datastudio.editor.debugging', '', { jobName: currentData.name }),
{ ...currentData, statement: selectsql } { ...currentData, statement: selectSql }
); );
if (!res) return; if (!res) return;
...@@ -402,7 +403,7 @@ const HeaderContainer = (props: connect) => { ...@@ -402,7 +403,7 @@ const HeaderContainer = (props: connect) => {
currentTab?.type == TabsPageType.project && currentTab?.type == TabsPageType.project &&
!isRunning(currentData) && !isRunning(currentData) &&
(currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL || (currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL ||
isSql(currentTab?.subType?.toLowerCase())), isSql(currentTab?.subType?.toLowerCase()??"")),
props: { props: {
style: { background: '#52c41a' }, style: { background: '#52c41a' },
type: 'primary' type: 'primary'
......
...@@ -86,7 +86,7 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => { ...@@ -86,7 +86,7 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
handlerMaxsize: handleMaxsize, handlerMaxsize: handleMaxsize,
visible: leftContainer.selectKey !== '', visible: leftContainer.selectKey !== '',
defaultSize: { width: leftContainer.width, height: leftContainer.height }, defaultSize: { width: leftContainer.width, height: leftContainer.height },
minWidth: 160, minWidth: 225,
maxWidth: MAX_WIDTH, maxWidth: MAX_WIDTH,
enable: { right: true }, enable: { right: true },
btnGroup: btn[leftContainer.selectKey] btnGroup: btn[leftContainer.selectKey]
......
...@@ -39,6 +39,7 @@ import { Monaco } from '@monaco-editor/react'; ...@@ -39,6 +39,7 @@ import { Monaco } from '@monaco-editor/react';
import { Button, Spin } from 'antd'; import { Button, Spin } from 'antd';
import { editor } from 'monaco-editor'; import { editor } from 'monaco-editor';
import React, { memo, useEffect, useRef, useState } from 'react'; import React, { memo, useEffect, useRef, useState } from 'react';
import {getCurrentData, getCurrentTab} from "@/pages/DataStudio/function";
export type EditorProps = { export type EditorProps = {
tabsItem: DataStudioTabsItemType; tabsItem: DataStudioTabsItemType;
...@@ -105,10 +106,12 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => { ...@@ -105,10 +106,12 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => {
editor.layout(); editor.layout();
editor.focus(); editor.focus();
editorInstance.current = editor; editorInstance.current = editor;
// @ts-ignore
editor['id']=getCurrentTab(tabs.panes,tabs.activeKey)?.params.taskId
tabsItem.monacoInstance = monaco; tabsItem.monacoInstance = monaco;
tabsItem.editorInstance = editor;
editor.onDidChangeCursorPosition((e) => { editor.onDidChangeCursorPosition((e) => {
props.footContainer.codePosition = [e.position.lineNumber, e.position.column]; props.footContainer.codePosition = [e.position.lineNumber, e.position.column];
dispatch({ dispatch({
type: STUDIO_MODEL.saveFooterValue, type: STUDIO_MODEL.saveFooterValue,
...@@ -144,7 +147,6 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => { ...@@ -144,7 +147,6 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => {
/> />
<CodeEdit <CodeEdit
monacoRef={tabsItem?.monacoInstance} monacoRef={tabsItem?.monacoInstance}
editorRef={tabsItem?.editorInstance}
code={tabsItem?.params?.taskData?.statement} code={tabsItem?.params?.taskData?.statement}
language={matchLanguage(tabsItem?.subType)} language={matchLanguage(tabsItem?.subType)}
editorDidMount={editorDidMount} editorDidMount={editorDidMount}
......
...@@ -164,7 +164,6 @@ export interface TabsItemType { ...@@ -164,7 +164,6 @@ export interface TabsItemType {
closable: boolean; closable: boolean;
path: string[]; path: string[];
monacoInstance: React.RefObject<Monaco | undefined>; monacoInstance: React.RefObject<Monaco | undefined>;
editorInstance: editor.IStandaloneCodeEditor | undefined;
console: ConsoleType; console: ConsoleType;
isModified: boolean; isModified: boolean;
} }
...@@ -184,6 +183,7 @@ export interface DataStudioTabsItemType extends TabsItemType { ...@@ -184,6 +183,7 @@ export interface DataStudioTabsItemType extends TabsItemType {
export type TabsType = { export type TabsType = {
activeKey: string; activeKey: string;
activeBreadcrumbTitle: string; activeBreadcrumbTitle: string;
selectedStatement?: string;
panes: TabsItemType[]; panes: TabsItemType[];
}; };
...@@ -868,7 +868,7 @@ const Model: ModelType = { ...@@ -868,7 +868,7 @@ const Model: ModelType = {
...state, ...state,
suggestions: payload suggestions: payload
}; };
} },
} }
}; };
......
...@@ -32,7 +32,8 @@ const operatorType = { ...@@ -32,7 +32,8 @@ const operatorType = {
CANCEL_JOB: 'canceljob', CANCEL_JOB: 'canceljob',
SAVEPOINT_CANCEL: 'cancel', SAVEPOINT_CANCEL: 'cancel',
SAVEPOINT_TRIGGER: 'trigger', SAVEPOINT_TRIGGER: 'trigger',
SAVEPOINT_STOP: 'stop' SAVEPOINT_STOP: 'stop',
AUTO_STOP: 'autostop'
}; };
export type OperatorType = { export type OperatorType = {
jobDetail: Jobs.JobInfoDetail; jobDetail: Jobs.JobInfoDetail;
...@@ -59,6 +60,21 @@ const JobOperator = (props: OperatorType) => { ...@@ -59,6 +60,21 @@ const JobOperator = (props: OperatorType) => {
id: jobDetail?.instance?.taskId, id: jobDetail?.instance?.taskId,
isOnLine: jobDetail?.instance?.step == JOB_LIFE_CYCLE.PUBLISH 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 { } else {
cancelTask('', jobDetail?.instance?.taskId); cancelTask('', jobDetail?.instance?.taskId);
} }
...@@ -91,7 +107,7 @@ const JobOperator = (props: OperatorType) => { ...@@ -91,7 +107,7 @@ const JobOperator = (props: OperatorType) => {
<Button <Button
key='autostop' key='autostop'
type='primary' type='primary'
onClick={() => handleJobOperator(operatorType.SAVEPOINT_STOP)} onClick={() => handleJobOperator(operatorType.AUTO_STOP)}
danger danger
> >
{jobDetail?.instance?.step == 5 {jobDetail?.instance?.step == 5
......
...@@ -244,6 +244,7 @@ export enum API_CONSTANTS { ...@@ -244,6 +244,7 @@ export enum API_CONSTANTS {
// /api/jobInstance/getLineage // /api/jobInstance/getLineage
JOB_INSTANCE_GET_LINEAGE = '/api/jobInstance/getLineage', JOB_INSTANCE_GET_LINEAGE = '/api/jobInstance/getLineage',
RESTART_TASK = '/api/task/restartTask', RESTART_TASK = '/api/task/restartTask',
SAVEPOINT = '/api/task/savepoint',
RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask', RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask',
GET_SAVEPOINTS = '/api/savepoints', GET_SAVEPOINTS = '/api/savepoints',
ALERT_HISTORY_LIST = '/api/alertHistory/list', ALERT_HISTORY_LIST = '/api/alertHistory/list',
......
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