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

[Refactor][web] refactor udf template && move to reg center (#1972)

* refactor ufd template && move to reg center * added editor buildAllSuggestions * change dir
parent 8ee93f9c
......@@ -23,6 +23,7 @@ import org.dinky.common.result.ProTableResult;
import org.dinky.common.result.Result;
import org.dinky.model.UDFTemplate;
import org.dinky.service.UDFTemplateService;
import org.dinky.utils.MessageResolverUtils;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -30,13 +31,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -44,17 +45,19 @@ import com.fasterxml.jackson.databind.JsonNode;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/** @since 0.6.8 */
/** UDFController */
@Slf4j
@RestController
@RequestMapping("/api/udf")
@RequestMapping("/api/udf/template")
@RequiredArgsConstructor
public class UDFController {
@Resource UDFTemplateService udfTemplateService;
private final UDFTemplateService udfTemplateService;
@PostMapping("/template/tree")
@PostMapping("/tree")
public Result<List<Object>> listUdfTemplates() {
List<UDFTemplate> list = udfTemplateService.list();
Map<String, Dict> one = new HashMap<>(3);
......@@ -105,19 +108,38 @@ public class UDFController {
return Result.succeed(CollUtil.newArrayList(result.values()));
}
@PostMapping("/template/list")
public ProTableResult<UDFTemplate> listUdfTemplates(@RequestBody JsonNode para) {
return udfTemplateService.selectForProTable(para);
/**
* get udf template list
*
* @param params {@link JsonNode}
* @return {@link ProTableResult} <{@link UDFTemplate}>
*/
@PostMapping("/list")
public ProTableResult<UDFTemplate> listUdfTemplates(@RequestBody JsonNode params) {
return udfTemplateService.selectForProTable(params);
}
@PutMapping("/template/")
public Result<String> addTemplate(@RequestBody UDFTemplate udfTemplate) {
/**
* save or update udf template
*
* @param udfTemplate {@link UDFTemplate}
* @return {@link Result} <{@link String}>
*/
@PutMapping
public Result<String> saveOrUpdate(@RequestBody UDFTemplate udfTemplate) {
return udfTemplateService.saveOrUpdate(udfTemplate)
? Result.succeed("操作成功")
: Result.failed("操作失败");
? Result.succeed(MessageResolverUtils.getMessage("save.success"))
: Result.failed(MessageResolverUtils.getMessage("save.failed"));
}
/**
* delete udf template by id, this method is deprecated, please use {@link #delete(Integer id)}
*
* @param para {@link JsonNode}
* @return {@link Result} <{@link String}>
*/
@DeleteMapping("/template/list")
@Deprecated
public Result deleteMul(@RequestBody JsonNode para) {
if (para.size() > 0) {
List<Integer> error = new ArrayList<>();
......@@ -137,4 +159,29 @@ public class UDFController {
return Result.failed("请选择要删除的记录");
}
}
/**
* delete udf template by id
*
* @param id {@link Integer}
* @return {@link Result} <{@link Void}>
*/
@DeleteMapping("/delete")
@Transactional(rollbackFor = Exception.class)
public Result<Void> delete(@RequestParam Integer id) {
if (udfTemplateService.removeById(id)) {
return Result.succeed(MessageResolverUtils.getMessage("delete.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("delete.failed"));
}
}
@PutMapping("/enable")
public Result<Void> enable(@RequestParam Integer id) {
if (udfTemplateService.enable(id)) {
return Result.succeed(MessageResolverUtils.getMessage("modify.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("modify.failed"));
}
}
}
......@@ -23,20 +23,7 @@ import org.dinky.db.mapper.SuperMapper;
import org.dinky.model.UDFTemplate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/** @since 0.6.8 udf 模板mapper */
/** udf template mapper */
@Mapper
public interface UDFTemplateMapper extends SuperMapper<UDFTemplate> {
@Override
@Select("select * from dinky_udf_template")
List<UDFTemplate> selectForProTable(
Page<UDFTemplate> page, Wrapper<UDFTemplate> queryWrapper, Map<String, Object> param);
}
public interface UDFTemplateMapper extends SuperMapper<UDFTemplate> {}
......@@ -32,4 +32,12 @@ public interface UDFTemplateService extends ISuperService<UDFTemplate> {
* @return boolean
*/
boolean saveOrUpdate(UDFTemplate udfTemplate);
/**
* enable or disable udf template
*
* @param id udf template id {@link UDFTemplate#id}
* @return {@link Boolean}
*/
Boolean enable(Integer id);
}
......@@ -51,4 +51,18 @@ public class UDFTemplateServiceImpl extends SuperServiceImpl<UDFTemplateMapper,
return updateById(udfTemplate);
}
}
/**
* @param id {@link Integer}
* @return {@link Boolean}
*/
@Override
public Boolean enable(Integer id) {
UDFTemplate udfTemplate = getById(id);
udfTemplate.setEnabled(!udfTemplate.getEnabled());
if (updateById(udfTemplate)) {
return true;
}
return false;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dinky.mapper.UDFTemplateMapper">
<select id="selectForProTable" resultType="org.dinky.model.UDFTemplate">
select
a.*
from
dinky_udf_template a
<where>
1=1
<if test='param.name!=null and param.name!=""'>
and `name` like '%${param.name}%'
</if>
<if test='param.codeType!=null and param.codeType!=""'>
and code_type = '${param.codeType}'
</if>
<if test='param.functionType!=null and param.functionType!=""'>
and function_type = '${param.functionType}'
</if>
<if test='param.templateCode!=null and param.templateCode!=""'>
and template_code like "%${param.templateCode}%"
</if>
<if test='param.createTime!=null and param.createTime!=""'>
and create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
and
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
${ew.sqlSegment}
</if>
</where>
</select>
</mapper>
......@@ -155,13 +155,19 @@ export default [
icon: 'GithubOutlined',
component: './RegCenter/GitProject',
},
{
path: '/registration/udf',
name: 'udf',
icon: 'ToolOutlined',
component: './RegCenter/UDF',
},
],
},
{
name: 'auth',
icon: 'SafetyCertificateOutlined',
path: '/auth',
// access: "canAdmin",
access: "canAdmin",
routes: [
{
path: '/auth',
......@@ -209,12 +215,6 @@ export default [
icon: 'SettingOutlined',
// component: './SettingCenter/FlinkSettings',
},
{
path: '/settings/udf',
name: 'udf',
icon: 'ToolOutlined',
// component: './SettingCenter/UDFTemplate',
},
{
path: '/settings/system',
name: 'system',
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type SqlMetaData = {
statement: string,
metaData: MetaData[],
};
export type MetaData = {
table: string,
connector: string,
columns: Column[],
};
export type Column = {
name: string,
type: string,
};
/**
* the editor's suggestions
*/
export type ISuggestions ={
label: string;
kind: any;
insertText: any;
insertTextRules: any;
detail?: any;
}
/*
* 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 {monaco} from "react-monaco-editor";
import keyWordJsonData from "./keyword.json";
import {Document, GlobalVar} from "@/types/RegCenter/data.d";
import {Column, ISuggestions, MetaData} from "@/components/CustomEditor/CodeEdit/data";
// 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;
};
/**
* get keyWordJson from {@link ./keyword.json}
* @param type
*/
const parseKeyWordJson = (type: string) => {
return JSON.parse(JSON.stringify(keyWordJsonData))[type];
};
/**
* build keyWordJsonSuggestions from {@link ./keyword.json}
*/
const buildKeyWordJsonSuggestions = () => {
let keyWordJsonSuggestions: ISuggestions[] = [];
// get all keys from keyWordJsonData
Object.keys(keyWordJsonData).forEach((key: string) => {
// parse data of key
const array = parseKeyWordJson(key);
// build suggestions
array.forEach((item: string) => {
keyWordJsonSuggestions.push({
label: item,
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: item,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
detail: key
});
});
});
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
};
/**
* build all suggestions
*/
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;
};
......@@ -20,9 +20,11 @@
import MonacoEditor, {monaco} from "react-monaco-editor";
import {MonacoEditorOptions} from "@/types/Public/data";
import {convertCodeEditTheme} from "@/utils/function";
import React from "react";
import React, {useState} from "react";
import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn";
import {editor} from "monaco-editor";
type CodeEditFormProps = {
type CodeEditFormProps = {
height?: string;
width?: string;
language?: string;
......@@ -33,10 +35,12 @@ import React from "react";
lineNumbers?: string;
theme?: string;
autoWrap?: string;
showFloatButton?: boolean;
};
const CodeEdit = (props: CodeEditFormProps) => {
const [editorRef, setEditorRef] = useState<any>();
/**
* 1. height: edit height
......@@ -49,6 +53,7 @@ const CodeEdit = (props: CodeEditFormProps) => {
* 8. lineNumbers: is show lineNumbers, value: on | off | relative | interval
* 9. theme: edit theme , value: vs-dark | vs | hc-black
* 10. autoWrap: is auto wrap, value: on | off | wordWrapColumn | bounded
* 11. showFloatButton: is show float button, value: true | false (default: false)
*/
const {
height = "100%", // if null or undefined, set default value
......@@ -63,42 +68,82 @@ const CodeEdit = (props: CodeEditFormProps) => {
lineNumbers, // show lineNumbers
theme, // edit theme
autoWrap = "on", // auto wrap
showFloatButton = false,
} = props;
const {ScrollType} = editor;
/**
* editorDidMount
* @param {editor.IStandaloneCodeEditor} editor
*/
const editorDidMount = (editor: editor.IStandaloneCodeEditor) => {
setEditorRef(editor);
editor.layout();
editor.focus();
};
/**
* handle scroll to top
*/
const handleBackTop = () => {
editorRef.revealLine(1);
};
/**
* handle scroll to bottom
*/
const handleBackBottom = () => {
editorRef.revealLine(editorRef.getModel().getLineCount());
};
/**
* handle scroll to down
*/
const handleDownScroll = () => {
editorRef.setScrollPosition({scrollTop: editorRef.getScrollTop() + 500}, ScrollType.Smooth);
};
/**
* handle scroll to up
*/
const handleUpScroll = () => {
editorRef?.setScrollPosition({scrollTop: editorRef.getScrollTop() - 500}, ScrollType.Smooth);
};
// register TypeScript language service
monaco.languages.register({
id: language || "typescript",
});
// get monaco editor model
const getModel = () => monaco.editor.getModels()[0];
const restEditBtnProps = {
handleBackTop,
handleBackBottom,
handleUpScroll,
handleDownScroll,
};
return (<>
<MonacoEditor
width={width}
height={height}
value={code}
language={language}
options={{
...options,
readOnly,
wordWrap: autoWrap,
autoDetectHighContrast: true,
lineNumbers,
}}
editorDidMount={(editor) => {
// 在编辑器加载完成后,设置自动布局和自动高亮显示
editor.layout();
editor.focus();
getModel().updateOptions({
tabSize: 2,
});
}}
onChange={onChange}
theme={theme ? theme : convertCodeEditTheme()}
/>
<div className={"monaco-float"}>
<MonacoEditor
width={width}
height={height}
value={code}
language={language}
options={{
...options,
readOnly,
wordWrap: autoWrap,
autoDetectHighContrast: true,
lineNumbers,
}}
editorDidMount={editorDidMount}
onChange={onChange}
theme={theme ? theme : convertCodeEditTheme()}
/>
{showFloatButton && <EditorFloatBtn {...restEditBtnProps}/>}
</div>
</>);
};
......
This diff is collapsed.
......@@ -23,14 +23,16 @@ import {MonacoEditorOptions} from "@/types/Public/data";
import React, {useState} from "react";
import {editor} from "monaco-editor";
import EditorFloatBtn from "@/components/CustomEditor/EditorFloatBtn";
import FullscreenBtn from "../FullscreenBtn";
/**
* props
* todo:
* 1. Realize full screen/exit full screen in the upper right corner of the editor (Visible after opening)
* - The full screen button is done, but the full screen is not implemented
* 2. Callback for right-clicking to clear logs (optional, not required)
*/
export type CodeShowFormProps = {
type CodeShowFormProps = {
height?: string;
width?: string;
language?: string;
......@@ -41,6 +43,7 @@ export type CodeShowFormProps = {
autoWrap?: string;
showFloatButton?: boolean;
refreshLogCallback?: () => void;
fullScreenBtn?: boolean;
};
const CodeShow = (props: CodeShowFormProps) => {
......@@ -69,6 +72,7 @@ const CodeShow = (props: CodeShowFormProps) => {
autoWrap = "on", // auto wrap
showFloatButton = false,
refreshLogCallback,
fullScreenBtn = false,
} = props;
const {ScrollType} = editor;
......@@ -77,10 +81,11 @@ const CodeShow = (props: CodeShowFormProps) => {
const [loading, setLoading] = useState<boolean>(false);
const [stopping, setStopping] = useState<boolean>(false);
const [autoRefresh, setAutoRefresh] = useState<boolean>(false);
const [fullScreen, setFullScreen] = useState<boolean>(false);
const [editorRef, setEditorRef] = useState<any>();
const [timer, setTimer] = useState<NodeJS.Timer>();
// register TypeScript language service
// register TypeScript language service, if language is not set default value is typescript!
monaco.languages.register({
id: language || "typescript",
});
......@@ -113,7 +118,7 @@ const CodeShow = (props: CodeShowFormProps) => {
/**
* handle stop auto refresh log
*/
const handleStartAutoRefresh = () => {
const handleStartAutoRefresh = async () => {
setAutoRefresh(true);
const timerSync = setInterval(() => {
handleSyncLog();
......@@ -147,7 +152,6 @@ const CodeShow = (props: CodeShowFormProps) => {
* handle scroll to up
*/
const handleUpScroll = () => {
// @ts-ignore
editorRef?.setScrollPosition({scrollTop: editorRef.getScrollTop() - 500}, ScrollType.Smooth);
};
......@@ -158,7 +162,6 @@ const CodeShow = (props: CodeShowFormProps) => {
*/
const editorDidMount = (editor: editor.IStandaloneCodeEditor) => {
setEditorRef(editor);
// 在编辑器加载完成后,设置自动布局和自动高亮显示
editor.layout();
editor.focus();
};
......@@ -176,8 +179,7 @@ const CodeShow = (props: CodeShowFormProps) => {
handleBackBottom,
handleUpScroll,
handleDownScroll,
}
};
/**
......@@ -185,6 +187,10 @@ const CodeShow = (props: CodeShowFormProps) => {
*/
return (<>
<div className={"monaco-float"}>
{/* fullScreen button */}
{fullScreenBtn && <FullscreenBtn isFullscreen={fullScreen} fullScreenCallBack={() => setFullScreen(!fullScreen)}/>}
{/* editor */}
<MonacoEditor
width={width}
height={height}
......@@ -203,6 +209,8 @@ const CodeShow = (props: CodeShowFormProps) => {
editorDidMount={editorDidMount}
theme={theme ? theme : convertCodeEditTheme()}
/>
{/* float button */}
{showFloatButton && <EditorFloatBtn {...restEditBtnProps}/>}
</div>
</>);
......
/*
* 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 React from "react";
import {FloatButton, Space} from "antd";
import {l} from "@/utils/intl";
import {DownCircleFilled, StopFilled, SyncOutlined, UpCircleFilled} from "@ant-design/icons";
import {PlayCircleFilled} from "@ant-design/icons/lib/icons";
/**
* props
*/
type EditFloatBtnProps = {
refreshLogCallback?: () => void; // refresh log callback
autoRefresh?: boolean; // auto refresh flag
stopping?: boolean; // stop auto refresh flag
loading?: boolean; // loading flag
handleSyncLog?: () => void; // sync log callback
handleStopAutoRefresh?: () => void; // stop auto refresh callback
handleStartAutoRefresh?: () => void; // start auto refresh callback
handleBackTop?: () => void; // back to top callback
handleBackBottom?: () => void; // back to bottom callback
handleUpScroll?: () => void; // up scroll callback
handleDownScroll?: () => void; // down scroll callback
}
const EditFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
/**
* init props
*/
const {
refreshLogCallback,
autoRefresh,
stopping,
loading,
handleSyncLog,
handleStopAutoRefresh,
handleStartAutoRefresh,
handleBackTop,
handleBackBottom,
handleUpScroll,
handleDownScroll
} = props;
/**
* render
*/
return <>
<FloatButton.Group
shape="circle"
className={"float-button"}
>
<Space direction={"vertical"}>
{/* if refreshLogCallback is not null, then show sync button , auto refresh button and stop auto refresh button */}
{refreshLogCallback &&
<>
<FloatButton tooltip={l("button.refresh")} icon={<SyncOutlined spin={loading}/>} onClick={handleSyncLog}/>
{autoRefresh ?
<FloatButton icon={<StopFilled spin={stopping}/>} tooltip={l("button.stopRefresh")} onClick={handleStopAutoRefresh}/> :
<FloatButton icon={<PlayCircleFilled/>} tooltip={l("button.startRefresh")} onClick={handleStartAutoRefresh}/>
}
</>
}
{/* back top */}
<FloatButton.BackTop tooltip={l("button.backTop")} onClick={handleBackTop} visibilityHeight={0}/>
{/* go bottom */}
<FloatButton.BackTop className={"back-bottom"} tooltip={l("button.backBottom")} onClick={handleBackBottom}
visibilityHeight={0}/>
{/* scroll up */}
<FloatButton icon={<UpCircleFilled/>} tooltip={l("button.upScroll")} onClick={handleUpScroll}/>
{/* scroll down */}
<FloatButton icon={<DownCircleFilled/>} tooltip={l("button.downScroll")} onClick={handleDownScroll}/>
</Space>
</FloatButton.Group>
</>;
};
export default EditFloatBtn;
......@@ -69,23 +69,51 @@ const EditorFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
{/* if refreshLogCallback is not null, then show sync button , auto refresh button and stop auto refresh button */}
{refreshLogCallback &&
<>
<FloatButton tooltip={l("button.refresh")} icon={<SyncOutlined spin={loading}/>} onClick={handleSyncLog}/>
{autoRefresh ?
<FloatButton icon={<StopFilled spin={stopping}/>} tooltip={l("button.stopRefresh")} onClick={handleStopAutoRefresh}/> :
<FloatButton icon={<PlayCircleFilled/>} tooltip={l("button.startRefresh")} onClick={handleStartAutoRefresh}/>
<FloatButton
tooltip={l("button.refresh")}
icon={<SyncOutlined spin={loading}/>}
onClick={handleSyncLog}
/>
{autoRefresh ?
<FloatButton
icon={<StopFilled spin={stopping}/>}
tooltip={l("button.stopRefresh")}
onClick={handleStopAutoRefresh}
/> :
<FloatButton
icon={<PlayCircleFilled/>}
tooltip={l("button.startRefresh")}
onClick={handleStartAutoRefresh}
/>
}
</>
}
{/* back top */}
<FloatButton.BackTop tooltip={l("button.backTop")} onClick={handleBackTop} visibilityHeight={0}/>
<FloatButton.BackTop
tooltip={l("button.backTop")}
onClick={handleBackTop}
visibilityHeight={0}
/>
{/* go bottom */}
<FloatButton.BackTop className={"back-bottom"} tooltip={l("button.backBottom")} onClick={handleBackBottom}
visibilityHeight={0}/>
<FloatButton.BackTop
className={"back-bottom"}
tooltip={l("button.backBottom")}
onClick={handleBackBottom}
visibilityHeight={0}
/>
{/* scroll up */}
<FloatButton icon={<UpCircleFilled/>} tooltip={l("button.upScroll")} onClick={handleUpScroll}/>
<FloatButton
icon={<UpCircleFilled/>}
tooltip={l("button.upScroll")}
onClick={handleUpScroll}
/>
{/* scroll down */}
<FloatButton icon={<DownCircleFilled/>} tooltip={l("button.downScroll")} onClick={handleDownScroll}/>
<FloatButton
icon={<DownCircleFilled/>}
tooltip={l("button.downScroll")}
onClick={handleDownScroll}
/>
</Space>
</FloatButton.Group>
</>;
......
/*
* 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 React from "react";
import {FullscreenExitOutlined, FullscreenOutlined} from "@ant-design/icons";
import {l} from "@/utils/intl";
import {FloatButton} from "antd";
type FullscreenBtnProps = {
isFullscreen: boolean;
fullScreenCallBack: () => void;
}
const FullscreenBtn: React.FC<FullscreenBtnProps> = (props) => {
const {isFullscreen, fullScreenCallBack} = props;
return <>
<FloatButton
className={"full-screen"}
icon={isFullscreen ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}
tooltip={isFullscreen ? l("global.fullScreen.exit") : l("global.fullScreen")}
onClick={fullScreenCallBack}/>
</>;
};
export default FullscreenBtn;
......@@ -33,6 +33,7 @@ body,
.content {
padding: 32px 0 24px;
}
.top {
text-align: center;
}
......@@ -53,7 +54,7 @@ body,
left: -30vw;
top: -5vh;
display: flex;
flex: auto ;
flex: auto;
flex-flow: column-reverse;
}
......@@ -66,29 +67,32 @@ body,
}
.loginformMain {
.loginformMain {
display: flex;
flex: auto;
max-height: max-content;
padding: 0vh 6vh 30vh 2vh;
justify-content: center ;
justify-content: center;
align-items: center;
flex-direction: column;
background-size: cover;
background-position: left center;
background-repeat: no-repeat;
z-index: 1;
.form{
.form {
position: relative;
height: 100%;
box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.4);
margin-left: 60vw;
margin-bottom: -15vh;
}
.loginform {
padding: 2vh 2vw;
}
}
// .login-form style --- end ----
......@@ -116,6 +120,7 @@ body,
::-webkit-scrollbar-corner {
background-color: #f5f5f5;
}
// scrollbar style --- end ----
.colorWeak {
......@@ -251,6 +256,15 @@ ol {
transform: rotate(180deg);
}
}
.full-screen {
position: absolute;
transform: translate(5%, 15%);
top: 0;
right: 2vw;
width: 40px;
height: 40px;
}
}
......
......@@ -51,6 +51,7 @@ export default {
'menu.registration.document': 'Document',
'menu.registration.fragment': 'Global Variable',
'menu.registration.gitprojects': 'Git Project(Beta)',
'menu.registration.udf': 'UDF Template',
'menu.auth': 'Auth Center',
'menu.auth.user': 'User',
'menu.auth.role': 'Role',
......@@ -59,7 +60,6 @@ export default {
'menu.auth.tenant': 'Tenant',
'menu.settings': 'Setting Center',
'menu.settings.flinksetting': 'Flink Settings',
'menu.settings.udf': 'UDF Template',
'menu.settings.system': 'System Info',
'menu.settings.process': 'Process List',
'menu.settings.services': 'Servers List',
......
This diff is collapsed.
......@@ -51,6 +51,7 @@ export default {
'menu.registration.document': '文档',
'menu.registration.fragment': '全局变量',
'menu.registration.gitprojects': 'Git 项目(Beta)',
'menu.registration.udf': 'UDF 模板',
'menu.auth': '认证中心',
'menu.auth.user': '用户',
'menu.auth.role': '角色',
......@@ -59,7 +60,6 @@ export default {
'menu.auth.tenant': '租户',
'menu.settings': '配置中心',
'menu.settings.flinksetting': 'Flink 配置',
'menu.settings.udf': 'UDF 模板',
'menu.settings.system': '系统信息',
'menu.settings.process': '进程列表',
'menu.settings.services': '服务器列表',
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ type GlobalVarDescProps = {
values: Partial<GlobalVar>;
columns: any;
}
const DocumentDesc: React.FC<GlobalVarDescProps> = (props) => {
const GlobalVarDesc: React.FC<GlobalVarDescProps> = (props) => {
const {values, columns} = props;
return <>
<ProDescriptions<GlobalVar>
......@@ -41,4 +41,4 @@ const DocumentDesc: React.FC<GlobalVarDescProps> = (props) => {
</>
}
export default DocumentDesc;
export default GlobalVarDesc;
......@@ -28,7 +28,7 @@ type GlobalVarDrawerProps = {
modalVisible: boolean;
columns: any;
}
const DocumentDrawer: React.FC<GlobalVarDrawerProps> = (props) => {
const GlobalVarDrawer: React.FC<GlobalVarDrawerProps> = (props) => {
const {onCancel: handleCancel, values, modalVisible, columns} = props;
......@@ -44,4 +44,4 @@ const DocumentDrawer: React.FC<GlobalVarDrawerProps> = (props) => {
}
export default DocumentDrawer;
\ No newline at end of file
export default GlobalVarDrawer;
/*
* 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 {ProForm, ProFormSelect, ProFormText} from "@ant-design/pro-components";
import {UDFTemplate} from "@/types/RegCenter/data";
import {FormInstance} from "antd/es/form/hooks/useForm";
import {Values} from "async-validator";
import React, {useState} from "react";
import {l} from "@/utils/intl";
import CodeEdit from "@/components/CustomEditor/CodeEdit";
import {renderLanguage} from "@/utils/function";
import {Select} from "antd";
import {CODE_TYPE, FUNCTION_TYPE_FILTER} from "@/pages/RegCenter/UDF/constants";
import {lowerCase, toLower} from "lodash";
import { DefaultOptionType } from "antd/es/select";
/**
* code edit props
*/
const CodeEditProps = {
height: "40vh",
width: "40vw",
lineNumbers: "on",
language: "java",
showFloatButton: true,
};
/**
* props
*/
type TemplateFormProps = {
values: Partial<UDFTemplate>;
form: FormInstance<Values>
}
const {Option} = Select;
const TemplateProFrom: React.FC<TemplateFormProps> = (props) => {
const {values, form} = props;
const [codeValue, setCodeValue] = useState<string>(values.templateCode || "");
const [codeLanguage, setCodeLanguage] = useState<string>(lowerCase(values.codeType) || "java");
const handleCodeTypeChange = (value: string) => {
setCodeLanguage(renderLanguage(toLower(value), ""));
};
const renderFunctionType = () => {
let functionTypes: DefaultOptionType[] =[];
FUNCTION_TYPE_FILTER.map(item => {
return functionTypes.push({
value: item.value,
label: item.text
});
});
return functionTypes;
};
const renderCodeEdit = () => {
return <>
<ProForm.Group>
<ProFormText
width={"xl"}
name="name"
label={l("rc.template.name")}
placeholder={l("rc.template.namePlaceholder")}
rules={[{required: true, message: l("rc.template.namePlaceholder")}]}
/>
</ProForm.Group>
<ProForm.Group>
<ProForm.Item
name="codeType"
label={l("rc.template.codeType")}
rules={[{required: true, message: l("rc.template.codeTypePlaceholder")}]}
>
<Select onSelect={handleCodeTypeChange}
style={{width: 280}}
placeholder={l("rc.template.codeTypePlaceholder")}
>
<Option value={CODE_TYPE.JAVA}>{CODE_TYPE.JAVA}</Option>
<Option value={CODE_TYPE.SCALA}>{CODE_TYPE.SCALA}</Option>
<Option value={CODE_TYPE.PYTHON}>{CODE_TYPE.PYTHON}</Option>
</Select>
</ProForm.Item>
<ProFormSelect
width={"md"}
name="functionType"
label={l("rc.template.functionType")}
rules={[{required: true, message: l("rc.template.functionTypePlaceholder")}]}
placeholder={l("rc.template.functionTypePlaceholder")}
options={renderFunctionType()}
/>
</ProForm.Group>
<ProForm.Group>
<ProForm.Item
name="templateCode"
label={l("rc.template.templateCodeLabel", "", {language: codeLanguage})}
rules={[{required: true, message: l("rc.template.templateCodePlaceholder")}]}
>
<CodeEdit
{...CodeEditProps}
code={codeValue}
onChange={(value) => setCodeValue(value)}
language={codeLanguage}
/>
</ProForm.Item>
</ProForm.Group>
</>;
};
return <>
<ProForm
form={form}
initialValues={{...values, codeType: values.codeType || CODE_TYPE.JAVA}}
submitter={false}
>
{renderCodeEdit()}
</ProForm>
</>;
};
export default TemplateProFrom;
/*
* 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 TemplateProFrom from "@/pages/RegCenter/UDF/components/TemplateModal/TemplateProFrom";
import React, {useEffect} from "react";
import {Button, Form} from "antd";
import {GitProject, UDFTemplate} from "@/types/RegCenter/data";
import {l} from "@/utils/intl";
import {ModalForm} from "@ant-design/pro-components";
import {FormContextValue} from "@/components/Context/FormContext";
type TemplateModalProps = {
visible: boolean;
onCancel: () => void;
onSubmit: (values: Partial<UDFTemplate>) => void;
values: Partial<UDFTemplate>;
}
const TemplateModal: React.FC<TemplateModalProps> = (props) => {
const {visible, onCancel, onSubmit, values} = props;
const [submitting, setSubmitting] = React.useState<boolean>(false);
/**
* init form
*/
const [form] = Form.useForm();
/**
* init form context
*/
const formContext = React.useMemo<FormContextValue>(() => ({
resetForm: () => form.resetFields(), // 定义 resetForm 方法
}), [form]);
/**
* when modalVisible or values changed, set form values
*/
useEffect(() => {
form.setFieldsValue(values);
}, [visible, values, form]);
/**
* handle cancel
*/
const handleCancel = () => {
onCancel();
setSubmitting(false);
formContext.resetForm();
};
/**
* submit form
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setSubmitting(true);
await onSubmit({...values, ...fieldsValue});
onCancel();
};
/**
* render footer
* @returns {[JSX.Element, JSX.Element]}
*/
const renderFooter = () => {
return [
<Button key={"cancel"} onClick={() => handleCancel()}>{l("button.cancel")}</Button>,
<Button key={"finish"} loading={submitting} type="primary"
onClick={() => submitForm()}>{l("button.finish")}</Button>,
];
};
return <>
<ModalForm<GitProject>
title={values.id ? l("rc.template.modify") : l("rc.template.create")}
open={visible}
form={form}
submitter={{render: () => [...renderFooter()]}}
initialValues={values}
>
<TemplateProFrom form={form} values={values}/>
</ModalForm>
</>;
};
export default TemplateModal;
/*
* 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 {ProTable} from "@ant-design/pro-components";
import React, {useRef, useState} from "react";
import {l} from "@/utils/intl";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC} from "@/services/constants";
import {ActionType, ProColumns} from "@ant-design/pro-table";
import {UDFTemplate} from "@/types/RegCenter/data";
import {queryList} from "@/services/api";
import {
CODE_TYPE_ENUM,
CODE_TYPE_FILTER,
FUNCTION_TYPE_ENUM,
FUNCTION_TYPE_FILTER
} from "@/pages/RegCenter/UDF/constants";
import {CreateBtn} from "@/components/CallBackButton/CreateBtn";
import {EditBtn} from "@/components/CallBackButton/EditBtn";
import {PopconfirmDeleteBtn} from "@/components/CallBackButton/PopconfirmDeleteBtn";
import {handleAddOrUpdate, handleRemoveById, updateEnabled} from "@/services/BusinessCrud";
import {EnableSwitchBtn} from "@/components/CallBackButton/EnableSwitchBtn";
import TemplateModal from "@/pages/RegCenter/UDF/components/TemplateModal";
import UDFTemplateDrawer from "../UDFTemplateDrawer";
import CodeShow from "@/components/CustomEditor/CodeShow";
const CodeShowProps = {
height: "40vh",
width: "40vw",
lineNumbers: "on",
language: "java",
};
const TemplateTable: React.FC = () => {
const actionRef = useRef<ActionType>();
const [loading, setLoading] = useState<boolean>(false);
const [modalVisible, handleModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [drawer, setDrawer] = useState<boolean>(false);
const [formValues, setFormValues] = useState<Partial<UDFTemplate>>({});
/**
* execute and callback function
* @param {() => void} callback
* @returns {Promise<void>}
*/
const executeAndCallback = async (callback: () => void) => {
setLoading(true);
await callback();
setLoading(false);
actionRef.current?.reload?.();
};
/**
* cancel all status
*/
const handleCancel = () => {
setFormValues({});
handleModalVisible(false);
handleUpdateModalVisible(false);
setDrawer(false);
actionRef.current?.reload?.();
};
/**
* change ModalVisible
* @param value
*/
const handleEdit = async (value: Partial<UDFTemplate>) => {
setFormValues(value);
handleUpdateModalVisible(true);
};
/**
* added or update submit
* @param {Partial<UDFTemplate>} value
* @returns {Promise<void>}
*/
const handleAddOrUpdateSubmit = async (value: Partial<UDFTemplate>) => {
await handleAddOrUpdate(API_CONSTANTS.UDF_TEMPLATE_ADD_UPDATE, value);
handleCancel();
};
/**
* update enabled
* @param {Partial<GitProject>} value
* @returns {Promise<void>}
*/
const handleChangeEnable = async (value: Partial<UDFTemplate>) => {
await executeAndCallback(async () => await updateEnabled(API_CONSTANTS.UDF_TEMPLATE_ENABLE, {id: value.id}));
};
/**
* delete udf template by id
* @param {number} id
* @returns {Promise<void>}
*/
const handleDeleteSubmit = async (id: number) => {
await executeAndCallback(async () => await handleRemoveById(API_CONSTANTS.UDF_TEMPLATE_DELETE, id));
};
/**
* handle open drawer
* @param {Partial<UDFTemplate>} record
*/
const handleOpenDrawer = (record: Partial<UDFTemplate>) => {
setFormValues(record)
setDrawer(true)
}
const columns: ProColumns<UDFTemplate>[] = [
{
title: l("rc.template.name"),
dataIndex: "name",
render: (dom, record) => {
return <a onClick={() => handleOpenDrawer(record)}>{dom}</a>;
} },
{
title: l("rc.template.codeType"),
dataIndex: "codeType",
filters: CODE_TYPE_FILTER,
valueEnum: CODE_TYPE_ENUM,
filterMultiple: false,
onFilter: false,
},
{
title: l("rc.template.functionType"),
dataIndex: "functionType",
filters: FUNCTION_TYPE_FILTER,
valueEnum: FUNCTION_TYPE_ENUM,
filterMultiple: false,
onFilter: false,
},
{
title: l("rc.template.templateCode"),
dataIndex: "templateCode",
filters: FUNCTION_TYPE_FILTER,
valueEnum: FUNCTION_TYPE_ENUM,
hideInTable: true,
filterMultiple: false,
onFilter: false,
render : (dom, record) => {
return <CodeShow {...CodeShowProps} code={record.templateCode} showFloatButton />;
}
},
{
title: l("global.table.isEnable"),
dataIndex: "enabled",
hideInSearch: true,
render: (_, record) => {
return <EnableSwitchBtn key={`${record.id}_enable`} disabled={drawer} record={record}
onChange={() => handleChangeEnable(record)}/>;
},
},
{
title: l("global.table.createTime"),
dataIndex: "createTime",
valueType: "dateTime",
sorter: true,
hideInSearch: true,
},
{
title: l("global.table.updateTime"),
dataIndex: "updateTime",
valueType: "dateTime",
sorter: true,
hideInSearch: true,
},
{
title: l("global.table.operate"),
width: "10vh",
hideInSearch: true,
hideInDescriptions: true,
render: (text, record) => [
<EditBtn key={`${record.id}_edit`} onClick={() => handleEdit(record)}/>,
<PopconfirmDeleteBtn key={`${record.id}_delete`} onClick={() => handleDeleteSubmit(record.id)}
description={l("rc.template.deleteConfirm")}/>,
]
}
];
return <>
<ProTable<UDFTemplate>
{...PROTABLE_OPTIONS_PUBLIC}
loading={loading}
actionRef={actionRef}
headerTitle={l("rc.udf.management")}
toolBarRender={() => [<CreateBtn key={"template"} onClick={() => handleModalVisible(true)}/>]}
request={(params, sorter, filter: any) => queryList(API_CONSTANTS.UDF_TEMPLATE, {...params, sorter, filter})}
columns={columns}
/>
{/* added */}
{modalVisible && <TemplateModal values={formValues} visible={modalVisible} onCancel={handleCancel}
onSubmit={(value: Partial<UDFTemplate>) => handleAddOrUpdateSubmit(value)}/>}
{/* modify */}
{updateModalVisible && <TemplateModal values={formValues} visible={updateModalVisible} onCancel={handleCancel}
onSubmit={(value: Partial<UDFTemplate>) => handleAddOrUpdateSubmit(value)}/>}
{/* drawer */}
{drawer &&
<UDFTemplateDrawer
onCancel={() => handleCancel()}
values={formValues}
modalVisible={drawer}
columns={columns}
/>}
</>;
};
export default TemplateTable;
/*
*
* 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 React from "react";
import {GlobalVar, UDFTemplate} from "@/types/RegCenter/data";
import { ProDescriptions } from "@ant-design/pro-components";
type UDFTemplateDescProps = {
values: Partial<UDFTemplate>;
columns: any;
}
const UDFTemplateDesc: React.FC<UDFTemplateDescProps> = (props) => {
const {values, columns} = props;
return <>
<ProDescriptions<GlobalVar>
column={1}
loading={values && Object.keys(values).length === 0}
title={values.name}
request={async () => ({
data: values,
})}
params={{id: values.id}}
columns={columns}
/>
</>;
};
export default UDFTemplateDesc;
/*
*
* 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 {UDFTemplate} from "@/types/RegCenter/data";
import React from "react";
import {Drawer} from "antd";
import UDFTemplateDesc from "./UDFTemplateDesc";
type UDFTemplateDrawerProps = {
onCancel: (flag?: boolean) => void;
values: Partial<UDFTemplate>;
modalVisible: boolean;
columns: any;
}
const UDFTemplateDrawer: React.FC<UDFTemplateDrawerProps> = (props) => {
const {onCancel: handleCancel, values, modalVisible, columns} = props;
return <>
<Drawer
width={"45%"}
open={modalVisible}
onClose={() => handleCancel(false)}
>
<UDFTemplateDesc values={values} columns={columns}/>
</Drawer>
</>;
};
export default UDFTemplateDrawer;
/*
* 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.
*/
/**
* code type
*/
export const CODE_TYPE = {
JAVA: 'Java',
PYTHON: 'Python',
SCALA: 'Scala',
}
/**
* code type filter
*/
export const CODE_TYPE_FILTER = [
{
value: CODE_TYPE.JAVA,
text: CODE_TYPE.JAVA,
}, {
value: CODE_TYPE.PYTHON,
text: CODE_TYPE.PYTHON,
},{
value: CODE_TYPE.SCALA,
text: CODE_TYPE.SCALA,
},
];
/**
* code type enum
*/
export const CODE_TYPE_ENUM = {
JAVA: {
text: "Java",
},
PYTHON: {
text: "Python",
},
SCALA: {
text: "Scala",
}
}
/**
* function type
*/
export const FUNCTION_TYPE = {
UDF: 'UDF',
UDAF: 'UDAF',
UDTF: 'UDTF',
}
/**
* function type enum
*/
export const FUNCTION_TYPE_ENUM = {
UDF: {
text: "UDF",
},
UDAF: {
text: "UDAF",
},
UDTF: {
text: "UDTF",
}
}
/**
* function type filter
*/
export const FUNCTION_TYPE_FILTER = [
{
value: FUNCTION_TYPE.UDF,
text: FUNCTION_TYPE.UDF,
}, {
value: FUNCTION_TYPE.UDAF,
text: FUNCTION_TYPE.UDAF,
},{
value: FUNCTION_TYPE.UDTF,
text: FUNCTION_TYPE.UDTF,
},
];
/*
* 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 {PageContainer} from "@ant-design/pro-components";
import TemplateTable from "@/pages/RegCenter/UDF/components/TemplateTable";
export default ()=>{
return <PageContainer title={false}>
<TemplateTable/>
</PageContainer>
}
......@@ -126,6 +126,16 @@ export const API_CONSTANTS = {
// ---- get project all build logs ----
GIT_PROJECT_BUILD_ALL_LOGS: "/api/git/getAllBuildLog",
// UDF template
UDF_TEMPLATE: "/api/udf/template/list",
// UDF template add or update
UDF_TEMPLATE_ADD_UPDATE: "/api/udf/template",
// UDF template delete
UDF_TEMPLATE_DELETE: "/api/udf/template/delete",
// UDF template enable or disable
UDF_TEMPLATE_ENABLE: "/api/udf/template/enable",
// system config center
//-- system root logs
......@@ -281,6 +291,7 @@ export const DIALECT = {
MARKDOWN: "markdown",
SCALA: "scala",
PYTHON: "py",
PYTHON_LONG: "python",
YML: "yml",
YAML: "yaml",
SH: "sh",
......
......@@ -210,3 +210,9 @@ export type GitProjectTreeNode = {
leaf: boolean;
children: GitProjectTreeNode[];
}
export type UDFTemplate = BaseBeanColumns & {
codeType: string,
functionType: string,
templateCode: string
}
......@@ -188,6 +188,8 @@ export const getLanguage = (type: string): string => {
return DIALECT.SCALA;
case DIALECT.PYTHON:
return DIALECT.PYTHON;
case DIALECT.PYTHON_LONG:
return DIALECT.PYTHON_LONG;
case DIALECT.SQL:
return DIALECT.SQL;
default:
......@@ -252,7 +254,7 @@ export const renderIcon = (type: string, splitChar: string, isLeft: boolean) =>
*/
export const renderLanguage = (type: string, splitChar: string) => {
if (trim(splitChar).length === 0) {
getLanguage(type);
return getLanguage(type);
} else {
let suffixOfType = type.toString().split(splitChar).reverse()[0];
return getLanguage(suffixOfType);
......
......@@ -785,9 +785,9 @@ INSERT INTO `dinky_tenant` VALUES (1, 'DefaultTenant', 0, 'DefaultTenant', '2022
DROP TABLE IF EXISTS `dinky_udf`;
CREATE TABLE `dinky_udf` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'udf name',
`class_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Complete class name',
`source_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'source code',
`name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'udf name',
`class_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Complete class name',
`source_code` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'source code',
`compiler_code` binary(255) NULL DEFAULT NULL COMMENT 'compiler product',
`version_id` int(11) NULL DEFAULT NULL COMMENT 'version',
`version_description` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'version description',
......@@ -798,9 +798,9 @@ CREATE TABLE `dinky_udf` (
`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',
`step` int(11) NULL DEFAULT NULL COMMENT 'job lifecycle step',
`enable` tinyint(1) NULL DEFAULT NULL COMMENT 'is enable',
`enable` tinyint(1) 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',
`update_time` datetime DEFAULT NULL 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;
......@@ -814,13 +814,13 @@ CREATE TABLE `dinky_udf` (
DROP TABLE IF EXISTS `dinky_udf_template`;
CREATE TABLE `dinky_udf_template` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模板名称',
`code_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代码类型',
`function_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '函数类型',
`template_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '模板代码',
`enabled` tinyint(1) NULL DEFAULT NULL COMMENT 'is enable',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'template name',
`code_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'code type',
`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) 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',
`update_time` datetime DEFAULT NULL 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;
......
......@@ -30,4 +30,18 @@ UPDATE dinky_cluster_configuration SET config_json =( SELECT JSON_SET( config_js
-- Fix spelling error
update dinky_task set dialect = 'KubernetesApplication' where dialect = 'KubernetesApplaction';
\ No newline at end of file
update dinky_task set dialect = 'KubernetesApplication' where dialect = 'KubernetesApplaction';
-- change dinky_udf_template table structure
alter table dinky_udf_template alter column `enabled` set default 1;
alter table dinky_udf_template modify column `name` varchar(100);
alter table dinky_udf_template modify column `template_code` longtext;
-- change dinky_udf table structure
alter table dinky_udf modify column `name` varchar(200);
alter table dinky_udf modify column `class_name` varchar(200);
alter table dinky_udf modify column `class_name` varchar(200);
alter table dinky_udf alter column `enable` set default 1;
alter table dinky_udf modify column `source_code` longtext;
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