mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-17 16:02:14 +00:00
[improvement][semantic-fe] Restructured the code to extract the question-answer settings and model management model controls into the OverviewContainer component.
This commit is contained in:
@@ -143,7 +143,7 @@ const DefaultSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
};
|
||||
const { code, msg, data } = await saveDomainExtendQuery({
|
||||
[chatConfigKey]: params,
|
||||
domainId,
|
||||
// domainId,
|
||||
id,
|
||||
});
|
||||
if (code === 200) {
|
||||
|
||||
@@ -126,7 +126,7 @@ const DimensionAndMetricVisibleModal: React.FC<Props> = ({
|
||||
|
||||
const { code, msg } = await saveDomainExtendQuery({
|
||||
[chatConfigKey]: params,
|
||||
domainId,
|
||||
// domainId,
|
||||
id,
|
||||
});
|
||||
if (code === 200) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
|
||||
import type { ForwardRefRenderFunction } from 'react';
|
||||
import { message, Form, Input, Select, Button } from 'antd';
|
||||
import { updateDomain } from '../../service';
|
||||
import { updateModel } from '../../service';
|
||||
import type { ISemantic } from '../../data';
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import styles from '../style.less';
|
||||
|
||||
type Props = {
|
||||
domainData?: ISemantic.IDomainItem;
|
||||
modelData?: ISemantic.IModelItem;
|
||||
dimensionList: ISemantic.IDimensionList;
|
||||
domainId: number;
|
||||
modelId: number;
|
||||
onSubmit: () => void;
|
||||
};
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const EntityCreateForm: ForwardRefRenderFunction<any, Props> = (
|
||||
{ domainData, dimensionList, domainId, onSubmit },
|
||||
{ modelData, dimensionList, modelId, onSubmit },
|
||||
ref,
|
||||
) => {
|
||||
const [form] = Form.useForm();
|
||||
@@ -27,15 +27,15 @@ const EntityCreateForm: ForwardRefRenderFunction<any, Props> = (
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if (!domainData?.entity) {
|
||||
if (!modelData?.entity) {
|
||||
return;
|
||||
}
|
||||
const { entity } = domainData;
|
||||
const { entity } = modelData;
|
||||
form.setFieldsValue({
|
||||
...entity,
|
||||
name: entity.names.join(','),
|
||||
});
|
||||
}, [domainData]);
|
||||
}, [modelData]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getFormValidateFields,
|
||||
@@ -54,14 +54,14 @@ const EntityCreateForm: ForwardRefRenderFunction<any, Props> = (
|
||||
const saveEntity = async () => {
|
||||
const values = await form.validateFields();
|
||||
const { name } = values;
|
||||
const { code, msg, data } = await updateDomain({
|
||||
...domainData,
|
||||
const { code, msg, data } = await updateModel({
|
||||
...modelData,
|
||||
entity: {
|
||||
...values,
|
||||
names: name.split(','),
|
||||
},
|
||||
id: domainId,
|
||||
domainId,
|
||||
id: modelId,
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
@@ -79,20 +79,11 @@ const EntityCreateForm: ForwardRefRenderFunction<any, Props> = (
|
||||
<FormItem hidden={true} name="id" label="ID">
|
||||
<Input placeholder="id" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
name="name"
|
||||
label="实体别名"
|
||||
// rules={[{ required: true, message: '请输入实体别名' }]}
|
||||
>
|
||||
<FormItem name="name" label="实体别名">
|
||||
<Input placeholder="请输入实体别名,多个名称以英文逗号分隔" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
name="entityId"
|
||||
label="唯一标识"
|
||||
// rules={[{ required: true, message: '请选择实体标识' }]}
|
||||
>
|
||||
<FormItem name="entityId" label="唯一标识">
|
||||
<Select
|
||||
// mode="multiple"
|
||||
allowClear
|
||||
style={{ width: '100%' }}
|
||||
// filterOption={(inputValue: string, item: any) => {
|
||||
|
||||
@@ -22,22 +22,22 @@ const EntitySection: React.FC<Props> = ({
|
||||
dispatch,
|
||||
chatConfigType = ChatConfigType.DETAIL,
|
||||
}) => {
|
||||
const { selectDomainId, dimensionList, metricList } = domainManger;
|
||||
const { selectDomainId, selectModelId: modelId, dimensionList, metricList } = domainManger;
|
||||
|
||||
const [entityData, setentityData] = useState<IChatConfig.IChatRichConfig>();
|
||||
const [entityData, setEntityData] = useState<IChatConfig.IChatRichConfig>();
|
||||
|
||||
const queryThemeListData: any = async () => {
|
||||
const { code, data } = await getDomainExtendDetailConfig({
|
||||
domainId: selectDomainId,
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
const { chatAggRichConfig, chatDetailRichConfig, id, domainId } = data;
|
||||
const { chatAggRichConfig, chatDetailRichConfig, id, domainId, modelId } = data;
|
||||
if (chatConfigType === ChatConfigType.DETAIL) {
|
||||
setentityData({ ...chatDetailRichConfig, id, domainId });
|
||||
setEntityData({ ...chatDetailRichConfig, id, domainId, modelId });
|
||||
}
|
||||
if (chatConfigType === ChatConfigType.AGG) {
|
||||
setentityData({ ...chatAggRichConfig, id, domainId });
|
||||
setEntityData({ ...chatAggRichConfig, id, domainId, modelId });
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -50,8 +50,11 @@ const EntitySection: React.FC<Props> = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!modelId) {
|
||||
return;
|
||||
}
|
||||
initPage();
|
||||
}, [selectDomainId]);
|
||||
}, [modelId]);
|
||||
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useState, useEffect, useRef } from 'react';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import type { StateType } from '../../model';
|
||||
import { getDomainDetail } from '../../service';
|
||||
import { getModelDetail } from '../../service';
|
||||
import ProCard from '@ant-design/pro-card';
|
||||
import EntityCreateForm from './EntityCreateForm';
|
||||
import type { ISemantic } from '../../data';
|
||||
@@ -14,19 +14,19 @@ type Props = {
|
||||
};
|
||||
|
||||
const EntitySettingSection: React.FC<Props> = ({ domainManger }) => {
|
||||
const { selectDomainId, dimensionList } = domainManger;
|
||||
const { dimensionList, selectModelId: modelId } = domainManger;
|
||||
|
||||
const [domainData, setDomainData] = useState<ISemantic.IDomainItem>();
|
||||
const [modelData, setModelData] = useState<ISemantic.IModelItem>();
|
||||
|
||||
const entityCreateRef = useRef<any>({});
|
||||
|
||||
const queryDomainData: any = async () => {
|
||||
const { code, data } = await getDomainDetail({
|
||||
domainId: selectDomainId,
|
||||
const { code, data } = await getModelDetail({
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
setDomainData(data);
|
||||
setModelData(data);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ const EntitySettingSection: React.FC<Props> = ({ domainManger }) => {
|
||||
|
||||
useEffect(() => {
|
||||
initPage();
|
||||
}, [selectDomainId]);
|
||||
}, [modelId]);
|
||||
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
@@ -49,8 +49,8 @@ const EntitySettingSection: React.FC<Props> = ({ domainManger }) => {
|
||||
<ProCard title="实体" bordered>
|
||||
<EntityCreateForm
|
||||
ref={entityCreateRef}
|
||||
domainId={Number(selectDomainId)}
|
||||
domainData={domainData}
|
||||
modelId={Number(modelId)}
|
||||
modelData={modelData}
|
||||
dimensionList={dimensionList}
|
||||
onSubmit={() => {
|
||||
queryDomainData();
|
||||
|
||||
@@ -12,14 +12,14 @@ type Props = {
|
||||
};
|
||||
|
||||
const RecommendedQuestionsSection: React.FC<Props> = ({ domainManger }) => {
|
||||
const { selectDomainId } = domainManger;
|
||||
const { selectModelId: modelId } = domainManger;
|
||||
|
||||
const [questionData, setQuestionData] = useState<string[]>([]);
|
||||
const [currentRecordId, setCurrentRecordId] = useState<number>(0);
|
||||
|
||||
const queryThemeListData: any = async () => {
|
||||
const { code, data } = await getDomainExtendConfig({
|
||||
domainId: selectDomainId,
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
@@ -51,7 +51,7 @@ const RecommendedQuestionsSection: React.FC<Props> = ({ domainManger }) => {
|
||||
return { question };
|
||||
}),
|
||||
id: currentRecordId,
|
||||
domainId: selectDomainId,
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
@@ -65,8 +65,11 @@ const RecommendedQuestionsSection: React.FC<Props> = ({ domainManger }) => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!modelId) {
|
||||
return;
|
||||
}
|
||||
initPage();
|
||||
}, [selectDomainId]);
|
||||
}, [modelId]);
|
||||
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
|
||||
Reference in New Issue
Block a user