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

fix modify cluster instance bug && fix some sql bug (#2479)

* fix modify cluster instance bug && fix some sql bug * fix modify cluster instance bug && fix some sql bug * Spotless Apply --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent 04499202
......@@ -42,6 +42,9 @@ import lombok.NoArgsConstructor;
@ApiModel(value = "ClusterInstanceDTO", description = "API Cluster Instance Data Transfer Object")
public class ClusterInstanceDTO {
@ApiModelProperty(value = "id", required = true, dataType = "Integer", example = "id")
private Integer id;
@ApiModelProperty(value = "Name", required = true, dataType = "String", example = "Name")
private String name;
......
......@@ -60,9 +60,6 @@ public class UDFTemplateServiceImpl extends SuperServiceImpl<UDFTemplateMapper,
public Boolean modifyUDFTemplateStatus(Integer id) {
UDFTemplate udfTemplate = getById(id);
udfTemplate.setEnabled(!udfTemplate.getEnabled());
if (updateById(udfTemplate)) {
return true;
}
return false;
return updateById(udfTemplate);
}
}
......@@ -2342,7 +2342,7 @@ CREATE TABLE `dinky_udf_template` (
`code_type` varchar(10) null DEFAULT null COMMENT 'code type',
`function_type` varchar(10) null DEFAULT null COMMENT 'function type',
`template_code` longtext null COMMENT 'code',
`enabled` tinyint(1) null DEFAULT 1 COMMENT 'is enable',
`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'
) ENGINE = InnoDB ROW_FORMAT = Dynamic;
......@@ -2356,7 +2356,7 @@ public class ${className} extends ScalarFunction {
return null;
}
}'
, null, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
, 1, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
INSERT INTO `dinky_udf_template`
VALUES (2, 'java_udtf', 'Java', 'UDTF', '${(package=='''')?string('''',''package ''+package+'';'')}
......@@ -2372,7 +2372,7 @@ public static class ${className} extends TableFunction<Row> {
}
}
}'
, null, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
, 1, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
INSERT INTO `dinky_udf_template`
VALUES (3, 'scala_udf', 'Scala', 'UDF', '${(package=='''')?string('''',''package ''+package+'';'')}
......@@ -2385,7 +2385,7 @@ class ${className} extends ScalarFunction {
"this is scala"
}
}'
, null, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
, 1, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
INSERT INTO `dinky_udf_template`
VALUES (4, 'python_udf_1', 'Python', 'UDF', 'from pyflink.table import ScalarFunction, DataTypes
from pyflink.table.udf import udf
......@@ -2399,7 +2399,7 @@ class ${className}(ScalarFunction):
${attr!''f''} = udf(${className}(), result_type=DataTypes.STRING())'
, null, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
, 1, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
INSERT INTO `dinky_udf_template`
VALUES (5, 'python_udf_2', 'Python', 'UDF', 'from pyflink.table import DataTypes
from pyflink.table.udf import udf
......@@ -2407,7 +2407,7 @@ from pyflink.table.udf import udf
@udf(result_type=DataTypes.STRING())
def ${className}(variable1:str):
return '''''
, null, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
, 1, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
DROP TABLE IF EXISTS `dinky_user`;
......
......@@ -20,6 +20,7 @@
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';
......@@ -116,7 +117,7 @@ const CodeShow = (props: CodeShowFormProps) => {
const handleStopAutoRefresh = () => {
setStopping(true);
setInterval(() => {
clearInterval(timer);
clearInterval(timer as any);
setStopping(false);
setAutoRefresh(false);
}, 1000);
......@@ -212,7 +213,8 @@ const CodeShow = (props: CodeShowFormProps) => {
<Editor
width={width}
height={height}
value={loading ? 'loading...' : code}
loading={<Loading loading={loading} />}
value={code ?? ''}
language={language}
options={{
scrollBeyondLastLine: false,
......@@ -257,7 +259,6 @@ const CodeShow = (props: CodeShowFormProps) => {
style={{
width: 35,
height: height,
backgroundColor: themeValue.borderColor,
paddingBlock: 10
}}
>
......
/*
* 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 { CircleBtn } from '@/components/CallBackButton/CircleBtn';
......@@ -68,7 +70,7 @@ const EditorFloatBtn: React.FC<EditFloatBtnProps> = (props) => {
*/
return (
<>
<Space direction={'vertical'} size={0}>
<Space direction={'vertical'} align={'center'} size={2}>
{refreshLogCallback && (
<>
<CircleBtn
......
/*
*
* 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 { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function';
import { MODAL_FORM_OPTIONS } from '@/services/constants';
import { Cluster } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import {
ProForm,
ProFormGroup,
ProFormSelect,
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
import React from 'react';
type InstanceFormProps = {
form: FormInstance<Values>;
value: Partial<Cluster.Instance>;
};
const InstanceForm: React.FC<InstanceFormProps> = (props) => {
const { form, value } = props;
const InstanceForm = () => {
const renderForm = () => {
return (
<>
......@@ -93,14 +81,7 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
);
};
return (
<>
{/*// @ts-ignore*/}
<ProForm {...MODAL_FORM_OPTIONS} form={form} initialValues={value} submitter={false}>
{renderForm()}
</ProForm>
</>
);
return <>{renderForm()}</>;
};
export default InstanceForm;
/*
*
* 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.
*
*/
......@@ -29,8 +29,8 @@ import InstanceForm from './InstanceForm';
type InstanceModalProps = {
visible: boolean;
onClose: () => void;
value: Partial<Cluster.Instance>;
onSubmit: (values: Partial<Cluster.Instance>) => void;
value: Cluster.Instance | Partial<Cluster.Instance>;
onSubmit: (values: Cluster.Instance) => void;
};
const InstanceModal: React.FC<InstanceModalProps> = (props) => {
const { visible, onClose, onSubmit, value } = props;
......@@ -72,7 +72,7 @@ const InstanceModal: React.FC<InstanceModalProps> = (props) => {
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setSubmitting(true);
await onSubmit({ ...value, ...fieldsValue });
onSubmit({ ...value, ...fieldsValue });
handleCancel();
};
......@@ -97,11 +97,12 @@ const InstanceModal: React.FC<InstanceModalProps> = (props) => {
{...MODAL_FORM_OPTIONS}
open={visible}
modalProps={{ onCancel: handleCancel }}
form={form}
title={value.id ? l('rc.ci.modify') : l('rc.ci.create')}
submitter={{ render: () => [...renderFooter()] }}
initialValues={value}
>
<InstanceForm form={form} value={value} />
<InstanceForm />
</ModalForm>
</>
);
......
......@@ -150,7 +150,7 @@ const DocumentTableList: React.FC = () => {
hideInTable: true,
hideInSearch: true,
render: (_, record) => {
return <CodeShow width={'85vh'} code={record.fillValue} />;
return <CodeShow language={'sql'} width={'40vw'} code={record.fillValue} />;
}
},
{
......
......@@ -1316,7 +1316,7 @@ CREATE TABLE `dinky_udf_template` (
`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',
`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',
PRIMARY KEY (`id`) USING BTREE
......@@ -1325,11 +1325,11 @@ CREATE TABLE `dinky_udf_template` (
-- ----------------------------
-- Records of dinky_udf_template
-- ----------------------------
INSERT INTO `dinky_udf_template` VALUES (1, 'java_udf', 'Java', 'UDF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.functions.ScalarFunction;\n\npublic class ${className} extends ScalarFunction {\n public String eval(String s) {\n return null;\n }\n}', NULL, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
INSERT INTO `dinky_udf_template` VALUES (2, 'java_udtf', 'Java', 'UDTF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.functions.ScalarFunction;\n\n@FunctionHint(output = @DataTypeHint(\"ROW<word STRING, length INT>\"))\npublic static class ${className} extends TableFunction<Row> {\n\n public void eval(String str) {\n for (String s : str.split(\" \")) {\n // use collect(...) to emit a row\n collect(Row.of(s, s.length()));\n }\n }\n}', NULL, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
INSERT INTO `dinky_udf_template` VALUES (3, 'scala_udf', 'Scala', 'UDF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.api._\nimport org.apache.flink.table.functions.ScalarFunction\n\n// 定义可参数化的函数逻辑\nclass ${className} extends ScalarFunction {\n def eval(s: String, begin: Integer, end: Integer): String = {\n \"this is scala\"\n }\n}', NULL, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
INSERT INTO `dinky_udf_template` VALUES (4, 'python_udf_1', 'Python', 'UDF', 'from pyflink.table import ScalarFunction, DataTypes\nfrom pyflink.table.udf import udf\n\nclass ${className}(ScalarFunction):\n def __init__(self):\n pass\n\n def eval(self, variable):\n return str(variable)\n\n\n${attr!\'f\'} = udf(${className}(), result_type=DataTypes.STRING())', NULL, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
INSERT INTO `dinky_udf_template` VALUES (5, 'python_udf_2', 'Python', 'UDF', 'from pyflink.table import DataTypes\nfrom pyflink.table.udf import udf\n\n@udf(result_type=DataTypes.STRING())\ndef ${className}(variable1:str):\n return \'\'', NULL, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
INSERT INTO `dinky_udf_template` VALUES (1, 'java_udf', 'Java', 'UDF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.functions.ScalarFunction;\n\npublic class ${className} extends ScalarFunction {\n public String eval(String s) {\n return null;\n }\n}', true, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
INSERT INTO `dinky_udf_template` VALUES (2, 'java_udtf', 'Java', 'UDTF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.functions.ScalarFunction;\n\n@FunctionHint(output = @DataTypeHint(\"ROW<word STRING, length INT>\"))\npublic static class ${className} extends TableFunction<Row> {\n\n public void eval(String str) {\n for (String s : str.split(\" \")) {\n // use collect(...) to emit a row\n collect(Row.of(s, s.length()));\n }\n }\n}', true, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
INSERT INTO `dinky_udf_template` VALUES (3, 'scala_udf', 'Scala', 'UDF', '${(package==\'\')?string(\'\',\'package \'+package+\';\')}\n\nimport org.apache.flink.table.api._\nimport org.apache.flink.table.functions.ScalarFunction\n\n// 定义可参数化的函数逻辑\nclass ${className} extends ScalarFunction {\n def eval(s: String, begin: Integer, end: Integer): String = {\n \"this is scala\"\n }\n}', true, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
INSERT INTO `dinky_udf_template` VALUES (4, 'python_udf_1', 'Python', 'UDF', 'from pyflink.table import ScalarFunction, DataTypes\nfrom pyflink.table.udf import udf\n\nclass ${className}(ScalarFunction):\n def __init__(self):\n pass\n\n def eval(self, variable):\n return str(variable)\n\n\n${attr!\'f\'} = udf(${className}(), result_type=DataTypes.STRING())', true, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
INSERT INTO `dinky_udf_template` VALUES (5, 'python_udf_2', 'Python', 'UDF', 'from pyflink.table import DataTypes\nfrom pyflink.table.udf import udf\n\n@udf(result_type=DataTypes.STRING())\ndef ${className}(variable1:str):\n return \'\'', true, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
-- ----------------------------
......
......@@ -1628,7 +1628,7 @@ CREATE TABLE "public"."dinky_udf_template" (
"code_type" varchar(10) COLLATE "pg_catalog"."default",
"function_type" varchar(10) COLLATE "pg_catalog"."default",
"template_code" text COLLATE "pg_catalog"."default",
"enabled" int2,
"enabled" int2 NOT null DEFAULT 1,
"create_time" timestamp(6),
"update_time" timestamp(6)
)
......@@ -1653,7 +1653,7 @@ public class ${className} extends ScalarFunction {
public String eval(String s) {
return null;
}
}', null, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
}', 1, '2022-10-19 09:17:37', '2022-10-25 17:45:57');
INSERT INTO "public"."dinky_udf_template" VALUES (2, 'java_udtf', 'Java', 'UDTF', '${(package=='''')?string('''',''package ''+package+'';'')}
import org.apache.flink.table.functions.ScalarFunction;
......@@ -1667,7 +1667,7 @@ public static class ${className} extends TableFunction<Row> {
collect(Row.of(s, s.length()));
}
}
}', null, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
}', 1, '2022-10-19 09:22:58', '2022-10-25 17:49:30');
INSERT INTO "public"."dinky_udf_template" VALUES (3, 'scala_udf', 'Scala', 'UDF', '${(package=='''')?string('''',''package ''+package+'';'')}
import org.apache.flink.table.api._
......@@ -1678,7 +1678,7 @@ class ${className} extends ScalarFunction {
def eval(s: String, begin: Integer, end: Integer): String = {
"this is scala"
}
}', null, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
}', 1, '2022-10-25 09:21:32', '2022-10-25 17:49:46');
INSERT INTO "public"."dinky_udf_template" VALUES (4, 'python_udf_1', 'Python', 'UDF', 'from pyflink.table import ScalarFunction, DataTypes
from pyflink.table.udf import udf
......@@ -1690,13 +1690,13 @@ class ${className}(ScalarFunction):
return str(variable)
${attr!''f''} = udf(${className}(), result_type=DataTypes.STRING())', null, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
${attr!''f''} = udf(${className}(), result_type=DataTypes.STRING())', 1, '2022-10-25 09:23:07', '2022-10-25 09:34:01');
INSERT INTO "public"."dinky_udf_template" VALUES (5, 'python_udf_2', 'Python', 'UDF', 'from pyflink.table import DataTypes
from pyflink.table.udf import udf
@udf(result_type=DataTypes.STRING())
def ${className}(variable1:str):
return ''''', null, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
return ''''', 1, '2022-10-25 09:25:13', '2022-10-25 09:34:47');
-- ----------------------------
......
......@@ -240,6 +240,7 @@ alter table dinky_task alter column `step` set default 1;
-- todo: 需要修改历史作业的默认值 , 过滤条件待定
replace INTO dinky_task SELECT
t.id,
t.`name`,
......@@ -679,3 +680,8 @@ WITH (
''connector'' = ''kafka''
)
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');
-- 修改 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
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