Skip to content

Commit

Permalink
improve some feature & added flinksql language for editor (#2533)
Browse files Browse the repository at this point in the history
* Spotless Apply

* improve some feature

* improve some feature

* Spotless Apply

* format code

* format code

* format code

* format code

---------

Co-authored-by: zhu-mingye <[email protected]>
  • Loading branch information
Zzm0809 and zhu-mingye authored Nov 16, 2023
1 parent ca88bac commit 44511d4
Show file tree
Hide file tree
Showing 37 changed files with 1,370 additions and 207 deletions.
6 changes: 0 additions & 6 deletions dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.dinky.data.dto;

import org.dinky.config.Dialect;
import org.dinky.data.model.Task;
import org.dinky.data.model.ext.TaskExtConfig;
import org.dinky.job.JobConfig;
Expand Down Expand Up @@ -231,7 +230,6 @@ public JobConfig getJobConfig() {
JobConfig jobConfig = new JobConfig();
BeanUtil.copyProperties(this, jobConfig);
jobConfig.setConfigJson(parsedConfig);
jobConfig.setJarTask(isJarTask());
jobConfig.setTaskId(id);
jobConfig.setJobName(name);

Expand All @@ -243,8 +241,4 @@ public Task buildTask() {
BeanUtil.copyProperties(this, task);
return task;
}

public boolean isJarTask() {
return Dialect.isJarDialect(dialect);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,6 @@ public String exportSql(Integer id) {
}

JobManager jobManager = JobManager.build(config);
if (config.isJarTask()) {
return "";
}

return jobManager.exportSql(task.getStatement());
}
Expand Down
2 changes: 1 addition & 1 deletion dinky-admin/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<!--这个是输出日志的格式,如果对里面的参数不理解,可以去看我的这篇文章,网址是:“https://blog.csdn.net/qq_42449963/article/details/104617356”-->
<!--<PatternLayout pattern="[dinky] %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>-->
<PatternLayout
pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%15.15t] %c{20}(%L): %m"/>
pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %p %c{20}(%L): %m"/>
</LogSseAppender>

</appenders>
Expand Down
10 changes: 0 additions & 10 deletions dinky-core/src/main/java/org/dinky/job/JobConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public class JobConfig {
notes = "Cluster configuration ID")
private Integer clusterConfigurationId;

@ApiModelProperty(value = "JAR file ID", dataType = "Integer", example = "101", notes = "JAR file ID")
private Integer jarId;

@ApiModelProperty(value = "Task JobLifeCycle", dataType = "Integer", example = "2", notes = "Task JobLifeCycle")
private Integer step;

Expand Down Expand Up @@ -128,13 +125,6 @@ public class JobConfig {
notes = "Flag indicating whether to use remote execution")
private boolean useRemote;

@ApiModelProperty(
value = "Flag indicating whether it's a JAR task",
dataType = "boolean",
example = "false",
notes = "Flag indicating whether it's a JAR task")
private boolean isJarTask;

@ApiModelProperty(
value = "Job manager address",
dataType = "String",
Expand Down
24 changes: 12 additions & 12 deletions dinky-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
"dependencies": {
"@ant-design/charts": "^1.4.2",
"@ant-design/icons": "^5.2.6",
"@ant-design/pro-components": "^2.6.27",
"@ant-design/pro-layout": "^7.17.6",
"@ant-design/pro-table": "^3.12.11",
"@ant-design/pro-components": "^2.6.41",
"@ant-design/pro-layout": "^7.17.15",
"@ant-design/pro-table": "^3.13.9",
"@ant-design/use-emotion-css": "^1.0.4",
"@antv/x6": "^2.15.1",
"@antv/x6": "^2.15.6",
"@antv/x6-plugin-selection": "^2.2.1",
"@antv/x6-react-shape": "^2.2.2",
"@monaco-editor/react": "^4.5.2",
"@monaco-editor/react": "^4.6.0",
"@umijs/route-utils": "^4.0.1",
"antd": "^5.9.3",
"antd": "^5.11.1",
"butterfly-dag": "^4.3.28",
"classnames": "^2.3.2",
"dayjs": "^1.11.10",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"million": "^2.6.1",
"million": "^2.6.4",
"moment": "^2.29.4",
"monaco-editor": "^0.44.0",
"omit.js": "^2.0.2",
"rc-menu": "^9.12.0",
"rc-util": "^5.37.0",
"rc-menu": "^9.12.2",
"rc-util": "^5.38.1",
"re-resizable": "^6.9.11",
"react": "^18.2.0",
"react-countup": "^6.4.2",
"react-countup": "^6.5.0",
"react-dom": "^18.0.0",
"react-helmet-async": "^1.3.0",
"react-lineage-dag": "^2.0.36",
Expand All @@ -70,8 +70,8 @@
"redux-persist": "^6.0.0",
"remark-gfm": "^4.0.0",
"screenfull": "^6.0.2",
"sql-formatter": "^13.0.2",
"styled-components": "^6.0.8",
"sql-formatter": "^13.1.0",
"styled-components": "^6.1.1",
"use-sse": "^2.0.1"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion dinky-web/src/components/CallBackButton/CircleBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
*
* 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.
Expand All @@ -16,7 +17,7 @@
*
*/

import { TabsItemType } from '@/pages/DataStudio/types';
import { TabsItemType } from '@/pages/DataStudio/model';
import { Button } from 'antd';
import React from 'react';

Expand Down
14 changes: 12 additions & 2 deletions dinky-web/src/components/CustomEditor/CodeEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import { editor, languages, Position } from 'monaco-editor';

import { buildAllSuggestionsToEditor } from '@/components/CustomEditor/CodeEdit/function';
import EditorFloatBtn from '@/components/CustomEditor/EditorFloatBtn';
import { LoadCustomEditorLanguage } from '@/components/CustomEditor/languages';
import { StateType } from '@/pages/DataStudio/model';
import { MonacoEditorOptions } from '@/types/Public/data';
import { convertCodeEditTheme } from '@/utils/function';
import { Editor, Monaco, OnChange } from '@monaco-editor/react';
import { Editor, Monaco, OnChange, useMonaco } from '@monaco-editor/react';
import { connect } from '@umijs/max';
import useMemoCallback from 'rc-menu/es/hooks/useMemoCallback';
import { memo, useCallback, useRef } from 'react';
import { memo, useCallback, useEffect, useRef } from 'react';
import ITextModel = editor.ITextModel;
import CompletionItem = languages.CompletionItem;
import CompletionContext = languages.CompletionContext;
Expand Down Expand Up @@ -94,6 +95,15 @@ const CodeEdit = (props: CodeEditFormProps & connect) => {

const { ScrollType } = editor;

// 使用编辑器钩子, 拿到编辑器实例
const monacoHook = useMonaco();

useEffect(() => {
convertCodeEditTheme(monacoHook?.editor);
// 需要调用 手动注册下自定义语言
LoadCustomEditorLanguage(monacoHook);
}, [monacoHook]);

// todo: 已知 bug , 切换 tab 时 , 会造成buildAllSuggestions 的重复调用 , 造成建议项重复 ,但不影响原有数据, 编辑器会将建议项自动缓存,不会进行去重
/**
* build all suggestions
Expand Down
4 changes: 2 additions & 2 deletions dinky-web/src/components/CustomEditor/CodeShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import EditorFloatBtn from '@/components/CustomEditor/EditorFloatBtn';
import { LogLanguage } from '@/components/CustomEditor/languages/javalog';
import { LoadCustomEditorLanguage } from '@/components/CustomEditor/languages';
import { Loading } from '@/pages/Other/Loading';
import { MonacoEditorOptions } from '@/types/Public/data';
import { convertCodeEditTheme } from '@/utils/function';
Expand Down Expand Up @@ -94,7 +94,7 @@ const CodeShow = (props: CodeShowFormProps) => {
useEffect(() => {
convertCodeEditTheme(monaco?.editor);
// 需要调用 手动注册下自定义语言
LogLanguage(monaco);
LoadCustomEditorLanguage(monaco);
}, [monaco]);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
*
* 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 TokenClassConsts = {
BINARY: 'binary',
BINARY_ESCAPE: 'binary.escape',
COMMENT: 'comment',
COMMENT_QUOTE: 'comment.quote',
DELIMITER: 'delimiter',
DELIMITER_CURLY: 'delimiter.curly',
DELIMITER_PAREN: 'delimiter.paren',
DELIMITER_SQUARE: 'delimiter.square',
IDENTIFIER: 'identifier',
IDENTIFIER_QUOTE: 'identifier.quote',
KEYWORD: 'keyword',
KEYWORD_SCOPE: 'keyword.scope',
NUMBER: 'number',
NUMBER_FLOAT: 'number.float',
NUMBER_BINARY: 'number.binary',
NUMBER_OCTAL: 'number.octal',
NUMBER_HEX: 'number.hex',
OPERATOR: 'operators',
OPERATOR_KEYWORD: 'operators.keyword',
OPERATOR_SYMBOL: 'operators.symbol',
PREDEFINED: 'predefined',
STRING: 'string',
STRING_ESCAPE: 'string.escape',
STRING_ESCAPE_CHAR: 'string.escape.char',
TYPE: 'type',
VARIABLE: 'variable',
WHITE: 'white'
};
Loading

0 comments on commit 44511d4

Please sign in to comment.