mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-20 06:34:55 +00:00
[improvement][semantic-fe] Fixing the logic error in the dimension value setting. (#499)
* [improvement][semantic-fe] Add model alias setting & Add view permission restrictions to the model permission management tab. [improvement][semantic-fe] Add permission control to the action buttons for the main domain; apply high sensitivity filtering to the authorization of metrics/dimensions. [improvement][semantic-fe] Optimize the editing mode in the dimension/metric/datasource components to use the modelId stored in the database for data, instead of relying on the data from the state manager. * [improvement][semantic-fe] Add time granularity setting in the data source configuration. * [improvement][semantic-fe] Dictionary import for dimension values supported in Q&A visibility * [improvement][semantic-fe] Modification of data source creation prompt wording" * [improvement][semantic-fe] metric market experience optimization * [improvement][semantic-fe] enhance the analysis of metric trends * [improvement][semantic-fe] optimize the presentation of metric trend permissions * [improvement][semantic-fe] add metric trend download functionality * [improvement][semantic-fe] fix the dimension initialization issue in metric correlation * [improvement][semantic-fe] Fix the issue of database changes not taking effect when creating based on an SQL data source. * [improvement][semantic-fe] Optimizing pagination logic and some CSS styles * [improvement][semantic-fe] Fixing the API for the indicator list by changing "current" to "pageNum" * [improvement][semantic-fe] Fixing the default value setting for the indicator list * [improvement][semantic-fe] Adding batch operations for indicators/dimensions/models * [improvement][semantic-fe] Replacing the single status update API for indicators/dimensions with a batch update API * [improvement][semantic-fe] Redesigning the indicator homepage to incorporate trend charts and table functionality for indicators * [improvement][semantic-fe] Optimizing the logic for setting dimension values and editing data sources, and adding system settings functionality * [improvement][semantic-fe] Upgrading antd version to 5.x, extracting the batch operation button component, optimizing the interaction for system settings, and expanding the configuration generation types for list-to-select component. * [improvement][semantic-fe] Adding the ability to filter dimensions based on whether they are tags or not. * [improvement][semantic-fe] Adding the ability to edit relationships between models in the canvas. * [improvement][semantic-fe] Updating the datePicker component to use dayjs instead. * [improvement][semantic-fe] Fixing the issue with passing the model ID for dimensions in the indicator market. * [improvement][semantic-fe] Fixing the abnormal state of the popup when creating a model. * [improvement][semantic-fe] Adding permission logic for bulk operations in the indicator market. * [improvement][semantic-fe] Adding the ability to download and transpose data. * [improvement][semantic-fe] Fixing the initialization issue with the date selection component in the indicator details page when switching time granularity. * [improvement][semantic-fe] Fixing the logic error in the dimension value setting.
This commit is contained in:
@@ -423,6 +423,7 @@ const ClassDimensionTable: React.FC<Props> = ({ domainManger, dispatch }) => {
|
||||
{createModalVisible && (
|
||||
<DimensionInfoModal
|
||||
modelId={modelId}
|
||||
domainId={domainId}
|
||||
bindModalVisible={createModalVisible}
|
||||
dimensionItem={dimensionItem}
|
||||
dataSourceList={dataSourceList}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Form, Input, Modal, Select } from 'antd';
|
||||
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import { ISemantic } from '../../data';
|
||||
import { saveCommonDimension, getDimensionList } from '../../service';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
import { message } from 'antd';
|
||||
|
||||
export type CreateFormProps = {
|
||||
domainId: number;
|
||||
dimensionItem?: ISemantic.IDimensionItem;
|
||||
onCancel: () => void;
|
||||
bindModalVisible: boolean;
|
||||
dimensionList: ISemantic.IDimensionItem[];
|
||||
onSubmit: (values?: any) => void;
|
||||
};
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const { TextArea } = Input;
|
||||
|
||||
const CommonDimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
domainId,
|
||||
onCancel,
|
||||
bindModalVisible,
|
||||
dimensionItem,
|
||||
onSubmit: handleUpdate,
|
||||
}) => {
|
||||
const isEdit = !!dimensionItem?.id;
|
||||
const [form] = Form.useForm();
|
||||
const { setFieldsValue, resetFields } = form;
|
||||
const [saveLoading, setSaveLoading] = useState<boolean>(false);
|
||||
const [dimensionOptions, setDimensionOptions] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
queryDimensionList();
|
||||
}, []);
|
||||
|
||||
const queryDimensionList = async () => {
|
||||
setSaveLoading(true);
|
||||
const { code, data, msg } = await getDimensionList({ domainId });
|
||||
setSaveLoading(false);
|
||||
const dimensionList = data?.list;
|
||||
if (code === 200 && Array.isArray(dimensionList)) {
|
||||
const dimensionMap = dimensionList.reduce(
|
||||
(
|
||||
dataMap: Record<
|
||||
string,
|
||||
{ label: string; options: { label: string; value: number; disabled?: boolean }[] }
|
||||
>,
|
||||
item: ISemantic.IDimensionItem,
|
||||
) => {
|
||||
const { modelId, modelName, name, id, commonDimensionId } = item;
|
||||
const target = dataMap[modelId];
|
||||
if (target) {
|
||||
target.options.push({
|
||||
label: name,
|
||||
value: id,
|
||||
disabled: !!commonDimensionId,
|
||||
});
|
||||
} else {
|
||||
dataMap[modelId] = {
|
||||
label: modelName || `${modelId}`,
|
||||
options: [
|
||||
{
|
||||
label: name,
|
||||
value: id,
|
||||
disabled: !!commonDimensionId,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
return dataMap;
|
||||
},
|
||||
{},
|
||||
);
|
||||
setDimensionOptions(Object.values(dimensionMap));
|
||||
} else {
|
||||
message.error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (isSilenceSubmit = false) => {
|
||||
const fieldsValue = await form.validateFields();
|
||||
await saveDimension(
|
||||
{
|
||||
...fieldsValue,
|
||||
},
|
||||
isSilenceSubmit,
|
||||
);
|
||||
};
|
||||
|
||||
const saveDimension = async (fieldsValue: any, isSilenceSubmit = false) => {
|
||||
const queryParams = {
|
||||
domainId: isEdit ? dimensionItem.domainId : domainId,
|
||||
type: 'categorical',
|
||||
...fieldsValue,
|
||||
};
|
||||
|
||||
const { code, msg } = await saveCommonDimension(queryParams);
|
||||
if (code === 200) {
|
||||
if (!isSilenceSubmit) {
|
||||
message.success('编辑公共维度成功');
|
||||
handleUpdate(fieldsValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
message.error(msg);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (dimensionItem) {
|
||||
setFieldsValue({ ...dimensionItem });
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}, [dimensionItem]);
|
||||
|
||||
const renderFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
loading={saveLoading}
|
||||
onClick={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const renderContent = () => {
|
||||
return (
|
||||
<>
|
||||
<FormItem hidden={true} name="id" label="ID">
|
||||
<Input placeholder="id" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
name="name"
|
||||
label="公共维度名称"
|
||||
rules={[{ required: true, message: '请输入公共维度名称' }]}
|
||||
>
|
||||
<Input placeholder="名称不可重复" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
name="bizName"
|
||||
label="字段名称"
|
||||
rules={[{ required: true, message: '请输入字段名称' }]}
|
||||
>
|
||||
<Input placeholder="名称不可重复" disabled={isEdit} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
// label="关联维度"
|
||||
label={
|
||||
<FormItemTitle
|
||||
title={`关联维度`}
|
||||
subTitle={`维度不能关联多个公共维度,已关联的维度会被禁用`}
|
||||
/>
|
||||
}
|
||||
name="dimensionIds"
|
||||
// rules={[{ required: true, message: '请选择所要关联的维度' }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
mode="multiple"
|
||||
allowClear
|
||||
placeholder="选择所要关联的维度"
|
||||
options={dimensionOptions}
|
||||
filterOption={(input, option: any) =>
|
||||
((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem name="description" label="维度描述">
|
||||
<TextArea placeholder="请输入维度描述" />
|
||||
</FormItem>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
width={800}
|
||||
destroyOnClose
|
||||
title="公共维度信息"
|
||||
style={{ top: 48 }}
|
||||
maskClosable={false}
|
||||
open={bindModalVisible}
|
||||
footer={renderFooter()}
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<Form {...formLayout} form={form}>
|
||||
{renderContent()}
|
||||
</Form>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default CommonDimensionInfoModal;
|
||||
@@ -0,0 +1,196 @@
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-table';
|
||||
import ProTable from '@ant-design/pro-table';
|
||||
import { message, Button, Space, Popconfirm, Input } from 'antd';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import type { StateType } from '../../model';
|
||||
import { getCommonDimensionList, deleteCommonDimension } from '../../service';
|
||||
import CommonDimensionInfoModal from './CommonDimensionInfoModal';
|
||||
import { ISemantic } from '../../data';
|
||||
import moment from 'moment';
|
||||
import styles from '../style.less';
|
||||
|
||||
type Props = {
|
||||
dispatch: Dispatch;
|
||||
domainManger: StateType;
|
||||
};
|
||||
|
||||
const CommonDimensionTable: React.FC<Props> = ({ domainManger, dispatch }) => {
|
||||
const { selectDomainId: domainId, dimensionList } = domainManger;
|
||||
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
|
||||
const [dimensionItem, setDimensionItem] = useState<ISemantic.IDimensionItem>();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
|
||||
const actionRef = useRef<ActionType>();
|
||||
|
||||
const queryDimensionList = async () => {
|
||||
setLoading(true);
|
||||
const { code, data, msg } = await getCommonDimensionList(domainId);
|
||||
setLoading(false);
|
||||
let resData: any = {};
|
||||
if (code === 200) {
|
||||
resData = {
|
||||
data: data || [],
|
||||
success: true,
|
||||
};
|
||||
} else {
|
||||
message.error(msg);
|
||||
resData = {
|
||||
data: [],
|
||||
total: 0,
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
return resData;
|
||||
};
|
||||
|
||||
const columns: ProColumns[] = [
|
||||
{
|
||||
dataIndex: 'id',
|
||||
title: 'ID',
|
||||
width: 80,
|
||||
order: 100,
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
dataIndex: 'key',
|
||||
title: '维度搜索',
|
||||
hideInTable: true,
|
||||
renderFormItem: () => <Input placeholder="请输入ID/维度名称/字段名称" />,
|
||||
},
|
||||
{
|
||||
dataIndex: 'name',
|
||||
title: '维度名称',
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
dataIndex: 'bizName',
|
||||
title: '字段名称',
|
||||
search: false,
|
||||
// order: 9,
|
||||
},
|
||||
{
|
||||
dataIndex: 'createdBy',
|
||||
title: '创建人',
|
||||
width: 100,
|
||||
search: false,
|
||||
},
|
||||
|
||||
{
|
||||
dataIndex: 'description',
|
||||
title: '描述',
|
||||
search: false,
|
||||
},
|
||||
|
||||
{
|
||||
dataIndex: 'updatedAt',
|
||||
title: '更新时间',
|
||||
width: 180,
|
||||
search: false,
|
||||
render: (value: any) => {
|
||||
return value && value !== '-' ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'x',
|
||||
valueType: 'option',
|
||||
width: 200,
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<Space className={styles.ctrlBtnContainer}>
|
||||
<Button
|
||||
key="dimensionEditBtn"
|
||||
type="link"
|
||||
onClick={() => {
|
||||
setDimensionItem(record);
|
||||
setCreateModalVisible(true);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="删除会自动解除所关联的维度,是否确认?"
|
||||
okText="是"
|
||||
cancelText="否"
|
||||
placement="left"
|
||||
onConfirm={async () => {
|
||||
const { code, msg } = await deleteCommonDimension(record.id);
|
||||
if (code === 200) {
|
||||
setDimensionItem(undefined);
|
||||
actionRef.current?.reload();
|
||||
} else {
|
||||
message.error(msg);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
key="dimensionDeleteEditBtn"
|
||||
onClick={() => {
|
||||
setDimensionItem(record);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<ProTable
|
||||
style={{ marginTop: 15 }}
|
||||
className={`${styles.classTable} ${styles.classTableSelectColumnAlignLeft}`}
|
||||
actionRef={actionRef}
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
request={queryDimensionList}
|
||||
loading={loading}
|
||||
search={false}
|
||||
tableAlertRender={() => {
|
||||
return false;
|
||||
}}
|
||||
size="small"
|
||||
options={{ reload: false, density: false, fullScreen: false }}
|
||||
toolBarRender={() => [
|
||||
<Button
|
||||
key="create"
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setDimensionItem(undefined);
|
||||
setCreateModalVisible(true);
|
||||
}}
|
||||
>
|
||||
创建公共维度
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
|
||||
{createModalVisible && (
|
||||
<CommonDimensionInfoModal
|
||||
domainId={domainId}
|
||||
bindModalVisible={createModalVisible}
|
||||
dimensionItem={dimensionItem}
|
||||
dimensionList={dimensionList}
|
||||
onSubmit={() => {
|
||||
setCreateModalVisible(false);
|
||||
actionRef?.current?.reload();
|
||||
return;
|
||||
}}
|
||||
onCancel={() => {
|
||||
setCreateModalVisible(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
||||
domainManger,
|
||||
}))(CommonDimensionTable);
|
||||
@@ -6,13 +6,19 @@ import SqlEditor from '@/components/SqlEditor';
|
||||
import InfoTagList from './InfoTagList';
|
||||
import { ISemantic } from '../data';
|
||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { createDimension, updateDimension, mockDimensionAlias } from '../service';
|
||||
import {
|
||||
createDimension,
|
||||
updateDimension,
|
||||
mockDimensionAlias,
|
||||
getCommonDimensionList,
|
||||
} from '../service';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
|
||||
import { message } from 'antd';
|
||||
|
||||
export type CreateFormProps = {
|
||||
modelId: number;
|
||||
domainId: number;
|
||||
dimensionItem?: ISemantic.IDimensionItem;
|
||||
onCancel: () => void;
|
||||
bindModalVisible: boolean;
|
||||
@@ -26,6 +32,7 @@ const { Option } = Select;
|
||||
const { TextArea } = Input;
|
||||
|
||||
const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
domainId,
|
||||
modelId,
|
||||
onCancel,
|
||||
bindModalVisible,
|
||||
@@ -40,6 +47,7 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
const [form] = Form.useForm();
|
||||
const { setFieldsValue, resetFields } = form;
|
||||
const [llmLoading, setLlmLoading] = useState<boolean>(false);
|
||||
const [commonDimensionOptions, setCommonDimensionOptions] = useState([]);
|
||||
|
||||
const handleSubmit = async (
|
||||
isSilenceSubmit = false,
|
||||
@@ -56,6 +64,26 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryCommonDimensionList();
|
||||
}, [domainId]);
|
||||
|
||||
const queryCommonDimensionList = async () => {
|
||||
const { code, data, msg } = await getCommonDimensionList(domainId);
|
||||
// const { list, pageSize, pageNum, total } = data || {};
|
||||
if (code === 200) {
|
||||
const options = data.map((item) => {
|
||||
return {
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
};
|
||||
});
|
||||
setCommonDimensionOptions(options);
|
||||
} else {
|
||||
message.error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
const saveDimension = async (fieldsValue: any, isSilenceSubmit = false) => {
|
||||
const queryParams = {
|
||||
modelId: isEdit ? dimensionItem.modelId : modelId,
|
||||
@@ -215,6 +243,9 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
))}
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem name="commonDimensionId" label="公共维度">
|
||||
<Select placeholder="请绑定公共维度" allowClear options={commonDimensionOptions} />
|
||||
</FormItem>
|
||||
<FormItem name="defaultValues" label="默认值">
|
||||
<InfoTagList />
|
||||
</FormItem>
|
||||
|
||||
@@ -13,6 +13,7 @@ import { HomeOutlined, FundViewOutlined } from '@ant-design/icons';
|
||||
import { ISemantic } from '../data';
|
||||
import SemanticGraphCanvas from '../SemanticGraphCanvas';
|
||||
import RecommendedQuestionsSection from '../components/Entity/RecommendedQuestionsSection';
|
||||
import CommonDimensionTable from './CommonDimension/CommonDimensionTable';
|
||||
import DatabaseTable from '../components/Database/DatabaseTable';
|
||||
|
||||
import type { Dispatch } from 'umi';
|
||||
@@ -72,6 +73,11 @@ const DomainManagerTab: React.FC<Props> = ({
|
||||
key: 'database',
|
||||
children: <DatabaseTable />,
|
||||
},
|
||||
// {
|
||||
// label: '公共维度',
|
||||
// key: 'commonDimension',
|
||||
// children: <CommonDimensionTable />,
|
||||
// },
|
||||
].filter((item) => {
|
||||
const target = domainList.find((domain) => domain.id === selectDomainId);
|
||||
if (target?.hasEditPermission) {
|
||||
|
||||
@@ -146,10 +146,14 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
const saveEntity = async (searchEnable = dimensionVisible) => {
|
||||
setSaveLoading(true);
|
||||
const globalKnowledgeConfigFormFields: any = await getFormValidateFields();
|
||||
|
||||
const tempData = { ...modelRichConfigData };
|
||||
const targetKnowledgeInfos = modelRichConfigData?.chatAggRichConfig?.knowledgeInfos;
|
||||
let knowledgeInfos: IChatConfig.IKnowledgeInfosItem[] = [];
|
||||
if (Array.isArray(targetKnowledgeInfos)) {
|
||||
const targetKnowledgeInfos = modelRichConfigData?.chatAggRichConfig?.knowledgeInfos || [];
|
||||
|
||||
const hasHistoryConfig = targetKnowledgeInfos.find((item) => item.itemId === dimensionItem.id);
|
||||
let knowledgeInfos: IChatConfig.IKnowledgeInfosItem[] = targetKnowledgeInfos;
|
||||
|
||||
if (hasHistoryConfig) {
|
||||
knowledgeInfos = targetKnowledgeInfos.reduce(
|
||||
(
|
||||
knowledgeInfosList: IChatConfig.IKnowledgeInfosItem[],
|
||||
@@ -173,6 +177,15 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
},
|
||||
[],
|
||||
);
|
||||
} else {
|
||||
knowledgeInfos.push({
|
||||
itemId: dimensionItem.id,
|
||||
bizName: dimensionItem.bizName,
|
||||
knowledgeAdvancedConfig: {
|
||||
...globalKnowledgeConfigFormFields,
|
||||
},
|
||||
searchEnable,
|
||||
});
|
||||
}
|
||||
|
||||
const { id, modelId, chatAggRichConfig } = tempData;
|
||||
|
||||
Reference in New Issue
Block a user