mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
[improvement][headless-fe] Restructured the data for the dimension value settings interface. (#760)
* [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. * [improvement][semantic-fe] Fixing the synchronization issue with the question and answer settings information. * [improvement][semantic-fe] Optimizing the canvas functionality for better performance and user experience. * [improvement][semantic-fe] Optimizing the update process for drawing model relationship edges in the canvas. * [improvement][semantic-fe] Changing the line type for canvas connections. * [improvement][semantic-fe] Replacing the initialization variable from "semantic" to "headless". * [improvement][semantic-fe] Fixing the missing migration issue for default drill-down dimension configuration in model editing. Additionally, optimizing the data retrieval method for initializing fields in the model. * [improvement][semantic-fe] Updating the logic for the fieldName. * [improvement][semantic-fe] Adjusting the position of the metrics tab. * [improvement][semantic-fe] Changing the 字段名称 to 英文名称. * [improvement][semantic-fe] Fix metric measurement deletion. * [improvement][semantic-fe] UI optimization for metric details page. * [improvement][semantic-fe] UI optimization for metric details page. * [improvement][semantic-fe] UI adjustment for metric details page. * [improvement][semantic-fe] The granularity field in the time type of model editing now supports setting it as empty. * [improvement][semantic-fe] Added field type and metric type to the metric creation options. * [improvement][semantic-fe] The organization structure selection feature has been added to the permission management. * [improvement][semantic-fe] Improved user experience for the metric list. * [improvement][semantic-fe] fix update the metric list. * [improvement][headless-fe] Added view management functionality. * [improvement][headless-fe] The view management functionality has been added. This feature allows users to create, edit, and manage different views within the system. * [improvement][headless-fe] Added model editing side effect detection. * [improvement][headless-fe] Fixed the logic error in view editing. * [improvement][headless-fe] Fixed the issue with initializing dimension associations in metric settings. * [improvement][headless-fe] Added the ability to hide the Q&A settings entry point. * [improvement][headless-fe] Fixed the issue with selecting search results in metric field creation. * [improvement][headless-fe] Added search functionality to the field list in model editing. * [improvement][headless-fe] fix the field list in model editing * [improvement][headless-fe] Restructured the data for the dimension value settings interface.
This commit is contained in:
@@ -1,22 +1,4 @@
|
|||||||
export * from './models/base';
|
export * from './models/base';
|
||||||
type ObjToArrayParams = Record<string, string>;
|
|
||||||
|
|
||||||
const keyTypeTran = {
|
|
||||||
string: String,
|
|
||||||
number: Number,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* obj转成value,label的数组
|
|
||||||
* @param _obj
|
|
||||||
*/
|
|
||||||
export const objToArray = (_obj: ObjToArrayParams, keyType: string = 'string') => {
|
|
||||||
return Object.keys(_obj).map((key) => {
|
|
||||||
return {
|
|
||||||
value: keyTypeTran[keyType](key),
|
|
||||||
label: _obj[key],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
type EnumToArrayItem = {
|
type EnumToArrayItem = {
|
||||||
value: number;
|
value: number;
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { connect } from 'umi';
|
|
||||||
import type { StateType } from '../model';
|
|
||||||
import OverviewContainer from '../OverviewContainer';
|
|
||||||
import type { Dispatch } from 'umi';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
domainManger: StateType;
|
|
||||||
dispatch: Dispatch;
|
|
||||||
};
|
|
||||||
const ChatSetting: React.FC<Props> = () => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<OverviewContainer mode={'chatSetting'} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
|
||||||
domainManger,
|
|
||||||
}))(ChatSetting);
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import React, { useRef } from 'react';
|
|
||||||
import { connect } from 'umi';
|
|
||||||
import type { StateType } from '../model';
|
|
||||||
import ProCard from '@ant-design/pro-card';
|
|
||||||
import EntitySection from '../components/Entity/EntitySection';
|
|
||||||
import { ChatConfigType } from '../enum';
|
|
||||||
import type { Dispatch } from 'umi';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
domainManger: StateType;
|
|
||||||
dispatch: Dispatch;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ChatSettingSection: React.FC<Props> = () => {
|
|
||||||
const metricRef = useRef<any>();
|
|
||||||
const tagRef = useRef<any>();
|
|
||||||
return (
|
|
||||||
<div style={{ width: 900, margin: '20px auto' }}>
|
|
||||||
<ProCard bordered title="指标模式" style={{ marginBottom: 20 }}>
|
|
||||||
<EntitySection
|
|
||||||
ref={metricRef}
|
|
||||||
chatConfigType={ChatConfigType.METRIC}
|
|
||||||
onConfigSave={() => {
|
|
||||||
tagRef.current.refreshConfigData();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</ProCard>
|
|
||||||
<ProCard bordered title="标签模式" style={{ marginBottom: 20 }}>
|
|
||||||
<EntitySection
|
|
||||||
ref={tagRef}
|
|
||||||
chatConfigType={ChatConfigType.TAG}
|
|
||||||
onConfigSave={() => {
|
|
||||||
metricRef.current.refreshConfigData();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</ProCard>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
|
||||||
domainManger,
|
|
||||||
}))(ChatSettingSection);
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
import { Tabs, Button } from 'antd';
|
|
||||||
import React from 'react';
|
|
||||||
import { connect } from 'umi';
|
|
||||||
|
|
||||||
import styles from '../components/style.less';
|
|
||||||
import type { StateType } from '../model';
|
|
||||||
import { LeftOutlined } from '@ant-design/icons';
|
|
||||||
import EntitySection from '../components/Entity/EntitySection';
|
|
||||||
import RecommendedQuestionsSection from '../components/Entity/RecommendedQuestionsSection';
|
|
||||||
import { ISemantic } from '../data';
|
|
||||||
|
|
||||||
import OverView from '../components/OverView';
|
|
||||||
import { ChatConfigType } from '../enum';
|
|
||||||
import type { Dispatch } from 'umi';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
isModel: boolean;
|
|
||||||
activeKey: string;
|
|
||||||
modelList: ISemantic.IModelItem[];
|
|
||||||
handleModelChange: (model?: ISemantic.IModelItem) => void;
|
|
||||||
onBackDomainBtnClick?: () => void;
|
|
||||||
onMenuChange?: (menuKey: string) => void;
|
|
||||||
domainManger: StateType;
|
|
||||||
dispatch: Dispatch;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ChatSetting: React.FC<Props> = ({
|
|
||||||
isModel,
|
|
||||||
activeKey,
|
|
||||||
modelList,
|
|
||||||
handleModelChange,
|
|
||||||
onBackDomainBtnClick,
|
|
||||||
onMenuChange,
|
|
||||||
}) => {
|
|
||||||
const defaultTabKey = 'metric';
|
|
||||||
|
|
||||||
const isModelItem = [
|
|
||||||
{
|
|
||||||
label: '指标模式',
|
|
||||||
key: 'metric',
|
|
||||||
children: <EntitySection chatConfigType={ChatConfigType.METRIC} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '标签模式',
|
|
||||||
key: 'dimenstion',
|
|
||||||
children: <EntitySection chatConfigType={ChatConfigType.TAG} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '推荐问题',
|
|
||||||
key: 'recommendedQuestions',
|
|
||||||
children: <RecommendedQuestionsSection />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const tabItem = [
|
|
||||||
{
|
|
||||||
label: '模型',
|
|
||||||
key: 'overview',
|
|
||||||
children: (
|
|
||||||
<OverView
|
|
||||||
modelList={modelList}
|
|
||||||
disabledEdit={true}
|
|
||||||
onModelChange={(model) => {
|
|
||||||
handleModelChange(model);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Tabs
|
|
||||||
className={styles.tab}
|
|
||||||
items={isModel ? isModelItem : tabItem}
|
|
||||||
activeKey={activeKey || defaultTabKey}
|
|
||||||
destroyInactiveTabPane
|
|
||||||
tabBarExtraContent={
|
|
||||||
isModel ? (
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
icon={<LeftOutlined />}
|
|
||||||
onClick={() => {
|
|
||||||
onBackDomainBtnClick?.();
|
|
||||||
}}
|
|
||||||
style={{ marginRight: 10 }}
|
|
||||||
>
|
|
||||||
返回主题域
|
|
||||||
</Button>
|
|
||||||
) : undefined
|
|
||||||
}
|
|
||||||
onChange={(menuKey: string) => {
|
|
||||||
onMenuChange?.(menuKey);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(({ domainManger }: { domainManger: StateType }) => ({
|
|
||||||
domainManger,
|
|
||||||
}))(ChatSetting);
|
|
||||||
@@ -12,17 +12,17 @@ import {
|
|||||||
SwapOutlined,
|
SwapOutlined,
|
||||||
PlayCircleOutlined,
|
PlayCircleOutlined,
|
||||||
CloudServerOutlined,
|
CloudServerOutlined,
|
||||||
|
ApiOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { isFunction } from 'lodash';
|
import { isFunction } from 'lodash';
|
||||||
import FullScreen from '@/components/FullScreen';
|
import FullScreen from '@/components/FullScreen';
|
||||||
import SqlEditor from '@/components/SqlEditor';
|
import SqlEditor from '@/components/SqlEditor';
|
||||||
import type { TaskResultItem, TaskResultColumn } from '../data';
|
import type { TaskResultItem, TaskResultColumn } from '../data';
|
||||||
import { excuteSql } from '@/pages/SemanticModel/service';
|
import { excuteSql } from '@/pages/SemanticModel/service';
|
||||||
// import DataSourceCreateForm from './DataSourceCreateForm';
|
|
||||||
import type { Dispatch } from 'umi';
|
import type { Dispatch } from 'umi';
|
||||||
import type { StateType } from '../../model';
|
import type { StateType } from '../../model';
|
||||||
|
import SqlParams from './SqlParams';
|
||||||
import styles from '../style.less';
|
import styles from '../style.less';
|
||||||
|
|
||||||
import 'ace-builds/src-min-noconflict/ext-searchbox';
|
import 'ace-builds/src-min-noconflict/ext-searchbox';
|
||||||
import 'ace-builds/src-min-noconflict/theme-sqlserver';
|
import 'ace-builds/src-min-noconflict/theme-sqlserver';
|
||||||
import 'ace-builds/src-min-noconflict/theme-monokai';
|
import 'ace-builds/src-min-noconflict/theme-monokai';
|
||||||
@@ -77,7 +77,6 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
});
|
});
|
||||||
const [dataBaseItems, setDataBaseItems] = useState<DatabaseItem[]>([]);
|
const [dataBaseItems, setDataBaseItems] = useState<DatabaseItem[]>([]);
|
||||||
const [currentDatabaseItem, setCurrentDatabaseItem] = useState<DatabaseItem>();
|
const [currentDatabaseItem, setCurrentDatabaseItem] = useState<DatabaseItem>();
|
||||||
// const [dataSourceModalVisible, setDataSourceModalVisible] = useState(false);
|
|
||||||
|
|
||||||
const [tableScroll, setTableScroll] = useState({
|
const [tableScroll, setTableScroll] = useState({
|
||||||
scrollToFirstRowOnChange: true,
|
scrollToFirstRowOnChange: true,
|
||||||
@@ -88,7 +87,7 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
const [runState, setRunState] = useState<boolean | undefined>();
|
const [runState, setRunState] = useState<boolean | undefined>();
|
||||||
|
|
||||||
const [taskLog, setTaskLog] = useState('');
|
const [taskLog, setTaskLog] = useState('');
|
||||||
const [isSqlExcLocked, setIsSqlExcLocked] = useState(false);
|
const [isSqlExcLocked, setIsSqlExcLocked] = useState<boolean>(false);
|
||||||
const [screenSize, setScreenSize] = useState<ScreenSize>('middle');
|
const [screenSize, setScreenSize] = useState<ScreenSize>('middle');
|
||||||
|
|
||||||
const [isSqlIdeFullScreen, setIsSqlIdeFullScreen] = useState<boolean>(false);
|
const [isSqlIdeFullScreen, setIsSqlIdeFullScreen] = useState<boolean>(false);
|
||||||
@@ -100,8 +99,11 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
const DEFAULT_FULLSCREEN_TOP = 0;
|
const DEFAULT_FULLSCREEN_TOP = 0;
|
||||||
|
|
||||||
const [partialSql, setPartialSql] = useState('');
|
const [partialSql, setPartialSql] = useState('');
|
||||||
const [isPartial, setIsPartial] = useState(false);
|
const [isPartial, setIsPartial] = useState<boolean>(false);
|
||||||
const [isRight, setIsRight] = useState(false);
|
const [isRight, setIsRight] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [variableCollapsed, setVariableCollapsed] = useState<boolean>(true);
|
||||||
|
const [sqlParams, setSqlParams] = useState<IDataSource.ISqlParamsItem[]>([]);
|
||||||
|
|
||||||
const [scriptColumns, setScriptColumns] = useState<any[]>([]);
|
const [scriptColumns, setScriptColumns] = useState<any[]>([]);
|
||||||
|
|
||||||
@@ -125,6 +127,10 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
setCurrentDatabaseItem(targetDataBase);
|
setCurrentDatabaseItem(targetDataBase);
|
||||||
}, [dataSourceItem, databaseConfigList]);
|
}, [dataSourceItem, databaseConfigList]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSqlParams(dataSourceItem?.modelDetail?.sqlVariables || []);
|
||||||
|
}, [dataSourceItem]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRunState(undefined);
|
setRunState(undefined);
|
||||||
}, [currentDatabaseItem, sql]);
|
}, [currentDatabaseItem, sql]);
|
||||||
@@ -138,6 +144,11 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleVariable = () => {
|
||||||
|
const collapsedValue = !variableCollapsed;
|
||||||
|
setVariableCollapsed(collapsedValue);
|
||||||
|
};
|
||||||
|
|
||||||
// 计算每列的宽度,通过容器插入文档中动态得到该列数据(包括表头)的最长宽度,设为列宽度,保证每列的数据都能一行展示完
|
// 计算每列的宽度,通过容器插入文档中动态得到该列数据(包括表头)的最长宽度,设为列宽度,保证每列的数据都能一行展示完
|
||||||
function getKeyWidthMap(list: TaskResultItem[]): TaskResultItem {
|
function getKeyWidthMap(list: TaskResultItem[]): TaskResultItem {
|
||||||
const widthMap = {};
|
const widthMap = {};
|
||||||
@@ -417,6 +428,9 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
<Tooltip title="格式化SQL语句">
|
<Tooltip title="格式化SQL语句">
|
||||||
<EditOutlined className={styles.sqlOprIcon} onClick={formatSQL} />
|
<EditOutlined className={styles.sqlOprIcon} onClick={formatSQL} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{/* <Tooltip title="动态变量">
|
||||||
|
<ApiOutlined className={styles.sqlOprIcon} onClick={handleVariable} />
|
||||||
|
</Tooltip> */}
|
||||||
<Tooltip title="改变主题">
|
<Tooltip title="改变主题">
|
||||||
<SwapOutlined className={styles.sqlOprIcon} onClick={handleThemeChange} />
|
<SwapOutlined className={styles.sqlOprIcon} onClick={handleThemeChange} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -463,6 +477,12 @@ const SqlDetail: React.FC<IProps> = ({
|
|||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
className={variableCollapsed ? styles.hideSqlParams : styles.sqlParams}
|
||||||
|
// style={{ height: sqlEditorHeight }}
|
||||||
|
>
|
||||||
|
<SqlParams value={sqlParams} onChange={setSqlParams} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Pane>
|
</Pane>
|
||||||
<div className={`${styles.sqlBottmWrap} ${screenSize}`}>
|
<div className={`${styles.sqlBottmWrap} ${screenSize}`}>
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import type { SqlParamsItem, OprType } from '../data';
|
||||||
|
|
||||||
|
import styles from '../style.less';
|
||||||
|
import { AppstoreAddOutlined, DeleteTwoTone, EditTwoTone } from '@ant-design/icons';
|
||||||
|
import SqlParamsDetailModal from './SqlParamsDetailModal';
|
||||||
|
import { List } from 'antd';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value?: SqlParamsItem[];
|
||||||
|
onChange?: (e: SqlParamsItem[]) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const defalutItem: SqlParamsItem = {
|
||||||
|
name: '',
|
||||||
|
type: 'query',
|
||||||
|
defaultValues: [],
|
||||||
|
valueType: 'string',
|
||||||
|
udf: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const SqlParams: FC<Props> = ({ value, onChange }) => {
|
||||||
|
const [oprType, setOprType] = useState<OprType>('add');
|
||||||
|
const [visible, setVisible] = useState<boolean>(false);
|
||||||
|
const [initValue, setInitValue] = useState<SqlParamsItem>();
|
||||||
|
const paramsChange = (params: SqlParamsItem[]) => {
|
||||||
|
if (onChange) {
|
||||||
|
onChange(params);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleAdd = () => {
|
||||||
|
setOprType('add');
|
||||||
|
setVisible(true);
|
||||||
|
setInitValue(defalutItem);
|
||||||
|
};
|
||||||
|
const handleSave = async (values: SqlParamsItem) => {
|
||||||
|
const newValue = value ? [...value] : [];
|
||||||
|
const { index, ...rest } = values;
|
||||||
|
if (index || index === 0) {
|
||||||
|
newValue[index] = rest;
|
||||||
|
} else {
|
||||||
|
newValue.push(rest);
|
||||||
|
}
|
||||||
|
setVisible(false);
|
||||||
|
setInitValue(undefined);
|
||||||
|
paramsChange(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = (index: number) => {
|
||||||
|
const newValue = value ? [...value] : [];
|
||||||
|
newValue.splice(index, 1);
|
||||||
|
paramsChange(newValue);
|
||||||
|
};
|
||||||
|
const handleEdit = (index: number) => {
|
||||||
|
const paramsItem = value ? value[index] : defalutItem;
|
||||||
|
setInitValue({ ...paramsItem, index });
|
||||||
|
setOprType('edit');
|
||||||
|
setVisible(true);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={styles.sqlParamsBody}>
|
||||||
|
<div className={styles.header}>
|
||||||
|
<span className={styles.title}>变量</span>
|
||||||
|
<AppstoreAddOutlined className={styles.icon} onClick={handleAdd} />
|
||||||
|
</div>
|
||||||
|
<List
|
||||||
|
className={styles.paramsList}
|
||||||
|
dataSource={value}
|
||||||
|
renderItem={(item, index) => (
|
||||||
|
<List.Item
|
||||||
|
title={item.name}
|
||||||
|
className={styles.paramsItem}
|
||||||
|
key={item.name}
|
||||||
|
actions={[
|
||||||
|
<>
|
||||||
|
<EditTwoTone
|
||||||
|
className={styles.icon}
|
||||||
|
onClick={() => {
|
||||||
|
handleEdit(index);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<DeleteTwoTone
|
||||||
|
className={styles.icon}
|
||||||
|
onClick={() => {
|
||||||
|
handleDelete(index);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<div className={styles.name}>{item.name}</div>
|
||||||
|
</List.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<SqlParamsDetailModal
|
||||||
|
nameList={value?.map((item) => item.name)}
|
||||||
|
oprType={oprType}
|
||||||
|
modalVisible={visible}
|
||||||
|
onSave={handleSave}
|
||||||
|
onCancel={() => {
|
||||||
|
setVisible(false);
|
||||||
|
}}
|
||||||
|
initValue={initValue}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SqlParams;
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { Modal, Form, Input, Select, Checkbox } from 'antd';
|
||||||
|
import { isFunction } from 'lodash';
|
||||||
|
import { objToArray } from '@/utils/utils';
|
||||||
|
import type { ParamsItemProps, OprType } from '../data';
|
||||||
|
import { IDataSource } from '../../data';
|
||||||
|
import TextArea from 'antd/lib/input/TextArea';
|
||||||
|
import ParamsSqlEditor from './SqlParamsSqlEditor';
|
||||||
|
|
||||||
|
const EnumSqlParamsType = {
|
||||||
|
auth: '权限变量',
|
||||||
|
query: '查询变量',
|
||||||
|
};
|
||||||
|
|
||||||
|
const EnumSqlValueType = {
|
||||||
|
string: '字符串',
|
||||||
|
sql: 'SQL表达式',
|
||||||
|
date: '日期',
|
||||||
|
boolean: '布尔',
|
||||||
|
number: '数字',
|
||||||
|
};
|
||||||
|
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
|
const ParamsTextArea: FC<ParamsItemProps> = ({ value, onChange }) => {
|
||||||
|
return (
|
||||||
|
<TextArea
|
||||||
|
value={value && value[0]}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (onChange) {
|
||||||
|
onChange([e.target.value]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
placeholder="请输入表达式"
|
||||||
|
rows={3}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
type IProps = {
|
||||||
|
oprType: OprType;
|
||||||
|
modalVisible: boolean;
|
||||||
|
onSave: (values: IDataSource.ISqlParamsItem) => Promise<any>;
|
||||||
|
onCancel?: (oprType: OprType) => void;
|
||||||
|
initValue?: IDataSource.ISqlParamsItem;
|
||||||
|
nameList?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const SqlParamsDetailModal: FC<IProps> = ({
|
||||||
|
oprType = 'add',
|
||||||
|
initValue = {} as IDataSource.ISqlParamsItem,
|
||||||
|
modalVisible,
|
||||||
|
onSave,
|
||||||
|
onCancel,
|
||||||
|
nameList,
|
||||||
|
}) => {
|
||||||
|
const [valueType, setValueType] = useState<IDataSource.ISqlParamsValueType>();
|
||||||
|
const [udf, setUdf] = useState<boolean>();
|
||||||
|
const [oldName, setOldName] = useState<string>();
|
||||||
|
|
||||||
|
const formLayout = {
|
||||||
|
labelCol: { span: 7 },
|
||||||
|
wrapperCol: { span: 13 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
const submitSave = async () => {
|
||||||
|
const fieldsValue = await form.validateFields();
|
||||||
|
onSave({ ...fieldsValue, index: initValue.index, udf });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = async () => {
|
||||||
|
if (onCancel && isFunction(onCancel)) {
|
||||||
|
setUdf(false);
|
||||||
|
onCancel(oprType);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
...initValue,
|
||||||
|
});
|
||||||
|
setValueType(initValue.valueType);
|
||||||
|
setUdf(initValue.udf);
|
||||||
|
setOldName(initValue.name);
|
||||||
|
}, [initValue]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
forceRender
|
||||||
|
title={`${oprType === 'add' ? '新建' : '编辑'}sql参数`}
|
||||||
|
open={modalVisible}
|
||||||
|
onOk={submitSave}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
>
|
||||||
|
<Form
|
||||||
|
{...formLayout}
|
||||||
|
initialValues={{
|
||||||
|
...initValue,
|
||||||
|
}}
|
||||||
|
form={form}
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
name="name"
|
||||||
|
label="参数名称"
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入参数名称' },
|
||||||
|
{
|
||||||
|
validator(_, value, confirm) {
|
||||||
|
if (
|
||||||
|
nameList?.some((item) => {
|
||||||
|
return item === value && value !== oldName;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
confirm('名称不能重复');
|
||||||
|
} else {
|
||||||
|
confirm();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input placeholder="请输入参数名称" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="type"
|
||||||
|
label="参数类型"
|
||||||
|
rules={[{ required: true, message: '请选择参数类型' }]}
|
||||||
|
>
|
||||||
|
<Select placeholder="请选择" disabled={true}>
|
||||||
|
{objToArray(EnumSqlParamsType).map((d) => (
|
||||||
|
<Option key={d.value} value={d.value}>
|
||||||
|
{d.label}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="valueType"
|
||||||
|
label="值类型"
|
||||||
|
rules={[{ required: true, message: '请选择值类型' }]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
placeholder="请选择值类型"
|
||||||
|
onChange={(e) => {
|
||||||
|
setValueType(e as IDataSource.ISqlParamsValueType);
|
||||||
|
if (e === 'sql') {
|
||||||
|
form.setFieldsValue({
|
||||||
|
defaultValues: undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{objToArray(EnumSqlValueType).map((d) => (
|
||||||
|
<Option key={d.value} value={d.value}>
|
||||||
|
{d.label}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="alias" label="别名">
|
||||||
|
<Input placeholder="请输入参数别名" />
|
||||||
|
</Form.Item>
|
||||||
|
{valueType !== 'sql' && (
|
||||||
|
<Form.Item name="udf" label="是否使用表达式">
|
||||||
|
<Checkbox
|
||||||
|
checked={udf}
|
||||||
|
onChange={(e) => {
|
||||||
|
setUdf(e.target.checked);
|
||||||
|
if (e.target.checked) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
defaultValues: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
{valueType === 'sql' || udf ? (
|
||||||
|
<Form.Item name="defaultValues" label="表达式">
|
||||||
|
<ParamsTextArea />
|
||||||
|
</Form.Item>
|
||||||
|
) : (
|
||||||
|
<Form.Item name="defaultValues" label="默认值">
|
||||||
|
<ParamsSqlEditor />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SqlParamsDetailModal;
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import React, { useState, useRef } from 'react';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { Input, Tag, Tooltip } from 'antd';
|
||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
|
import styles from '../style.less';
|
||||||
|
|
||||||
|
type ParamsItemProps = {
|
||||||
|
value?: string[];
|
||||||
|
onChange?: (e: string[]) => void;
|
||||||
|
};
|
||||||
|
const ParamsSqlEditor: FC<ParamsItemProps> = ({ value, onChange }) => {
|
||||||
|
const [editInputValue, setEditInputValue] = useState<string>();
|
||||||
|
const [inputValue, setInputValue] = useState<string>();
|
||||||
|
const [editInputIndex, setEditInputIndex] = useState<number>(-1);
|
||||||
|
const [inputVisible, setInputVisible] = useState<boolean>(false);
|
||||||
|
const editInput = useRef<typeof Input>(null);
|
||||||
|
const inputRef = useRef<typeof Input>(null);
|
||||||
|
|
||||||
|
const handleEditInputChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
|
setEditInputValue(e.target.value);
|
||||||
|
};
|
||||||
|
const handleEditInputConfirm = () => {
|
||||||
|
const newValues = value ? [...value] : [];
|
||||||
|
newValues[editInputIndex] = editInputValue || '';
|
||||||
|
if (onChange) {
|
||||||
|
onChange(newValues);
|
||||||
|
}
|
||||||
|
setEditInputIndex(-1);
|
||||||
|
setEditInputValue('');
|
||||||
|
};
|
||||||
|
const handleClose = (removedTag: string) => {
|
||||||
|
const newValues = value ? value.filter((tag) => tag !== removedTag) : [];
|
||||||
|
if (onChange) {
|
||||||
|
onChange(newValues);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
|
setInputValue(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleInputConfirm = () => {
|
||||||
|
const newValues = value ? [...value] : [];
|
||||||
|
if (inputValue && !newValues.includes(inputValue)) {
|
||||||
|
newValues.push(inputValue);
|
||||||
|
}
|
||||||
|
if (onChange) {
|
||||||
|
onChange(newValues);
|
||||||
|
}
|
||||||
|
setInputVisible(false);
|
||||||
|
setInputValue('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const showInput = () => {
|
||||||
|
setInputVisible(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
inputRef.current?.focus();
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{value &&
|
||||||
|
value.map((tag: any, index: number) => {
|
||||||
|
if (editInputIndex === index) {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
ref={editInput}
|
||||||
|
key={tag}
|
||||||
|
size="small"
|
||||||
|
className={styles.tagInput}
|
||||||
|
value={editInputValue}
|
||||||
|
onChange={handleEditInputChange}
|
||||||
|
onBlur={handleEditInputConfirm}
|
||||||
|
onPressEnter={handleEditInputConfirm}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isLongTag = tag.length > 20;
|
||||||
|
|
||||||
|
const tagElem = (
|
||||||
|
<Tag
|
||||||
|
className={styles.editTag}
|
||||||
|
key={tag}
|
||||||
|
closable={true}
|
||||||
|
onClose={() => handleClose(tag)}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
onDoubleClick={(e) => {
|
||||||
|
setEditInputIndex(index);
|
||||||
|
setEditInputValue(tag);
|
||||||
|
e.preventDefault();
|
||||||
|
setTimeout(() => {
|
||||||
|
editInput.current?.focus();
|
||||||
|
}, 0);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isLongTag ? `${tag.slice(0, 20)}...` : tag}
|
||||||
|
</span>
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
return isLongTag ? (
|
||||||
|
<Tooltip title={tag} key={tag}>
|
||||||
|
{tagElem}
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
tagElem
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{inputVisible && (
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
className={styles.tagInput}
|
||||||
|
value={inputValue}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
onBlur={handleInputConfirm}
|
||||||
|
onPressEnter={handleInputConfirm}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{!inputVisible && (
|
||||||
|
<Tag className={styles.siteTagPlus} onClick={showInput}>
|
||||||
|
<PlusOutlined /> 增加默认值
|
||||||
|
</Tag>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ParamsSqlEditor;
|
||||||
@@ -6,3 +6,10 @@ export type TaskResultColumn = {
|
|||||||
|
|
||||||
// 任务查询结果
|
// 任务查询结果
|
||||||
export type TaskResultItem = Record<string, string | number>;
|
export type TaskResultItem = Record<string, string | number>;
|
||||||
|
|
||||||
|
export type OprType = 'add' | 'edit';
|
||||||
|
|
||||||
|
export type ParamsItemProps = {
|
||||||
|
value?: any;
|
||||||
|
onChange?: (e: any) => void;
|
||||||
|
};
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ const OverviewContainer: React.FC<Props> = ({ mode, domainManger, dispatch }) =>
|
|||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
{selectDomainId ? (
|
{selectDomainId ? (
|
||||||
<>
|
<>
|
||||||
{mode === 'domain' ? (
|
|
||||||
<DomainManagerTab
|
<DomainManagerTab
|
||||||
isModel={isModel}
|
isModel={isModel}
|
||||||
activeKey={activeKey}
|
activeKey={activeKey}
|
||||||
@@ -249,23 +248,6 @@ const OverviewContainer: React.FC<Props> = ({ mode, domainManger, dispatch }) =>
|
|||||||
pushUrlMenu(selectDomainId, selectModelId, menuKey);
|
pushUrlMenu(selectDomainId, selectModelId, menuKey);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<ChatSettingTab
|
|
||||||
isModel={isModel}
|
|
||||||
activeKey={activeKey}
|
|
||||||
modelList={modelList}
|
|
||||||
handleModelChange={(model) => {
|
|
||||||
handleModelChange(model);
|
|
||||||
}}
|
|
||||||
onBackDomainBtnClick={() => {
|
|
||||||
cleanModelInfo(selectDomainId);
|
|
||||||
}}
|
|
||||||
onMenuChange={(menuKey) => {
|
|
||||||
setActiveKey(menuKey);
|
|
||||||
pushUrlMenu(selectDomainId, selectModelId, menuKey);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<h2 className={styles.mainTip}>请选择项目</h2>
|
<h2 className={styles.mainTip}>请选择项目</h2>
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ const DimensionValueSettingModal: React.FC<CreateFormProps> = ({
|
|||||||
{
|
{
|
||||||
label: '维度值设置',
|
label: '维度值设置',
|
||||||
key: 'setting',
|
key: 'setting',
|
||||||
children: <DimensionValueSettingForm modelId={modelId} dimensionItem={dimensionItem} />,
|
children: <DimensionValueSettingForm dimensionItem={dimensionItem} />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,244 +0,0 @@
|
|||||||
import { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
|
|
||||||
import type { ForwardRefRenderFunction } from 'react';
|
|
||||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
|
||||||
import { formLayout } from '@/components/FormHelper/utils';
|
|
||||||
import { message, Form, Input, Select, Button, InputNumber } from 'antd';
|
|
||||||
import { addDomainExtend, editDomainExtend } from '../../service';
|
|
||||||
import {
|
|
||||||
formatRichEntityDataListToIds,
|
|
||||||
wrapperTransTypeAndId,
|
|
||||||
splitListToTransTypeId,
|
|
||||||
} from './utils';
|
|
||||||
import styles from '../style.less';
|
|
||||||
import { ISemantic } from '../../data';
|
|
||||||
import { ChatConfigType, TransType, SemanticNodeType } from '../../enum';
|
|
||||||
import TransTypeTag from '../TransTypeTag';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
entityData: any;
|
|
||||||
chatConfigKey: string;
|
|
||||||
chatConfigType: ChatConfigType.TAG | ChatConfigType.METRIC;
|
|
||||||
metricList: ISemantic.IMetricItem[];
|
|
||||||
dimensionList: ISemantic.IDimensionItem[];
|
|
||||||
domainId: number;
|
|
||||||
onSubmit: (params?: any) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
|
||||||
const Option = Select.Option;
|
|
||||||
|
|
||||||
const formDefaultValue = {
|
|
||||||
unit: 7,
|
|
||||||
period: 'DAY',
|
|
||||||
timeMode: 'LAST',
|
|
||||||
};
|
|
||||||
|
|
||||||
const DefaultSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|
||||||
{ metricList, dimensionList, entityData, chatConfigKey, chatConfigType, onSubmit },
|
|
||||||
ref,
|
|
||||||
) => {
|
|
||||||
const [form] = Form.useForm();
|
|
||||||
const [dataItemListOptions, setDataItemListOptions] = useState<any>([]);
|
|
||||||
const formatEntityData = formatRichEntityDataListToIds(entityData);
|
|
||||||
const getFormValidateFields = async () => {
|
|
||||||
return await form.validateFields();
|
|
||||||
};
|
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
|
||||||
getFormValidateFields,
|
|
||||||
}));
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
if (!(entityData?.id && entityData?.chatDefaultConfig)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { chatDefaultConfig, id } = formatEntityData;
|
|
||||||
form.setFieldsValue({
|
|
||||||
...formDefaultValue,
|
|
||||||
...chatDefaultConfig,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
if (chatConfigType === ChatConfigType.TAG) {
|
|
||||||
initDataItemValue(chatDefaultConfig);
|
|
||||||
}
|
|
||||||
}, [entityData, dataItemListOptions]);
|
|
||||||
|
|
||||||
const initDataItemValue = (chatDefaultConfig: {
|
|
||||||
dimensionIds: number[];
|
|
||||||
metricIds: number[];
|
|
||||||
}) => {
|
|
||||||
const { dimensionIds, metricIds } = chatDefaultConfig;
|
|
||||||
const dimensionIdString = dimensionIds.map((dimensionId: number) => {
|
|
||||||
return wrapperTransTypeAndId(TransType.DIMENSION, dimensionId);
|
|
||||||
});
|
|
||||||
const metricIdString = metricIds.map((metricId: number) => {
|
|
||||||
return wrapperTransTypeAndId(TransType.METRIC, metricId);
|
|
||||||
});
|
|
||||||
form.setFieldsValue({
|
|
||||||
dataItemIds: [...dimensionIdString, ...metricIdString],
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (Array.isArray(dimensionList) && Array.isArray(metricList)) {
|
|
||||||
const dimensionEnum = dimensionList.map((item: ISemantic.IDimensionItem) => {
|
|
||||||
const { name, id, bizName } = item;
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
label: (
|
|
||||||
<>
|
|
||||||
<TransTypeTag type={SemanticNodeType.DIMENSION} />
|
|
||||||
{name}
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
value: wrapperTransTypeAndId(TransType.DIMENSION, id),
|
|
||||||
bizName,
|
|
||||||
id,
|
|
||||||
transType: TransType.DIMENSION,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const metricEnum = metricList.map((item: ISemantic.IMetricItem) => {
|
|
||||||
const { name, id, bizName } = item;
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
label: (
|
|
||||||
<>
|
|
||||||
<TransTypeTag type={SemanticNodeType.METRIC} />
|
|
||||||
{name}
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
value: wrapperTransTypeAndId(TransType.METRIC, id),
|
|
||||||
bizName,
|
|
||||||
id,
|
|
||||||
transType: TransType.METRIC,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
setDataItemListOptions([...dimensionEnum, ...metricEnum]);
|
|
||||||
}
|
|
||||||
}, [dimensionList, metricList]);
|
|
||||||
|
|
||||||
const saveEntity = async () => {
|
|
||||||
const values = await form.validateFields();
|
|
||||||
const { id, dataItemIds } = values;
|
|
||||||
let dimensionConfig = {};
|
|
||||||
if (dataItemIds) {
|
|
||||||
const { dimensionIds, metricIds } = splitListToTransTypeId(dataItemIds);
|
|
||||||
dimensionConfig = {
|
|
||||||
dimensionIds,
|
|
||||||
metricIds,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
let saveDomainExtendQuery = addDomainExtend;
|
|
||||||
if (id) {
|
|
||||||
saveDomainExtendQuery = editDomainExtend;
|
|
||||||
}
|
|
||||||
const params = {
|
|
||||||
...formatEntityData,
|
|
||||||
chatDefaultConfig: { ...values, ...dimensionConfig },
|
|
||||||
};
|
|
||||||
const { modelId } = entityData;
|
|
||||||
const { code, msg, data } = await saveDomainExtendQuery({
|
|
||||||
[chatConfigKey]: params,
|
|
||||||
modelId,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
if (code === 200) {
|
|
||||||
form.setFieldValue('id', data);
|
|
||||||
onSubmit?.();
|
|
||||||
message.success('保存成功');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
message.error(msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Form
|
|
||||||
{...formLayout}
|
|
||||||
form={form}
|
|
||||||
layout="vertical"
|
|
||||||
className={styles.form}
|
|
||||||
initialValues={formDefaultValue}
|
|
||||||
>
|
|
||||||
<FormItem hidden={true} name="id" label="ID">
|
|
||||||
<Input placeholder="id" />
|
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
{chatConfigType === ChatConfigType.TAG && (
|
|
||||||
<FormItem name="dataItemIds" label="圈选结果展示字段">
|
|
||||||
<Select
|
|
||||||
mode="multiple"
|
|
||||||
allowClear
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
optionLabelProp="name"
|
|
||||||
filterOption={(inputValue: string, item: any) => {
|
|
||||||
const { name } = item;
|
|
||||||
if (name.includes(inputValue)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
placeholder="请选择圈选结果展示字段"
|
|
||||||
options={dataItemListOptions}
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
<FormItem
|
|
||||||
label={
|
|
||||||
<FormItemTitle
|
|
||||||
title={'时间范围'}
|
|
||||||
subTitle={'问答搜索结果选择中,如果没有指定时间范围,将会采用默认时间范围'}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Input.Group compact>
|
|
||||||
{chatConfigType === ChatConfigType.TAG ? (
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
display: 'inline-block',
|
|
||||||
lineHeight: '32px',
|
|
||||||
marginRight: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
前
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<FormItem name={'timeMode'} noStyle>
|
|
||||||
<Select style={{ width: '90px' }}>
|
|
||||||
<Option value="LAST">前</Option>
|
|
||||||
<Option value="RECENT">最近</Option>
|
|
||||||
</Select>
|
|
||||||
</FormItem>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<FormItem name={'unit'} noStyle>
|
|
||||||
<InputNumber style={{ width: '120px' }} />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem name={'period'} noStyle>
|
|
||||||
<Select style={{ width: '90px' }}>
|
|
||||||
<Option value="DAY">天</Option>
|
|
||||||
<Option value="WEEK">周</Option>
|
|
||||||
<Option value="MONTH">月</Option>
|
|
||||||
<Option value="YEAR">年</Option>
|
|
||||||
</Select>
|
|
||||||
</FormItem>
|
|
||||||
</Input.Group>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem>
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
onClick={() => {
|
|
||||||
saveEntity();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
保 存
|
|
||||||
</Button>
|
|
||||||
</FormItem>
|
|
||||||
</Form>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default forwardRef(DefaultSettingForm);
|
|
||||||
@@ -1,107 +1,118 @@
|
|||||||
import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||||
import type { ForwardRefRenderFunction } from 'react';
|
import type { ForwardRefRenderFunction } from 'react';
|
||||||
import { Form, Input, Switch, Space, Button, Divider, Tooltip, message } from 'antd';
|
import { Form, Switch, Space, Button, Tooltip, message, Select } from 'antd';
|
||||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||||
import { RedoOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
import { RedoOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
||||||
import { formLayout } from '@/components/FormHelper/utils';
|
import { formLayout } from '@/components/FormHelper/utils';
|
||||||
import { DictTaskState, TransType } from '../../enum';
|
import { DictTaskState, KnowledgeConfigTypeEnum, KnowledgeConfigStatusEnum } from '../../enum';
|
||||||
import {
|
import {
|
||||||
getDomainExtendDetailConfig,
|
|
||||||
addDomainExtend,
|
|
||||||
editDomainExtend,
|
|
||||||
searchKnowledgeConfigQuery,
|
searchKnowledgeConfigQuery,
|
||||||
searchDictLatestTaskList,
|
searchDictLatestTaskList,
|
||||||
createDictTask,
|
createDictTask,
|
||||||
|
editDictConfig,
|
||||||
|
createDictConfig,
|
||||||
|
deleteDictTask,
|
||||||
} from '../../service';
|
} from '../../service';
|
||||||
import type { IChatConfig, ISemantic } from '../../data';
|
import type { ISemantic } from '../../data';
|
||||||
import { isString } from 'lodash';
|
import { isString } from 'lodash';
|
||||||
import styles from '../style.less';
|
import styles from '../style.less';
|
||||||
import CommonEditList from '../../components/CommonEditList';
|
import CommonEditList from '../../components/CommonEditList';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modelId: number;
|
|
||||||
dimensionItem: ISemantic.IDimensionItem;
|
dimensionItem: ISemantic.IDimensionItem;
|
||||||
onSubmit?: () => void;
|
onSubmit?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type TaskStateMap = Record<string, DictTaskState>;
|
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||||
{ modelId, dimensionItem },
|
{ dimensionItem },
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const exchangeFields = ['blackList', 'whiteList'];
|
const exchangeFields = ['blackList', 'whiteList'];
|
||||||
const [modelRichConfigData, setModelRichConfigData] = useState<IChatConfig.IConfig>();
|
|
||||||
const [dimensionVisible, setDimensionVisible] = useState<boolean>(false);
|
const [dimensionVisible, setDimensionVisible] = useState<boolean>(false);
|
||||||
const [taskStateMap, setTaskStateMap] = useState<TaskStateMap>({});
|
const [taskItemState, setTaskItemState] = useState<ISemantic.IDictKnowledgeTaskItem>();
|
||||||
const [saveLoading, setSaveLoading] = useState<boolean>(false);
|
const [saveLoading, setSaveLoading] = useState<boolean>(false);
|
||||||
const [refreshLoading, setRefreshLoading] = useState<boolean>(false);
|
const [refreshLoading, setRefreshLoading] = useState<boolean>(false);
|
||||||
|
const [knowledgeConfig, setKnowledgeConfig] = useState<ISemantic.IDictKnowledgeConfigItem>();
|
||||||
|
|
||||||
const queryThemeListData: any = async () => {
|
const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
|
||||||
const { code, data } = await getDomainExtendDetailConfig({
|
const [importDictState, setImportDictState] = useState<boolean>(false);
|
||||||
modelId,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (code === 200) {
|
const defaultKnowledgeConfig: ISemantic.IDictKnowledgeConfigItemConfig = {
|
||||||
setModelRichConfigData(data);
|
blackList: [],
|
||||||
const targetKnowledgeInfos = data?.chatAggRichConfig?.knowledgeInfos || [];
|
whiteList: [],
|
||||||
const targetConfig = targetKnowledgeInfos.find(
|
ruleList: [],
|
||||||
(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(() => {
|
useEffect(() => {
|
||||||
queryThemeListData();
|
searchKnowledgeConfig();
|
||||||
queryDictLatestTaskList();
|
queryDictLatestTaskList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const taskRender = (dimension: ISemantic.IDimensionItem) => {
|
const taskRender = () => {
|
||||||
const { id, type } = dimension;
|
if (taskItemState?.taskStatus) {
|
||||||
const target = taskStateMap[id];
|
return (
|
||||||
if (type === TransType.DIMENSION && target) {
|
<span style={{ color: '#5493ff', fontWeight: 'bold' }}>
|
||||||
return DictTaskState[target] || '未知状态';
|
{DictTaskState[taskItemState.taskStatus] || '未知状态'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return '--';
|
return '--';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const searchKnowledgeConfig = async () => {
|
||||||
|
setRefreshLoading(true);
|
||||||
|
const { code, data } = await searchKnowledgeConfigQuery({
|
||||||
|
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||||
|
itemId: dimensionItem.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
setRefreshLoading(false);
|
||||||
|
if (code !== 200) {
|
||||||
|
message.error('获取字典导入配置失败!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const configItem = data[0];
|
||||||
|
if (configItem) {
|
||||||
|
const { status, config } = configItem;
|
||||||
|
if (status === KnowledgeConfigStatusEnum.ONLINE) {
|
||||||
|
setDimensionVisible(true);
|
||||||
|
} else {
|
||||||
|
setDimensionVisible(false);
|
||||||
|
}
|
||||||
|
form.setFieldsValue({
|
||||||
|
...config,
|
||||||
|
});
|
||||||
|
setKnowledgeConfig(configItem);
|
||||||
|
} else {
|
||||||
|
form.setFieldsValue({
|
||||||
|
...defaultKnowledgeConfig,
|
||||||
|
});
|
||||||
|
createDictConfigQuery(dimensionItem, defaultKnowledgeConfig);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const queryDictLatestTaskList = async () => {
|
const queryDictLatestTaskList = async () => {
|
||||||
setRefreshLoading(true);
|
setRefreshLoading(true);
|
||||||
searchKnowledgeConfigQuery({ itemId: dimensionItem.id });
|
|
||||||
const { code, data } = await searchDictLatestTaskList({
|
const { code, data } = await searchDictLatestTaskList({
|
||||||
modelId,
|
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||||
|
itemId: dimensionItem.id,
|
||||||
});
|
});
|
||||||
setRefreshLoading(false);
|
setRefreshLoading(false);
|
||||||
if (code !== 200) {
|
if (code !== 200) {
|
||||||
message.error('获取字典导入任务失败!');
|
message.error('获取字典导入任务失败!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tastMap = data.reduce(
|
|
||||||
(stateMap: TaskStateMap, item: { dimId: number; status: DictTaskState }) => {
|
if (data?.id) {
|
||||||
const { dimId, status } = item;
|
if (data.taskStatus !== 'running') {
|
||||||
stateMap[dimId] = status;
|
setImportDictState(false);
|
||||||
return stateMap;
|
}
|
||||||
},
|
setTaskItemState(data);
|
||||||
{},
|
}
|
||||||
);
|
|
||||||
setTaskStateMap(tastMap);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFormValidateFields = async () => {
|
const getFormValidateFields = async () => {
|
||||||
@@ -128,12 +139,29 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
getFormValidateFields,
|
getFormValidateFields,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const createDictConfigQuery = async (
|
||||||
|
dimension: ISemantic.IDimensionItem,
|
||||||
|
config: ISemantic.IDictKnowledgeConfigItemConfig,
|
||||||
|
) => {
|
||||||
|
const { code, data } = await createDictConfig({
|
||||||
|
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||||
|
itemId: dimension.id,
|
||||||
|
config,
|
||||||
|
status: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (code !== 200) {
|
||||||
|
message.error('字典导入配置创建失败!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setKnowledgeConfig(data);
|
||||||
|
};
|
||||||
|
|
||||||
const createDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
const createDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
||||||
|
setImportDictState(true);
|
||||||
const { code } = await createDictTask({
|
const { code } = await createDictTask({
|
||||||
updateMode: 'REALTIME_ADD',
|
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||||
modelAndDimPair: {
|
itemId: dimension.id,
|
||||||
[modelId]: [dimension.id],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (code !== 200) {
|
if (code !== 200) {
|
||||||
@@ -145,73 +173,40 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveEntity = async (searchEnable = dimensionVisible) => {
|
const editDictTaskQuery = async (
|
||||||
setSaveLoading(true);
|
status: KnowledgeConfigStatusEnum = KnowledgeConfigStatusEnum.ONLINE,
|
||||||
const globalKnowledgeConfigFormFields: any = await getFormValidateFields();
|
|
||||||
|
|
||||||
const tempData = { ...modelRichConfigData };
|
|
||||||
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[],
|
|
||||||
item: IChatConfig.IKnowledgeInfosItem,
|
|
||||||
) => {
|
) => {
|
||||||
if (item.itemId === dimensionItem.id) {
|
if (!knowledgeConfig?.id) {
|
||||||
knowledgeInfosList.push({
|
return;
|
||||||
...item,
|
}
|
||||||
knowledgeAdvancedConfig: {
|
const config = await form.validateFields();
|
||||||
...item.knowledgeAdvancedConfig,
|
setSaveLoading(true);
|
||||||
...globalKnowledgeConfigFormFields,
|
const { code } = await editDictConfig({
|
||||||
},
|
...knowledgeConfig,
|
||||||
searchEnable,
|
config: {
|
||||||
});
|
...knowledgeConfig.config,
|
||||||
} else {
|
...config,
|
||||||
knowledgeInfosList.push({
|
},
|
||||||
...item,
|
status,
|
||||||
});
|
});
|
||||||
}
|
setSaveLoading(false);
|
||||||
return knowledgeInfosList;
|
if (code !== 200) {
|
||||||
},
|
message.error('字典导入配置保存失败!');
|
||||||
[],
|
return;
|
||||||
);
|
}
|
||||||
} else {
|
};
|
||||||
knowledgeInfos.push({
|
|
||||||
itemId: dimensionItem.id,
|
const deleteDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
||||||
bizName: dimensionItem.bizName,
|
setDeleteLoading(true);
|
||||||
knowledgeAdvancedConfig: {
|
const { code } = await deleteDictTask({
|
||||||
...globalKnowledgeConfigFormFields,
|
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||||
},
|
itemId: dimension.id,
|
||||||
searchEnable,
|
});
|
||||||
});
|
setDeleteLoading(false);
|
||||||
}
|
if (code !== 200) {
|
||||||
|
message.error('字典清除失败!');
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
message.error(msg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -236,7 +231,11 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
size="small"
|
size="small"
|
||||||
checked={dimensionVisible}
|
checked={dimensionVisible}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
saveEntity(value);
|
editDictTaskQuery(
|
||||||
|
value
|
||||||
|
? KnowledgeConfigStatusEnum.ONLINE
|
||||||
|
: KnowledgeConfigStatusEnum.OFFLINE,
|
||||||
|
);
|
||||||
setDimensionVisible(value);
|
setDimensionVisible(value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -249,21 +248,27 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
>
|
>
|
||||||
{dimensionVisible && (
|
{dimensionVisible && (
|
||||||
<Space size={20} style={{ marginBottom: 20 }}>
|
<Space size={20} style={{ marginBottom: 20 }}>
|
||||||
|
<Tooltip title="立即将维度值导入字典">
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
style={{ padding: 0 }}
|
style={{ padding: 0 }}
|
||||||
|
disabled={importDictState}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
createDictTaskQuery(dimensionItem);
|
createDictTaskQuery(dimensionItem);
|
||||||
|
setTaskItemState({
|
||||||
|
...(taskItemState || ({} as ISemantic.IDictKnowledgeTaskItem)),
|
||||||
|
taskStatus: 'running',
|
||||||
|
});
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip title="立即将维度值导入字典">
|
|
||||||
<Space>
|
<Space>
|
||||||
立即导入字典 <InfoCircleOutlined />
|
立即导入字典 <InfoCircleOutlined />
|
||||||
</Space>
|
</Space>
|
||||||
</Tooltip>
|
|
||||||
</Button>
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
<Tooltip title="刷新字典任务状态">
|
<Tooltip title="刷新字典任务状态">
|
||||||
<Space>
|
<Space>
|
||||||
@@ -276,12 +281,34 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
导入状态
|
导入状态
|
||||||
<RedoOutlined />:
|
<Space>
|
||||||
|
<RedoOutlined />: <span>{taskRender(dimensionItem)}</span>
|
||||||
|
</Space>
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<span>{taskRender(dimensionItem)}</span>
|
<Button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
style={{ padding: 0 }}
|
||||||
|
disabled={taskItemState?.taskStatus === 'running'}
|
||||||
|
loading={deleteLoading}
|
||||||
|
onClick={(event) => {
|
||||||
|
deleteDictTaskQuery(dimensionItem);
|
||||||
|
setTaskItemState({
|
||||||
|
...(taskItemState || ({} as ISemantic.IDictKnowledgeTaskItem)),
|
||||||
|
taskStatus: '',
|
||||||
|
});
|
||||||
|
event.stopPropagation();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tooltip title="清除当前配置的字典">
|
||||||
|
<Space>
|
||||||
|
清除字典 <InfoCircleOutlined />
|
||||||
|
</Space>
|
||||||
|
</Tooltip>
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -306,7 +333,7 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
saveEntity();
|
editDictTaskQuery();
|
||||||
}}
|
}}
|
||||||
loading={saveLoading}
|
loading={saveLoading}
|
||||||
>
|
>
|
||||||
@@ -316,11 +343,21 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FormItem name="blackList" label="黑名单">
|
<FormItem name="blackList" label="黑名单">
|
||||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
<Select
|
||||||
|
mode="tags"
|
||||||
|
placeholder="输入维度值后回车确认,多别名输入、复制粘贴支持英文逗号自动分隔"
|
||||||
|
tokenSeparators={[',']}
|
||||||
|
maxTagCount={9}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<FormItem name="whiteList" label="白名单">
|
<FormItem name="whiteList" label="白名单">
|
||||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
<Select
|
||||||
|
mode="tags"
|
||||||
|
placeholder="输入维度值后回车确认,多别名输入、复制粘贴支持英文逗号自动分隔"
|
||||||
|
tokenSeparators={[',']}
|
||||||
|
maxTagCount={9}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<FormItem name="ruleList">
|
<FormItem name="ruleList">
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
import { message, Space } from 'antd';
|
|
||||||
import { useEffect, useState, forwardRef, useImperativeHandle, Ref } from 'react';
|
|
||||||
import type { Dispatch } from 'umi';
|
|
||||||
import { connect } from 'umi';
|
|
||||||
import type { StateType } from '../../model';
|
|
||||||
import { getDomainExtendDetailConfig } from '../../service';
|
|
||||||
import ProCard from '@ant-design/pro-card';
|
|
||||||
|
|
||||||
import DefaultSettingForm from './DefaultSettingForm';
|
|
||||||
import type { IChatConfig } from '../../data';
|
|
||||||
import { ChatConfigType } from '../../enum';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
chatConfigType: ChatConfigType.TAG | ChatConfigType.METRIC;
|
|
||||||
onConfigSave?: () => void;
|
|
||||||
dispatch: Dispatch;
|
|
||||||
domainManger: StateType;
|
|
||||||
};
|
|
||||||
|
|
||||||
const EntitySection: React.FC<Props> = forwardRef(
|
|
||||||
({ domainManger, chatConfigType = ChatConfigType.TAG, onConfigSave }, ref: Ref<any>) => {
|
|
||||||
const { selectDomainId, selectModelId: modelId, dimensionList, metricList } = domainManger;
|
|
||||||
|
|
||||||
const [entityData, setEntityData] = useState<IChatConfig.IChatRichConfig>();
|
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
|
||||||
refreshConfigData: queryThemeListData,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const queryThemeListData: any = async () => {
|
|
||||||
const { code, data } = await getDomainExtendDetailConfig({
|
|
||||||
modelId,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (code === 200) {
|
|
||||||
const { chatAggRichConfig, chatDetailRichConfig, id, domainId, modelId } = data;
|
|
||||||
if (chatConfigType === ChatConfigType.TAG) {
|
|
||||||
setEntityData({ ...chatDetailRichConfig, id, domainId, modelId });
|
|
||||||
}
|
|
||||||
if (chatConfigType === ChatConfigType.METRIC) {
|
|
||||||
setEntityData({ ...chatAggRichConfig, id, domainId, modelId });
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
message.error('获取问答设置信息失败');
|
|
||||||
};
|
|
||||||
|
|
||||||
const initPage = async () => {
|
|
||||||
queryThemeListData();
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!modelId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
initPage();
|
|
||||||
}, [modelId]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ width: 800, margin: '0 auto' }}>
|
|
||||||
<Space direction="vertical" style={{ width: '100%' }} size={20}>
|
|
||||||
<ProCard bordered title="默认设置">
|
|
||||||
<DefaultSettingForm
|
|
||||||
domainId={Number(selectDomainId)}
|
|
||||||
entityData={entityData || {}}
|
|
||||||
chatConfigType={chatConfigType}
|
|
||||||
chatConfigKey={
|
|
||||||
chatConfigType === ChatConfigType.TAG ? 'chatDetailConfig' : 'chatAggConfig'
|
|
||||||
}
|
|
||||||
dimensionList={dimensionList.filter((item) => {
|
|
||||||
const blackDimensionList = entityData?.visibility?.blackDimIdList;
|
|
||||||
if (Array.isArray(blackDimensionList)) {
|
|
||||||
return !blackDimensionList.includes(item.id);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})}
|
|
||||||
metricList={metricList.filter((item) => {
|
|
||||||
const blackMetricIdList = entityData?.visibility?.blackMetricIdList;
|
|
||||||
if (Array.isArray(blackMetricIdList)) {
|
|
||||||
return !blackMetricIdList.includes(item.id);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})}
|
|
||||||
onSubmit={() => {
|
|
||||||
queryThemeListData();
|
|
||||||
onConfigSave?.();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</ProCard>
|
|
||||||
</Space>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
export default connect(
|
|
||||||
({ domainManger }: { domainManger: StateType }) => ({
|
|
||||||
domainManger,
|
|
||||||
}),
|
|
||||||
() => {},
|
|
||||||
null,
|
|
||||||
{ forwardRef: true },
|
|
||||||
)(EntitySection);
|
|
||||||
@@ -13,6 +13,7 @@ export type SensitiveLevel = 0 | 1 | 2 | null;
|
|||||||
|
|
||||||
export type ToolBarSearchCallBack = (text: string) => void;
|
export type ToolBarSearchCallBack = (text: string) => void;
|
||||||
|
|
||||||
|
|
||||||
export declare namespace IDataSource {
|
export declare namespace IDataSource {
|
||||||
interface IExecuteSqlColumn {
|
interface IExecuteSqlColumn {
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -57,6 +58,17 @@ export declare namespace IDataSource {
|
|||||||
dataType: string;
|
dataType: string;
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ISqlParamsValueType = 'string' | 'sql' | 'date' | 'boolean' | 'number';
|
||||||
|
interface ISqlParamsItem {
|
||||||
|
index?: number;
|
||||||
|
defaultValues: (boolean | string | number)[];
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
valueType: ISqlParamsValueType;
|
||||||
|
udf?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
interface IDataSourceDetail {
|
interface IDataSourceDetail {
|
||||||
queryType: string;
|
queryType: string;
|
||||||
sqlQuery: string;
|
sqlQuery: string;
|
||||||
@@ -65,6 +77,7 @@ export declare namespace IDataSource {
|
|||||||
fields: IDataSourceDetailFieldsItem[];
|
fields: IDataSourceDetailFieldsItem[];
|
||||||
dimensions: IDimensionsItem[];
|
dimensions: IDimensionsItem[];
|
||||||
measures: IMeasuresItem[];
|
measures: IMeasuresItem[];
|
||||||
|
sqlVariables:
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IDataSourceItem {
|
interface IDataSourceItem {
|
||||||
@@ -330,6 +343,42 @@ export declare namespace ISemantic {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
type IDatabaseItemList = IDatabaseItem[];
|
type IDatabaseItemList = IDatabaseItem[];
|
||||||
|
|
||||||
|
|
||||||
|
interface IDictKnowledgeConfigItemConfig {
|
||||||
|
metricId?: number;
|
||||||
|
blackList: string[];
|
||||||
|
whiteList: string[];
|
||||||
|
ruleList: any[];
|
||||||
|
limit?: number;
|
||||||
|
}
|
||||||
|
interface IDictKnowledgeConfigItem {
|
||||||
|
id: number;
|
||||||
|
modelId: number;
|
||||||
|
bizName: string;
|
||||||
|
type: string;
|
||||||
|
itemId: number;
|
||||||
|
config: IDictKnowledgeConfigItemConfig;
|
||||||
|
status: string;
|
||||||
|
nature?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IDictKnowledgeTaskItem {
|
||||||
|
id: number;
|
||||||
|
modelId: number;
|
||||||
|
bizName: string;
|
||||||
|
type: string;
|
||||||
|
itemId: number;
|
||||||
|
config: IDictKnowledgeConfigItemConfig;
|
||||||
|
status: string | null;
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
taskStatus: string;
|
||||||
|
createdAt: string;
|
||||||
|
createdBy: string;
|
||||||
|
elapsedMs: number | null;
|
||||||
|
nature: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare namespace IChatConfig {
|
export declare namespace IChatConfig {
|
||||||
@@ -345,20 +394,6 @@ export declare namespace IChatConfig {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IConfig {
|
|
||||||
id: any;
|
|
||||||
modelId: number;
|
|
||||||
modelName: string;
|
|
||||||
chatAggRichConfig: IChatRichConfig;
|
|
||||||
chatDetailRichConfig: IChatRichConfig;
|
|
||||||
recommendedQuestions: { question: string }[];
|
|
||||||
bizName: string;
|
|
||||||
statusEnum: string;
|
|
||||||
createdBy: string;
|
|
||||||
updatedBy: string;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IKnowledgeInfosItem {
|
interface IKnowledgeInfosItem {
|
||||||
itemId: number;
|
itemId: number;
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ export enum MetricTypeWording {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum DictTaskState {
|
export enum DictTaskState {
|
||||||
ERROR = '错误',
|
error = '错误',
|
||||||
PENDING = '等待',
|
pending = '等待',
|
||||||
RUNNING = '正在执行',
|
running = '正在执行',
|
||||||
SUCCESS = '成功',
|
success = '成功',
|
||||||
UNKNOWN = '未知',
|
unknown = '未知',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum StatusEnum {
|
export enum StatusEnum {
|
||||||
@@ -41,3 +41,22 @@ export enum OperatorEnum {
|
|||||||
IN = 'IN',
|
IN = 'IN',
|
||||||
LIKE = 'LIKE',
|
LIKE = 'LIKE',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum KnowledgeConfigTypeEnum {
|
||||||
|
DIMENSION = 'DIMENSION',
|
||||||
|
METRIC = 'METRIC',
|
||||||
|
DOMAIN = 'DOMAIN',
|
||||||
|
ENTITY = 'ENTITY',
|
||||||
|
VIEW = 'VIEW',
|
||||||
|
MODEL = 'MODEL',
|
||||||
|
UNKNOWN = 'UNKNOWN',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum KnowledgeConfigStatusEnum {
|
||||||
|
ONLINE = 'ONLINE',
|
||||||
|
OFFLINE = 'OFFLINE',
|
||||||
|
DELETED = 'DELETED',
|
||||||
|
INITIALIZED = 'INITIALIZED',
|
||||||
|
UNAVAILABLE = 'UNAVAILABLE',
|
||||||
|
UNKNOWN = 'UNKNOWN',
|
||||||
|
}
|
||||||
|
|||||||
@@ -256,12 +256,6 @@ export function getDomainExtendConfig(data: any): Promise<any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDomainExtendDetailConfig(data: any): Promise<any> {
|
|
||||||
return request(`${process.env.CHAT_API_BASE_URL}conf/richDesc/${data.modelId}`, {
|
|
||||||
method: 'GET',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getDatasourceRelaList(id?: number): Promise<any> {
|
export function getDatasourceRelaList(id?: number): Promise<any> {
|
||||||
return request(`${process.env.API_BASE_URL}datasource/getDatasourceRelaList/${id}`, {
|
return request(`${process.env.API_BASE_URL}datasource/getDatasourceRelaList/${id}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -444,19 +438,33 @@ export function getMetricsToCreateNewMetric(data: any): Promise<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createDictTask(data: any): Promise<any> {
|
export function createDictTask(data: any): Promise<any> {
|
||||||
return request(`${process.env.CHAT_API_BASE_URL}dict/task`, {
|
return request(`${process.env.API_BASE_URL}knowledge/task`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteDictTask(data: any): Promise<any> {
|
export function createDictConfig(data: any): Promise<any> {
|
||||||
return request(`${process.env.CHAT_API_BASE_URL}dict/task/delete`, {
|
return request(`${process.env.API_BASE_URL}knowledge/conf`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function editDictConfig(data: any): Promise<any> {
|
||||||
|
return request(`${process.env.API_BASE_URL}knowledge/conf`, {
|
||||||
|
method: 'PUT',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteDictTask(data: any): Promise<any> {
|
||||||
|
return request(`${process.env.API_BASE_URL}knowledge/task/delete`, {
|
||||||
|
method: 'PUT',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function searchDictLatestTaskList(data: any): Promise<any> {
|
export function searchDictLatestTaskList(data: any): Promise<any> {
|
||||||
return request(`${process.env.API_BASE_URL}knowledge/task/search`, {
|
return request(`${process.env.API_BASE_URL}knowledge/task/search`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -451,3 +451,22 @@ export function isArrayOfValues(array: any) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ObjToArrayParams = Record<string, string>;
|
||||||
|
|
||||||
|
const keyTypeTran = {
|
||||||
|
string: String,
|
||||||
|
number: Number,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* obj转成value,label的数组
|
||||||
|
* @param _obj
|
||||||
|
*/
|
||||||
|
export const objToArray = (_obj: ObjToArrayParams, keyType: string = 'string') => {
|
||||||
|
return Object.keys(_obj).map((key) => {
|
||||||
|
return {
|
||||||
|
value: keyTypeTran[keyType](key),
|
||||||
|
label: _obj[key],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user