-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add doris instance steps form
- Loading branch information
Showing
10 changed files
with
246 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...in/java/cn/sliew/scaleph/engine/doris/service/resource/cluster/DorisClusterConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package cn.sliew.scaleph.engine.doris.service.resource.cluster; | ||
|
||
import cn.sliew.scaleph.config.resource.ResourceLabels; | ||
import cn.sliew.scaleph.engine.doris.operator.DorisCluster; | ||
import cn.sliew.scaleph.engine.doris.operator.spec.DorisClusterSpec; | ||
import cn.sliew.scaleph.engine.doris.service.dto.WsDorisInstanceDTO; | ||
import cn.sliew.scaleph.kubernetes.resource.ResourceConverter; | ||
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.Map; | ||
|
||
public enum DorisClusterConverter implements ResourceConverter<WsDorisInstanceDTO, DorisCluster> { | ||
INSTANCE; | ||
|
||
@Override | ||
public DorisCluster convertTo(WsDorisInstanceDTO source) { | ||
DorisCluster cluster = new DorisCluster(); | ||
ObjectMetaBuilder builder = new ObjectMetaBuilder(true); | ||
String name = StringUtils.hasText(source.getInstanceId()) ? source.getInstanceId() : source.getName(); | ||
builder.withName(name); | ||
builder.withNamespace(source.getNamespace()); | ||
builder.withLabels(Map.of(ResourceLabels.SCALEPH_LABEL_NAME, source.getName())); | ||
cluster.setMetadata(builder.build()); | ||
DorisClusterSpec spec = new DorisClusterSpec(); | ||
spec.setFeSpec(source.getFeSpec()); | ||
spec.setBeSpec(source.getBeSpec()); | ||
spec.setCnSpec(source.getCnSpec()); | ||
spec.setBrokerSpec(source.getBrokerSpec()); | ||
spec.setAdminUser(source.getAdmin()); | ||
cluster.setSpec(spec); | ||
return cluster; | ||
} | ||
|
||
@Override | ||
public WsDorisInstanceDTO convertFrom(DorisCluster target) { | ||
WsDorisInstanceDTO dto = new WsDorisInstanceDTO(); | ||
String name = target.getMetadata().getName(); | ||
if (target.getMetadata().getLabels() != null) { | ||
Map<String, String> labels = target.getMetadata().getLabels(); | ||
name = labels.computeIfAbsent(ResourceLabels.SCALEPH_LABEL_NAME, key -> target.getMetadata().getName()); | ||
} | ||
dto.setName(name); | ||
dto.setInstanceId(target.getMetadata().getName()); | ||
dto.setNamespace(target.getMetadata().getNamespace()); | ||
|
||
DorisClusterSpec spec = target.getSpec(); | ||
dto.setFeSpec(spec.getFeSpec()); | ||
dto.setBeSpec(spec.getBeSpec()); | ||
dto.setCnSpec(spec.getCnSpec()); | ||
dto.setBrokerSpec(spec.getBrokerSpec()); | ||
dto.setAdmin(spec.getAdminUser()); | ||
return dto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
scaleph-ui-react/src/pages/Project/Workspace/Doris/Instance/Steps/ComponentStepForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, {useEffect} from "react"; | ||
import {ProCard} from "@ant-design/pro-components"; | ||
import DorisFeComponent from "@/pages/Project/Workspace/Doris/Template/Steps/Component/DorisFeComponent"; | ||
import DorisAdminUser from "@/pages/Project/Workspace/Doris/Template/Steps/Component/DorisAdminUser"; | ||
import DorisBeComponent from "@/pages/Project/Workspace/Doris/Template/Steps/Component/DorisBeComponent"; | ||
import DorisCnComponent from "@/pages/Project/Workspace/Doris/Template/Steps/Component/DorisCnComponent"; | ||
import {connect} from "umi"; | ||
import {Form} from "antd"; | ||
import {WsDorisTemplateService} from "@/services/project/WsDorisTemplateService"; | ||
|
||
const DorisInstanceComponent: React.FC = (props: any) => { | ||
const form = Form.useFormInstance() | ||
|
||
useEffect(() => { | ||
if (props.dorisInstanceSteps.instance) { | ||
form.setFieldsValue(WsDorisTemplateService.parseData({...props.dorisInstanceSteps.instance})) | ||
} | ||
}, [props.dorisInstanceSteps.instance]); | ||
|
||
return ( | ||
<ProCard> | ||
<DorisAdminUser/> | ||
<DorisFeComponent/> | ||
<DorisBeComponent/> | ||
<DorisCnComponent/> | ||
</ProCard> | ||
); | ||
} | ||
|
||
const mapModelToProps = ({dorisInstanceSteps}: any) => ({dorisInstanceSteps}) | ||
export default connect(mapModelToProps)(DorisInstanceComponent); |
41 changes: 41 additions & 0 deletions
41
scaleph-ui-react/src/pages/Project/Workspace/Doris/Instance/Steps/YAMLStepForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, {useEffect, useRef} from "react"; | ||
import {ProCard} from "@ant-design/pro-components"; | ||
import Editor, {Monaco, useMonaco} from "@monaco-editor/react"; | ||
import {connect} from "umi"; | ||
|
||
const DorisInstanceYAML: 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 ( | ||
<ProCard> | ||
<Editor | ||
width="730" | ||
height="600px" | ||
language="yaml" | ||
theme="vs-white" | ||
value={props.dorisInstanceSteps.instanceYaml} | ||
options={{ | ||
selectOnLineNumbers: true, | ||
readOnly: true, | ||
minimap: { | ||
enabled: false | ||
} | ||
}} | ||
onMount={handleEditorDidMount} | ||
/> | ||
</ProCard> | ||
|
||
); | ||
} | ||
|
||
const mapModelToProps = ({dorisInstanceSteps}: any) => ({dorisInstanceSteps}) | ||
export default connect(mapModelToProps)(DorisInstanceYAML); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.