Unverified Commit b7bb85af authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Feature][admin] support suggestion for editor (#2489)

* feature-support-suggestion * Spotless Apply * fix bug && 优化编辑器建议提示代码 * Spotless Apply * FORMAT * modify some code * Spotless Apply * fix code * Spotless Apply * modify some code * Spotless Apply * fix * fix bug * Spotless Apply * fix bug * Spotless Apply * fix bug * fix bug * Spotless Apply --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com> Co-authored-by: 's avatarZackYoung <zackyoungh@163.com>
parent f217df23
/*
*
* 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.
*
*/
package org.dinky.controller;
import org.dinky.data.dto.SuggestionDTO;
import org.dinky.data.result.Result;
import org.dinky.data.vo.suggestion.SuggestionVO;
import org.dinky.service.SuggestionService;
import java.util.Set;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@Api(tags = "Suggestion Controller")
@RequestMapping("/api/suggestion")
@RequiredArgsConstructor
public class SuggestionController {
private final SuggestionService suggestionService;
@PostMapping("/queryAllSuggestions")
@ApiOperation(value = "QueryAllSuggestions", notes = "queryAllSuggestions")
@ApiImplicitParam(name = "suggestionDTO", value = "suggestionDTO", required = true, dataType = "SuggestionDTO")
public Result<Set<SuggestionVO>> queryAllSuggestions(@RequestBody SuggestionDTO suggestionDTO) {
return Result.succeed(suggestionService.getSuggestions(suggestionDTO.isEnableSchemaSuggestion()));
}
@PostMapping("/queryAllSuggestionsByKeyWord")
@ApiOperation(value = "QueryAllSuggestionsByKeyWord", notes = "queryAllSuggestionsByKeyWord")
@ApiImplicitParam(name = "suggestionDTO", value = "suggestionDTO", required = true, dataType = "SuggestionDTO")
public Result<Set<SuggestionVO>> queryAllSuggestionsByKeyWord(@RequestBody SuggestionDTO suggestionDTO) {
return Result.succeed(suggestionService.getSuggestionsByKeyWord(
suggestionDTO.isEnableSchemaSuggestion(), suggestionDTO.getKeyWord()));
}
@PostMapping("/queryAllSuggestionsBySqlStatement")
@ApiOperation(value = "QueryAllSuggestionsBySqlStatement", notes = "queryAllSuggestionsBySqlStatement")
@ApiImplicitParam(name = "suggestionDTO", value = "suggestionDTO", required = true, dataType = "SuggestionDTO")
public Result<Set<SuggestionVO>> queryAllSuggestionsBySqlStatement(@RequestBody SuggestionDTO suggestionDTO) {
return Result.succeed(suggestionService.getSuggestionsBySqlStatement(
suggestionDTO.isEnableSchemaSuggestion(),
suggestionDTO.getSqlStatement(),
suggestionDTO.getPosition()));
}
}
/*
*
* 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.
*
*/
package org.dinky.data.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SuggestionDTO {
private boolean enableSchemaSuggestion;
private String keyWord;
private String sqlStatement;
private int position;
}
/*
*
* 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.
*
*/
package org.dinky.data.vo.suggestion;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SuggestionLabelVO implements Serializable {
private static final long serialVersionUID = 4631906403475634212L;
// label
private String label;
// value
private String detail;
// description
private String description;
}
/*
*
* 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.
*
*/
package org.dinky.data.vo.suggestion;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SuggestionVO implements Serializable {
private static final long serialVersionUID = 4631906403475634212L;
private Object key;
// label
private SuggestionLabelVO label;
// kind
/**
* 此字段值可选为:
* <p>
* Method = 0, // 方法
* Function = 1, // 函数
* Constructor = 2, // 构造函数
* Field = 3, // 字段
* Variable = 4, // 变量
* Class = 5, // 类
* Struct = 6, // 结构体
* Interface = 7, // 接口
* Module = 8, // 模块
* Property = 9, // 属性
* Event = 10, // 事件
* Operator = 11, // 操作符
* Unit = 12, // 单元
* Value = 13, // 值
* Constant = 14, // 常量
* Enum = 15, // 枚举
* EnumMember = 16, // 枚举成员
* Keyword = 17, // 关键字
* Text = 18, // 文本
* Color = 19, // 颜色
* File = 20, // 文件
* Reference = 21, // 引用
* Customcolor = 22, // 自定义颜色
* Folder = 23, // 文件夹
* TypeParameter = 24, // 类型参数
* User = 25, // 用户
* Issue = 26, // 问题
* Snippet = 27 // 代码片段
*/
private int kind;
// insertText
private String insertText;
// detail
private String detail;
}
/*
*
* 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.
*
*/
package org.dinky.service;
import org.dinky.data.vo.suggestion.SuggestionVO;
import java.util.Set;
public interface SuggestionService {
/**
* get suggestions for editor
* @param enableSchemaSuggestion whether enable schema suggestion
* @return suggestions list
*/
Set<SuggestionVO> getSuggestions(boolean enableSchemaSuggestion);
/**
* by keyword get suggestions list
* @param enableSchemaSuggestion whether enable schema suggestion
* @param keyWord keyword
* @return suggestions list
*/
Set<SuggestionVO> getSuggestionsByKeyWord(boolean enableSchemaSuggestion, String keyWord);
/**
* by sql statement get suggestions list
* @param enableSchemaSuggestion whether enable schema suggestion
* @param sqlStatement sql statement
* @return suggestions list
*/
Set<SuggestionVO> getSuggestionsBySqlStatement(boolean enableSchemaSuggestion, String sqlStatement, int position);
}
/*
*
* 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.
*
*/
package org.dinky.service.impl;
import org.dinky.data.model.Document;
import org.dinky.data.model.FragmentVariable;
import org.dinky.data.vo.suggestion.SuggestionLabelVO;
import org.dinky.data.vo.suggestion.SuggestionVO;
import org.dinky.service.DocumentService;
import org.dinky.service.FragmentVariableService;
import org.dinky.service.SuggestionService;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service
@RequiredArgsConstructor
@Slf4j
public class SuggestionServiceImpl implements SuggestionService {
private final DocumentService documentService;
private final FragmentVariableService fragmentVariableService;
/**
* get suggestions for editor
*
* @param enableSchemaSuggestion whether enable schema suggestion
* @return suggestions list
*/
@Override
public Set<SuggestionVO> getSuggestions(boolean enableSchemaSuggestion) {
Set<SuggestionVO> suggestionVOS = new HashSet<>();
// 1. 构建文档的建议列表
buildDocumentSuggestions(new HashSet<>(documentService.list()), suggestionVOS);
// 2. 全局变量的建议列表
buildGlobalVariableSuggestions(new HashSet<>(fragmentVariableService.listEnabledAll()), suggestionVOS);
// todo: 如果启用了schema,需要构建schema的建议列表
// 3. schema的建议列表
if (enableSchemaSuggestion) {
buildSchemaSuggestions(new HashSet<>(), suggestionVOS);
}
// 4. 自定义关键词提示
buildCustomSuggestions(new HashSet<>(), suggestionVOS);
return suggestionVOS;
}
/**
* build global variable suggestions
*
* @param fragmentVariableList fragment variable list
* @param suggestionVOS suggestion list
*/
private static void buildGlobalVariableSuggestions(
Set<FragmentVariable> fragmentVariableList, Set<SuggestionVO> suggestionVOS) {
fragmentVariableList.stream()
.map(fragmentVariable -> {
SuggestionLabelVO suggestionLabelVO = SuggestionLabelVO.builder()
.label(fragmentVariable.getName())
.detail(fragmentVariable.getNote())
.description(fragmentVariable.getNote())
.build();
return SuggestionVO.builder()
.key(fragmentVariable.getId() + "_fragmentVariable")
.label(suggestionLabelVO)
.kind(4)
.insertText(fragmentVariable.getFragmentValue())
.detail(fragmentVariable.getNote())
.build();
})
.forEach(suggestionVOS::add);
}
/**
* build schema suggestions
*
* @param buildingSchemaList schema list
* @param suggestionVOS suggestion list
*/
private static void buildSchemaSuggestions(Set<Object> buildingSchemaList, Set<SuggestionVO> suggestionVOS) {
// todo: 构建schema的建议列表 , 包含 库名 、表名、字段名、.... , 能做到根据库名点出表名,根据表名点出字段名
}
/**
* build custom suggestions
*
* @param customKeyWordList custom keyword list
* @param suggestionVOS suggestion list
*/
private static void buildCustomSuggestions(Set<Object> customKeyWordList, Set<SuggestionVO> suggestionVOS) {
// todo: 自定义关键词提示,
// 1. 此处自定义是属于 dinky 内部自定义语法关键词提示, 如果有片段, 将片段的建议列表加入到文档中进行提示
// 2. 可以加入 yml 语法的关键词提示 , 因为在集群配置中会有 yml 的配置文件写法 , 获取方式待定
}
/**
* build document suggestions
*
* @param documentList document list
* @param suggestionVOS suggestion list
*/
private static void buildDocumentSuggestions(Set<Document> documentList, Set<SuggestionVO> suggestionVOS) {
documentList.stream()
.map(document -> {
String detail =
document.getCategory() + " ->" + document.getType() + " -> " + document.getSubtype();
SuggestionLabelVO suggestionLabelVO = SuggestionLabelVO.builder()
.label(document.getName())
.detail(detail)
.description(document.getDescription())
.build();
return SuggestionVO.builder()
.key(document.getId() + "_document")
.label(suggestionLabelVO)
.insertText(document.getFillValue())
.kind(4)
.detail(detail)
.build();
})
.forEach(suggestionVOS::add);
}
/**
* by keyword get suggestions list
*
* @param enableSchemaSuggestion whether enable schema suggestion
* @param keyWord keyword
* @return suggestions list
*/
@Override
public Set<SuggestionVO> getSuggestionsByKeyWord(boolean enableSchemaSuggestion, String keyWord) {
return getSuggestions(enableSchemaSuggestion).stream()
.filter(suggestionVO -> suggestionVO.getLabel().getLabel().contains(keyWord))
.collect(Collectors.toSet());
}
/**
* by sql statement get suggestions list
*
* @param enableSchemaSuggestion whether enable schema suggestion
* @param sqlStatement sql statement
* @return suggestions list
*/
@Override
public Set<SuggestionVO> getSuggestionsBySqlStatement(
boolean enableSchemaSuggestion, String sqlStatement, int position) {
// todo: 根据传入的sql,获取建议列表, 需要和flink的sql解析器结合起来
return new HashSet<>();
}
}
......@@ -36,7 +36,7 @@ VALUES ( 2, 1, 'python-udf', 'https://github.com/zackyoungh/dinky-quickstart-pyt
INSERT INTO `dinky_resources` (`id`, `file_name`, `description`, `user_id`, `type`, `size`, `pid`, `full_name`,
`is_directory`)
VALUES (0, 'Root', 'main folder', 1, 0, 0, -1, '/', 1);
VALUES (0, 'Root', 'main folder', 1, 0, 0, -1, '', 1);
INSERT INTO `dinky_sys_menu`
......
......@@ -378,9 +378,12 @@ public class UDFUtil {
return getPythonUdfList(SystemConfiguration.getInstances().getPythonHome(), udfFile);
}
private static final String PYTHON_FUNC_FILE_MD5 =
MD5.create().digestHex(ResourceUtil.readUtf8Str("getPyFuncList.py"));
public static List<String> getPythonUdfList(String pythonPath, String udfFile) {
File checkFile = new File(PathConstant.TMP_PATH, "getPyFuncList.py");
if (!checkFile.exists()) {
if (!checkFile.exists() || !MD5.create().digestHex(checkFile).equals(PYTHON_FUNC_FILE_MD5)) {
FileUtil.writeUtf8String(ResourceUtil.readUtf8Str("getPyFuncList.py"), checkFile);
}
List<String> udfNameList = execPyAndGetUdfNameList(pythonPath, checkFile.getAbsolutePath(), udfFile);
......
/*
* 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
* 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.
*
* 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.
*/
import { Column, ISuggestions, MetaData } from '@/components/CustomEditor/CodeEdit/data';
import { Document, GlobalVar } from '@/types/RegCenter/data.d';
import { SuggestionInfo } from '@/types/Public/data';
import * as monaco from 'monaco-editor';
import { editor, languages } from 'monaco-editor';
import keyWordJsonData from './keyword.json';
// todo: get sqlMetaData from interface
const buildMetaDataSuggestions = () => {
let metaDataSuggestions: ISuggestions[] = [];
let metaData: [] = []; // temp
metaData.forEach((item: MetaData) => {
metaDataSuggestions.push({
label: item.table,
kind: monaco.languages.CompletionItemKind.Constant,
insertText: item.table,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
detail: 'FlinkSQL Connector => ' + item.connector
});
item.columns.forEach((column: Column) => {
metaDataSuggestions.push({
label: column.name,
kind: monaco.languages.CompletionItemKind.Field,
insertText: column.name,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
detail: 'Column => ' + column.type + ' from ' + item.table
});
});
});
return metaDataSuggestions;
};
// todo: get document from interface
const buildFullDocumentSuggestions = () => {
let fullDocumentSuggestions: ISuggestions[] = [];
let fillDocuments: [] = []; // temp
fillDocuments.forEach((item: Document) => {
fullDocumentSuggestions.push({
label: item.name,
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: item.fillValue,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
detail: item.description
});
});
return fullDocumentSuggestions;
};
import ITextModel = editor.ITextModel;
import ProviderResult = languages.ProviderResult;
import CompletionList = languages.CompletionList;
import CompletionItem = languages.CompletionItem;
// 导入 lodash
/**
* get keyWordJson from {@link ./keyword.json}
......@@ -72,16 +39,21 @@ const parseKeyWordJson = (type: string) => {
/**
* build keyWordJsonSuggestions from {@link ./keyword.json}
*/
const buildKeyWordJsonSuggestions = () => {
let keyWordJsonSuggestions: ISuggestions[] = [];
export const buildKeyWordJsonSuggestions = (range: monaco.Range) => {
// get all keys from keyWordJsonData
Object.keys(keyWordJsonData).forEach((key: string) => {
let keyWordJsonSuggestions: CompletionItem[] = [];
Object.keys(keyWordJsonData).map((key: string) => {
// parse data of key
const array = parseKeyWordJson(key);
// build suggestions
array.forEach((item: string) => {
return array.forEach((item: string) => {
keyWordJsonSuggestions.push({
label: item,
label: {
label: item,
detail: key + ' ' + item
},
range: range,
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: item,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
......@@ -89,34 +61,142 @@ const buildKeyWordJsonSuggestions = () => {
});
});
});
return keyWordJsonSuggestions;
};
// todo: get globalVariable from interface
const buildGlobalVariableSuggestions = () => {
let globalVariableSuggestions: ISuggestions[] = [];
let globalVariables: [] = []; // temp
globalVariables.forEach((item: GlobalVar) => {
globalVariableSuggestions.push({
label: item.name,
kind: monaco.languages.CompletionItemKind.Variable,
insertText: item.fragmentValue,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
detail: item.note
});
});
return globalVariableSuggestions;
/**
* Method = 0,
* Function = 1,
* Constructor = 2,
* Field = 3,
* Variable = 4,
* Class = 5,
* Struct = 6,
* Interface = 7,
* Module = 8,
* Property = 9,
* Event = 10,
* Operator = 11,
* Unit = 12,
* Value = 13,
* Constant = 14,
* Enum = 15,
* EnumMember = 16,
* Keyword = 17,
* Text = 18,
* Color = 19,
* File = 20,
* Reference = 21,
* Customcolor = 22,
* Folder = 23,
* TypeParameter = 24,
* User = 25,
* Issue = 26,
* Snippet = 27
* @param kind
*/
const mappingKind = (kind: number) => {
switch (kind) {
case 0:
return monaco.languages.CompletionItemKind.Method;
case 1:
return monaco.languages.CompletionItemKind.Function;
case 2:
return monaco.languages.CompletionItemKind.Constructor;
case 3:
return monaco.languages.CompletionItemKind.Field;
case 4:
return monaco.languages.CompletionItemKind.Variable;
case 5:
return monaco.languages.CompletionItemKind.Class;
case 6:
return monaco.languages.CompletionItemKind.Struct;
case 7:
return monaco.languages.CompletionItemKind.Interface;
case 8:
return monaco.languages.CompletionItemKind.Module;
case 9:
return monaco.languages.CompletionItemKind.Property;
case 10:
return monaco.languages.CompletionItemKind.Event;
case 11:
return monaco.languages.CompletionItemKind.Operator;
case 12:
return monaco.languages.CompletionItemKind.Unit;
case 13:
return monaco.languages.CompletionItemKind.Value;
case 14:
return monaco.languages.CompletionItemKind.Constant;
case 15:
return monaco.languages.CompletionItemKind.Enum;
case 16:
return monaco.languages.CompletionItemKind.EnumMember;
case 17:
return monaco.languages.CompletionItemKind.Keyword;
case 18:
return monaco.languages.CompletionItemKind.Text;
case 19:
return monaco.languages.CompletionItemKind.Color;
case 20:
return monaco.languages.CompletionItemKind.File;
case 21:
return monaco.languages.CompletionItemKind.Reference;
case 22:
return monaco.languages.CompletionItemKind.Customcolor;
case 23:
return monaco.languages.CompletionItemKind.Folder;
case 24:
return monaco.languages.CompletionItemKind.TypeParameter;
case 25:
return monaco.languages.CompletionItemKind.User;
case 26:
return monaco.languages.CompletionItemKind.Issue;
case 27:
return monaco.languages.CompletionItemKind.Snippet;
default:
return monaco.languages.CompletionItemKind.Keyword;
}
};
/**
* build all suggestions
* build all suggestions to editor
* @param model ITextModel
* @param position monaco.Position
* @param suggestionsData SuggestionInfo[]
* @returns ProviderResult<CompletionList>
*/
export const buildAllSuggestions = () => {
let suggestions: ISuggestions[] = [];
suggestions = suggestions
.concat(buildMetaDataSuggestions()) // concat metaDataSuggestions
.concat(buildFullDocumentSuggestions()) // concat fullDocumentSuggestions
.concat(buildGlobalVariableSuggestions()) // concat globalVariableSuggestions
.concat(buildKeyWordJsonSuggestions()); // concat keyWordJsonSuggestions
return suggestions;
export const buildAllSuggestionsToEditor = (
model: ITextModel,
position: monaco.Position,
suggestionsData: SuggestionInfo[]
): ProviderResult<CompletionList> => {
const valueRange = model.getWordUntilPosition(position); //get inout word range
// get range
const range = new monaco.Range(
position.lineNumber,
valueRange.startColumn,
position.lineNumber,
valueRange.endColumn
);
const subgraphOptions: CompletionItem[] = suggestionsData.map((item) => {
return {
key: item.key,
label: {
label: item.label.label,
// detail: item.label?.detail ?? '',
description: item.label?.description ?? ''
},
range: range,
kind: mappingKind(item.kind),
insertText: item.insertText,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
// detail: item?.detail,
};
});
//todo: 补充补全建议 关键词建议
return {
suggestions: subgraphOptions
};
};
......@@ -18,13 +18,24 @@
*/
import * as monaco from 'monaco-editor';
import { editor, languages, Position } from 'monaco-editor';
import { buildAllSuggestionsToEditor } from '@/components/CustomEditor/CodeEdit/function';
import EditorFloatBtn from '@/components/CustomEditor/EditorFloatBtn';
import { StateType } from '@/pages/DataStudio/model';
import { MonacoEditorOptions } from '@/types/Public/data';
import { convertCodeEditTheme } from '@/utils/function';
import { Editor, OnChange } from '@monaco-editor/react';
import { editor } from 'monaco-editor';
import { useState } from 'react';
import { Editor, Monaco, OnChange } from '@monaco-editor/react';
import { connect } from '@umijs/max';
import useMemoCallback from 'rc-menu/es/hooks/useMemoCallback';
import { memo, useCallback, useRef } from 'react';
import ITextModel = editor.ITextModel;
import CompletionItem = languages.CompletionItem;
import CompletionContext = languages.CompletionContext;
let provider = {
dispose: () => {}
};
export type CodeEditFormProps = {
height?: string;
......@@ -38,11 +49,13 @@ export type CodeEditFormProps = {
theme?: string;
autoWrap?: string;
showFloatButton?: boolean;
editorDidMount?: (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;
enableSuggestions?: boolean;
monacoRef?: any;
editorRef?: any;
};
const CodeEdit = (props: CodeEditFormProps) => {
const [editorRef, setEditorRef] = useState<any>();
const CodeEdit = (props: CodeEditFormProps & connect) => {
/**
* 1. height: edit height
* 2. width: edit width
......@@ -67,54 +80,118 @@ const CodeEdit = (props: CodeEditFormProps) => {
code, // content
readOnly = false, // is readOnly
lineNumbers, // show lineNumbers
theme, // edit theme
enableSuggestions = false, // enable suggestions
suggestionsData, // suggestions data
autoWrap = 'on', // auto wrap
showFloatButton = false
showFloatButton = false,
editorDidMount,
editorRef,
monacoRef,
tabs: { activeKey }
} = props;
const editorInstance = useRef<editor.IStandaloneCodeEditor | any>(editorRef);
const monacoInstance = useRef<Monaco | any>(monacoRef);
const { ScrollType } = editor;
// todo: 已知 bug , 切换 tab 时 , 会造成buildAllSuggestions 的重复调用 , 造成建议项重复 ,但不影响原有数据, 编辑器会将建议项自动缓存,不会进行去重
/**
* build all suggestions
*/
const buildAllSuggestions = (model: ITextModel, position: monaco.Position) => {
return buildAllSuggestionsToEditor(model, position, suggestionsData);
};
const buildAllSuggestionsCallback = useCallback(
async (model: ITextModel, position: monaco.Position) => {
return buildAllSuggestions(model, position);
},
[code, activeKey]
);
// memo
const memoizedBuildAllSuggestionsCallback = useMemoCallback(buildAllSuggestionsCallback);
function reloadCompilation(monacoIns: Monaco) {
provider = monacoIns.languages.registerCompletionItemProvider(language, {
provideCompletionItems: (
model: editor.ITextModel,
position: Position,
context: CompletionContext
) => {
const allSuggestions = memoizedBuildAllSuggestionsCallback(model, position);
context.triggerKind =
monacoIns.languages.CompletionTriggerKind.TriggerForIncompleteCompletions;
return allSuggestions;
},
resolveCompletionItem: (item: CompletionItem) => {
return {
...item,
detail: item.detail ?? `-- ${item.detail}`
};
}
});
}
/**
* editorDidMount
* @param {editor.IStandaloneCodeEditor} editor
* @param monaco
*/
const editorDidMount = (editor: editor.IStandaloneCodeEditor) => {
setEditorRef(editor);
const editorDidMountChange = (editor: editor.IStandaloneCodeEditor, monacoIns: Monaco) => {
if (editorRef?.current && monacoRef?.current && editorDidMount) {
editorDidMount(editor, monacoIns);
}
editorInstance.current = editor;
monacoInstance.current = monacoIns;
if (enableSuggestions) {
reloadCompilation(monacoIns);
}
// register TypeScript language service
monacoIns.languages.register({
id: language || 'typescript'
});
editor.layout();
editor.focus();
};
/**
* handle scroll to top
*/
const handleBackTop = () => {
editorRef.revealLine(1);
editorInstance?.current?.revealLine(1);
};
/**
* handle scroll to bottom
*/
const handleBackBottom = () => {
editorRef.revealLine(editorRef.getModel().getLineCount());
editorInstance?.current?.revealLine(editorInstance?.current?.getModel()?.getLineCount());
};
/**
* handle scroll to down
*/
const handleDownScroll = () => {
editorRef.setScrollPosition({ scrollTop: editorRef.getScrollTop() + 500 }, ScrollType.Smooth);
editorInstance?.current?.setScrollPosition(
{ scrollTop: editorInstance?.current?.getScrollTop() + 500 },
ScrollType.Smooth
);
};
/**
* handle scroll to up
*/
const handleUpScroll = () => {
editorRef?.setScrollPosition({ scrollTop: editorRef.getScrollTop() - 500 }, ScrollType.Smooth);
editorInstance?.current?.setScrollPosition(
{ scrollTop: editorInstance?.current?.getScrollTop() - 500 },
ScrollType.Smooth
);
};
// register TypeScript language service
monaco.languages.register({
id: language || 'typescript'
});
// todo: 标记错误信息
const restEditBtnProps = {
handleBackTop,
......@@ -123,6 +200,83 @@ const CodeEdit = (props: CodeEditFormProps) => {
handleDownScroll
};
const finalEditorOptions = {
...options,
tabCompletion: 'on', // tab 补全
cursorSmoothCaretAnimation: true, // 光标动画
screenReaderAnnounceInlineSuggestion: true, // 屏幕阅读器提示
formatOnPaste: true, // 粘贴时格式化
mouseWheelZoom: true, // 鼠标滚轮缩放
autoClosingBrackets: 'always', // 自动闭合括号
autoClosingOvertype: 'always', // 用于在右引号或括号上键入的选项
autoClosingQuotes: 'always', // 自动闭合引号
showUnused: true, // 显示未使用的代码
unfoldOnClickAfterEndOfLine: true, // 控制在折叠线之后单击空内容是否会展开该线
showFoldingControls: 'always', // 代码折叠控件 'always' | 'mouseover' | 'never'
automaticLayout: true, // 自动布局
readOnly, // 是否只读
wrappingIndent:
language === 'yaml' || language === 'yml' || language === 'json' ? 'indent' : 'none',
inlineSuggest: {
enabled: true,
showToolbar: 'always',
keepOnBlur: false,
allowQuickSuggestions: true,
showOnAllSymbols: true
},
inlineSuggestionVisible: true,
quickSuggestions: true,
guides: {
bracketPairs: true
},
bracketPairColorization: {
enabled: true,
independentColorPoolPerBracketType: true
},
foldingRanges: true,
inlineCompletionsAccessibilityVerbose: true,
suggest: {
shareSuggestSelections: true,
quickSuggestions: true,
showStatusBar: true,
preview: true,
previewMode: 'preview',
showInlineDetails: true,
showMethods: true,
showFunctions: true,
showConstructors: true,
showFields: true,
showEvents: true,
showOperators: true,
showClasses: true,
showModules: true,
showStructs: true,
showInterfaces: true,
showProperties: true,
showUnits: true,
showValues: true,
showConstants: true,
showEnums: true,
showEnumMembers: true,
showKeywords: true,
showWords: true,
showFolders: true,
showReferences: true,
showSnippets: true
},
scrollbar: {
useShadows: false,
vertical: 'visible',
horizontal: 'visible',
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
},
wordWrap: autoWrap,
autoDetectHighContrast: true,
lineNumbers
};
return (
<>
<div className={'monaco-float'}>
......@@ -131,15 +285,9 @@ const CodeEdit = (props: CodeEditFormProps) => {
height={height}
value={code}
language={language}
options={{
...options,
readOnly,
wordWrap: autoWrap,
autoDetectHighContrast: true,
lineNumbers
}}
options={finalEditorOptions}
className={'editor-develop'}
onMount={editorDidMount}
onMount={editorDidMountChange}
onChange={onChange}
theme={convertCodeEditTheme()}
/>
......@@ -149,4 +297,7 @@ const CodeEdit = (props: CodeEditFormProps) => {
);
};
export default CodeEdit;
export default connect(({ Studio }: { Studio: StateType }) => ({
suggestionsData: Studio.suggestions,
tabs: Studio.tabs
}))(memo(CodeEdit));
......@@ -19,14 +19,13 @@
import EditorFloatBtn from '@/components/CustomEditor/EditorFloatBtn';
import { LogLanguage } from '@/components/CustomEditor/languages/javalog';
import useThemeValue from '@/hooks/useThemeValue';
import { Loading } from '@/pages/Other/Loading';
import { MonacoEditorOptions } from '@/types/Public/data';
import { convertCodeEditTheme } from '@/utils/function';
import { Editor, useMonaco } from '@monaco-editor/react';
import { editor } from 'monaco-editor';
import { EditorLanguage } from 'monaco-editor/esm/metadata';
import { CSSProperties, useEffect, useState } from 'react';
import { CSSProperties, useEffect, useRef, useState } from 'react';
import FullscreenBtn from '../FullscreenBtn';
// loader.config({monaco});
......@@ -86,9 +85,8 @@ const CodeShow = (props: CodeShowFormProps) => {
const [stopping, setStopping] = useState<boolean>(false);
const [autoRefresh, setAutoRefresh] = useState<boolean>(false);
const [fullScreen, setFullScreen] = useState<boolean>(false);
const [editorRef, setEditorRef] = useState<any>();
const editorInstance = useRef<editor.IStandaloneCodeEditor | any>();
const [timer, setTimer] = useState<NodeJS.Timer>();
const themeValue = useThemeValue();
// 使用编辑器钩子, 拿到编辑器实例
const monaco = useMonaco();
......@@ -138,28 +136,34 @@ const CodeShow = (props: CodeShowFormProps) => {
* handle scroll to top
*/
const handleBackTop = () => {
editorRef.revealLine(1);
editorInstance?.current?.revealLine(1);
};
/**
* handle scroll to bottom
*/
const handleBackBottom = () => {
editorRef.revealLine(editorRef.getModel().getLineCount());
editorInstance?.current?.revealLine(editorInstance?.current?.getModel().getLineCount());
};
/**
* handle scroll to down
*/
const handleDownScroll = () => {
editorRef.setScrollPosition({ scrollTop: editorRef.getScrollTop() + 500 }, ScrollType.Smooth);
editorInstance?.current?.setScrollPosition(
{ scrollTop: editorInstance?.current?.getScrollTop() + 500 },
ScrollType.Smooth
);
};
/**
* handle scroll to up
*/
const handleUpScroll = () => {
editorRef?.setScrollPosition({ scrollTop: editorRef.getScrollTop() - 500 }, ScrollType.Smooth);
editorInstance?.current?.setScrollPosition(
{ scrollTop: editorInstance?.current?.getScrollTop() - 500 },
ScrollType.Smooth
);
};
/**
......@@ -167,7 +171,7 @@ const CodeShow = (props: CodeShowFormProps) => {
* @param {editor.IStandaloneCodeEditor} editor
*/
const editorDidMount = (editor: editor.IStandaloneCodeEditor) => {
setEditorRef(editor);
editorInstance.current = editor;
editor.layout();
editor.focus();
if (scrollBeyondLastLine) {
......
......@@ -471,12 +471,12 @@ export const LogSvg = () => {
xmlns='http://www.w3.org/2000/svg'
>
<path
d='M704 64c35.328 0 64 28.672 64 64v321.7408A288 288 0 0 0 496.5376 896H128c-35.328 0-64-28.672-64-64V128c0-35.328 28.672-64 64-64h576zM480 384h-256a32 32 0 0 0-31.488 26.2656l-0.512 5.7344v32c0 15.7184 11.3152 28.7744 26.2656 31.488l5.7344 0.512h256a32 32 0 0 0 31.488-26.2656L512 448v-32a32 32 0 0 0-26.2656-31.488l-5.7344-0.512z m128-192h-384a32 32 0 0 0-31.488 26.2656l-0.512 5.7344V256c0 15.7184 11.3152 28.7744 26.2656 31.488l5.7344 0.512h384a32 32 0 0 0 31.488-26.2656L640 256v-32a32 32 0 0 0-26.2656-31.488l-5.7344-0.512z'
fill='#007AF5'
d='M109.7 697c40.2-24.1 115.8-36.2 226.6-36.2 77.9 0 168.5 42.8 335.4 70.6 83.9 14 164.8 14 242.6 0l-22.4 208-782.2 11.4V697z m782.2-104.2c-40.4 0-73.1-32.7-73.1-73.1s32.7-73.1 73.1-73.1 73.1 32.7 73.1 73.1-32.7 73.1-73.1 73.1z'
fill='#66CCFF'
></path>
<path
d='M736 512a224 224 0 1 1 0 448 224 224 0 0 1 0-448z m0 80.0256a32 32 0 0 0-31.488 26.2144l-0.512 5.7856v128l0.512 5.7344a32.0512 32.0512 0 0 0 25.7536 25.7024l5.7344 0.512h128l5.7344-0.512a32.0512 32.0512 0 0 0 25.7536-25.7024l0.512-5.7856-0.512-5.7344a32.0512 32.0512 0 0 0-25.7536-25.7024l-5.7344-0.512H768v-96.0512l-0.512-5.7344a32 32 0 0 0-31.488-26.2144z'
fill='#66AFF9'
d='M71.7 688.9V324.5H64c-15.1 0-27.4-12.3-27.4-27.4 0-15.1 12.3-27.4 27.4-27.4h7.7V139c0-51.5 41.8-93.3 93.3-93.3h672.9c51.5 0 93.3 41.8 93.3 93.3v309.6h-54.9V139c0-21.2-17.2-38.4-38.4-38.4h-673c-21.2 0-38.4 17.2-38.4 38.4v130.7h7.7c15.1 0 27.4 12.3 27.4 27.4 0 15.1-12.3 27.4-27.4 27.4h-7.7v364.3h7.7c15.1 0 27.4 12.3 27.4 27.4 0 15.1-12.3 27.4-27.4 27.4h-7.7V885c0 21.2 17.2 38.4 38.4 38.4h672.9c21.2 0 38.4-17.2 38.4-38.4V558.8h54.9V885c0 51.5-41.8 93.3-93.3 93.3H164.9c-51.5 0-93.3-41.8-93.3-93.3V743.7H64c-15.1 0-27.4-12.3-27.4-27.4 0-15.1 12.3-27.4 27.4-27.4h7.7z m211.7-396.3h384c15.1 0 27.4 12.3 27.4 27.4s-12.3 27.4-27.4 27.4h-384c-15.1 0-27.4-12.3-27.4-27.4s12.3-27.4 27.4-27.4z m0 182.8h384c15.1 0 27.4 12.3 27.4 27.4 0 15.1-12.3 27.4-27.4 27.4h-384c-15.1 0-27.4-12.3-27.4-27.4 0-15.1 12.3-27.4 27.4-27.4zM896 594.3c-50.5 0-91.4-40.9-91.4-91.4s40.9-91.4 91.4-91.4 91.4 40.9 91.4 91.4-40.9 91.4-91.4 91.4z m0-36.6c30.3 0 54.9-24.6 54.9-54.9S926.3 448 896 448s-54.9 24.6-54.9 54.9 24.6 54.8 54.9 54.8z'
fill='#4E5F80'
></path>
</svg>
)}
......
......@@ -281,6 +281,7 @@ ol {
align-items: center;
justify-content: space-between;
height: 100%;
box-shadow: 0 0 2px 1px rgba(171, 165, 165, 0.32);
.float-button {
position: absolute;
......
/*
*
* 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.
*
*/
import {
createContext,
Dispatch,
......@@ -19,7 +38,7 @@ export const FullScreenContext = createContext<FullScreenContextProps>(
{} as FullScreenContextProps
);
export const FullScreenProvider: FC = memo(({ children }) => {
export const FullScreenProvider: FC = memo(({ children }: any) => {
const [fullscreen, setFullscreen] = useState<boolean>(false);
const { initialState, setInitialState } = useModel('@@initialState');
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
......@@ -41,7 +41,7 @@ type PermissionsFormProps = {
*/
const CodeEditProps = {
height: '25vh',
lineNumbers: 'off'
lineNumbers: 'on'
};
const PermissionsForm: React.FC<PermissionsFormProps> = (props) => {
......@@ -99,9 +99,7 @@ const PermissionsForm: React.FC<PermissionsFormProps> = (props) => {
]}
>
<CodeEdit
onChange={(value) => {
setExpression(value ?? '');
}}
onChange={setExpression}
code={expression}
language={'sql'}
{...CodeEditProps}
......
......@@ -17,6 +17,7 @@
*
*/
import CodeEdit from '@/components/CustomEditor/CodeEdit';
import { useEditor } from '@/hooks/useEditor';
import { getCurrentTab } from '@/pages/DataStudio/function';
import { TASK_VAR_FILTER } from '@/pages/DataStudio/MiddleContainer/Editor/constants';
......@@ -25,18 +26,18 @@ import {
DataStudioTabsItemType,
StateType,
STUDIO_MODEL,
STUDIO_MODEL_ASYNC,
TaskDataType
} from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import { API_CONSTANTS } from '@/services/endpoints';
import { convertCodeEditTheme } from '@/utils/function';
import { l } from '@/utils/intl';
import { connect, useRequest } from '@@/exports';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { Editor } from '@monaco-editor/react';
import { Monaco } from '@monaco-editor/react';
import { Button, Spin } from 'antd';
import { editor, KeyCode, KeyMod } from 'monaco-editor';
import React, { useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { format } from 'sql-formatter';
export type EditorProps = {
......@@ -52,10 +53,20 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
height
} = props;
useEffect(() => {
dispatch({
type: STUDIO_MODEL_ASYNC.querySuggestions,
payload: {
enableSchemaSuggestions: false
}
});
}, []);
const [isModalOpen, setIsModalOpen] = useState(false);
const [diff, setDiff] = useState<any>([]);
const { fullscreen, setFullscreen } = useEditor();
const [editorIns, setEditorIns] = useState<editor.IStandaloneCodeEditor>(null);
const editorInstance = useRef<editor.IStandaloneCodeEditor | any>();
const monacoInstance = useRef<Monaco | any>();
const currentTab = getCurrentTab(panes, activeKey) as DataStudioTabsItemType;
const currentData = currentTab.params.taskData;
......@@ -96,6 +107,40 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
setIsModalOpen(false);
};
const editorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => {
editor.layout();
editor.focus();
monacoInstance.current = monaco;
editorInstance.current = editor;
editor.onDidChangeCursorPosition((e) => {
props.footContainer.codePosition = [e.position.lineNumber, e.position.column];
dispatch({
type: STUDIO_MODEL.saveFooterValue,
payload: { ...props.footContainer }
});
});
editor.addCommand(KeyMod.Alt | KeyCode.Digit3, () => {
editor?.trigger('anyString', 'editor.action.formatDocument', '');
editor.setValue(format(editor.getValue()));
});
};
const handleEditChange = (v: string | undefined) => {
if (!currentData || !currentTab) {
return;
}
if (typeof v === 'string') {
currentData.statement = v;
}
currentTab.isModified = true;
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: { ...props.tabs }
});
};
return (
<Spin spinning={loading} delay={600}>
<div style={{ width: '100%', height: fullscreen ? 'calc(100vh - 50px)' : height }}>
......@@ -105,78 +150,39 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
fileName={currentData?.name}
onUse={upDateTask}
/>
<Editor
value={currentTab?.params?.taskData?.statement}
<CodeEdit
monacoRef={monacoInstance}
editorRef={editorInstance}
code={currentTab?.params?.taskData?.statement}
language={'sql'}
editorDidMount={editorDidMount}
onChange={handleEditChange}
enableSuggestions={true}
options={{
readOnlyMessage: { value: l('pages.datastudio.editor.onlyread') },
readOnly: currentData?.step == JOB_LIFE_CYCLE.PUBLISH,
scrollBeyondLastLine: false,
wordWrap: 'on',
autoDetectHighContrast: true,
scrollbar: {
// Subtle shadows to the left & top. Defaults to true.
useShadows: false,
// Defaults to 'auto'
vertical: 'visible',
// Defaults to 'auto'
horizontal: 'visible',
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
},
automaticLayout: true
wordWrap: 'on'
}}
className={'editor-develop'}
onMount={(editor: editor.IStandaloneCodeEditor) => {
editor.layout();
editor.focus();
editor.onDidChangeCursorPosition((e) => {
props.footContainer.codePosition = [e.position.lineNumber, e.position.column];
dispatch({
type: STUDIO_MODEL.saveFooterValue,
payload: { ...props.footContainer }
});
});
editor.addCommand(KeyMod.Alt | KeyCode.Digit3, () => {
editor?.trigger('anyString', 'editor.action.formatDocument');
editor.setValue(format(editor.getValue()));
});
setEditorIns(editor);
}}
onChange={(v) => {
if (!currentData || !currentTab) {
return;
}
if (typeof v === 'string') {
currentData.statement = v;
}
currentTab.isModified = true;
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: { ...props.tabs }
});
}}
theme={convertCodeEditTheme()}
></Editor>
/>
<div
style={{
position: 'absolute',
top: 20,
right: '7%'
top: 15,
right: '10%',
boxShadow: '0 0 10px #ccc'
}}
>
{fullscreen ? (
<Button
type='text'
style={{
color: '#fff'
zIndex: 999
}}
title={l('global.fullScreen.exit')}
icon={<FullscreenExitOutlined />}
onClick={() => {
editorIns.layout();
editorInstance?.current?.layout();
setFullscreen(false);
}}
/>
......@@ -184,11 +190,12 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
<Button
type='text'
style={{
color: '#fff'
zIndex: 999
}}
title={l('global.fullScreen')}
icon={<FullscreenOutlined />}
onClick={() => {
editorIns.layout();
editorInstance?.current?.layout();
setFullscreen(true);
}}
/>
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
......@@ -27,12 +27,12 @@ export const KEY_BOARD_MIDDLE = [
},
{
key: 'alt2',
label: 'Alt + 2',
label: 'Alt / Option + 2',
description: l('shortcut.key.check')
},
{
key: 'alt3',
label: 'Alt + 3',
label: 'Alt / Option + 3',
description: l('shortcut.key.beautify')
}
// {
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
import { queryDataByParams } from '@/services/BusinessCrud';
import { getDataByParams, queryDataByParams } from '@/services/BusinessCrud';
export function getSessionData() {
return queryDataByParams('api/cluster/listSessionEnable');
......@@ -32,3 +32,7 @@ export function getClusterConfigurationData() {
export function getFlinkConfigs() {
return queryDataByParams('/api/flinkConf/configOptions');
}
export function querySuggessionData(params: any) {
return getDataByParams('/api/suggestion/queryAllSuggestions', params);
}
......@@ -19,8 +19,12 @@
import { getFooterValue, isDataStudioTabsItemType } from '@/pages/DataStudio/function';
import { getTaskData } from '@/pages/DataStudio/LeftContainer/Project/service';
import { getFlinkConfigs } from '@/pages/DataStudio/RightContainer/JobConfig/service';
import {
getFlinkConfigs,
querySuggessionData
} from '@/pages/DataStudio/RightContainer/JobConfig/service';
import { QueryParams } from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import { SuggestionInfo } from '@/types/Public/data';
import { Cluster, DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { createModelTypes } from '@/utils/modelUtils';
......@@ -284,6 +288,7 @@ export type StateType = {
tabs: TabsType;
bottomContainerContent: BottomContainerContent;
footContainer: FooterType;
suggestions: SuggestionInfo[];
};
export type ModelType = {
......@@ -292,6 +297,7 @@ export type ModelType = {
effects: {
queryProject: Effect;
queryFlinkConfigOptions: Effect;
querySuggestions: Effect;
};
reducers: {
updateToolContentHeight: Reducer<StateType>;
......@@ -324,6 +330,7 @@ export type ModelType = {
saveFooterValue: Reducer<StateType>;
updateJobRunningMsg: Reducer<StateType>;
saveFlinkConfigOptions: Reducer<StateType>;
updateSuggestions: Reducer<StateType>;
};
};
......@@ -387,7 +394,8 @@ const Model: ModelType = {
jobState: '',
runningLog: ''
}
}
},
suggestions: []
},
effects: {
*queryProject({ payload }, { call, put }) {
......@@ -403,6 +411,13 @@ const Model: ModelType = {
type: 'saveFlinkConfigOptions',
payload: response
});
},
*querySuggestions({ payload }, { call, put }) {
const response: SuggestionInfo[] = yield call(querySuggessionData, payload);
yield put({
type: 'updateSuggestions',
payload: response
});
}
},
reducers: {
......@@ -829,6 +844,12 @@ const Model: ModelType = {
jobRunningMsg: payload
}
};
},
updateSuggestions(state, { payload }) {
return {
...state,
suggestions: payload
};
}
}
};
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
......
/*
* 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
* 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.
*
* 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.
*/
import CodeEdit from '@/components/CustomEditor/CodeEdit';
......@@ -153,7 +155,7 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkConfigChange(value ?? '')}
onChange={flinkConfigChange}
code={values.flinkConfig || ''}
/>
</ProForm.Item>
......@@ -165,7 +167,7 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
>
<CodeEdit
{...CodeEditProps}
onChange={(value) => flinkTemplateChange(value ?? '')}
onChange={flinkTemplateChange}
code={values.flinkTemplate || ''}
/>
</ProForm.Item>
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
......@@ -133,9 +133,10 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
rules={[{ required: true, message: l('rc.doc.fillValueHelp') }]}
>
<CodeEdit
onChange={(value) => handleFillValueChange(value ?? '')}
onChange={handleFillValueChange}
code={codeFillValue}
language={'sql'}
enableSuggestions={false}
{...CodeEditProps}
/>
</ProFormItem>
......
......@@ -186,7 +186,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
type={'primary'}
danger
hidden={!onReTry}
disabled={onReTry && Number(steps[currentStep]?.status) !== 2}
disabled={steps[currentStep - 1]?.status !== 'error'}
onClick={() => handleReTry()}
>
{l('button.retry')}
......@@ -196,6 +196,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
type={'dashed'}
hidden={showLog}
loading={currentStep !== steps.length && percent !== 99}
disabled={onReTry && steps[currentStep - 1]?.status === 'error'}
onClick={() => onRebuild()}
>
{l('button.rebuild')}
......@@ -203,6 +204,8 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
<Button
key={'finish'}
type={showLog ? 'default' : 'primary'}
danger={showLog}
disabled={steps[currentStep - 1]?.status === 'error' && percent !== 99}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => handleCancel()}
>
......
/*
* 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
* 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.
*
* 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.
*/
import FadeIn from '@/components/Animation/FadeIn';
......@@ -26,7 +28,6 @@ import {
ResourceIcon
} from '@/components/Icons/CustomIcons';
import { TagAlignCenter } from '@/components/StyledComponents';
import { useAccess } from '@/hooks/useAccess';
import { SettingConfigKeyEnum } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/constants';
import { DSConfig } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/DSConfig';
import { EnvConfig } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/EnvConfig';
......@@ -46,8 +47,6 @@ const imgSize = 25;
const SettingOverView = () => {
const [activeKey, setActiveKey] = useState(SettingConfigKeyEnum.DINKY);
const [tags, setTags] = useState([]);
const access = useAccess();
const [data, setData] = useState<Settings>({
dolphinscheduler: [],
......@@ -198,12 +197,20 @@ const SettingOverView = () => {
<div style={{ paddingBottom: '20px' }}>
<ProCard
ghost
bodyStyle={{ height: '80vh' }}
className={'schemaTree'}
size='small'
bordered
tabs={{
activeKey: activeKey,
type: 'card',
cardProps: {
hoverable: true,
bodyStyle: {
height: parent.innerHeight - 155
},
boxShadow: true
},
animated: true,
onChange: (key: any) => setActiveKey(key),
// todo: 目前无法通过这种方式进行权限显示 多 Tag 的方式,待实现
......
/*
* 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
* 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.
*
* 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.
*/
import CodeShow, { CodeShowFormProps } from '@/components/CustomEditor/CodeShow';
......@@ -21,7 +23,7 @@ import { Empty } from 'antd';
import React from 'react';
const CodeEditProps: any = {
height: '82vh',
height: '100%',
width: '100%',
lineNumbers: 'on',
language: 'java'
......
/*
*
* 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
* 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
* 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.
* 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.
*
*/
......@@ -42,11 +42,11 @@ export const buildLogInfoTreeData = (data: LogInfo[]): any =>
name: item.name,
parentId: item.parentId,
label: item.path,
icon: item.leaf && renderIcon(item.name, '.', item.leaf),
icon: renderIcon(item.name, '.', item.leaf),
path: item.path,
title: buildTitleLabel(item),
fullInfo: item,
key: item.id,
key: item.id ?? item.name,
id: item.id,
children: buildLogInfoTreeData(item.children)
};
......
/*
* 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
* 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.
*
* 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.
*/
import LogsShow from '@/pages/SettingCenter/SystemLogs/TagInfo/LogList/LogsShow';
......@@ -62,12 +64,19 @@ const LogList = () => {
return (
<>
<ProCard ghost bordered>
<ProCard ghost hoverable bordered colSpan={'18%'} className={'siderTree'}>
<ProCard bodyStyle={{ height: parent.innerHeight - 160 }} ghost bordered>
<ProCard
ghost
bodyStyle={{ height: parent.innerHeight - 160 }}
hoverable
bordered
colSpan={'18%'}
className={'siderTree'}
>
<LogsTree treeData={treeData} onNodeClick={(info: any) => handleNodeClick(info)} />
</ProCard>
<ProCard.Divider type={'vertical'} />
<ProCard ghost hoverable bordered>
<ProCard ghost bodyStyle={{ height: parent.innerHeight - 175 }} hoverable bordered>
<LogsShow code={log} refreshLogCallback={() => refreshLogByClickNode()} />
</ProCard>
</ProCard>
......
/*
* 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
* 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.
*
* 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.
*/
import { LogSvg } from '@/components/Icons/CodeLanguageIcon';
......@@ -74,6 +76,7 @@ const TagInfo = () => {
size='small'
bordered
tabs={{
size: 'small',
activeKey: activeKey,
type: 'card',
animated: true,
......
/*
* 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
* 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.
*
* 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.
*/
/**
* theme of nav
*/
export const THEME = {
NAV_THEME: 'navTheme',
dark: 'realDark',
......@@ -54,3 +53,17 @@ export type ExcludeNameAndEnableColumns = {
createTime: Date;
updateTime: Date;
};
export type SuggestionLabel = {
label: string;
detail?: string;
description?: string;
};
export type SuggestionInfo = {
key: string | number;
label: SuggestionLabel;
kind: number;
insertText: string;
detail?: string;
};
......@@ -31,8 +31,8 @@ CREATE TABLE `dinky_alert_group` (
`alert_instance_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'Alert instance IDS',
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'note',
`enabled` tinyint(4) NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `alert_group_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Alert group' ROW_FORMAT = Dynamic;
......@@ -54,8 +54,8 @@ CREATE TABLE `dinky_alert_history` (
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'content description',
`status` int(11) NULL DEFAULT NULL COMMENT 'alert status',
`log` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'log',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Alert history' ROW_FORMAT = Dynamic;
......@@ -74,8 +74,8 @@ CREATE TABLE `dinky_alert_instance` (
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'alert instance type such as: DingTalk,Wechat(Webhook,app) Feishu ,email',
`params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'configuration',
`enabled` tinyint(4) NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `alert_instance_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Alert instance' ROW_FORMAT = Dynamic;
......@@ -97,8 +97,8 @@ CREATE TABLE `dinky_catalogue` (
`parent_id` int(11) NOT NULL DEFAULT 0 COMMENT 'parent ID',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
`is_leaf` tinyint(1) NOT NULL COMMENT 'is leaf node',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `catalogue_un_idx1`(`name`, `parent_id`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'catalogue' ROW_FORMAT = Dynamic;
......@@ -126,8 +126,8 @@ CREATE TABLE `dinky_cluster` (
`cluster_configuration_id` int(11) NULL DEFAULT NULL COMMENT 'cluster configuration id',
`task_id` int(11) NULL DEFAULT NULL COMMENT 'task ID',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `cluster_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'cluster instance management' ROW_FORMAT = Dynamic;
......@@ -149,8 +149,8 @@ CREATE TABLE `dinky_cluster_configuration` (
`is_available` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is available',
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'note',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `cluster_configuration_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'cluster configuration management' ROW_FORMAT = Dynamic;
......@@ -182,8 +182,8 @@ CREATE TABLE `dinky_database` (
`health_time` datetime(0) NULL DEFAULT NULL COMMENT 'last heartbeat time of trigger',
`heartbeat_time` datetime(0) NULL DEFAULT NULL COMMENT 'last heartbeat time',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `database_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'database management' ROW_FORMAT = Dynamic;
......@@ -207,14 +207,15 @@ CREATE TABLE `dinky_flink_document` (
`version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'document version such as:(flink1.12,flink1.13,flink1.14,flink1.15)',
`like_num` int(11) NULL DEFAULT 0 COMMENT 'like number',
`enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update_time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'flink document management' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dinky_flink_document
-- ----------------------------
begin ;
insert into `dinky_flink_document` values (1, 'Variable', '优化参数', 'Batch/Streaming', 'set table.exec.async-lookup.buffer-capacity', '异步查找连接可以触发的最大异步操作的操作数。
The max number of async i/o operation that the async lookup join can trigger.', 'Set ''table.exec.async-lookup.buffer-capacity''=''100'';', '1.14', 0, 1, '2022-01-20 15:00:00', '2022-01-20 15:00:00');
insert into `dinky_flink_document` values (2, 'Variable', '优化参数', 'Batch/Streaming', 'set table.exec.async-lookup.timeout', '异步操作完成的超时时间。
......@@ -1035,6 +1036,8 @@ WITH (
)
AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;', 'All Versions', 0, 1, '2023-10-31 16:41:46', '2023-10-31 16:43:29');
commit ;
-- ----------------------------
-- Table structure for dinky_fragment
-- ----------------------------
......@@ -1046,8 +1049,8 @@ CREATE TABLE `dinky_fragment` (
`fragment_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'fragment value',
`note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'note',
`enabled` tinyint(4) NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `fragment_un_idx1`(`name`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'fragment management' ROW_FORMAT = Dynamic;
......@@ -1103,7 +1106,7 @@ CREATE TABLE `dinky_job_history` (
`config_json` json NULL COMMENT 'configuration',
`cluster_json` json NULL COMMENT 'cluster instance configuration',
`cluster_configuration_json` json NULL COMMENT 'cluster config',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Job history details' ROW_FORMAT = Dynamic;
......@@ -1125,8 +1128,8 @@ CREATE TABLE `dinky_job_instance` (
`jid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Flink JobId',
`status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'job instance status',
`history_id` int(11) NULL DEFAULT NULL COMMENT 'execution history ID',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`finish_time` datetime(0) NULL DEFAULT NULL COMMENT 'finish time',
`duration` bigint(20) NULL DEFAULT NULL COMMENT 'job duration',
`error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'error logs',
......@@ -1151,8 +1154,8 @@ CREATE TABLE `dinky_role` (
`role_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'role name',
`is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'note',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `role_un_idx1`(`role_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'role' ROW_FORMAT = Dynamic;
......@@ -1174,7 +1177,7 @@ CREATE TABLE `dinky_savepoints` (
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'task name',
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'savepoint type',
`path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'savepoint path',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'job savepoint management' ROW_FORMAT = Dynamic;
......@@ -1190,8 +1193,8 @@ CREATE TABLE `dinky_sys_config` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'configuration name',
`value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'configuration value',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'system configuration' ROW_FORMAT = Dynamic;
......@@ -1226,8 +1229,8 @@ CREATE TABLE `dinky_task` (
`step` int(11) NULL DEFAULT 1 COMMENT 'Job lifecycle,',
`job_instance_id` bigint(20) NULL DEFAULT NULL COMMENT 'job instance id',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`version_id` int(11) NULL DEFAULT NULL COMMENT 'version id',
statement text null,
PRIMARY KEY (`id`) USING BTREE,
......@@ -1249,7 +1252,7 @@ CREATE TABLE `dinky_task_version` (
`dialect` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'dialect',
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'type',
`task_configure` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'task configuration',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `task_version_un_idx1`(`task_id`, `tenant_id`, `version_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'job history version' ROW_FORMAT = Dynamic;
......@@ -1267,8 +1270,8 @@ CREATE TABLE `dinky_tenant` (
`tenant_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'tenant code',
`is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'note',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'tenant' ROW_FORMAT = Dynamic;
......@@ -1297,8 +1300,8 @@ CREATE TABLE `dinky_udf` (
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'type',
`step` int(11) NULL DEFAULT NULL COMMENT 'job lifecycle step',
`enable` tinyint(1) NULL DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'udf' ROW_FORMAT = Dynamic;
......@@ -1317,8 +1320,8 @@ CREATE TABLE `dinky_udf_template` (
`function_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'function type',
`template_code` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'code',
`enabled` tinyint(1) not null DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'udf template' ROW_FORMAT = Dynamic;
......@@ -1348,8 +1351,8 @@ CREATE TABLE `dinky_user` (
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'is enable',
`super_admin_flag` tinyint DEFAULT '0' COMMENT 'is super admin(0:false,1true)',
`is_delete` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'is delete',
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='user';
......@@ -1370,8 +1373,8 @@ CREATE TABLE `dinky_user_role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(11) NOT NULL COMMENT 'user id',
`role_id` int(11) NOT NULL COMMENT 'role id',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_role_un_idx1`(`user_id`, `role_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Relationship between users and roles' ROW_FORMAT = Dynamic;
......@@ -1390,8 +1393,8 @@ CREATE TABLE `dinky_user_tenant` (
`user_id` int(11) NOT NULL COMMENT 'user id',
`tenant_id` int(11) NOT NULL COMMENT 'tenant id',
`tenant_admin_flag` tinyint DEFAULT '0' COMMENT 'tenant admin flag(0:false,1:true)',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_tenant_un_idx1`(`user_id`, `tenant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Relationship between users and tenants' ROW_FORMAT = Dynamic;
......@@ -1413,7 +1416,7 @@ CREATE TABLE `metadata_column` (
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'column description',
`table_id` int(11) NOT NULL COMMENT 'table id',
`primary` bit(1) NULL DEFAULT NULL COMMENT 'table primary key',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create time',
PRIMARY KEY (`table_id`, `column_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'column informations' ROW_FORMAT = Dynamic;
......@@ -1430,7 +1433,7 @@ CREATE TABLE `metadata_database` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`database_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'database name',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'database description',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'metadata of database information' ROW_FORMAT = Dynamic;
......@@ -1447,7 +1450,7 @@ CREATE TABLE `metadata_database_property` (
`key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'key',
`value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'value',
`database_id` int(11) NOT NULL COMMENT 'database id',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create time',
PRIMARY KEY (`key`, `database_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'metadata of database configurations' ROW_FORMAT = Dynamic;
......@@ -1466,7 +1469,7 @@ CREATE TABLE `metadata_function` (
`class_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'class name',
`database_id` int(11) NOT NULL COMMENT 'database id',
`function_language` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'function language',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'UDF informations' ROW_FORMAT = Dynamic;
......@@ -1485,7 +1488,7 @@ CREATE TABLE `metadata_table` (
`table_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'type,such as:database,table,view',
`database_id` int(11) NOT NULL COMMENT 'database id',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'table description',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'metadata of table information' ROW_FORMAT = Dynamic;
......@@ -1503,8 +1506,8 @@ CREATE TABLE `metadata_table_property` (
`key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'key',
`value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'value',
`table_id` int(11) NOT NULL COMMENT 'table id',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'create tiime',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
PRIMARY KEY (`key`, `table_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'metadata of table configurations' ROW_FORMAT = Dynamic;
......@@ -1517,17 +1520,16 @@ CREATE TABLE `metadata_table_property` (
-- Table structure for dinky_row_permissions
-- ----------------------------
DROP TABLE IF EXISTS dinky_row_permissions;
CREATE TABLE dinky_row_permissions
(
id int auto_increment comment 'ID'
primary key,
role_id int not null comment 'role id',
table_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL comment 'table name',
expression varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL comment 'expression',
create_time datetime null comment '创建时间',
update_time datetime null comment '更新时间'
)
COMMENT 'row permissions of select' COLLATE = utf8mb4_general_ci;
CREATE TABLE `dinky_row_permissions` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
`role_id` int NOT NULL COMMENT 'role id',
`table_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'table name',
`expression` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'expression',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='row permissions of select';
-- ----------------------------
......@@ -1624,9 +1626,9 @@ CREATE TABLE `dinky_sys_login_log` (
`ip` varchar(40) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ip addr',
`status` int NOT NULL COMMENT 'login status',
`msg` text COLLATE utf8mb4_general_ci NOT NULL COMMENT 'status msg',
`create_time` datetime NOT NULL COMMENT 'create time',
`access_time` datetime DEFAULT NULL COMMENT 'access time',
`update_time` datetime NOT NULL,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`is_deleted` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='system login log record';
......@@ -1845,32 +1847,35 @@ CREATE TABLE `dinky_sys_role_menu` (
-- Table structure dinky_sys_alert
-- ----------------------------
drop table if exists `dinky_alert_template`;
create table if not exists dinky_alert_template
(
id int auto_increment
primary key COMMENT 'id',
name varchar(20) unicode COMMENT 'template name',
template_content text null COMMENT 'template content',
enabled tinyint default 1 null COMMENT 'is enable',
create_time datetime null COMMENT 'create time',
update_time datetime null COMMENT 'update time'
);
CREATE TABLE `dinky_alert_template` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(20) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL COMMENT 'template name',
`template_content` text COLLATE utf8mb4_general_ci COMMENT 'template content',
`enabled` tinyint DEFAULT '1' COMMENT 'is enable',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
drop table if exists `dinky_alert_rules`;
create table if not exists dinky_alert_rules
(
id int auto_increment
primary key comment 'id',
name varchar(40) unique not null comment 'rule name',
rule text null comment 'specify rule',
template_id int null comment 'template id',
rule_type varchar(10) null comment 'alert rule type',
trigger_conditions varchar(20) null comment 'trigger conditions',
description text null comment 'description',
enabled tinyint default 1 null comment 'is enable',
create_time datetime null comment 'create time',
update_time datetime null comment 'update time'
);
CREATE TABLE `dinky_alert_rules` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'rule name',
`rule` text COLLATE utf8mb4_general_ci COMMENT 'specify rule',
`template_id` int DEFAULT NULL COMMENT 'template id',
`rule_type` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'alert rule type',
`trigger_conditions` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'trigger conditions',
`description` text COLLATE utf8mb4_general_ci COMMENT 'description',
`enabled` tinyint DEFAULT '1' COMMENT 'is enable',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
......@@ -1893,9 +1898,11 @@ INSERT INTO dinky_alert_template VALUES (1, 'Default', '
- **End Time :** ${endTime}
- **<font color=''red''>${(exceptions.rootException)?substring(0,20)}</font>**
[Go toTask Web](http://${taskUrl})
', 1, null, null);
', 1, current_timestamp(), current_timestamp());
commit;
drop table if exists `dinky_udf_manage`;
CREATE TABLE `dinky_udf_manage` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL COMMENT 'udf name',
......@@ -1903,8 +1910,8 @@ CREATE TABLE `dinky_udf_manage` (
`task_id` int(11) DEFAULT NULL COMMENT 'task id',
`resources_id` int(11) DEFAULT NULL COMMENT 'resources id',
`enabled` tinyint(1) DEFAULT 1 COMMENT 'is enable',
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE,
KEY `name,resources_id` (`name`,`resources_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='udf';
......@@ -1922,8 +1929,8 @@ CREATE TABLE `dinky_sys_token` (
`expire_type` tinyint(4) NOT NULL COMMENT '1: never expire, 2: expire after a period of time, 3: expire at a certain time',
`expire_start_time` datetime DEFAULT NULL COMMENT 'expire start time ,when expire_type = 3 , it is the start time of the period',
`expire_end_time` datetime DEFAULT NULL COMMENT 'expire end time ,when expire_type = 2,3 , it is the end time of the period',
`create_time` datetime NOT NULL COMMENT 'create time',
`update_time` datetime NOT NULL COMMENT 'modify time',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`creator` bigint(20) DEFAULT NULL COMMENT '创建人',
`updator` bigint(20) DEFAULT NULL COMMENT '修改人',
`source` tinyint(2) DEFAULT NULL COMMENT '1:login 2:custom',
......@@ -1932,5 +1939,4 @@ CREATE TABLE `dinky_sys_token` (
KEY `source` (`source`) USING HASH
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COMMENT='token management';
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
......@@ -2338,7 +2338,7 @@ COMMENT ON COLUMN "public"."dinky_resources"."update_time" IS 'update time';
-- ----------------------------
-- Records of dinky_resources
-- ----------------------------
INSERT INTO "public"."dinky_resources" VALUES (1, 'Root', 'main folder', 1, 0, 0, -1, '/', 1, '2023-06-28 20:20:13', '2023-06-28 20:20:13');
INSERT INTO "public"."dinky_resources" VALUES (1, 'Root', 'main folder', 1, 0, 0, -1, '', 1, '2023-06-28 20:20:13', '2023-06-28 20:20:13');
-- ----------------------------
-- Indexes structure for table dinky_resources
......
......@@ -20,6 +20,7 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
begin ;
-- rename table
ALTER TABLE dlink_alert_group RENAME dinky_alert_group;
ALTER TABLE dlink_alert_history RENAME dinky_alert_history;
......@@ -312,4 +313,6 @@ drop table if exists dinky_jar;
drop table if exists dinky_schema_history;
drop table if exists dinky_upload_file_record;
commit ;
SET FOREIGN_KEY_CHECKS = 1;
......@@ -18,6 +18,7 @@
*/
begin ;
delete from `dinky_task_statement` where id in (select id from `dinky_task` where `name` = 'dlink_default_catalog');
delete from `dinky_task` where `name` = 'dlink_default_catalog';
......@@ -58,7 +59,7 @@ UPDATE `dinky_sys_config` SET `name` = 'flink.settings.useRestAPI' where `name`
UPDATE `dinky_sys_config` SET `name` = 'flink.settings.sqlSeparator' where `name` = 'sqlSeparator';
UPDATE `dinky_sys_config` SET `name` = 'flink.settings.jobIdWait' where `name` = 'jobIdWait';
INSERT INTO `dinky_resources` (`id`, `file_name`, `description`, `user_id`, `type`, `size`, `pid`, `full_name`, `is_directory`) VALUES (0, 'Root', 'main folder', 1, 0, 0, -1, '/Root', 1);
INSERT INTO `dinky_resources` (`id`, `file_name`, `description`, `user_id`, `type`, `size`, `pid`, `full_name`, `is_directory`) VALUES (0, 'Root', 'main folder', 1, 0, 0, -1, '', 1);
-- ----------------------------
......@@ -685,4 +686,8 @@ AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;', 'All Versions
-- 修改 dinky_udf_template 表的 enable 字段 不允许为空 默认为 1
alter table dinky_udf_template modify column `enabled` tinyint(1) not null default 1 comment 'is enable, 0:no 1:yes';
\ No newline at end of file
alter table dinky_udf_template modify column `enabled` tinyint(1) not null default 1 comment 'is enable, 0:no 1:yes';
commit ;
\ No newline at end of file
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