Skip to content

Commit

Permalink
[Feature][scaleph-ui-react] update flink kubernetes template add step…
Browse files Browse the repository at this point in the history
…s form (#660)

* feature: update flink kubernetes template steps

* feature: update flink kubernetes template steps
  • Loading branch information
kalencaya authored Dec 8, 2023
1 parent bf832d6 commit ade805e
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ private WsFlinkKubernetesTemplateDTO getGlobalDefault(DeploymentKind deploymentK

@Override
public int insert(WsFlinkKubernetesTemplateAddParam param) {
WsFlinkKubernetesTemplate record = new WsFlinkKubernetesTemplate();
WsFlinkKubernetesTemplateDTO dto = new WsFlinkKubernetesTemplateDTO();
BeanUtils.copyProperties(param, dto);
WsFlinkKubernetesTemplateDTO mergeWithDefault = mergeDefault(dto);
mergeWithDefault.setAdditionalDependencies(param.getAdditionalDependencies());
WsFlinkKubernetesTemplate record = WsFlinkKubernetesTemplateConvert.INSTANCE.toDo(mergeWithDefault);
BeanUtils.copyProperties(param, record);
record.setTemplateId(UUIDUtil.randomUUId());
return wsFlinkKubernetesTemplateMapper.insert(record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
package cn.sliew.scaleph.engine.flink.kubernetes.service.param;

import cn.sliew.scaleph.common.dict.flink.kubernetes.DeploymentKind;
import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.IngressSpec;
import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.JobManagerSpec;
import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.TaskManagerSpec;
import cn.sliew.scaleph.engine.flink.kubernetes.service.vo.KubernetesOptionsVO;
import io.fabric8.kubernetes.api.model.Pod;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

@Data
public class WsFlinkKubernetesTemplateAddParam {
Expand All @@ -44,6 +51,30 @@ public class WsFlinkKubernetesTemplateAddParam {
@Schema(description = "namespace")
private String namespace;

@Schema(description = "kubernetes options")
private KubernetesOptionsVO kubernetesOptions;

@Schema(description = "job manager")
private JobManagerSpec jobManager;

@Schema(description = "task manager")
private TaskManagerSpec taskManager;

@Schema(description = "pod template")
private Pod podTemplate;

@Schema(description = "flink configuration")
private Map<String, String> flinkConfiguration;

@Schema(description = "log configuration")
private Map<String, String> logConfiguration;

@Schema(description = "ingress")
private IngressSpec ingress;

@Schema(description = "additional dependencies")
private List<Long> additionalDependencies;

@Schema(description = "remark")
private String remark;
}
3 changes: 3 additions & 0 deletions scaleph-ui-react/src/locales/zh-CN/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,14 @@ export default {
'pages.project.flink.kubernetes.template.name': '名称',
'pages.project.flink.kubernetes.template.deploymentKind': '部署模式',
'pages.project.flink.kubernetes.template.namespace': 'Namespace',
'pages.project.flink.kubernetes.template.namespace.tooltip': '填写 Kubernetes Namespace',
'pages.project.flink.kubernetes.template.detail': '模板详情',
'pages.project.flink.kubernetes.template.step.base': '基础信息',
'pages.project.flink.kubernetes.template.step.advanced': '高级配置',
'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',
'pages.project.flink.kubernetes.template.step.yaml': 'YAML',

'pages.project.flink.kubernetes.session-cluster': 'SessionCluster',
'pages.project.flink.kubernetes.session-cluster.name': '名称',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {useEffect, useRef} from "react";
import Editor, {Monaco, useMonaco} from "@monaco-editor/react";
import {Props} from '@/app.d';
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import {connect} from "@@/exports";
import {connect} from "umi";

const TemplateEditor: React.FC<Props<WsFlinkKubernetesTemplate>> = (props: any) => {
const editorRef = useRef(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import {ProCard} from "@ant-design/pro-components";
import AdvancedBasic from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedBasic";
import AdvancedResource from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedResource";
import AdvancedCheckpoint from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedCheckpoint";
import AdvancedPeriodicSavepoint
from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedPeriodicSavepoint";
import AdvancedRestart from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedRestart";
import AdvancedFaultTolerance
from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedFaultTolerance";
import AdvancedHighAvailability
from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedHighAvailability";
import AdvancedAdditionalDependencies
from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedAdditionalDependencies";
import AdvancedAdditional from "@/pages/Project/Workspace/Kubernetes/Template/Detail/Advanced/AdvancedAdditional";

const FlinkKubernetesTemplateAdvancedStep: React.FC = () => {
return (
<ProCard>
<AdvancedBasic/>
<AdvancedResource/>
<AdvancedCheckpoint/>
<AdvancedPeriodicSavepoint/>
<AdvancedRestart/>
<AdvancedFaultTolerance/>
<AdvancedHighAvailability/>
<AdvancedAdditionalDependencies/>
<AdvancedAdditional/>
</ProCard>
);
}

export default FlinkKubernetesTemplateAdvancedStep;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ProCard, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea} from
import {useIntl} from "umi";
import {DICT_TYPE} from "@/constant";
import {DictDataService} from "@/services/admin/dictData.service";
import {InfoCircleOutlined} from "@ant-design/icons";

const FlinkKubernetesTemplateBase: React.FC = () => {
const intl = useIntl();
Expand All @@ -24,6 +25,10 @@ const FlinkKubernetesTemplateBase: React.FC = () => {
<ProFormText
name={"namespace"}
label={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.namespace'})}
tooltip={{
title: intl.formatMessage({id: 'pages.project.flink.kubernetes.template.namespace.tooltip'}),
icon: <InfoCircleOutlined/>,
}}
rules={[{required: true}]}
/>
<ProFormTextArea
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, {useEffect, useRef} from "react";
import Editor, {Monaco, useMonaco} from "@monaco-editor/react";
import {connect} from "umi";

const FlinkKubernetesTemplateYAMLStepDefaultEditor: React.FC = (props: any) => {
const editorRef = useRef(null);
const monaco = useMonaco();

useEffect(() => {
monaco?.languages.typescript.javascriptDefaults.setEagerModelSync(true);
}, [monaco]);

const handleEditorDidMount = (editor, monaco: Monaco) => {
editorRef.current = editor;
}

return (
<Editor
width="730"
height="600px"
language="yaml"
theme="vs-white"
value={props.flinkKubernetesTemplateSteps.templateYamlWithDefault}
options={{
selectOnLineNumbers: true,
readOnly: true,
minimap: {
enabled: false
}
}}
onMount={handleEditorDidMount}
/>
);
}

const mapModelToProps = ({flinkKubernetesTemplateSteps}: any) => ({flinkKubernetesTemplateSteps})
export default connect(mapModelToProps)(FlinkKubernetesTemplateYAMLStepDefaultEditor);
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, {useEffect, useRef} from "react";
import Editor, {Monaco, useMonaco} from "@monaco-editor/react";
import {Props} from '@/app.d';
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import {connect} from "umi";

const FlinkKubernetesTemplateYAMLStepEditor: React.FC<Props<WsFlinkKubernetesTemplate>> = (props: any) => {
const editorRef = useRef(null);
const monaco = useMonaco();

useEffect(() => {
// do conditional chaining
monaco?.languages.typescript.javascriptDefaults.setEagerModelSync(true);
}, [monaco]);

const handleEditorDidMount = (editor, monaco: Monaco) => {
editorRef.current = editor;
}

return (
<Editor
width="730"
height="600px"
language="yaml"
theme="vs-white"
value={props.flinkKubernetesTemplateSteps.templateYaml}
options={{
selectOnLineNumbers: true,
readOnly: true,
minimap: {
enabled: false
}
}}
onMount={handleEditorDidMount}
/>
);
}

const mapModelToProps = ({flinkKubernetesTemplateSteps}: any) => ({flinkKubernetesTemplateSteps})
export default connect(mapModelToProps)(FlinkKubernetesTemplateYAMLStepEditor);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import {Col, Row} from "antd";
import {ProCard} from "@ant-design/pro-components";
import FlinkKubernetesTemplateYAMLStepEditor
from "@/pages/Project/Workspace/Kubernetes/Template/Steps/YAML/TemplateEditor";
import FlinkKubernetesTemplateYAMLStepDefaultEditor
from "@/pages/Project/Workspace/Kubernetes/Template/Steps/YAML/DefaultTemplateEditor";

const FlinkKubernetesTemplateYAMLStep: React.FC = () => {
return (
<ProCard>
<Row>
<Col span={12}>
<ProCard title={"Template"}>
<FlinkKubernetesTemplateYAMLStepEditor/>
</ProCard>
</Col>
<Col span={12}>
<ProCard title={"Template & Defaults"}>
<FlinkKubernetesTemplateYAMLStepDefaultEditor/>
</ProCard>
</Col>
</Row>
</ProCard>
);
}

export default FlinkKubernetesTemplateYAMLStep;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {connect, history, useIntl} from "umi";
import React, {useRef} from "react";
import {ProCard, ProFormInstance, StepsForm} from "@ant-design/pro-components";
import {WORKSPACE_CONF} from "@/constant";
import {WsDorisTemplate, WsFlinkKubernetesTemplate} from "@/services/project/typings";
import {WsDorisTemplateService} from "@/services/project/WsDorisTemplateService";
import {WsFlinkKubernetesTemplate, WsFlinkKubernetesTemplateAddParam} from "@/services/project/typings";
import FlinkKubernetesTemplateBase from "@/pages/Project/Workspace/Kubernetes/Template/Steps/BaseStepForm";
import FlinkKubernetesTemplateAdvancedStep from "@/pages/Project/Workspace/Kubernetes/Template/Steps/AdvancedStepForm";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import FlinkKubernetesTemplateYAMLStep from "@/pages/Project/Workspace/Kubernetes/Template/Steps/YAMLStepForm";

const FlinkKubernetesTemplateSteps: React.FC = (props: any) => {
const intl = useIntl();
Expand All @@ -14,33 +16,36 @@ const FlinkKubernetesTemplateSteps: React.FC = (props: any) => {
const onBaseStepFinish = (values: Record<string, any>) => {
const template: WsFlinkKubernetesTemplate = {
projectId: localProjectId,
deploymentKind: values.deploymentKind,
deploymentKind: {value: values.deploymentKind},
name: values.name,
namespace: values.namespace,
remark: values.remark,
remark: values.remark
}
editDorisTemplate(template)
editFlinkKubernetesTemplate(template)
return Promise.resolve(true)
}

const onComponentStepFinish = (values: Record<string, any>) => {
const onAdvancedStepFinish = (values: Record<string, any>) => {
try {
const template: WsDorisTemplate = WsDorisTemplateService.formatData(props.dorisTemplateSteps.template, values)
editDorisTemplate(template)
const template: WsFlinkKubernetesTemplate = WsFlinkKubernetesTemplateService.formatData(props.flinkKubernetesTemplateSteps.template, values)
editFlinkKubernetesTemplate(template)
} catch (unused) {
}
return Promise.resolve(true)
}

const editDorisTemplate = (template: WsDorisTemplate) => {
const editFlinkKubernetesTemplate = (template: WsFlinkKubernetesTemplate) => {
props.dispatch({
type: 'flinkKubernetesTemplateSteps/editTemplate',
payload: template
})
}

const onAllFinish = (values: Record<string, any>) => {
return WsDorisTemplateService.add(props.dorisTemplateSteps.template).then((response) => {
console.log('onAllFinish', props.flinkKubernetesTemplateSteps.template)
const param: WsFlinkKubernetesTemplateAddParam = {...props.flinkKubernetesTemplateSteps.template}
param.deploymentKind = props.flinkKubernetesTemplateSteps.template.deploymentKind?.value
return WsFlinkKubernetesTemplateService.add(param).then((response) => {
if (response.success) {
history.back()
}
Expand All @@ -55,7 +60,7 @@ const FlinkKubernetesTemplateSteps: React.FC = (props: any) => {
grid: true,
rowProps: {gutter: [16, 8]}
}}
// onFinish={onAllFinish}
onFinish={onAllFinish}
>
<StepsForm.StepForm
name="base"
Expand All @@ -64,19 +69,19 @@ const FlinkKubernetesTemplateSteps: React.FC = (props: any) => {
onFinish={onBaseStepFinish}>
<FlinkKubernetesTemplateBase/>
</StepsForm.StepForm>
{/*<StepsForm.StepForm*/}
{/* name="component"*/}
{/* title={intl.formatMessage({id: 'pages.project.doris.template.steps.component'})}*/}
{/* style={{width: 1000}}*/}
{/* onFinish={onComponentStepFinish}>*/}
{/* <DorisTemplateComponent/>*/}
{/*</StepsForm.StepForm>*/}
{/*<StepsForm.StepForm*/}
{/* name="yaml"*/}
{/* title={intl.formatMessage({id: 'pages.project.doris.template.steps.yaml'})}*/}
{/* style={{width: 1000}}>*/}
{/* <DorisTemplateYAML/>*/}
{/*</StepsForm.StepForm>*/}
<StepsForm.StepForm
name="component"
title={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.step.advanced'})}
style={{width: 1000}}
onFinish={onAdvancedStepFinish}>
<FlinkKubernetesTemplateAdvancedStep/>
</StepsForm.StepForm>
<StepsForm.StepForm
name="yaml"
title={intl.formatMessage({id: 'pages.project.flink.kubernetes.template.step.yaml'})}
style={{width: 1100}}>
<FlinkKubernetesTemplateYAMLStep/>
</StepsForm.StepForm>
</StepsForm>
</ProCard>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const FlinkKubernetesDeploymentTemplateWeb: React.FC = () => {
type="link"
icon={<EditOutlined/>}
onClick={() => {
setDeploymentTemplateFormData({visiable: true, data: record});
history.push("/workspace/flink/kubernetes/template/detail", record)
}}
/>
</Tooltip>
Expand Down
8 changes: 8 additions & 0 deletions scaleph-ui-react/src/services/project/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ export type WsFlinkKubernetesTemplateAddParam = {
name: string;
deploymentKind?: string;
namespace: string;
kubernetesOptions?: KubernetesOptionsVO;
jobManager?: Record<string, any>;
taskManager?: Record<string, any>;
podTemplate?: Record<string, any>;
flinkConfiguration?: Record<string, any>;
logConfiguration?: Record<string, any>;
ingress?: Record<string, any>;
additionalDependencies?: Array<number>;
remark?: string;
};

Expand Down

0 comments on commit ade805e

Please sign in to comment.