-
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][scaleph-engine-doris] add doris instance detail web (#653)
* feature: add doris instance detail web * feature: add doris instance detail web * feature: add doris instance detail web
- Loading branch information
Showing
20 changed files
with
322 additions
and
65 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
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
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
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
186 changes: 186 additions & 0 deletions
186
scaleph-ui-react/src/pages/Project/Workspace/Doris/Instance/Detail/index.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,186 @@ | ||
import {useIntl, useLocation} from "umi"; | ||
import React, {useEffect, useRef, useState} from "react"; | ||
import {WsDorisInstance} from "@/services/project/typings"; | ||
import {PageContainer, ProCard, StatisticCard} from "@ant-design/pro-components"; | ||
import {Divider, Space, Statistic} from "antd"; | ||
import RcResizeObserver from 'rc-resize-observer'; | ||
import Editor, {Monaco, useMonaco} from "@monaco-editor/react"; | ||
import {WsDorisTemplateService} from "@/services/project/WsDorisTemplateService"; | ||
import YAML from "yaml"; | ||
import {WsDorisInstanceService} from "@/services/project/WsDorisInstanceService"; | ||
|
||
const DorisInstanceDetailWeb: React.FC = () => { | ||
const intl = useIntl(); | ||
const data = useLocation().state as WsDorisInstance | ||
const editorRef = useRef(null); | ||
const monaco = useMonaco(); | ||
|
||
const [yaml, setYaml] = useState<string>(null); | ||
const [responsive, setResponsive] = useState(false); | ||
|
||
useEffect(() => { | ||
monaco?.languages.typescript.javascriptDefaults.setEagerModelSync(true); | ||
}, [monaco]); | ||
|
||
const handleEditorDidMount = (editor, monaco: Monaco) => { | ||
editorRef.current = editor; | ||
} | ||
|
||
useEffect(() => { | ||
const yamlData = {...data} | ||
yamlData.deployed = undefined | ||
WsDorisInstanceService.asYaml(yamlData).then((response) => { | ||
if (response.success) { | ||
setYaml(YAML.stringify(response.data)) | ||
} | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<PageContainer title={intl.formatMessage({id: 'pages.project.doris.template.detail'})}> | ||
<RcResizeObserver | ||
key="resize-observer" | ||
onResize={(offset) => { | ||
setResponsive(offset.width < 596); | ||
}} | ||
> | ||
<ProCard.Group title={intl.formatMessage({id: 'pages.project.doris.template.detail.component'})} | ||
direction={responsive ? 'column' : 'row'}> | ||
<ProCard bordered hoverable> | ||
<StatisticCard title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.fe'})} | ||
statistic={{ | ||
value: data.feSpec?.replicas, | ||
prefix: intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.replicas'}) + ' x', | ||
description: ( | ||
<Space> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.cpu'})} | ||
value={data.feSpec?.requests?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.memory'})} | ||
value={data.feSpec?.requests?.memory}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.cpu'})} | ||
value={data.feSpec?.limits?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.memory'})} | ||
value={data.feSpec?.limits?.memory}/> | ||
</Space> | ||
), | ||
}} | ||
footer={ | ||
<div>{intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.image'}) + ": " + data.feSpec?.image ? data.feSpec?.image : '-'}</div> | ||
} | ||
/> | ||
</ProCard> | ||
<Divider type={responsive ? 'horizontal' : 'vertical'}/> | ||
<ProCard bordered hoverable> | ||
<StatisticCard title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.be'})} | ||
statistic={{ | ||
value: data.beSpec?.replicas, | ||
prefix: intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.replicas'}) + ' x', | ||
description: ( | ||
<Space> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.cpu'})} | ||
value={data.beSpec?.requests?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.memory'})} | ||
value={data.beSpec?.requests?.memory}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.cpu'})} | ||
value={data.beSpec?.limits?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.memory'})} | ||
value={data.beSpec?.limits?.memory}/> | ||
</Space> | ||
), | ||
}} | ||
footer={ | ||
<div>{intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.image'}) + ": " + data.beSpec?.image ? data.beSpec?.image : '-'}</div> | ||
} | ||
/> | ||
</ProCard> | ||
<Divider type={responsive ? 'horizontal' : 'vertical'}/> | ||
<ProCard bordered hoverable> | ||
<StatisticCard title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.cn'})} | ||
statistic={{ | ||
value: data.cnSpec?.replicas, | ||
prefix: intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.replicas'}) + ' x', | ||
description: ( | ||
<Space> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.cpu'})} | ||
value={data.cnSpec?.requests?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.memory'})} | ||
value={data.cnSpec?.requests?.memory}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.cpu'})} | ||
value={data.cnSpec?.limits?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.memory'})} | ||
value={data.cnSpec?.limits?.memory}/> | ||
</Space> | ||
), | ||
}} | ||
footer={ | ||
<div>{intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.image'}) + ": " + data.cnSpec?.image ? data.cnSpec?.image : '-'}</div> | ||
} | ||
/> | ||
</ProCard> | ||
<Divider type={responsive ? 'horizontal' : 'vertical'}/> | ||
<ProCard bordered hoverable> | ||
<StatisticCard title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.broker'})} | ||
statistic={{ | ||
value: data.brokerSpec?.replicas, | ||
prefix: intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.replicas'}) + ' x', | ||
description: ( | ||
<Space> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.cpu'})} | ||
value={data.brokerSpec?.requests?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.memory'})} | ||
value={data.brokerSpec?.requests?.memory}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.cpu'})} | ||
value={data.brokerSpec?.limits?.cpu}/> | ||
<Statistic | ||
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.memory'})} | ||
value={data.brokerSpec?.limits?.memory}/> | ||
</Space> | ||
), | ||
}} | ||
footer={ | ||
<div>{intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.image'}) + ": " + data.brokerSpec?.image ? data.brokerSpec?.image : '-'}</div> | ||
} | ||
/> | ||
</ProCard> | ||
</ProCard.Group> | ||
<Divider type={'horizontal'}/> | ||
<ProCard.Group title="YAML" direction={responsive ? 'column' : 'row'}> | ||
<ProCard bordered> | ||
<Editor | ||
width="730" | ||
height="600px" | ||
language="yaml" | ||
theme="vs-white" | ||
value={yaml} | ||
options={{ | ||
selectOnLineNumbers: true, | ||
readOnly: true, | ||
minimap: { | ||
enabled: false | ||
} | ||
}} | ||
onMount={handleEditorDidMount} | ||
/> | ||
</ProCard> | ||
</ProCard.Group> | ||
</RcResizeObserver> | ||
</PageContainer> | ||
); | ||
} | ||
|
||
export default DorisInstanceDetailWeb; |
83 changes: 83 additions & 0 deletions
83
scaleph-ui-react/src/pages/Project/Workspace/Doris/Instance/DorisInstanceSimpleForm.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,83 @@ | ||
import {useIntl} from "umi"; | ||
import React from "react"; | ||
import {Form, message, Modal} from "antd"; | ||
import {ProForm, ProFormDigit, ProFormText, ProFormTextArea} from "@ant-design/pro-components"; | ||
import {ModalFormProps} from '@/app.d'; | ||
import {WsDorisInstance} from "@/services/project/typings"; | ||
import {WORKSPACE_CONF} from "@/constant"; | ||
import {WsDorisInstanceService} from "@/services/project/WsDorisInstanceService"; | ||
|
||
const DorisInstanceSimpleForm: React.FC<ModalFormProps<WsDorisInstance>> = ({ | ||
data, | ||
visible, | ||
onVisibleChange, | ||
onCancel | ||
}) => { | ||
const intl = useIntl(); | ||
const [form] = Form.useForm(); | ||
const projectId = localStorage.getItem(WORKSPACE_CONF.projectId); | ||
|
||
return ( | ||
<Modal | ||
open={visible} | ||
title={ | ||
data.id | ||
? intl.formatMessage({id: 'app.common.operate.edit.label'}) + | ||
intl.formatMessage({id: 'pages.project.doris.template'}) | ||
: intl.formatMessage({id: 'app.common.operate.new.label'}) + | ||
intl.formatMessage({id: 'pages.project.doris.template'}) | ||
} | ||
width={580} | ||
destroyOnClose={true} | ||
onCancel={onCancel} | ||
onOk={() => { | ||
form.validateFields().then((values) => { | ||
data.id | ||
? WsDorisInstanceService.update({...values}).then((response) => { | ||
if (response.success) { | ||
message.success(intl.formatMessage({id: 'app.common.operate.edit.success'})); | ||
if (onVisibleChange) { | ||
onVisibleChange(false); | ||
} | ||
} | ||
}) | ||
: WsDorisInstanceService.add({...values, projectId: projectId}).then((response) => { | ||
if (response.success) { | ||
message.success(intl.formatMessage({id: 'app.common.operate.new.success'})); | ||
if (onVisibleChange) { | ||
onVisibleChange(false); | ||
} | ||
} | ||
}); | ||
}); | ||
}} | ||
> | ||
<ProForm | ||
form={form} | ||
layout={"horizontal"} | ||
submitter={false} | ||
labelCol={{span: 6}} | ||
wrapperCol={{span: 16}} | ||
initialValues={{ | ||
id: data.id, | ||
name: data.name, | ||
namespace: data.namespace, | ||
remark: data.remark | ||
}} | ||
> | ||
<ProFormDigit name={"id"} hidden/> | ||
<ProFormText | ||
name={"name"} | ||
label={intl.formatMessage({id: 'pages.project.doris.instance.name'})} | ||
rules={[{required: true}]} | ||
/> | ||
<ProFormTextArea | ||
name={"remark"} | ||
label={intl.formatMessage({id: 'app.common.data.remark'})} | ||
/> | ||
</ProForm> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default DorisInstanceSimpleForm; |
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.