Skip to content

Commit

Permalink
[Fix] [Web] Fix debug (DataLinkDC#2720)
Browse files Browse the repository at this point in the history
* fix_debug

* fix_debug

* fix_debug
  • Loading branch information
zackyoungh authored Dec 22, 2023
1 parent e9c59e2 commit e0cb9b7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
19 changes: 10 additions & 9 deletions dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DataStudio/LeftContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const LeftContainer: React.FC<LeftContainerProps> = (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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,10 +106,12 @@ const StudioEditor: React.FC<EditorProps & connect> = (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,
Expand Down Expand Up @@ -144,7 +147,6 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => {
/>
<CodeEdit
monacoRef={tabsItem?.monacoInstance}
editorRef={tabsItem?.editorInstance}
code={tabsItem?.params?.taskData?.statement}
language={matchLanguage(tabsItem?.subType)}
editorDidMount={editorDidMount}
Expand Down
4 changes: 2 additions & 2 deletions dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export interface TabsItemType {
closable: boolean;
path: string[];
monacoInstance: React.RefObject<Monaco | undefined>;
editorInstance: editor.IStandaloneCodeEditor | undefined;
console: ConsoleType;
isModified: boolean;
}
Expand All @@ -184,6 +183,7 @@ export interface DataStudioTabsItemType extends TabsItemType {
export type TabsType = {
activeKey: string;
activeBreadcrumbTitle: string;
selectedStatement?: string;
panes: TabsItemType[];
};

Expand Down Expand Up @@ -868,7 +868,7 @@ const Model: ModelType = {
...state,
suggestions: payload
};
}
},
}
};

Expand Down
20 changes: 18 additions & 2 deletions dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -91,7 +107,7 @@ const JobOperator = (props: OperatorType) => {
<Button
key='autostop'
type='primary'
onClick={() => handleJobOperator(operatorType.SAVEPOINT_STOP)}
onClick={() => handleJobOperator(operatorType.AUTO_STOP)}
danger
>
{jobDetail?.instance?.step == 5
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/services/endpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export enum API_CONSTANTS {
// /api/jobInstance/getLineage
JOB_INSTANCE_GET_LINEAGE = '/api/jobInstance/getLineage',
RESTART_TASK = '/api/task/restartTask',
SAVEPOINT = '/api/task/savepoint',
RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask',
GET_SAVEPOINTS = '/api/savepoints',
ALERT_HISTORY_LIST = '/api/alertHistory/list',
Expand Down

0 comments on commit e0cb9b7

Please sign in to comment.