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

Fix udf bug (#2501)

* Spotless Apply * Spotless Apply * fix-udf-bug * fix-udf-bug * modify git build model layout * fix table enum bug * Spotless Apply * modify some code * Spotless Apply * modify some code * modify git build model layout && udf bug * modify some code * modify some code * Spotless Apply --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent 59a32223
......@@ -98,6 +98,11 @@ public class GitProject extends SuperEntity<GitProject> {
@TableField(value = "build_state")
private Integer buildState;
/**
* 区别于 java 和 Python 类型 | different from java and python;
* 1. 构建 java 工程时: 步骤值映射如下: 0: 环境检查 1: 克隆项目 2: 编译构建 3: 获取产物 4: 分析 UDF 5: 完成; (when build java project, the step value is as follows: 0: environment check 1: clone project 2: compile and build 3: get artifact 4: analyze UDF 5: finish)
* 2. 构建 python 工程时: 步骤值映射如下: 0: 环境检查 1: 克隆项目 2: 获取产物 3: 分析 UDF 4: 完成;(when build python project, the step value is as follows: 0: environment check 1: clone project 2: get artifact 3: analyze UDF 4: finish)
*/
@ApiModelProperty(value = "Build Step", dataType = "Integer")
@TableField(value = "build_step")
private Integer buildStep;
......
......@@ -169,7 +169,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
Resources resources = getById(id);
Assert.notNull(resources, () -> new BusException(Status.RESOURCE_DIR_OR_FILE_NOT_EXIST));
Assert.isFalse(resources.getSize() > ALLOW_MAX_CAT_CONTENT_SIZE, () -> new BusException("file is too large!"));
return URLUtils.toFile("rs:" + resources.getFullName());
return URLUtils.toFile("rs://" + resources.getFullName());
}
@Transactional(rollbackFor = Exception.class)
......
......@@ -93,7 +93,8 @@ public class MavenUtil {
} else {
localRepositoryDirectory = repositoryDir;
}
String mavenCommandLine = getMavenCommandLine(pom, mavenHome, localRepositoryDirectory, setting, goals, args);
String mavenCommandLine =
getMavenCommandLineByMvn(pom, mavenHome, localRepositoryDirectory, setting, goals, args);
Opt.ofNullable(consumer).ifPresent(c -> c.accept("Executing command: " + mavenCommandLine + "\n"));
int waitValue = RuntimeUtils.run(
......@@ -102,7 +103,7 @@ public class MavenUtil {
s = DateUtil.date().toMsStr() + " - " + s + "\n";
consumer.accept(s);
},
log::error);
consumer::accept);
return waitValue == 0;
}
......@@ -149,6 +150,30 @@ public class MavenUtil {
return StrUtil.join(" ", commandLine);
}
public static String getMavenCommandLineByMvn(
String projectDir,
String mavenHome,
String repositoryDir,
String settingsPath,
List<String> goals,
List<String> args) {
projectDir = StrUtil.wrap(projectDir, "\"");
settingsPath = StrUtil.wrap(settingsPath, "\"");
List<String> commandLine = new LinkedList<>();
commandLine.add(mavenHome + "/bin/mvn");
commandLine.add("-Dmaven.multiModuleProjectDirectory=" + projectDir);
commandLine.add("-Dmaven.home=" + StrUtil.wrap(mavenHome, "\""));
Opt.ofBlankAble(repositoryDir)
.ifPresent(x -> commandLine.add("-Dmaven.repo.local=" + StrUtil.wrap(repositoryDir, "\"")));
commandLine.add("-Dclassworlds.conf=" + StrUtil.wrap(mavenHome + "/bin/m2.conf", "\""));
commandLine.add("-s " + settingsPath);
commandLine.add("-f " + projectDir);
commandLine.add(StrUtil.join(" ", args));
commandLine.add(StrUtil.join(" ", goals));
return StrUtil.join(" ", commandLine);
}
public static String getMavenVersion() {
return RuntimeUtil.execForStr(getMavenHome() + "/bin/" + EXECTOR + " -v");
}
......
......@@ -29,6 +29,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.lang.Opt;
import lombok.extern.slf4j.Slf4j;
......@@ -61,7 +62,8 @@ public class RuntimeUtils {
reader.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
errorConsumer.accept(ExceptionUtil.stacktraceToOneLineString(e));
RUNNING.remove(process);
}
})
.start();
......@@ -74,7 +76,7 @@ public class RuntimeUtils {
Opt.ofNullable(errorConsumer).ifPresent(x -> x.accept(errMsg));
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
errorConsumer.accept(ExceptionUtil.stacktraceToOneLineString(e));
}
return waitValue;
}
......
......@@ -11,7 +11,7 @@ ds.work.flow.not.save=Please Save Workflow First
schedule.status.unknown=Unknown Status: {0}
user.binding.role.delete.all=User Binding Role Delete All
modify.failed=Update Failed
git.build.success=Git Build Success
git.build.success=Pre-update status success, start executing the build process
menu.has.child=Menu Has Child, Can Not Delete
tenant.already.exists=Tenant Already Exists
save.failed=Save Failed
......
......@@ -11,7 +11,7 @@ ds.work.flow.not.save=\u8BF7\u5148\u4FDD\u5B58\u5DE5\u4F5C\u6D41
schedule.status.unknown=\u672A\u77E5\u72B6\u6001: {0}
user.binding.role.delete.all=\u7528\u6237\u7ED1\u5B9A\u89D2\u8272\u5220\u9664\u6240\u6709
modify.failed=\u4FEE\u6539\u5931\u8D25
git.build.success=\u6784\u5EFA\u6210\u529F
git.build.success=\u9884\u66F4\u65B0\u72B6\u6001\u6210\u529F,\u5F00\u59CB\u6267\u884C\u6784\u5EFA\u6D41\u7A0B
menu.has.child=\u5B58\u5728\u5B50\u83DC\u5355 \u4E0D\u5141\u8BB8\u5220\u9664
tenant.already.exists=\u79DF\u6237\u5DF2\u5B58\u5728
save.failed=\u4FDD\u5B58\u5931\u8D25
......
......@@ -24,6 +24,8 @@ export default {
'button.recovery': 'Recovery',
'button.cancel': 'Cancel',
'button.finish': 'Finish',
'button.retry': 'Retry',
'button.rebuild': 'Re Build',
'button.back': 'Back',
'button.save': 'Save',
'button.delete': 'Delete',
......
......@@ -760,7 +760,8 @@ export default {
'rc.gp.build.step.1': 'Check Env',
'rc.gp.build.step.2': 'Git Clone',
'rc.gp.build.step.3': 'Maven Build',
'rc.gp.build.step.4': 'Get Jars',
// 获取产物
'rc.gp.build.step.4': 'Get Artifact',
'rc.gp.build.step.5': 'Analysis UDF',
'rc.gp.build.step.6': 'Finish',
'rc.gp.buildArgs': 'Build Arguments',
......
......@@ -26,6 +26,8 @@ export default {
'button.confirm': '确定',
'button.cancel': '取消',
'button.finish': '完成',
'button.retry': '重试',
'button.rebuild': '重新构建',
'button.back': '返回',
'button.save': '保存',
'button.delete': '删除',
......
......@@ -726,7 +726,7 @@ export default {
'rc.gp.build.step.1': '环境检查',
'rc.gp.build.step.2': '克隆项目',
'rc.gp.build.step.3': '编译构建',
'rc.gp.build.step.4': '获取 Jar 包',
'rc.gp.build.step.4': '获取产物',
'rc.gp.build.step.5': '分析 UDF',
'rc.gp.build.step.6': '完成',
'rc.gp.buildArgs': '构建参数',
......
......@@ -163,7 +163,7 @@ const ConsoleContent = (props: ConsoleProps) => {
onSelect={onSelect}
treeData={[processNode]}
expandedKeys={expandedKeys}
expandAction={"doubleClick"}
expandAction={'doubleClick'}
onExpand={handleExpand}
/>
) : (
......
/*
* 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 { DataSources } from '@/types/RegCenter/data';
import { transformTreeData } from '@/utils/function';
import { l } from '@/utils/intl';
import { CheckSquareOutlined, KeyOutlined } from '@ant-design/icons';
import { ProTable } from '@ant-design/pro-components';
import { ProColumns } from '@ant-design/pro-table/es/typing';
import React from 'react';
type ColumnInfoProps = {
columnInfo: Partial<DataSources.Column[]>;
};
const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
const { columnInfo } = props;
const columns: ProColumns<DataSources.Column>[] = [
{
title: l('rc.ds.no'),
dataIndex: 'position',
width: '4%'
},
{
title: l('rc.ds.columnName'),
dataIndex: 'name',
width: '10%',
ellipsis: true
},
{
title: l('rc.ds.columnType'),
dataIndex: 'type',
width: '6%'
},
{
title: l('rc.ds.primarykey'),
dataIndex: 'keyFlag',
width: '4%',
render: (_, record) => {
return record.keyFlag ? <KeyOutlined style={{ color: '#FAA100' }} /> : undefined;
}
},
{
title: l('rc.ds.autoIncrement'),
dataIndex: 'autoIncrement',
width: '4%',
render: (_, record) => {
return record.autoIncrement ? (
<CheckSquareOutlined style={{ color: '#1296db' }} />
) : undefined;
}
},
{
title: l('rc.ds.isNull'),
dataIndex: 'nullable',
width: '4%',
render: (_, record) => {
return !record.nullable ? <CheckSquareOutlined style={{ color: '#1296db' }} /> : undefined;
}
},
{
title: l('rc.ds.default'),
dataIndex: 'defaultValue',
ellipsis: true,
width: '8%'
},
{
title: l('rc.ds.length'),
dataIndex: 'length',
width: '4%'
},
{
title: l('rc.ds.precision'),
dataIndex: 'precision',
width: '4%'
},
{
title: l('rc.ds.decimalDigits'),
dataIndex: 'scale',
ellipsis: true,
width: '6%'
},
{
title: l('rc.ds.character'),
dataIndex: 'characterSet',
width: '6%',
ellipsis: true
},
{
title: l('rc.ds.collationRule'),
dataIndex: 'collation',
width: '10%',
ellipsis: true
},
{
title: l('rc.ds.javaType'),
dataIndex: 'javaType',
ellipsis: true,
width: '8%'
},
{
title: l('rc.ds.comment'),
dataIndex: 'comment',
ellipsis: true
}
];
return (
<>
<ProTable<DataSources.Column>
toolBarRender={false}
pagination={{
defaultPageSize: 14,
hideOnSinglePage: true
}}
search={false}
options={false}
size={'small'}
bordered
columns={columns}
dataSource={transformTreeData(columnInfo) as DataSources.Column[]}
/>
</>
);
};
export default ColumnInfo;
/*
* 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 { Height80VHDiv } from '@/components/StyledComponents';
......
/*
*
* 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,15 +29,19 @@ import { API_CONSTANTS } from '@/services/endpoints';
import { GitProject } from '@/types/RegCenter/data.d';
import { InitGitBuildStepsState } from '@/types/RegCenter/init.d';
import { GitBuildStepsState } from '@/types/RegCenter/state.d';
import { Modal } from 'antd';
import { l } from '@/utils/intl';
import { Button, Modal } from 'antd';
import React, { useEffect, useState } from 'react';
/**
* props
*/
type BuildStepsProps = {
onCancel: (flag?: boolean) => void;
onOk: (flag?: boolean) => void;
onReTry?: () => void;
onRebuild: () => void;
title: string;
showLog?: boolean;
values: Partial<GitProject>;
};
......@@ -45,7 +49,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
/**
* extract props
*/
const { onCancel: handleModalVisible, title, values } = props;
const { onOk: handleModalVisible, onReTry, showLog = false, onRebuild, title, values } = props;
// todo: refactor this
const [buildStepState, setBuildStepState] = useState<GitBuildStepsState>(InitGitBuildStepsState);
......@@ -88,7 +92,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
// type // 1是总状态 2是log 3是部分状态
// status // 0是失败 1是进行中 2 完成
let result = JSON.parse(e.data);
const { currentStep, type, data, status, history } = result;
const { currentStep, type, data, status } = result;
lastStep = currentStep;
if (type === 0) {
......@@ -171,18 +175,46 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
handleModalVisible();
};
// todo: 重试需要实现在不关闭弹窗的情况下,重新构建, 目前是关闭弹窗,重新打开,重新构建
const handleReTry = () => {
onReTry?.();
};
const footerButtons = [
<Button
key={'retry'}
type={'primary'}
danger
hidden={!onReTry}
disabled={onReTry && Number(steps[currentStep]?.status) !== 2}
onClick={() => handleReTry()}
>
{l('button.retry')}
</Button>,
<Button
key={'rebuild'}
type={'dashed'}
hidden={showLog}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => onRebuild()}
>
{l('button.rebuild')}
</Button>,
<Button
key={'finish'}
type={showLog ? 'default' : 'primary'}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => handleCancel()}
>
{showLog ? l('button.close') : l('button.finish')}
</Button>
];
/**
* render
*/
return (
<Modal
title={title}
width={'85%'}
open={true}
maskClosable={false}
onCancel={() => handleCancel()}
okButtonProps={{ style: { display: 'none' } }}
>
<Modal title={title} width={'85%'} open={true} maskClosable={false} footer={footerButtons}>
<AutoSteps
steps={steps}
percent={percent}
......
/*
*
* 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 ClassList from '@/pages/RegCenter/GitProject/components/BuildSteps/JarSho
import { CodeTree } from '@/pages/RegCenter/GitProject/components/CodeTree';
import ProjectModal from '@/pages/RegCenter/GitProject/components/ProjectModal';
import {
GIT_PROJECT_BUILD_STEP,
GIT_PROJECT_BUILD_STEP_ENUM,
GIT_PROJECT_BUILD_STEP_JAVA_ENUM,
GIT_PROJECT_BUILD_STEP_PYTHON_ENUM,
GIT_PROJECT_CODE_TYPE,
GIT_PROJECT_CODE_TYPE_ENUM,
GIT_PROJECT_STATUS,
......@@ -227,8 +227,9 @@ const ProjectProTable: React.FC = () => {
title: l('rc.gp.buildStep'),
dataIndex: 'buildStep',
hideInSearch: true,
filters: GIT_PROJECT_BUILD_STEP,
valueEnum: GIT_PROJECT_BUILD_STEP_ENUM
// filters: GIT_PROJECT_BUILD_STEP,
valueEnum: (row) =>
row.codeType === 1 ? GIT_PROJECT_BUILD_STEP_JAVA_ENUM : GIT_PROJECT_BUILD_STEP_PYTHON_ENUM
},
{
title: l('rc.gp.buildState'),
......@@ -352,6 +353,15 @@ const ProjectProTable: React.FC = () => {
return <Empty image={Empty.PRESENTED_IMAGE_DEFAULT} />;
};
/**
* re try build
* @param value
*/
const handleReTryBuild = async (value: Partial<GitProject>) => {
handleCancel();
await handleBuild(value);
};
/**
* render
*/
......@@ -401,7 +411,9 @@ const ProjectProTable: React.FC = () => {
{gitProjectStatus.buildOpen && (
<BuildSteps
title={l('rc.gp.build')}
onCancel={handleCancel}
onOk={handleCancel}
onRebuild={() => handleReTryBuild(gitProjectStatus.value)}
onReTry={() => handleReTryBuild(gitProjectStatus.value)}
values={gitProjectStatus.value}
/>
)}
......@@ -410,7 +422,9 @@ const ProjectProTable: React.FC = () => {
{gitProjectStatus.logOpen && (
<BuildSteps
title={l('rc.gp.log')}
onCancel={handleCancel}
onOk={handleCancel}
showLog={gitProjectStatus.logOpen}
onRebuild={() => handleReTryBuild(gitProjectStatus.value)}
values={gitProjectStatus.value}
/>
)}
......
/*
*
* 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.
*
*/
......@@ -131,7 +131,7 @@ export const CLONE_TYPES = [
* @param item
*/
export const renderBranchesTagColor = (item: string) => {
let colorTag = item.includes('dev')
return item.includes('dev')
? 'processing'
: item.includes('test')
? 'warning'
......@@ -142,13 +142,14 @@ export const renderBranchesTagColor = (item: string) => {
: item.includes('main')
? 'success'
: 'default';
return colorTag;
};
/**
* git project build step enum
* 区别于 java 和 Python 类型 | different from java and python
* 构建 java 工程时: 步骤值映射如下: 0: 环境检查 1: 克隆项目 2: 编译构建 3: 获取产物 4: 分析 UDF 5: 完成; (when build java project, the step value is as follows: 0: environment check 1: clone project 2: compile and build 3: get artifact 4: analyze UDF 5: finish)
* 构建 python 工程时: 步骤值映射如下: 0: 环境检查 1: 克隆项目 2: 获取产物 3: 分析 UDF 4: 完成;(when build python project, the step value is as follows: 0: environment check 1: clone project 2: get artifact 3: analyze UDF 4: finish)
*/
export const GIT_PROJECT_BUILD_STEP_ENUM = {
const GIT_PROJECT_BUILD_STEP_BASE = {
0: {
title: l('rc.gp.build.step.0'),
text: l('rc.gp.build.step.0'),
......@@ -158,7 +159,13 @@ export const GIT_PROJECT_BUILD_STEP_ENUM = {
title: l('rc.gp.build.step.1'),
text: l('rc.gp.build.step.1'),
status: 'default'
},
}
};
/**
* git project build step enum
*/
export const GIT_PROJECT_BUILD_STEP_JAVA_ENUM = {
...GIT_PROJECT_BUILD_STEP_BASE,
2: {
title: l('rc.gp.build.step.2'),
text: l('rc.gp.build.step.2'),
......@@ -185,6 +192,31 @@ export const GIT_PROJECT_BUILD_STEP_ENUM = {
status: 'success'
}
};
export const GIT_PROJECT_BUILD_STEP_PYTHON_ENUM = {
...GIT_PROJECT_BUILD_STEP_BASE,
2: {
title: l('rc.gp.build.step.2'),
text: l('rc.gp.build.step.2'),
status: 'processing'
},
3: {
title: l('rc.gp.build.step.4'),
text: l('rc.gp.build.step.4'),
status: 'success'
},
4: {
title: l('rc.gp.build.step.5'),
text: l('rc.gp.build.step.5'),
status: 'success'
},
5: {
title: l('rc.gp.build.step.6'),
text: l('rc.gp.build.step.6'),
status: 'success'
}
};
/**
* git project build step filter
*/
......@@ -228,7 +260,6 @@ export const GIT_PROJECT_BUILD_STEP = [
/**
* git project build step enum
* @type {{"100%": string, "0%": string, "20%": string, "40%": string, "60%": string, "80%": string}}
*/
export const processColor = {
'0%': '#8ac1ea',
......
/*
* 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.
*/
export type BuildStepsState = {
key: number;
title: string;
status: string;
status: string; // 0-notStart(未开始) 1-process(进行中/构建中) 2-failed(构建失败) 3-success(构建成功)
description: string;
disabled: boolean;
onClick: () => void;
......
......@@ -18,286 +18,283 @@
*/
import RightContextMenu from '@/components/RightContextMenu';
import {AuthorizedObject, useAccess} from '@/hooks/useAccess';
import { AuthorizedObject, useAccess } from '@/hooks/useAccess';
import {
RIGHT_CONTEXT_FILE_MENU,
RIGHT_CONTEXT_FOLDER_MENU
RIGHT_CONTEXT_FILE_MENU,
RIGHT_CONTEXT_FOLDER_MENU
} from '@/pages/RegCenter/Resource/components/constants';
import FileShow from '@/pages/RegCenter/Resource/components/FileShow';
import FileTree from '@/pages/RegCenter/Resource/components/FileTree';
import ResourceModal from '@/pages/RegCenter/Resource/components/ResourceModal';
import ResourcesUploadModal from '@/pages/RegCenter/Resource/components/ResourcesUploadModal';
import {handleOption, handleRemoveById, queryDataByParams} from '@/services/BusinessCrud';
import {API_CONSTANTS} from '@/services/endpoints';
import {ResourceInfo} from '@/types/RegCenter/data';
import {InitResourceState} from '@/types/RegCenter/init.d';
import {ResourceState} from '@/types/RegCenter/state.d';
import {l} from '@/utils/intl';
import {ProCard} from '@ant-design/pro-components';
import {MenuInfo} from 'rc-menu/es/interface';
import {Resizable} from 're-resizable';
import React, {useCallback, useState} from 'react';
import {useAsyncEffect} from "ahooks";
import {unSupportView} from "@/utils/function";
import { handleOption, handleRemoveById, queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { ResourceInfo } from '@/types/RegCenter/data';
import { InitResourceState } from '@/types/RegCenter/init.d';
import { ResourceState } from '@/types/RegCenter/state.d';
import { unSupportView } from '@/utils/function';
import { l } from '@/utils/intl';
import { ProCard } from '@ant-design/pro-components';
import { useAsyncEffect } from 'ahooks';
import { MenuInfo } from 'rc-menu/es/interface';
import { Resizable } from 're-resizable';
import React, { useCallback, useState } from 'react';
const ResourceOverView: React.FC = () => {
const [resourceState, setResourceState] = useState<ResourceState>(InitResourceState);
const [resourceState, setResourceState] = useState<ResourceState>(InitResourceState);
const [editModal, setEditModal] = useState<string>('');
const [editModal, setEditModal] = useState<string>('');
const [uploadValue] = useState({
url: API_CONSTANTS.RESOURCE_UPLOAD,
pid: '',
description: ''
});
const [uploadValue] = useState({
url: API_CONSTANTS.RESOURCE_UPLOAD,
pid: '',
description: ''
});
const refreshTree = async () => {
await queryDataByParams<ResourceInfo[]>(API_CONSTANTS.RESOURCE_SHOW_TREE).then((res) =>
setResourceState((prevState) => ({...prevState, treeData: res ?? []}))
);
};
useAsyncEffect(async () => {
await refreshTree();
}, [])
/**
* query content by id
* @type {(id: number) => Promise<void>}
*/
const queryContent: (id: number) => Promise<void> = useCallback(
async (id: number) => {
await queryDataByParams<string>(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {
id
}).then((res) => setResourceState((prevState) => ({...prevState, content: res ?? ''})));
},
[]
const refreshTree = async () => {
await queryDataByParams<ResourceInfo[]>(API_CONSTANTS.RESOURCE_SHOW_TREE).then((res) =>
setResourceState((prevState) => ({ ...prevState, treeData: res ?? [] }))
);
};
/**
* the node click event
* @param info
* @returns {Promise<void>}
*/
const handleNodeClick = async (info: any): Promise<void> => {
const {
node: {id, isLeaf, key, name},
node
} = info;
setResourceState((prevState) => ({...prevState, selectedKeys: [key], clickedNode: node}));
if (isLeaf && !unSupportView(name)) {
await queryContent(id);
} else {
setResourceState((prevState) => ({...prevState, content: ''}));
}
};
useAsyncEffect(async () => {
await refreshTree();
}, []);
/**
* the node right click event OF upload,
*/
const handleCreateFolder = () => {
if (resourceState.rightClickedNode) {
setEditModal('createFolder');
const {id} = resourceState.rightClickedNode;
setResourceState((prevState) => ({
...prevState,
editOpen: true,
value: {id, fileName: '', description: ''},
contextMenuOpen: false
}));
}
};
const handleUpload = () => {
if (resourceState.rightClickedNode) {
uploadValue.pid = resourceState.rightClickedNode.id;
// todo: upload
setResourceState((prevState) => ({...prevState, uploadOpen: true, contextMenuOpen: false}));
}
};
/**
* query content by id
* @type {(id: number) => Promise<void>}
*/
const queryContent: (id: number) => Promise<void> = useCallback(async (id: number) => {
await queryDataByParams<string>(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {
id
}).then((res) => setResourceState((prevState) => ({ ...prevState, content: res ?? '' })));
}, []);
/**
* the node right click event OF delete,
*/
const handleDelete = async () => {
if (resourceState.rightClickedNode) {
setResourceState((prevState) => ({...prevState, contextMenuOpen: false}));
await handleRemoveById(API_CONSTANTS.RESOURCE_REMOVE, resourceState.rightClickedNode.id);
await refreshTree();
}
};
/**
* the node click event
* @param info
* @returns {Promise<void>}
*/
const handleNodeClick = async (info: any): Promise<void> => {
const {
node: { id, isLeaf, key, name },
node
} = info;
setResourceState((prevState) => ({ ...prevState, selectedKeys: [key], clickedNode: node }));
if (isLeaf && !unSupportView(name)) {
await queryContent(id);
} else {
setResourceState((prevState) => ({ ...prevState, content: '' }));
}
};
/**
* the node right click event OF rename,
*/
const handleRename = () => {
if (resourceState.rightClickedNode) {
setEditModal('rename');
const {id, name, desc} = resourceState.rightClickedNode;
setResourceState((prevState) => ({
...prevState,
editOpen: true,
value: {id, fileName: name, description: desc},
contextMenuOpen: false
}));
}
};
/**
* the node right click event OF upload,
*/
const handleCreateFolder = () => {
if (resourceState.rightClickedNode) {
setEditModal('createFolder');
const { id } = resourceState.rightClickedNode;
setResourceState((prevState) => ({
...prevState,
editOpen: true,
value: { id, fileName: '', description: '' },
contextMenuOpen: false
}));
}
};
const handleUpload = () => {
if (resourceState.rightClickedNode) {
uploadValue.pid = resourceState.rightClickedNode.id;
// todo: upload
setResourceState((prevState) => ({ ...prevState, uploadOpen: true, contextMenuOpen: false }));
}
};
const handleMenuClick = async (node: MenuInfo) => {
switch (node.key) {
case 'createFolder':
handleCreateFolder();
break;
case 'upload':
handleUpload();
break;
case 'delete':
await handleDelete();
break;
case 'rename':
handleRename();
break;
default:
break;
}
};
/**
* the node right click event OF delete,
*/
const handleDelete = async () => {
if (resourceState.rightClickedNode) {
setResourceState((prevState) => ({ ...prevState, contextMenuOpen: false }));
await handleRemoveById(API_CONSTANTS.RESOURCE_REMOVE, resourceState.rightClickedNode.id);
await refreshTree();
}
};
/**
* the right click event
* @param info
*/
const handleRightClick = (info: any) => {
// 获取右键点击的节点信息
const {node, event} = info;
console.log('node', node);
setResourceState((prevState) => ({
...prevState,
selectedKeys: [node.key],
rightClickedNode: node,
contextMenuOpen: true,
contextMenuPosition: {
...prevState.contextMenuPosition,
left: event.clientX + 20,
top: event.clientY + 20
}
}));
};
/**
* the node right click event OF rename,
*/
const handleRename = () => {
if (resourceState.rightClickedNode) {
setEditModal('rename');
const { id, name, desc } = resourceState.rightClickedNode;
setResourceState((prevState) => ({
...prevState,
editOpen: true,
value: { id, fileName: name, description: desc },
contextMenuOpen: false
}));
}
};
/**
* the rename cancel
*/
const handleModalCancel = async () => {
setResourceState((prevState) => ({...prevState, editOpen: false}));
await refreshTree();
};
const handleMenuClick = async (node: MenuInfo) => {
switch (node.key) {
case 'createFolder':
handleCreateFolder();
break;
case 'upload':
handleUpload();
break;
case 'delete':
await handleDelete();
break;
case 'rename':
handleRename();
break;
default:
break;
}
};
/**
* the rename ok
*/
const handleModalSubmit = async (value: Partial<ResourceInfo>) => {
const {id: pid} = resourceState.rightClickedNode;
if (editModal === 'createFolder') {
await handleOption(API_CONSTANTS.RESOURCE_CREATE_FOLDER, l('right.menu.createFolder'), {
...value,
pid
});
setResourceState((prevState) => ({...prevState, editOpen: false}));
} else if (editModal === 'rename') {
await handleOption(API_CONSTANTS.RESOURCE_RENAME, l('right.menu.rename'), {...value, pid});
}
};
const handleUploadCancel = async () => {
setResourceState((prevState) => ({...prevState, uploadOpen: false}));
await refreshTree();
};
/**
* the right click event
* @param info
*/
const handleRightClick = (info: any) => {
// 获取右键点击的节点信息
const { node, event } = info;
console.log('node', node);
setResourceState((prevState) => ({
...prevState,
selectedKeys: [node.key],
rightClickedNode: node,
contextMenuOpen: true,
contextMenuPosition: {
...prevState.contextMenuPosition,
left: event.clientX + 20,
top: event.clientY + 20
}
}));
};
/**
* the content change
* @param value
*/
const handleContentChange = (value: any) => {
setResourceState((prevState) => ({...prevState, content: value}));
// todo: save content
};
/**
* the rename cancel
*/
const handleModalCancel = async () => {
setResourceState((prevState) => ({ ...prevState, editOpen: false }));
await refreshTree();
};
const access = useAccess();
/**
* the rename ok
*/
const handleModalSubmit = async (value: Partial<ResourceInfo>) => {
const { id: pid } = resourceState.rightClickedNode;
if (editModal === 'createFolder') {
await handleOption(API_CONSTANTS.RESOURCE_CREATE_FOLDER, l('right.menu.createFolder'), {
...value,
pid
});
setResourceState((prevState) => ({ ...prevState, editOpen: false }));
} else if (editModal === 'rename') {
await handleOption(API_CONSTANTS.RESOURCE_RENAME, l('right.menu.rename'), { ...value, pid });
}
};
const handleUploadCancel = async () => {
setResourceState((prevState) => ({ ...prevState, uploadOpen: false }));
await refreshTree();
};
const renderRightMenu = () => {
if (!resourceState.rightClickedNode.isLeaf) {
return RIGHT_CONTEXT_FOLDER_MENU.filter(
(menu) => !menu.path || !!AuthorizedObject({path: menu.path, children: menu, access})
);
}
return RIGHT_CONTEXT_FILE_MENU.filter(
(menu) => !menu.path || !!AuthorizedObject({path: menu.path, children: menu, access})
);
};
/**
* the content change
* @param value
*/
const handleContentChange = (value: any) => {
setResourceState((prevState) => ({ ...prevState, content: value }));
// todo: save content
};
/**
* render
*/
return (
<>
<ProCard size={'small'}>
<Resizable
defaultSize={{
width: 500,
height: '100%'
}}
minWidth={200}
maxWidth={1200}
>
<ProCard ghost hoverable colSpan={'18%'} className={'siderTree schemaTree'}>
<FileTree
selectedKeys={resourceState.selectedKeys}
treeData={resourceState.treeData}
onRightClick={handleRightClick}
onNodeClick={(info: any) => handleNodeClick(info)}
/>
<RightContextMenu
contextMenuPosition={resourceState.contextMenuPosition}
open={resourceState.contextMenuOpen}
openChange={() =>
setResourceState((prevState) => ({...prevState, contextMenuOpen: false}))
}
items={renderRightMenu()}
onClick={handleMenuClick}
/>
</ProCard>
</Resizable>
<ProCard.Divider type={'vertical'}/>
<ProCard ghost hoverable className={'schemaTree'} bodyStyle={{height: '100%'}}>
<FileShow
onChange={handleContentChange}
code={resourceState.content}
item={resourceState.clickedNode}
/>
</ProCard>
</ProCard>
{resourceState.editOpen && (
<ResourceModal
title={
editModal === 'createFolder'
? l('right.menu.createFolder')
: editModal === 'rename'
? l('right.menu.rename')
: ''
}
formValues={resourceState.value}
onOk={handleModalSubmit}
onClose={handleModalCancel}
visible={resourceState.editOpen}
/>
)}
{resourceState.uploadOpen && (
<ResourcesUploadModal
onUpload={uploadValue}
visible={resourceState.uploadOpen}
onOk={handleUploadCancel}
onClose={handleUploadCancel}
/>
)}
</>
const access = useAccess();
const renderRightMenu = () => {
if (!resourceState.rightClickedNode.isLeaf) {
return RIGHT_CONTEXT_FOLDER_MENU.filter(
(menu) => !menu.path || !!AuthorizedObject({ path: menu.path, children: menu, access })
);
}
return RIGHT_CONTEXT_FILE_MENU.filter(
(menu) => !menu.path || !!AuthorizedObject({ path: menu.path, children: menu, access })
);
};
/**
* render
*/
return (
<>
<ProCard size={'small'}>
<Resizable
defaultSize={{
width: 500,
height: '100%'
}}
minWidth={200}
maxWidth={1200}
>
<ProCard ghost hoverable colSpan={'18%'} className={'siderTree schemaTree'}>
<FileTree
selectedKeys={resourceState.selectedKeys}
treeData={resourceState.treeData}
onRightClick={handleRightClick}
onNodeClick={(info: any) => handleNodeClick(info)}
/>
<RightContextMenu
contextMenuPosition={resourceState.contextMenuPosition}
open={resourceState.contextMenuOpen}
openChange={() =>
setResourceState((prevState) => ({ ...prevState, contextMenuOpen: false }))
}
items={renderRightMenu()}
onClick={handleMenuClick}
/>
</ProCard>
</Resizable>
<ProCard.Divider type={'vertical'} />
<ProCard ghost hoverable className={'schemaTree'} bodyStyle={{ height: '100%' }}>
<FileShow
onChange={handleContentChange}
code={resourceState.content}
item={resourceState.clickedNode}
/>
</ProCard>
</ProCard>
{resourceState.editOpen && (
<ResourceModal
title={
editModal === 'createFolder'
? l('right.menu.createFolder')
: editModal === 'rename'
? l('right.menu.rename')
: ''
}
formValues={resourceState.value}
onOk={handleModalSubmit}
onClose={handleModalCancel}
visible={resourceState.editOpen}
/>
)}
{resourceState.uploadOpen && (
<ResourcesUploadModal
onUpload={uploadValue}
visible={resourceState.uploadOpen}
onOk={handleUploadCancel}
onClose={handleUploadCancel}
/>
)}
</>
);
};
export default ResourceOverView;
......@@ -19,11 +19,13 @@
import { EditBtn } from '@/components/CallBackButton/EditBtn';
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import { BackIcon } from '@/components/Icons/CustomIcons';
import UDFRegisterModal from '@/pages/RegCenter/UDF/components/UDFRegister/UDFRegisterModal';
import { API_CONSTANTS } from '@/services/endpoints';
import { UDFRegisterInfo, UDFRegisterInfoParent } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { useRequest } from '@@/plugin-request';
import { SaveTwoTone } from '@ant-design/icons';
import { ProColumns } from '@ant-design/pro-components';
import ProTable, { ActionType } from '@ant-design/pro-table';
import React, { Key, useEffect, useRef, useState } from 'react';
......@@ -182,6 +184,8 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
editable={{
deleteText: false,
type: 'single',
saveText: <SaveTwoTone title={l('button.save')} />,
cancelText: <BackIcon title={l('button.back')} />,
editableKeys: udfRegisterState.editableKeys,
onChange: editableKeysChange,
onSave: async (_, row) => handleOnSave(row),
......
......@@ -1550,7 +1550,7 @@ CREATE TABLE `dinky_git_project` (
`last_build` datetime DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`build_state` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-notStart 1-process 2-failed 3-success',
`build_step` tinyint(2) NOT NULL DEFAULT '0',
`build_step` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'different from java and python, when build java project, the step value is as follows: 0: environment check 1: clone project 2: compile and build 3: get artifact 4: analyze UDF 5: finish; when build python project, the step value is as follows: 0: environment check 1: clone project 2: get artifact 3: analyze UDF 4: finish',
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0-disable 1-enable',
`udf_class_map_list` text COMMENT 'scan udf class',
`order_line` int(11) NOT NULL DEFAULT '1' COMMENT 'order',
......
......@@ -1204,10 +1204,22 @@ CREATE TABLE "public"."dinky_git_project" (
"update_time" timestamp(6) NOT null
)
;
COMMENT ON COLUMN "public"."dinky_git_project"."id" IS 'ID';
COMMENT ON COLUMN "public"."dinky_git_project"."tenant_id" IS 'tenant id';
COMMENT ON COLUMN "public"."dinky_git_project"."name" IS 'project name';
COMMENT ON COLUMN "public"."dinky_git_project"."url" IS 'git url';
COMMENT ON COLUMN "public"."dinky_git_project"."branch" IS 'git branch';
COMMENT ON COLUMN "public"."dinky_git_project"."username" IS 'username';
COMMENT ON COLUMN "public"."dinky_git_project"."password" IS 'password';
COMMENT ON COLUMN "public"."dinky_git_project"."pom" IS 'pom';
COMMENT ON COLUMN "public"."dinky_git_project"."build_args" IS 'build args';
COMMENT ON COLUMN "public"."dinky_git_project"."private_key" IS 'keypath';
COMMENT ON COLUMN "public"."dinky_git_project"."code_type" IS 'code type(1-java,2-python)';
COMMENT ON COLUMN "public"."dinky_git_project"."type" IS '1-http ,2-ssh';
COMMENT ON COLUMN "public"."dinky_git_project"."last_build" IS 'last build time';
COMMENT ON COLUMN "public"."dinky_git_project"."description" IS 'description';
COMMENT ON COLUMN "public"."dinky_git_project"."build_state" IS '0-notStart 1-process 2-failed 3-success';
COMMENT ON COLUMN "public"."dinky_git_project"."build_step" IS 'different from java and python, when build java project, the step value is as follows: 0: environment check 1: clone project 2: compile and build 3: get artifact 4: analyze UDF 5: finish; when build python project, the step value is as follows: 0: environment check 1: clone project 2: get artifact 3: analyze UDF 4: finish';
COMMENT ON COLUMN "public"."dinky_git_project"."enabled" IS '0-disable 1-enable';
COMMENT ON COLUMN "public"."dinky_git_project"."udf_class_map_list" IS 'scan udf class';
COMMENT ON COLUMN "public"."dinky_git_project"."order_line" IS 'order';
......
......@@ -97,7 +97,7 @@ CREATE TABLE `dinky_git_project` (
`last_build` datetime DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`build_state` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-notStart 1-process 2-failed 3-success',
`build_step` tinyint(2) NOT NULL DEFAULT '0',
`build_step` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'different from java and python, when build java project, the step value is as follows: 0: environment check 1: clone project 2: compile and build 3: get artifact 4: analyze UDF 5: finish; when build python project, the step value is as follows: 0: environment check 1: clone project 2: get artifact 3: analyze UDF 4: finish',
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0-disable 1-enable',
`udf_class_map_list` text COMMENT 'scan udf class',
`order_line` int(11) NOT NULL DEFAULT '1' COMMENT 'order',
......
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