Files
supersonic/webapp/packages/supersonic-fe/src/pages/SemanticModel/components/CommonDimension/CommonDimensionTable.tsx
tristanliu caefa501f2 [improvement][semantic-fe] Fixing the logic error in the dimension value setting. (#499)
* [improvement][semantic-fe] Add model alias setting & Add view permission restrictions to the model permission management tab.
[improvement][semantic-fe] Add permission control to the action buttons for the main domain; apply high sensitivity filtering to the authorization of metrics/dimensions.
[improvement][semantic-fe] Optimize the editing mode in the dimension/metric/datasource components to use the modelId stored in the database for data, instead of relying on the data from the state manager.

* [improvement][semantic-fe] Add time granularity setting in the data source configuration.

* [improvement][semantic-fe] Dictionary import for dimension values supported in Q&A visibility

* [improvement][semantic-fe] Modification of data source creation prompt wording"

* [improvement][semantic-fe] metric market experience optimization

* [improvement][semantic-fe] enhance the analysis of metric trends

* [improvement][semantic-fe] optimize the presentation of metric trend permissions

* [improvement][semantic-fe] add metric trend download functionality

* [improvement][semantic-fe] fix the dimension initialization issue in metric correlation

* [improvement][semantic-fe] Fix the issue of database changes not taking effect when creating based on an SQL data source.

* [improvement][semantic-fe] Optimizing pagination logic and some CSS styles

* [improvement][semantic-fe] Fixing the API for the indicator list by changing "current" to "pageNum"

* [improvement][semantic-fe] Fixing the default value setting for the indicator list

* [improvement][semantic-fe] Adding batch operations for indicators/dimensions/models

* [improvement][semantic-fe] Replacing the single status update API for indicators/dimensions with a batch update API

* [improvement][semantic-fe] Redesigning the indicator homepage to incorporate trend charts and table functionality for indicators

* [improvement][semantic-fe] Optimizing the logic for setting dimension values and editing data sources, and adding system settings functionality

* [improvement][semantic-fe] Upgrading antd version to 5.x, extracting the batch operation button component, optimizing the interaction for system settings, and expanding the configuration generation types for list-to-select component.

* [improvement][semantic-fe] Adding the ability to filter dimensions based on whether they are tags or not.

* [improvement][semantic-fe] Adding the ability to edit relationships between models in the canvas.

* [improvement][semantic-fe] Updating the datePicker component to use dayjs instead.

* [improvement][semantic-fe] Fixing the issue with passing the model ID for dimensions in the indicator market.

* [improvement][semantic-fe] Fixing the abnormal state of the popup when creating a model.

* [improvement][semantic-fe] Adding permission logic for bulk operations in the indicator market.

* [improvement][semantic-fe] Adding the ability to download and transpose data.

* [improvement][semantic-fe] Fixing the initialization issue with the date selection component in the indicator details page when switching time granularity.

* [improvement][semantic-fe] Fixing the logic error in the dimension value setting.
2023-12-12 19:40:24 +08:00

197 lines
5.1 KiB
TypeScript

import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { message, Button, Space, Popconfirm, Input } from 'antd';
import React, { useRef, useState } from 'react';
import type { Dispatch } from 'umi';
import { connect } from 'umi';
import type { StateType } from '../../model';
import { getCommonDimensionList, deleteCommonDimension } from '../../service';
import CommonDimensionInfoModal from './CommonDimensionInfoModal';
import { ISemantic } from '../../data';
import moment from 'moment';
import styles from '../style.less';
type Props = {
dispatch: Dispatch;
domainManger: StateType;
};
const CommonDimensionTable: React.FC<Props> = ({ domainManger, dispatch }) => {
const { selectDomainId: domainId, dimensionList } = domainManger;
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
const [dimensionItem, setDimensionItem] = useState<ISemantic.IDimensionItem>();
const [loading, setLoading] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
const queryDimensionList = async () => {
setLoading(true);
const { code, data, msg } = await getCommonDimensionList(domainId);
setLoading(false);
let resData: any = {};
if (code === 200) {
resData = {
data: data || [],
success: true,
};
} else {
message.error(msg);
resData = {
data: [],
total: 0,
success: false,
};
}
return resData;
};
const columns: ProColumns[] = [
{
dataIndex: 'id',
title: 'ID',
width: 80,
order: 100,
search: false,
},
{
dataIndex: 'key',
title: '维度搜索',
hideInTable: true,
renderFormItem: () => <Input placeholder="请输入ID/维度名称/字段名称" />,
},
{
dataIndex: 'name',
title: '维度名称',
search: false,
},
{
dataIndex: 'bizName',
title: '字段名称',
search: false,
// order: 9,
},
{
dataIndex: 'createdBy',
title: '创建人',
width: 100,
search: false,
},
{
dataIndex: 'description',
title: '描述',
search: false,
},
{
dataIndex: 'updatedAt',
title: '更新时间',
width: 180,
search: false,
render: (value: any) => {
return value && value !== '-' ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '-';
},
},
{
title: '操作',
dataIndex: 'x',
valueType: 'option',
width: 200,
render: (_, record) => {
return (
<Space className={styles.ctrlBtnContainer}>
<Button
key="dimensionEditBtn"
type="link"
onClick={() => {
setDimensionItem(record);
setCreateModalVisible(true);
}}
>
</Button>
<Popconfirm
title="删除会自动解除所关联的维度,是否确认?"
okText="是"
cancelText="否"
placement="left"
onConfirm={async () => {
const { code, msg } = await deleteCommonDimension(record.id);
if (code === 200) {
setDimensionItem(undefined);
actionRef.current?.reload();
} else {
message.error(msg);
}
}}
>
<Button
type="link"
key="dimensionDeleteEditBtn"
onClick={() => {
setDimensionItem(record);
}}
>
</Button>
</Popconfirm>
</Space>
);
},
},
];
return (
<>
<ProTable
style={{ marginTop: 15 }}
className={`${styles.classTable} ${styles.classTableSelectColumnAlignLeft}`}
actionRef={actionRef}
rowKey="id"
columns={columns}
request={queryDimensionList}
loading={loading}
search={false}
tableAlertRender={() => {
return false;
}}
size="small"
options={{ reload: false, density: false, fullScreen: false }}
toolBarRender={() => [
<Button
key="create"
type="primary"
onClick={() => {
setDimensionItem(undefined);
setCreateModalVisible(true);
}}
>
</Button>,
]}
/>
{createModalVisible && (
<CommonDimensionInfoModal
domainId={domainId}
bindModalVisible={createModalVisible}
dimensionItem={dimensionItem}
dimensionList={dimensionList}
onSubmit={() => {
setCreateModalVisible(false);
actionRef?.current?.reload();
return;
}}
onCancel={() => {
setCreateModalVisible(false);
}}
/>
)}
</>
);
};
export default connect(({ domainManger }: { domainManger: StateType }) => ({
domainManger,
}))(CommonDimensionTable);