mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-18 16:27:13 +00:00
[improvement][semantic-fe] Optimizing the logic for setting dimension values and editing data sources, and adding system settings functionality (#383)
* [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
This commit is contained in:
@@ -146,7 +146,7 @@ const ClassDataSourceTable: React.FC<Props> = ({ dispatch, domainManger }) => {
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
{
|
||||
{createDataSourceModalOpen && (
|
||||
<ClassDataSourceTypeModal
|
||||
open={createDataSourceModalOpen}
|
||||
onCancel={() => {
|
||||
@@ -157,7 +157,7 @@ const ClassDataSourceTable: React.FC<Props> = ({ dispatch, domainManger }) => {
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,8 +2,9 @@ import { Button, Drawer, Result, Modal, Card, Row, Col } from 'antd';
|
||||
import { ConsoleSqlOutlined, CoffeeOutlined } from '@ant-design/icons';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { history, connect } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import DataSourceCreateForm from '../Datasource/components/DataSourceCreateForm';
|
||||
import { excuteSql } from '../service';
|
||||
import type { StateType } from '../model';
|
||||
import DataSource from '../Datasource';
|
||||
import { IDataSource } from '../data';
|
||||
@@ -33,8 +34,12 @@ const ClassDataSourceTypeModal: React.FC<Props> = ({
|
||||
|
||||
const [dataSourceModalVisible, setDataSourceModalVisible] = useState(false);
|
||||
const [fastModeSql, setFastModeSql] = useState<string>('');
|
||||
const [sql, setSql] = useState<string>('');
|
||||
|
||||
const [createDataSourceModalOpen, setCreateDataSourceModalOpen] = useState(false);
|
||||
const [createDataSourceModalOpen, setCreateDataSourceModalOpen] = useState<boolean>(false);
|
||||
const [dataSourceEditOpen, setDataSourceEditOpen] = useState<boolean>(false);
|
||||
const [currentDatabaseId, setCurrentDatabaseId] = useState<number>();
|
||||
const [scriptColumns, setScriptColumns] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dataSourceItem || !open) {
|
||||
@@ -65,6 +70,28 @@ const ClassDataSourceTypeModal: React.FC<Props> = ({
|
||||
onCancel?.();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryTableColumnListByScript(dataSourceItem);
|
||||
}, [dataSourceItem]);
|
||||
|
||||
const fetchTaskResult = (params) => {
|
||||
setScriptColumns(params.columns);
|
||||
};
|
||||
|
||||
const queryTableColumnListByScript = async (dataSource: IDataSource.IDataSourceItem) => {
|
||||
if (!dataSource) {
|
||||
return;
|
||||
}
|
||||
const { code, data, msg } = await excuteSql({
|
||||
sql: dataSource.datasourceDetail?.sqlQuery,
|
||||
id: dataSource.databaseId,
|
||||
});
|
||||
if (code === 200) {
|
||||
fetchTaskResult(data);
|
||||
setSql(dataSource?.datasourceDetail?.sqlQuery);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
@@ -140,25 +167,47 @@ const ClassDataSourceTypeModal: React.FC<Props> = ({
|
||||
/>
|
||||
)}
|
||||
{createModalVisible && (
|
||||
<Drawer
|
||||
width={'100%'}
|
||||
destroyOnClose
|
||||
title="数据源编辑"
|
||||
open={true}
|
||||
onClose={() => {
|
||||
<DataSourceCreateForm
|
||||
sql={sql}
|
||||
databaseId={currentDatabaseId}
|
||||
basicInfoFormMode="normal"
|
||||
dataSourceItem={dataSourceItem}
|
||||
scriptColumns={scriptColumns}
|
||||
onCancel={() => {
|
||||
setCreateModalVisible(false);
|
||||
handleCancel();
|
||||
}}
|
||||
footer={null}
|
||||
onSubmit={() => {
|
||||
setCreateModalVisible(false);
|
||||
onSubmit?.();
|
||||
}}
|
||||
createModalVisible={createModalVisible}
|
||||
onDataSourceBtnClick={() => {
|
||||
setDataSourceEditOpen(true);
|
||||
}}
|
||||
>
|
||||
<DataSource
|
||||
initialValues={dataSourceItem}
|
||||
onSubmitSuccess={() => {
|
||||
setCreateModalVisible(false);
|
||||
onSubmit?.();
|
||||
<Drawer
|
||||
width={'100%'}
|
||||
title="数据源编辑"
|
||||
open={dataSourceEditOpen}
|
||||
onClose={() => {
|
||||
setDataSourceEditOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Drawer>
|
||||
footer={null}
|
||||
>
|
||||
<DataSource
|
||||
initialValues={dataSourceItem}
|
||||
onSubmitSuccess={(dataSourceInfo) => {
|
||||
const { columns, sql, databaseId } = dataSourceInfo;
|
||||
setSql(sql);
|
||||
setScriptColumns(columns);
|
||||
setCurrentDatabaseId(databaseId);
|
||||
onSubmit?.();
|
||||
setDataSourceEditOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Drawer>
|
||||
</DataSourceCreateForm>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -423,6 +423,12 @@ const ClassDimensionTable: React.FC<Props> = ({ domainManger, dispatch }) => {
|
||||
open={dimensionValueSettingModalVisible}
|
||||
dimensionItem={dimensionItem}
|
||||
onCancel={() => {
|
||||
dispatch({
|
||||
type: 'domainManger/queryDimensionList',
|
||||
payload: {
|
||||
modelId,
|
||||
},
|
||||
});
|
||||
setDimensionValueSettingModalVisible(false);
|
||||
}}
|
||||
onSubmit={() => {
|
||||
|
||||
@@ -61,7 +61,7 @@ const CommonEditList: React.FC<Props> = ({ title, defaultCollapse = false, value
|
||||
activeKey ? (
|
||||
<Button
|
||||
key="saveBtn"
|
||||
type="primary"
|
||||
type="link"
|
||||
onClick={() => {
|
||||
if (!currentRecord && !currentSql) {
|
||||
setActiveKey(undefined);
|
||||
@@ -98,7 +98,7 @@ const CommonEditList: React.FC<Props> = ({ title, defaultCollapse = false, value
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type="primary"
|
||||
type="link"
|
||||
key="createBtn"
|
||||
onClick={() => {
|
||||
setCurrentRecord(undefined);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import { Space } from 'antd';
|
||||
import React, { useRef } from 'react';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import type { StateType } from '../../model';
|
||||
import ProCard from '@ant-design/pro-card';
|
||||
import DatabaseCreateForm from './DatabaseCreateForm';
|
||||
|
||||
type Props = {
|
||||
dispatch: Dispatch;
|
||||
domainManger: StateType;
|
||||
};
|
||||
|
||||
const DatabaseSection: React.FC<Props> = ({ domainManger, dispatch }) => {
|
||||
const { selectDomainId, dataBaseConfig } = domainManger;
|
||||
|
||||
const entityCreateRef = useRef<any>({});
|
||||
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={20}>
|
||||
<ProCard title="数据库设置" bordered>
|
||||
<DatabaseCreateForm
|
||||
ref={entityCreateRef}
|
||||
dataBaseConfig={dataBaseConfig}
|
||||
domainId={Number(selectDomainId)}
|
||||
onSubmit={() => {
|
||||
dispatch({
|
||||
type: 'domainManger/queryDatabaseByDomainId',
|
||||
payload: {
|
||||
domainId: selectDomainId,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</ProCard>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
||||
domainManger,
|
||||
}))(DatabaseSection);
|
||||
@@ -1,16 +1,17 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Modal, message, Space, Tooltip } from 'antd';
|
||||
import { Button, Modal, message, Space, Tooltip, Tabs } from 'antd';
|
||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { ISemantic } from '../data';
|
||||
import CommonEditTable from './CommonEditTable';
|
||||
import { updateDimension, mockDimensionValuesAlias } from '../service';
|
||||
import { connect } from 'umi';
|
||||
import DimensionValueSettingForm from './Entity/DimensionValueSettingForm';
|
||||
import type { StateType } from '../model';
|
||||
|
||||
export type CreateFormProps = {
|
||||
dimensionValueSettingList: ISemantic.IDimensionValueSettingItem[];
|
||||
onCancel: () => void;
|
||||
dimensionItem?: ISemantic.IDimensionItem;
|
||||
dimensionItem: ISemantic.IDimensionItem;
|
||||
open: boolean;
|
||||
onSubmit: (values?: any) => void;
|
||||
domainManger: StateType;
|
||||
@@ -18,7 +19,7 @@ export type CreateFormProps = {
|
||||
|
||||
type TableDataSource = { techName: string; bizName: string; alias?: string[] };
|
||||
|
||||
const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
const DimensionValueSettingModal: React.FC<CreateFormProps> = ({
|
||||
onCancel,
|
||||
open,
|
||||
dimensionItem,
|
||||
@@ -27,9 +28,10 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
onSubmit,
|
||||
}) => {
|
||||
const [tableDataSource, setTableDataSource] = useState<TableDataSource[]>([]);
|
||||
const { selectDomainId } = domainManger;
|
||||
const { selectDomainId, selectModelId: modelId } = domainManger;
|
||||
const [dimValueMaps, setDimValueMaps] = useState<ISemantic.IDimensionValueSettingItem[]>([]);
|
||||
const [llmLoading, setLlmLoading] = useState<boolean>(false);
|
||||
const [menuKey, setMenuKey] = useState<string>('default');
|
||||
|
||||
useEffect(() => {
|
||||
setTableDataSource(dimensionValueSettingList);
|
||||
@@ -74,29 +76,33 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
const renderFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
loading={llmLoading}
|
||||
onClick={() => {
|
||||
generatorDimensionValue();
|
||||
}}
|
||||
>
|
||||
<Space>
|
||||
智能填充
|
||||
<Tooltip title="智能填充将根据维度相关信息,使用大语言模型获取可能被使用的维度值">
|
||||
<InfoCircleOutlined />
|
||||
</Tooltip>
|
||||
</Space>
|
||||
</Button>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
{menuKey === 'default' && (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
loading={llmLoading}
|
||||
onClick={() => {
|
||||
generatorDimensionValue();
|
||||
}}
|
||||
>
|
||||
<Space>
|
||||
智能填充
|
||||
<Tooltip title="智能填充将根据维度相关信息,使用大语言模型获取可能被使用的维度值">
|
||||
<InfoCircleOutlined />
|
||||
</Tooltip>
|
||||
</Space>
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -154,6 +160,38 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const tabItem = [
|
||||
{
|
||||
label: '维度值填充',
|
||||
key: 'default',
|
||||
children: (
|
||||
<CommonEditTable
|
||||
tableDataSource={tableDataSource}
|
||||
columnList={columns}
|
||||
onDataSourceChange={(tableData) => {
|
||||
const dimValueMaps = tableData.map((item: TableDataSource) => {
|
||||
return {
|
||||
...item,
|
||||
};
|
||||
});
|
||||
|
||||
setDimValueMaps(dimValueMaps);
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
label: '维度值设置',
|
||||
key: 'setting',
|
||||
children: <DimensionValueSettingForm modelId={modelId} dimensionItem={dimensionItem} />,
|
||||
},
|
||||
];
|
||||
|
||||
const handleMenuChange = (key: string) => {
|
||||
setMenuKey(key);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
width={1200}
|
||||
@@ -165,18 +203,12 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
footer={renderFooter()}
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<CommonEditTable
|
||||
tableDataSource={tableDataSource}
|
||||
columnList={columns}
|
||||
onDataSourceChange={(tableData) => {
|
||||
const dimValueMaps = tableData.map((item: TableDataSource) => {
|
||||
return {
|
||||
...item,
|
||||
// alias: item.alias ? `${item.alias}`.split(',') : [],
|
||||
};
|
||||
});
|
||||
|
||||
setDimValueMaps(dimValueMaps);
|
||||
<Tabs
|
||||
items={tabItem}
|
||||
size="large"
|
||||
activeKey={menuKey}
|
||||
onChange={(menuKey: string) => {
|
||||
handleMenuChange(menuKey);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
@@ -185,4 +217,4 @@ const DimensionInfoModal: React.FC<CreateFormProps> = ({
|
||||
|
||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
||||
domainManger,
|
||||
}))(DimensionInfoModal);
|
||||
}))(DimensionValueSettingModal);
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { Modal, message, Tabs, Button } from 'antd';
|
||||
|
||||
import { addDomainExtend, editDomainExtend } from '../../service';
|
||||
import DimensionMetricVisibleTransfer from './DimensionMetricVisibleTransfer';
|
||||
import { IChatConfig } from '../../data';
|
||||
import DimensionValueSettingForm from './DimensionValueSettingForm';
|
||||
import { TransType } from '../../enum';
|
||||
import { wrapperTransTypeAndId, formatRichEntityDataListToIds } from './utils';
|
||||
|
||||
type Props = {
|
||||
domainId: number;
|
||||
entityData: any;
|
||||
chatConfigKey: string;
|
||||
settingSourceList: any[];
|
||||
onCancel: () => void;
|
||||
visible: boolean;
|
||||
onSubmit: (params?: { isSilenceSubmit?: boolean }) => void;
|
||||
};
|
||||
|
||||
const dimensionConfig = {
|
||||
blackIdListKey: 'blackDimIdList',
|
||||
visibleIdListKey: 'whiteDimIdList',
|
||||
modalTitle: '问答可见信息',
|
||||
titles: ['不可见维度/指标', '可见维度/指标'],
|
||||
};
|
||||
|
||||
const DimensionAndMetricVisibleModal: React.FC<Props> = ({
|
||||
domainId,
|
||||
visible,
|
||||
entityData = {},
|
||||
chatConfigKey,
|
||||
settingSourceList,
|
||||
onCancel,
|
||||
onSubmit,
|
||||
}) => {
|
||||
const [selectedKeyList, setSelectedKeyList] = useState<string[]>([]);
|
||||
const settingTypeConfig = dimensionConfig;
|
||||
const formatEntityData = formatRichEntityDataListToIds(entityData);
|
||||
const [knowledgeInfosMap, setKnowledgeInfosMap] = useState<IChatConfig.IKnowledgeInfosItemMap>(
|
||||
{},
|
||||
);
|
||||
|
||||
const [activeKey, setActiveKey] = useState<string>('visibleSetting');
|
||||
const formRef = useRef<any>();
|
||||
|
||||
const [globalKnowledgeConfigInitialValues, setGlobalKnowledgeConfigInitialValues] =
|
||||
useState<IChatConfig.IKnowledgeConfig>();
|
||||
|
||||
useEffect(() => {
|
||||
if (entityData?.visibility && Array.isArray(settingSourceList)) {
|
||||
const { whiteDimIdList, whiteMetricIdList } = entityData.visibility;
|
||||
const dimensionIdString = whiteDimIdList.map((dimensionId: number) => {
|
||||
return wrapperTransTypeAndId(TransType.DIMENSION, dimensionId);
|
||||
});
|
||||
const metricIdString = whiteMetricIdList.map((metricId: number) => {
|
||||
return wrapperTransTypeAndId(TransType.METRIC, metricId);
|
||||
});
|
||||
setSelectedKeyList([...dimensionIdString, ...metricIdString]);
|
||||
}
|
||||
if (entityData?.globalKnowledgeConfig) {
|
||||
setGlobalKnowledgeConfigInitialValues(entityData.globalKnowledgeConfig);
|
||||
}
|
||||
if (Array.isArray(entityData?.knowledgeInfos)) {
|
||||
const infoMap = entityData.knowledgeInfos.reduce(
|
||||
(maps: IChatConfig.IKnowledgeInfosItemMap, item: IChatConfig.IKnowledgeInfosItem) => {
|
||||
const { bizName } = item;
|
||||
maps[bizName] = item;
|
||||
return maps;
|
||||
},
|
||||
{},
|
||||
);
|
||||
setKnowledgeInfosMap(infoMap);
|
||||
}
|
||||
}, [entityData, settingSourceList]);
|
||||
|
||||
const saveEntity = async (submitData: any, isSilenceSubmit = false) => {
|
||||
const { selectedKeyList, knowledgeInfosMap } = submitData;
|
||||
const globalKnowledgeConfigFormFields = await formRef?.current?.getFormValidateFields?.();
|
||||
let globalKnowledgeConfig = entityData.globalKnowledgeConfig;
|
||||
if (globalKnowledgeConfigFormFields) {
|
||||
globalKnowledgeConfig = globalKnowledgeConfigFormFields;
|
||||
}
|
||||
const { id, modelId } = entityData;
|
||||
let saveDomainExtendQuery = addDomainExtend;
|
||||
if (id) {
|
||||
saveDomainExtendQuery = editDomainExtend;
|
||||
}
|
||||
|
||||
const blackIdListMap = settingSourceList.reduce(
|
||||
(ids, item) => {
|
||||
const { id, transType } = item;
|
||||
if (!selectedKeyList.includes(wrapperTransTypeAndId(transType, id))) {
|
||||
if (transType === TransType.DIMENSION) {
|
||||
ids.blackDimIdList.push(id);
|
||||
}
|
||||
if (transType === TransType.METRIC) {
|
||||
ids.blackMetricIdList.push(id);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
},
|
||||
{
|
||||
blackDimIdList: [],
|
||||
blackMetricIdList: [],
|
||||
},
|
||||
);
|
||||
|
||||
const knowledgeInfos = Object.keys(knowledgeInfosMap).reduce(
|
||||
(infoList: IChatConfig.IKnowledgeInfosItem[], key: string) => {
|
||||
const target = knowledgeInfosMap[key];
|
||||
if (target.searchEnable) {
|
||||
infoList.push(target);
|
||||
}
|
||||
return infoList;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const params = {
|
||||
...formatEntityData,
|
||||
visibility: blackIdListMap,
|
||||
knowledgeInfos,
|
||||
...(globalKnowledgeConfig ? { globalKnowledgeConfig } : {}),
|
||||
};
|
||||
|
||||
const { code, msg } = await saveDomainExtendQuery({
|
||||
[chatConfigKey]: params,
|
||||
id,
|
||||
modelId,
|
||||
});
|
||||
if (code === 200) {
|
||||
if (!isSilenceSubmit) {
|
||||
message.success('保存成功');
|
||||
}
|
||||
onSubmit?.({ isSilenceSubmit });
|
||||
return;
|
||||
}
|
||||
message.error(msg);
|
||||
};
|
||||
|
||||
const handleTransferChange = (newTargetKeys: string[]) => {
|
||||
setSelectedKeyList(newTargetKeys);
|
||||
};
|
||||
|
||||
const renderFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
saveEntity({ selectedKeyList, knowledgeInfosMap });
|
||||
}}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const tabItem = [
|
||||
{
|
||||
label: '可见设置',
|
||||
key: 'visibleSetting',
|
||||
children: (
|
||||
<DimensionMetricVisibleTransfer
|
||||
onKnowledgeInfosMapChange={(knowledgeInfos) => {
|
||||
setKnowledgeInfosMap(knowledgeInfos);
|
||||
saveEntity({ selectedKeyList, knowledgeInfosMap: knowledgeInfos }, true);
|
||||
}}
|
||||
knowledgeInfosMap={knowledgeInfosMap}
|
||||
titles={settingTypeConfig.titles}
|
||||
sourceList={settingSourceList}
|
||||
targetList={selectedKeyList}
|
||||
onChange={(newTargetKeys) => {
|
||||
handleTransferChange(newTargetKeys);
|
||||
saveEntity({ selectedKeyList: newTargetKeys, knowledgeInfosMap }, true);
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
label: '全局维度值过滤',
|
||||
key: 'dimensionValueFilter',
|
||||
children: (
|
||||
<div style={{ margin: '0 auto', width: '975px' }}>
|
||||
<DimensionValueSettingForm
|
||||
initialValues={globalKnowledgeConfigInitialValues}
|
||||
ref={formRef}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
width={1500}
|
||||
destroyOnClose
|
||||
title={settingTypeConfig.modalTitle}
|
||||
maskClosable={false}
|
||||
open={visible}
|
||||
footer={activeKey === 'visibleSetting' ? false : renderFooter()}
|
||||
// footer={false}
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<Tabs
|
||||
items={tabItem}
|
||||
defaultActiveKey="visibleSetting"
|
||||
onChange={(key) => {
|
||||
setActiveKey(key);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DimensionAndMetricVisibleModal;
|
||||
@@ -1,89 +0,0 @@
|
||||
import { useState, forwardRef } from 'react';
|
||||
import type { ForwardRefRenderFunction } from 'react';
|
||||
import { Form, Button } from 'antd';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import DimensionAndMetricVisibleModal from './DimensionAndMetricVisibleModal';
|
||||
import { TransType } from '../../enum';
|
||||
import { wrapperTransTypeAndId } from './utils';
|
||||
|
||||
type Props = {
|
||||
entityData: any;
|
||||
chatConfigKey: string;
|
||||
metricList: any[];
|
||||
dimensionList: any[];
|
||||
domainId: number;
|
||||
onSubmit: (params?: any) => void;
|
||||
};
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const DimensionMetricVisibleForm: ForwardRefRenderFunction<any, Props> = ({
|
||||
domainId,
|
||||
metricList,
|
||||
dimensionList,
|
||||
entityData,
|
||||
chatConfigKey,
|
||||
onSubmit,
|
||||
}) => {
|
||||
const [dimensionModalVisible, setDimensionModalVisible] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Form {...formLayout}>
|
||||
<FormItem
|
||||
label={
|
||||
<FormItemTitle title={'可见维度/指标'} subTitle={'设置可见后,将允许在问答中被使用'} />
|
||||
}
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setDimensionModalVisible(true);
|
||||
}}
|
||||
>
|
||||
设 置
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
{dimensionModalVisible && (
|
||||
<DimensionAndMetricVisibleModal
|
||||
domainId={domainId}
|
||||
entityData={entityData}
|
||||
chatConfigKey={chatConfigKey}
|
||||
settingSourceList={[
|
||||
...dimensionList.map((item) => {
|
||||
const transType = TransType.DIMENSION;
|
||||
const { id } = item;
|
||||
return {
|
||||
...item,
|
||||
transType,
|
||||
key: wrapperTransTypeAndId(transType, id),
|
||||
};
|
||||
}),
|
||||
...metricList.map((item) => {
|
||||
const transType = TransType.METRIC;
|
||||
const { id } = item;
|
||||
return {
|
||||
...item,
|
||||
transType,
|
||||
key: wrapperTransTypeAndId(transType, id),
|
||||
};
|
||||
}),
|
||||
]}
|
||||
visible={dimensionModalVisible}
|
||||
onCancel={() => {
|
||||
setDimensionModalVisible(false);
|
||||
}}
|
||||
onSubmit={(params) => {
|
||||
onSubmit?.();
|
||||
if (!params?.isSilenceSubmit) {
|
||||
setDimensionModalVisible(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(DimensionMetricVisibleForm);
|
||||
@@ -37,96 +37,96 @@ const DimensionMetricVisibleTableTransfer: React.FC<Props> = ({
|
||||
onKnowledgeInfosMapChange,
|
||||
...restProps
|
||||
}) => {
|
||||
const { selectModelId: modelId } = domainManger;
|
||||
const [dimensionValueSettingModalVisible, setDimensionValueSettingModalVisible] =
|
||||
useState<boolean>(false);
|
||||
const [currentRecord, setCurrentRecord] = useState<RecordType>({} as RecordType);
|
||||
const [currentDimensionSettingFormData, setCurrentDimensionSettingFormData] =
|
||||
useState<IChatConfig.IKnowledgeConfig>();
|
||||
// const { selectModelId: modelId } = domainManger;
|
||||
// const [dimensionValueSettingModalVisible, setDimensionValueSettingModalVisible] =
|
||||
// useState<boolean>(false);
|
||||
// const [currentRecord, setCurrentRecord] = useState<RecordType>({} as RecordType);
|
||||
// const [currentDimensionSettingFormData, setCurrentDimensionSettingFormData] =
|
||||
// useState<IChatConfig.IKnowledgeConfig>();
|
||||
|
||||
const [recordLoadingMap, setRecordLoadingMap] = useState<Record<string, boolean>>({});
|
||||
// const [recordLoadingMap, setRecordLoadingMap] = useState<Record<string, boolean>>({});
|
||||
|
||||
const [taskStateMap, setTaskStateMap] = useState<TaskStateMap>({});
|
||||
// const [taskStateMap, setTaskStateMap] = useState<TaskStateMap>({});
|
||||
|
||||
useEffect(() => {
|
||||
queryDictLatestTaskList();
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// queryDictLatestTaskList();
|
||||
// }, []);
|
||||
|
||||
const updateKnowledgeInfosMap = (record: RecordType, updateData: Record<string, any>) => {
|
||||
const { bizName, id } = record;
|
||||
const knowledgeMap = {
|
||||
...knowledgeInfosMap,
|
||||
};
|
||||
const target = knowledgeMap[bizName];
|
||||
if (target) {
|
||||
knowledgeMap[bizName] = {
|
||||
...target,
|
||||
...updateData,
|
||||
};
|
||||
} else {
|
||||
knowledgeMap[bizName] = {
|
||||
itemId: id,
|
||||
bizName,
|
||||
...updateData,
|
||||
};
|
||||
}
|
||||
onKnowledgeInfosMapChange?.(knowledgeMap);
|
||||
};
|
||||
// const updateKnowledgeInfosMap = (record: RecordType, updateData: Record<string, any>) => {
|
||||
// const { bizName, id } = record;
|
||||
// const knowledgeMap = {
|
||||
// ...knowledgeInfosMap,
|
||||
// };
|
||||
// const target = knowledgeMap[bizName];
|
||||
// if (target) {
|
||||
// knowledgeMap[bizName] = {
|
||||
// ...target,
|
||||
// ...updateData,
|
||||
// };
|
||||
// } else {
|
||||
// knowledgeMap[bizName] = {
|
||||
// itemId: id,
|
||||
// bizName,
|
||||
// ...updateData,
|
||||
// };
|
||||
// }
|
||||
// onKnowledgeInfosMapChange?.(knowledgeMap);
|
||||
// };
|
||||
|
||||
const queryDictLatestTaskList = async () => {
|
||||
const { code, data } = await searchDictLatestTaskList({
|
||||
modelId,
|
||||
});
|
||||
if (code !== 200) {
|
||||
message.error('获取字典导入任务失败!');
|
||||
return;
|
||||
}
|
||||
const tastMap = data.reduce(
|
||||
(stateMap: TaskStateMap, item: { dimId: number; status: DictTaskState }) => {
|
||||
const { dimId, status } = item;
|
||||
stateMap[dimId] = status;
|
||||
return stateMap;
|
||||
},
|
||||
{},
|
||||
);
|
||||
setTaskStateMap(tastMap);
|
||||
};
|
||||
// const queryDictLatestTaskList = async () => {
|
||||
// const { code, data } = await searchDictLatestTaskList({
|
||||
// modelId,
|
||||
// });
|
||||
// if (code !== 200) {
|
||||
// message.error('获取字典导入任务失败!');
|
||||
// return;
|
||||
// }
|
||||
// const tastMap = data.reduce(
|
||||
// (stateMap: TaskStateMap, item: { dimId: number; status: DictTaskState }) => {
|
||||
// const { dimId, status } = item;
|
||||
// stateMap[dimId] = status;
|
||||
// return stateMap;
|
||||
// },
|
||||
// {},
|
||||
// );
|
||||
// setTaskStateMap(tastMap);
|
||||
// };
|
||||
|
||||
const createDictTaskQuery = async (recordData: RecordType) => {
|
||||
setRecordLoadingMap({
|
||||
...recordLoadingMap,
|
||||
[recordData.id]: true,
|
||||
});
|
||||
const { code } = await createDictTask({
|
||||
updateMode: 'REALTIME_ADD',
|
||||
modelAndDimPair: {
|
||||
[modelId]: [recordData.id],
|
||||
},
|
||||
});
|
||||
setRecordLoadingMap({
|
||||
...recordLoadingMap,
|
||||
[recordData.id]: false,
|
||||
});
|
||||
if (code !== 200) {
|
||||
message.error('字典导入任务创建失败!');
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
queryDictLatestTaskList();
|
||||
}, 2000);
|
||||
};
|
||||
// const createDictTaskQuery = async (recordData: RecordType) => {
|
||||
// setRecordLoadingMap({
|
||||
// ...recordLoadingMap,
|
||||
// [recordData.id]: true,
|
||||
// });
|
||||
// const { code } = await createDictTask({
|
||||
// updateMode: 'REALTIME_ADD',
|
||||
// modelAndDimPair: {
|
||||
// [modelId]: [recordData.id],
|
||||
// },
|
||||
// });
|
||||
// setRecordLoadingMap({
|
||||
// ...recordLoadingMap,
|
||||
// [recordData.id]: false,
|
||||
// });
|
||||
// if (code !== 200) {
|
||||
// message.error('字典导入任务创建失败!');
|
||||
// return;
|
||||
// }
|
||||
// setTimeout(() => {
|
||||
// queryDictLatestTaskList();
|
||||
// }, 2000);
|
||||
// };
|
||||
|
||||
const deleteDictTask = async (recordData: RecordType) => {
|
||||
const { code } = await createDictTask({
|
||||
updateMode: 'REALTIME_DELETE',
|
||||
modelAndDimPair: {
|
||||
[modelId]: [recordData.id],
|
||||
},
|
||||
});
|
||||
if (code !== 200) {
|
||||
message.error('删除字典导入任务创建失败!');
|
||||
}
|
||||
};
|
||||
// const deleteDictTask = async (recordData: RecordType) => {
|
||||
// const { code } = await createDictTask({
|
||||
// updateMode: 'REALTIME_DELETE',
|
||||
// modelAndDimPair: {
|
||||
// [modelId]: [recordData.id],
|
||||
// },
|
||||
// });
|
||||
// if (code !== 200) {
|
||||
// message.error('删除字典导入任务创建失败!');
|
||||
// }
|
||||
// };
|
||||
|
||||
let rightColumns: ColumnsType<RecordType> = [
|
||||
{
|
||||
@@ -141,104 +141,104 @@ const DimensionMetricVisibleTableTransfer: React.FC<Props> = ({
|
||||
return <TransTypeTag type={type} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: 'y',
|
||||
title: (
|
||||
<TableTitleTooltips
|
||||
title="维度值可见"
|
||||
tooltips="勾选可见后,维度值将在搜索时可以被联想出来"
|
||||
/>
|
||||
),
|
||||
width: 120,
|
||||
render: (_: any, record: RecordType) => {
|
||||
const { type, bizName } = record;
|
||||
return type === TransType.DIMENSION ? (
|
||||
<Checkbox
|
||||
checked={knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
onChange={(e: CheckboxChangeEvent) => {
|
||||
updateKnowledgeInfosMap(record, { searchEnable: e.target.checked });
|
||||
if (!e.target.checked) {
|
||||
deleteDictTask(record);
|
||||
}
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: 'taskState',
|
||||
width: 130,
|
||||
title: (
|
||||
<Space>
|
||||
导入字典状态
|
||||
<span
|
||||
className={styles.taskStateRefreshIcon}
|
||||
onClick={() => {
|
||||
queryDictLatestTaskList();
|
||||
}}
|
||||
>
|
||||
<Tooltip title="刷新字典任务状态">
|
||||
<RedoOutlined />
|
||||
</Tooltip>
|
||||
</span>
|
||||
</Space>
|
||||
),
|
||||
render: (_, record) => {
|
||||
const { id, type } = record;
|
||||
const target = taskStateMap[id];
|
||||
if (type === TransType.DIMENSION && target) {
|
||||
return DictTaskState[target] || '未知状态';
|
||||
}
|
||||
return '--';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'x',
|
||||
render: (_: any, record: RecordType) => {
|
||||
const { type, bizName, id } = record;
|
||||
return type === TransType.DIMENSION ? (
|
||||
<Space>
|
||||
<Button
|
||||
style={{ padding: 0 }}
|
||||
key="importDictBtn"
|
||||
type="link"
|
||||
disabled={!knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
loading={!!recordLoadingMap[id]}
|
||||
onClick={(event) => {
|
||||
createDictTaskQuery(record);
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
导入字典
|
||||
</Button>
|
||||
<Button
|
||||
style={{ padding: 0 }}
|
||||
key="editable"
|
||||
type="link"
|
||||
disabled={!knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
onClick={(event) => {
|
||||
setCurrentRecord(record);
|
||||
setCurrentDimensionSettingFormData(
|
||||
knowledgeInfosMap?.[bizName]?.knowledgeAdvancedConfig,
|
||||
);
|
||||
setDimensionValueSettingModalVisible(true);
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
可见维度值设置
|
||||
</Button>
|
||||
</Space>
|
||||
) : (
|
||||
<></>
|
||||
);
|
||||
},
|
||||
},
|
||||
// {
|
||||
// dataIndex: 'y',
|
||||
// title: (
|
||||
// <TableTitleTooltips
|
||||
// title="维度值可见"
|
||||
// tooltips="勾选可见后,维度值将在搜索时可以被联想出来"
|
||||
// />
|
||||
// ),
|
||||
// width: 120,
|
||||
// render: (_: any, record: RecordType) => {
|
||||
// const { type, bizName } = record;
|
||||
// return type === TransType.DIMENSION ? (
|
||||
// <Checkbox
|
||||
// checked={knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
// onChange={(e: CheckboxChangeEvent) => {
|
||||
// updateKnowledgeInfosMap(record, { searchEnable: e.target.checked });
|
||||
// if (!e.target.checked) {
|
||||
// deleteDictTask(record);
|
||||
// }
|
||||
// }}
|
||||
// onClick={(event) => {
|
||||
// event.stopPropagation();
|
||||
// }}
|
||||
// />
|
||||
// ) : (
|
||||
// <></>
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// dataIndex: 'taskState',
|
||||
// width: 130,
|
||||
// title: (
|
||||
// <Space>
|
||||
// 导入字典状态
|
||||
// <span
|
||||
// className={styles.taskStateRefreshIcon}
|
||||
// onClick={() => {
|
||||
// queryDictLatestTaskList();
|
||||
// }}
|
||||
// >
|
||||
// <Tooltip title="刷新字典任务状态">
|
||||
// <RedoOutlined />
|
||||
// </Tooltip>
|
||||
// </span>
|
||||
// </Space>
|
||||
// ),
|
||||
// render: (_, record) => {
|
||||
// const { id, type } = record;
|
||||
// const target = taskStateMap[id];
|
||||
// if (type === TransType.DIMENSION && target) {
|
||||
// return DictTaskState[target] || '未知状态';
|
||||
// }
|
||||
// return '--';
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: '操作',
|
||||
// dataIndex: 'x',
|
||||
// render: (_: any, record: RecordType) => {
|
||||
// const { type, bizName, id } = record;
|
||||
// return type === TransType.DIMENSION ? (
|
||||
// <Space>
|
||||
// <Button
|
||||
// style={{ padding: 0 }}
|
||||
// key="importDictBtn"
|
||||
// type="link"
|
||||
// disabled={!knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
// loading={!!recordLoadingMap[id]}
|
||||
// onClick={(event) => {
|
||||
// createDictTaskQuery(record);
|
||||
// event.stopPropagation();
|
||||
// }}
|
||||
// >
|
||||
// 导入字典
|
||||
// </Button>
|
||||
// <Button
|
||||
// style={{ padding: 0 }}
|
||||
// key="editable"
|
||||
// type="link"
|
||||
// disabled={!knowledgeInfosMap?.[bizName]?.searchEnable}
|
||||
// onClick={(event) => {
|
||||
// setCurrentRecord(record);
|
||||
// setCurrentDimensionSettingFormData(
|
||||
// knowledgeInfosMap?.[bizName]?.knowledgeAdvancedConfig,
|
||||
// );
|
||||
// setDimensionValueSettingModalVisible(true);
|
||||
// event.stopPropagation();
|
||||
// }}
|
||||
// >
|
||||
// 可见维度值设置
|
||||
// </Button>
|
||||
// </Space>
|
||||
// ) : (
|
||||
// <></>
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
];
|
||||
|
||||
const leftColumns: ColumnsType<RecordType> = [
|
||||
@@ -299,7 +299,7 @@ const DimensionMetricVisibleTableTransfer: React.FC<Props> = ({
|
||||
);
|
||||
}}
|
||||
</Transfer>
|
||||
<DimensionValueSettingModal
|
||||
{/* <DimensionValueSettingModal
|
||||
visible={dimensionValueSettingModalVisible}
|
||||
initialValues={currentDimensionSettingFormData}
|
||||
onSubmit={(formValues) => {
|
||||
@@ -309,12 +309,11 @@ const DimensionMetricVisibleTableTransfer: React.FC<Props> = ({
|
||||
onCancel={() => {
|
||||
setDimensionValueSettingModalVisible(false);
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// export default DimensionMetricVisibleTableTransfer;
|
||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
||||
domainManger,
|
||||
}))(DimensionMetricVisibleTableTransfer);
|
||||
|
||||
@@ -1,29 +1,117 @@
|
||||
import { useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||
import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||
import type { ForwardRefRenderFunction } from 'react';
|
||||
import { Form, Input } from 'antd';
|
||||
|
||||
import { Form, Input, Switch, Space, Button, Divider, Tooltip, message } from 'antd';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
import { RedoOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import { DictTaskState, TransType } from '../../enum';
|
||||
import {
|
||||
getDomainExtendDetailConfig,
|
||||
addDomainExtend,
|
||||
editDomainExtend,
|
||||
searchDictLatestTaskList,
|
||||
createDictTask,
|
||||
} from '../../service';
|
||||
import type { IChatConfig, ISemantic } from '../../data';
|
||||
import { isString } from 'lodash';
|
||||
import styles from '../style.less';
|
||||
import CommonEditList from '../../components/CommonEditList';
|
||||
|
||||
type Props = {
|
||||
initialValues: any;
|
||||
modelId: number;
|
||||
dimensionItem: ISemantic.IDimensionItem;
|
||||
onSubmit?: () => void;
|
||||
};
|
||||
|
||||
type TaskStateMap = Record<string, DictTaskState>;
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const EntityCreateForm: ForwardRefRenderFunction<any, Props> = ({ initialValues }, ref) => {
|
||||
const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
{ modelId, dimensionItem },
|
||||
ref,
|
||||
) => {
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const exchangeFields = ['blackList', 'whiteList'];
|
||||
const [modelRichConfigData, setModelRichConfigData] = useState<IChatConfig.IConfig>();
|
||||
const [dimensionVisible, setDimensionVisible] = useState<boolean>(false);
|
||||
const [taskStateMap, setTaskStateMap] = useState<TaskStateMap>({});
|
||||
const [saveLoading, setSaveLoading] = useState<boolean>(false);
|
||||
const [refreshLoading, setRefreshLoading] = useState<boolean>(false);
|
||||
|
||||
const queryThemeListData: any = async () => {
|
||||
const { code, data } = await getDomainExtendDetailConfig({
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
setModelRichConfigData(data);
|
||||
const targetKnowledgeInfos = data?.chatAggRichConfig?.knowledgeInfos || [];
|
||||
const targetConfig = targetKnowledgeInfos.find(
|
||||
(item: IChatConfig.IKnowledgeInfosItem) => item.itemId === dimensionItem.id,
|
||||
);
|
||||
if (targetConfig) {
|
||||
const { knowledgeAdvancedConfig, searchEnable } = targetConfig;
|
||||
setDimensionVisible(searchEnable);
|
||||
const { blackList, whiteList, ruleList } = knowledgeAdvancedConfig;
|
||||
form.setFieldsValue({
|
||||
blackList: blackList.join(','),
|
||||
whiteList: whiteList.join(','),
|
||||
ruleList: ruleList || [],
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
message.error('获取问答设置信息失败');
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryThemeListData();
|
||||
queryDictLatestTaskList();
|
||||
}, []);
|
||||
|
||||
const taskRender = (dimension: ISemantic.IDimensionItem) => {
|
||||
const { id, type } = dimension;
|
||||
const target = taskStateMap[id];
|
||||
if (type === TransType.DIMENSION && target) {
|
||||
return DictTaskState[target] || '未知状态';
|
||||
}
|
||||
return '--';
|
||||
};
|
||||
|
||||
const queryDictLatestTaskList = async () => {
|
||||
setRefreshLoading(true);
|
||||
const { code, data } = await searchDictLatestTaskList({
|
||||
modelId,
|
||||
});
|
||||
setRefreshLoading(false);
|
||||
if (code !== 200) {
|
||||
message.error('获取字典导入任务失败!');
|
||||
return;
|
||||
}
|
||||
const tastMap = data.reduce(
|
||||
(stateMap: TaskStateMap, item: { dimId: number; status: DictTaskState }) => {
|
||||
const { dimId, status } = item;
|
||||
stateMap[dimId] = status;
|
||||
return stateMap;
|
||||
},
|
||||
{},
|
||||
);
|
||||
setTaskStateMap(tastMap);
|
||||
};
|
||||
|
||||
const getFormValidateFields = async () => {
|
||||
const fields = await form.validateFields();
|
||||
const fieldValue = Object.keys(fields).reduce((formField, key: string) => {
|
||||
const targetValue = fields[key];
|
||||
if (isString(targetValue) && exchangeFields.includes(key)) {
|
||||
formField[key] = targetValue.split(',');
|
||||
if (exchangeFields.includes(key)) {
|
||||
if (isString(targetValue)) {
|
||||
formField[key] = targetValue.split(',');
|
||||
} else {
|
||||
formField[key] = [];
|
||||
}
|
||||
} else {
|
||||
formField[key] = targetValue;
|
||||
}
|
||||
@@ -34,47 +122,201 @@ const EntityCreateForm: ForwardRefRenderFunction<any, Props> = ({ initialValues
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if (!initialValues) {
|
||||
return;
|
||||
}
|
||||
const fieldValue = Object.keys(initialValues).reduce((formField, key: string) => {
|
||||
const targetValue = initialValues[key];
|
||||
if (Array.isArray(targetValue) && exchangeFields.includes(key)) {
|
||||
formField[key] = targetValue.join(',');
|
||||
} else {
|
||||
formField[key] = targetValue;
|
||||
}
|
||||
return formField;
|
||||
}, {});
|
||||
form.setFieldsValue({
|
||||
...fieldValue,
|
||||
});
|
||||
}, [initialValues]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getFormValidateFields,
|
||||
}));
|
||||
|
||||
const createDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
||||
const { code } = await createDictTask({
|
||||
updateMode: 'REALTIME_ADD',
|
||||
modelAndDimPair: {
|
||||
[modelId]: [dimension.id],
|
||||
},
|
||||
});
|
||||
|
||||
if (code !== 200) {
|
||||
message.error('字典导入任务创建失败!');
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
queryDictLatestTaskList();
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
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)) {
|
||||
knowledgeInfos = targetKnowledgeInfos.reduce(
|
||||
(
|
||||
knowledgeInfosList: IChatConfig.IKnowledgeInfosItem[],
|
||||
item: IChatConfig.IKnowledgeInfosItem,
|
||||
) => {
|
||||
if (item.itemId === dimensionItem.id) {
|
||||
knowledgeInfosList.push({
|
||||
...item,
|
||||
knowledgeAdvancedConfig: {
|
||||
...item.knowledgeAdvancedConfig,
|
||||
...globalKnowledgeConfigFormFields,
|
||||
},
|
||||
searchEnable,
|
||||
});
|
||||
} else {
|
||||
knowledgeInfosList.push({
|
||||
...item,
|
||||
});
|
||||
}
|
||||
return knowledgeInfosList;
|
||||
},
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
const { id, modelId, chatAggRichConfig } = tempData;
|
||||
const saveParams = {
|
||||
id,
|
||||
modelId,
|
||||
chatAggConfig: {
|
||||
...chatAggRichConfig,
|
||||
knowledgeInfos,
|
||||
},
|
||||
};
|
||||
let saveDomainExtendQuery = addDomainExtend;
|
||||
if (id) {
|
||||
saveDomainExtendQuery = editDomainExtend;
|
||||
}
|
||||
|
||||
const { code, msg } = await saveDomainExtendQuery({
|
||||
...saveParams,
|
||||
});
|
||||
setSaveLoading(false);
|
||||
if (code === 200) {
|
||||
return;
|
||||
}
|
||||
message.error(msg);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form {...formLayout} form={form} layout="vertical" className={styles.form}>
|
||||
<FormItem name="blackList" label="黑名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
</FormItem>
|
||||
<Form
|
||||
{...formLayout}
|
||||
form={form}
|
||||
style={{ margin: '0 30px 30px 30px' }}
|
||||
layout="vertical"
|
||||
className={styles.form}
|
||||
>
|
||||
<FormItem
|
||||
style={{ marginTop: 15, marginBottom: -30 }}
|
||||
label={
|
||||
<FormItemTitle
|
||||
title={
|
||||
<>
|
||||
<Space>
|
||||
<span style={{ fontSize: 16 }}>维度值可见</span>
|
||||
<Switch
|
||||
defaultChecked
|
||||
size="small"
|
||||
checked={dimensionVisible}
|
||||
onChange={(value) => {
|
||||
saveEntity(value);
|
||||
setDimensionVisible(value);
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
</>
|
||||
}
|
||||
subTitle={'设置可见后,维度值将在搜索时可以被联想出来'}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{dimensionVisible && (
|
||||
<Space size={20} style={{ marginBottom: 20 }}>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{ padding: 0 }}
|
||||
onClick={(event) => {
|
||||
createDictTaskQuery(dimensionItem);
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<Tooltip title="立即将维度值导入字典">
|
||||
<Space>
|
||||
立即导入字典 <InfoCircleOutlined />
|
||||
</Space>
|
||||
</Tooltip>
|
||||
</Button>
|
||||
|
||||
<FormItem name="whiteList" label="白名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
</FormItem>
|
||||
<Tooltip title="刷新字典任务状态">
|
||||
<Space>
|
||||
<Button
|
||||
style={{ cursor: 'pointer' }}
|
||||
type="text"
|
||||
loading={refreshLoading}
|
||||
onClick={() => {
|
||||
queryDictLatestTaskList();
|
||||
}}
|
||||
>
|
||||
导入状态
|
||||
<RedoOutlined />:
|
||||
</Button>
|
||||
</Space>
|
||||
</Tooltip>
|
||||
|
||||
<FormItem name="ruleList">
|
||||
{/* <SqlEditor height={'150px'} /> */}
|
||||
<CommonEditList title="过滤规则" />
|
||||
<span>{taskRender(dimensionItem)}</span>
|
||||
</Space>
|
||||
)}
|
||||
</FormItem>
|
||||
{dimensionVisible && (
|
||||
<>
|
||||
<Divider
|
||||
style={{
|
||||
marginBottom: 35,
|
||||
}}
|
||||
/>
|
||||
<div style={{ padding: 20, border: '1px solid #eee', borderRadius: 10 }}>
|
||||
<div
|
||||
style={{
|
||||
color: '#2f374c',
|
||||
fontSize: 16,
|
||||
display: 'flex',
|
||||
marginBottom: 20,
|
||||
}}
|
||||
>
|
||||
<span style={{ flex: 'auto' }}>维度值过滤</span>
|
||||
<span style={{ marginLeft: 'auto' }}>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
saveEntity();
|
||||
}}
|
||||
loading={saveLoading}
|
||||
>
|
||||
保 存
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<FormItem name="blackList" label="黑名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem name="whiteList" label="白名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem name="ruleList">
|
||||
<CommonEditList title="过滤规则" />
|
||||
</FormItem>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(EntityCreateForm);
|
||||
export default forwardRef(DimensionValueSettingForm);
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Button, Modal } from 'antd';
|
||||
import DimensionValueSettingForm from './DimensionValueSettingForm';
|
||||
|
||||
type Props = {
|
||||
initialValues: any;
|
||||
onCancel?: () => void;
|
||||
visible: boolean;
|
||||
onSubmit?: (params?: any) => void;
|
||||
};
|
||||
const DimensionValueSettingModal: React.FC<Props> = ({
|
||||
initialValues,
|
||||
visible,
|
||||
onCancel,
|
||||
onSubmit,
|
||||
}) => {
|
||||
const formRef = useRef<any>();
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const formValues = await formRef.current.getFormValidateFields();
|
||||
onSubmit?.(formValues);
|
||||
};
|
||||
|
||||
const renderFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleSubmit();
|
||||
}}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
width={600}
|
||||
destroyOnClose
|
||||
title={'维度值设置'}
|
||||
maskClosable={false}
|
||||
open={visible}
|
||||
footer={renderFooter()}
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<DimensionValueSettingForm initialValues={initialValues} ref={formRef} />
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DimensionValueSettingModal;
|
||||
@@ -8,7 +8,6 @@ import ProCard from '@ant-design/pro-card';
|
||||
|
||||
import DefaultSettingForm from './DefaultSettingForm';
|
||||
import type { IChatConfig } from '../../data';
|
||||
import DimensionMetricVisibleForm from './DimensionMetricVisibleForm';
|
||||
import { ChatConfigType } from '../../enum';
|
||||
|
||||
type Props = {
|
||||
@@ -19,7 +18,6 @@ type Props = {
|
||||
|
||||
const EntitySection: React.FC<Props> = ({
|
||||
domainManger,
|
||||
dispatch,
|
||||
chatConfigType = ChatConfigType.DETAIL,
|
||||
}) => {
|
||||
const { selectDomainId, selectModelId: modelId, dimensionList, metricList } = domainManger;
|
||||
@@ -59,28 +57,6 @@ const EntitySection: React.FC<Props> = ({
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={20}>
|
||||
<ProCard bordered title="问答可见">
|
||||
<DimensionMetricVisibleForm
|
||||
chatConfigKey={
|
||||
chatConfigType === ChatConfigType.DETAIL ? 'chatDetailConfig' : 'chatAggConfig'
|
||||
}
|
||||
entityData={entityData || {}}
|
||||
domainId={Number(selectDomainId)}
|
||||
metricList={metricList}
|
||||
dimensionList={dimensionList}
|
||||
onSubmit={(params: any = {}) => {
|
||||
if (params.from === 'dimensionSearchVisible') {
|
||||
dispatch({
|
||||
type: 'domainManger/queryDimensionList',
|
||||
payload: {
|
||||
domainId: selectDomainId,
|
||||
},
|
||||
});
|
||||
}
|
||||
queryThemeListData();
|
||||
}}
|
||||
/>
|
||||
</ProCard>
|
||||
<ProCard bordered title="默认设置">
|
||||
<DefaultSettingForm
|
||||
domainId={Number(selectDomainId)}
|
||||
|
||||
@@ -57,7 +57,7 @@ const ModelTable: React.FC<Props> = ({
|
||||
},
|
||||
{
|
||||
dataIndex: 'name',
|
||||
title: '指标名称',
|
||||
title: '模型名称',
|
||||
search: false,
|
||||
render: (_, record) => {
|
||||
return (
|
||||
@@ -73,9 +73,9 @@ const ModelTable: React.FC<Props> = ({
|
||||
},
|
||||
{
|
||||
dataIndex: 'key',
|
||||
title: '指标搜索',
|
||||
title: '模型搜索',
|
||||
hideInTable: true,
|
||||
renderFormItem: () => <Input placeholder="请输入ID/指标名称/字段名称/标签" />,
|
||||
renderFormItem: () => <Input placeholder="请输入ID/模型名称/字段名称/标签" />,
|
||||
},
|
||||
{
|
||||
dataIndex: 'alias',
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import { CheckCard } from '@ant-design/pro-components';
|
||||
import React, { useState } from 'react';
|
||||
import { Button, Dropdown, message, Popconfirm } from 'antd';
|
||||
import { PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
|
||||
import React from 'react';
|
||||
import { ISemantic } from '../data';
|
||||
import { connect } from 'umi';
|
||||
import icon from '../../../assets/icon/cloudEditor.svg';
|
||||
import type { Dispatch } from 'umi';
|
||||
import type { StateType } from '../model';
|
||||
import { formatNumber } from '../../../utils/utils';
|
||||
import { deleteModel } from '../service';
|
||||
import ModelCreateFormModal from './ModelCreateFormModal';
|
||||
import ModelTable from './ModelTable';
|
||||
import styles from './style.less';
|
||||
|
||||
type Props = {
|
||||
disabledEdit?: boolean;
|
||||
@@ -21,136 +13,10 @@ type Props = {
|
||||
dispatch: Dispatch;
|
||||
};
|
||||
|
||||
const OverView: React.FC<Props> = ({
|
||||
modelList,
|
||||
disabledEdit = false,
|
||||
onModelChange,
|
||||
domainManger,
|
||||
}) => {
|
||||
// const { selectDomainId, selectModelId } = domainManger;
|
||||
// const [currentModel, setCurrentModel] = useState<any>({});
|
||||
// const [modelCreateFormModalVisible, setModelCreateFormModalVisible] = useState<boolean>(false);
|
||||
|
||||
// const descNode = (model: ISemantic.IDomainItem) => {
|
||||
// const { metricCnt, dimensionCnt } = model;
|
||||
// return (
|
||||
// <div className={styles.overviewExtraContainer}>
|
||||
// <div className={styles.extraWrapper}>
|
||||
// <div className={styles.extraStatistic}>
|
||||
// <div className={styles.extraTitle}>维度数</div>
|
||||
// <div className={styles.extraValue}>
|
||||
// <span className="ant-statistic-content-value">{formatNumber(dimensionCnt || 0)}</span>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div className={styles.extraWrapper}>
|
||||
// <div className={styles.extraStatistic}>
|
||||
// <div className={styles.extraTitle}>指标数</div>
|
||||
// <div className={styles.extraValue}>
|
||||
// <span className="ant-statistic-content-value">{formatNumber(metricCnt || 0)}</span>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
// const extraNode = (model: ISemantic.IDomainItem) => {
|
||||
// return (
|
||||
// <Dropdown
|
||||
// placement="top"
|
||||
// menu={{
|
||||
// onClick: ({ key, domEvent }) => {
|
||||
// domEvent.stopPropagation();
|
||||
// if (key === 'edit') {
|
||||
// setCurrentModel(model);
|
||||
// setModelCreateFormModalVisible(true);
|
||||
// }
|
||||
// },
|
||||
// items: [
|
||||
// {
|
||||
// label: '编辑',
|
||||
// key: 'edit',
|
||||
// },
|
||||
// {
|
||||
// label: (
|
||||
// <Popconfirm
|
||||
// title="确认删除?"
|
||||
// okText="是"
|
||||
// cancelText="否"
|
||||
// onConfirm={async () => {
|
||||
// const { code, msg } = await deleteModel(model.id);
|
||||
// if (code === 200) {
|
||||
// onModelChange?.();
|
||||
// } else {
|
||||
// message.error(msg);
|
||||
// }
|
||||
// }}
|
||||
// >
|
||||
// <a key="modelDeleteBtn">删除</a>
|
||||
// </Popconfirm>
|
||||
// ),
|
||||
// key: 'delete',
|
||||
// },
|
||||
// ],
|
||||
// }}
|
||||
// >
|
||||
// <EllipsisOutlined
|
||||
// style={{ fontSize: 22, color: 'rgba(0,0,0,0.5)' }}
|
||||
// onClick={(e) => e.stopPropagation()}
|
||||
// />
|
||||
// </Dropdown>
|
||||
// );
|
||||
// };
|
||||
|
||||
const OverView: React.FC<Props> = ({ modelList, disabledEdit = false, onModelChange }) => {
|
||||
return (
|
||||
<div style={{ padding: '0px 20px 20px' }}>
|
||||
<div style={{ padding: '20px' }}>
|
||||
<ModelTable modelList={modelList} disabledEdit={disabledEdit} onModelChange={onModelChange} />
|
||||
{/* {!disabledEdit && (
|
||||
<div style={{ paddingBottom: '20px' }}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setModelCreateFormModalVisible(true);
|
||||
}}
|
||||
type="primary"
|
||||
>
|
||||
<PlusOutlined />
|
||||
新增模型
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<CheckCard.Group value={selectModelId} defaultValue={selectModelId}>
|
||||
{modelList &&
|
||||
modelList.map((model: ISemantic.IDomainItem) => {
|
||||
return (
|
||||
<CheckCard
|
||||
avatar={icon}
|
||||
title={`${model.name}`}
|
||||
key={model.id}
|
||||
value={model.id}
|
||||
description={descNode(model)}
|
||||
extra={!disabledEdit && extraNode(model)}
|
||||
onClick={() => {
|
||||
onModelChange?.(model);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</CheckCard.Group> */}
|
||||
{/* {modelCreateFormModalVisible && (
|
||||
<ModelCreateFormModal
|
||||
domainId={selectDomainId}
|
||||
basicInfo={currentModel}
|
||||
onSubmit={() => {
|
||||
setModelCreateFormModalVisible(false);
|
||||
onModelChange?.();
|
||||
}}
|
||||
onCancel={() => {
|
||||
setModelCreateFormModalVisible(false);
|
||||
}}
|
||||
/>
|
||||
)} */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -210,7 +210,11 @@
|
||||
.classTable {
|
||||
:global {
|
||||
.ant-pro-table-search-query-filter {
|
||||
padding-left: 0 !important;
|
||||
// padding-left: 0 !important;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.ant-pro-table-list-toolbar-container {
|
||||
padding-top: 0;
|
||||
}
|
||||
.ant-table-tbody > tr.ant-table-row-selected > td {
|
||||
background: none;
|
||||
|
||||
Reference in New Issue
Block a user