Skip to content

Commit

Permalink
[Feature][scaleph-ui-react] optimize flink kubernetes template steps (#…
Browse files Browse the repository at this point in the history
…656)

* feature: add doris instance steps form

* feature: optimize common jars

* feature: optimize flink kubernetes template

* feature: optimize flink kubernetes template
  • Loading branch information
kalencaya authored Dec 5, 2023
1 parent 5ec126a commit 50e4ea5
Show file tree
Hide file tree
Showing 24 changed files with 315 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class ResourceJar extends BaseDO {

private static final long serialVersionUID = 1L;

@TableField("`group`")
private String group;

@TableField("file_name")
private String fileName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<result column="create_time" property="createTime" />
<result column="editor" property="editor" />
<result column="update_time" property="updateTime" />
<result column="group" property="group" />
<result column="file_name" property="fileName" />
<result column="path" property="path" />
<result column="remark" property="remark" />
Expand All @@ -35,7 +34,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, creator, create_time, editor, update_time,
`group`, file_name, `path`, remark
file_name, `path`, remark
</sql>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
sec_user t1
JOIN sec_user_role t2 ON t1.id = t2.user_id
WHERE
t2.role_id = 1
t2.role_id = #{roleId}
<if test="status != null">
AND t1.`status` = #{status}
</if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public interface JarConvert extends BaseConvert<ResourceJar, JarDTO> {

default JarListParam convert(ResourceListParam param) {
JarListParam target = BeanUtil.copy(param, new JarListParam());
target.setGroup(param.getLabel());
target.setFileName(param.getName());
target.setFileName(param.getLabel());
return target;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public Page<JarDTO> list(JarListParam param) throws IOException {
final Page<ResourceJar> page = jarMapper.selectPage(
new Page<>(param.getCurrent(), param.getPageSize()),
Wrappers.lambdaQuery(ResourceJar.class)
.eq(StringUtils.hasText(param.getGroup()), ResourceJar::getGroup, param.getGroup())
.like(StringUtils.hasText(param.getFileName()), ResourceJar::getFileName, param.getFileName()));
Page<JarDTO> result =
new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
Expand All @@ -101,7 +100,7 @@ public void upload(JarUploadParam param, MultipartFile file) throws IOException
String fileName = file.getOriginalFilename();
Path path = null;
try (InputStream inputStream = file.getInputStream()) {
path = fileSystemService.upload(inputStream, getJarPath(param.getGroup(), fileName));
path = fileSystemService.upload(inputStream, getJarPath(fileName));
}
ResourceJar record = new ResourceJar();
BeanUtils.copyProperties(param, record);
Expand Down Expand Up @@ -134,11 +133,10 @@ public void delete(Long id) throws IOException {
jarMapper.deleteById(id);
}

private String getJarPath(String group, String fileName) {
return String.format("%s/%s/%s", getJarRootPath(), group, fileName);
private String getJarPath(String fileName) {
return String.format("%s/%s", getJarRootPath(), fileName);
}


private String getJarRootPath() {
return "jar";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
@EqualsAndHashCode(callSuper = true)
public class JarListParam extends PaginationParam {

@Schema(description = "jar group")
private String group;

@Schema(description = "文件名称。支持模糊匹配")
private String fileName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class JarUploadParam {

@NotBlank
@Schema(description = "jar group")
private String group;


@Schema(description = "备注")
private String remark;
}
7 changes: 7 additions & 0 deletions scaleph-ui-react/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export default [
pCode: PRIVILEGE_CODE.workspaceClusterConfigShow,
access: 'normalRouteFilter'
},
{
path: '/workspace/flink/kubernetes/template/steps',
exact: true,
component: './Project/Workspace/Kubernetes/Template/Steps',
pCode: PRIVILEGE_CODE.workspaceClusterConfigShow,
access: 'normalRouteFilter'
},
{
path: '/workspace/flink/kubernetes/template/detail',
exact: true,
Expand Down
11 changes: 6 additions & 5 deletions scaleph-ui-react/src/locales/zh-CN/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,12 @@ export default {
// Sql
'pages.project.di.step.sql.query': 'SQL',

'pages.project.flink.kubernetes.deployment.template': 'Deployment Template',
'pages.project.flink.kubernetes.deployment.template.name': '名称',
'pages.project.flink.kubernetes.deployment.template.deploymentKind': '部署模式',
'pages.project.flink.kubernetes.deployment.template.namespace': 'Namespace',
'pages.project.flink.kubernetes.deployment.template.define': '模板定义',
'pages.project.flink.kubernetes.template': 'Template',
'pages.project.flink.kubernetes.template.name': '名称',
'pages.project.flink.kubernetes.template.deploymentKind': '部署模式',
'pages.project.flink.kubernetes.template.namespace': 'Namespace',
'pages.project.flink.kubernetes.template.detail': '模板详情',
'pages.project.flink.kubernetes.template.step.base': '基础信息',
'pages.project.flink.kubernetes.template.step.advanced.configOptions': 'ConfigOption',
'pages.project.flink.kubernetes.template.step.advanced.configOptions.key': 'Config',
'pages.project.flink.kubernetes.template.step.advanced.configOptions.value': 'Value',
Expand Down
1 change: 0 additions & 1 deletion scaleph-ui-react/src/locales/zh-CN/pages/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default {
'YARN 上传 core-site.xml 和 hdfs-site.xml, ' +
'Kubernetes 上传 kubeconfig 文件',
'pages.resource.jar': '公共 Jar',
'pages.resource.jar.group': 'Group',
'pages.resource.jar.file': 'Jar',
'pages.resource.jar.fileName': '文件名',
'pages.resource.jar.path': '存储路径',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import { Reducer, Effect } from "umi";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import YAML from "yaml";

export interface StateType {
template: WsFlinkKubernetesTemplate,
templateYaml: string
templateYamlWithDefault: string
}

export interface ModelType {
namespace: string;

state: StateType;

effects: {
queryTemplate: Effect;
};

reducers: {
updateTemplate: Reducer<StateType>;
};
}

const model: ModelType = {
namespace: "flinkKubernetesTemplateDetail",

state: {
template: null,
templateYaml: null,
templateYamlWithDefault: null
},

effects: {
*editTemplate({ payload }, { call, put }) {
const { data } = yield call(WsFlinkKubernetesTemplateService.asYaml, payload);
const response = yield call(WsFlinkKubernetesTemplateService.asYamlWithDefault, payload);
yield put({ type: 'updateTemplate', payload: {template: payload, templateYaml: YAML.stringify(data), templateYamlWithDefault: YAML.stringify(response.data)} });
},
},

reducers: {
updateTemplate(state, { payload }) {
return {
...state,
template: payload.template,
templateYaml: payload.templateYaml,
templateYamlWithDefault: payload.templateYamlWithDefault,
};
},
},
};

export default model;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import { Reducer, Effect } from "umi";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import YAML from "yaml";

export interface StateType {
template: WsFlinkKubernetesTemplate,
templateYaml: string
templateYamlWithDefault: string
}

export interface ModelType {
namespace: string;

state: StateType;

effects: {
queryTemplate: Effect;
};

reducers: {
updateTemplate: Reducer<StateType>;
};
}

const model: ModelType = {
namespace: "flinkKubernetesTemplateSteps",

state: {
template: null,
templateYaml: null,
templateYamlWithDefault: null
},

effects: {
*editTemplate({ payload }, { call, put }) {
const { data } = yield call(WsFlinkKubernetesTemplateService.asYaml, payload);
const response = yield call(WsFlinkKubernetesTemplateService.asYamlWithDefault, payload);
yield put({ type: 'updateTemplate', payload: {template: payload, templateYaml: YAML.stringify(data), templateYamlWithDefault: YAML.stringify(response.data)} });
},
},

reducers: {
updateTemplate(state, { payload }) {
return {
...state,
template: payload.template,
templateYaml: payload.templateYaml,
templateYamlWithDefault: payload.templateYamlWithDefault,
};
},
},
};

export default model;
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import {useIntl} from "umi";
import React from "react";
import {Form, message, Modal} from "antd";
import {ProForm, ProFormDigit, ProFormRadio, ProFormSelect, ProFormText} from "@ant-design/pro-components";
import {ProForm, ProFormDigit, ProFormRadio, ProFormText, ProFormTextArea} from "@ant-design/pro-components";
import {ModalFormProps} from '@/app.d';
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import {
WsFlinkKubernetesTemplateService
} from "@/services/project/WsFlinkKubernetesTemplateService";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import {DICT_TYPE, WORKSPACE_CONF} from "@/constant";
import {DictDataService} from "@/services/admin/dictData.service";

const DeploymentTemplateForm: React.FC<ModalFormProps<WsFlinkKubernetesTemplate>> = ({
data,
visible,
onVisibleChange,
onCancel
}) => {
data,
visible,
onVisibleChange,
onCancel
}) => {
const intl = useIntl();
const [form] = Form.useForm();
const projectId = localStorage.getItem(WORKSPACE_CONF.projectId);
Expand All @@ -26,9 +24,9 @@ const DeploymentTemplateForm: React.FC<ModalFormProps<WsFlinkKubernetesTemplate>
title={
data.id
? intl.formatMessage({id: 'app.common.operate.edit.label'}) +
intl.formatMessage({id: 'pages.project.flink.kubernetes.deployment.template'})
intl.formatMessage({id: 'pages.project.flink.kubernetes.template'})
: intl.formatMessage({id: 'app.common.operate.new.label'}) +
intl.formatMessage({id: 'pages.project.flink.kubernetes.deployment.template'})
intl.formatMessage({id: 'pages.project.flink.kubernetes.template'})
}
width={580}
destroyOnClose={true}
Expand Down Expand Up @@ -72,22 +70,22 @@ const DeploymentTemplateForm: React.FC<ModalFormProps<WsFlinkKubernetesTemplate>
<ProFormDigit name={"id"} hidden/>
<ProFormText
name={"name"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.deployment.template.name'})}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.name'})}
rules={[{required: true}]}
/>
<ProFormRadio.Group
name={"deploymentKind"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.deployment.template.deploymentKind'})}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.deploymentKind'})}
rules={[{required: true}]}
disabled={data?.id}
request={() => DictDataService.listDictDataByType2(DICT_TYPE.deploymentKind)}
/>
<ProFormText
name={"namespace"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.deployment.template.namespace'})}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.namespace'})}
rules={[{required: true}]}
/>
<ProFormText
<ProFormTextArea
name={"remark"}
label={intl.formatMessage({id: 'app.common.data.remark'})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AdvancedBasic: React.FC = () => {
name="image"
label={'image'}
colProps={{span: 10, offset: 1}}
initialValue={"flink:1.16"}
initialValue={"flink:1.18"}
/>
<ProFormSelect
name="imagePullPolicy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FlinkKubernetesDeploymentTemplateDetailWeb: React.FC = (props: any) => {
{label: 'YAML', key: 'yaml', children: <DeploymentTemplateYAML data={data}/>},
]
return (
<PageContainer>
<PageContainer title={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.detail'})}>
<Tabs items={items}/>
<FooterToolbar>
<Button onClick={onCancel}>{intl.formatMessage({id: 'app.common.operate.cancel.label'})}</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from "react";
import {ProCard, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea} from "@ant-design/pro-components";
import {useIntl} from "umi";
import {DICT_TYPE} from "@/constant";
import {DictDataService} from "@/services/admin/dictData.service";

const FlinkKubernetesTemplateBase: React.FC = () => {
const intl = useIntl();

return (
<ProCard>
<ProFormDigit name={"id"} hidden/>
<ProFormText
name={"name"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.name'})}
rules={[{required: true}]}
/>
<ProFormSelect
name={"deploymentKind"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.deploymentKind'})}
rules={[{required: true}]}
request={() => DictDataService.listDictDataByType2(DICT_TYPE.deploymentKind)}
/>
<ProFormText
name={"namespace"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.namespace'})}
rules={[{required: true}]}
/>
<ProFormTextArea
name={"remark"}
label={intl.formatMessage({id: 'app.common.data.remark'})}
/>
</ProCard>
);
}

export default FlinkKubernetesTemplateBase;
Loading

0 comments on commit 50e4ea5

Please sign in to comment.