[improvement][semantic-fe] Redesigning the indicator homepage to incorporate trend charts and table functionality for indicators (#347)

* [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
This commit is contained in:
tristanliu
2023-11-09 05:37:36 -06:00
committed by GitHub
parent 4e139c837a
commit 18aa14118c
27 changed files with 1654 additions and 916 deletions

View File

@@ -35,23 +35,10 @@ const ROUTES = [
envEnableList: [ENV_KEY.CHAT],
},
{
path: '/model',
path: '/model/:domainId?/:modelId?/:menuKey?',
component: './SemanticModel/DomainManager',
name: 'semanticModel',
envEnableList: [ENV_KEY.SEMANTIC],
routes: [
{
path: '/model/:domainId?/:modelId?/:menuKey?',
component: './SemanticModel/DomainManager',
name: 'model',
envEnableList: [ENV_KEY.SEMANTIC],
},
{
path: '/database',
name: 'database',
component: './SemanticModel/components/Database/DatabaseTable',
envEnableList: [ENV_KEY.SEMANTIC],
},
],
},
{
@@ -66,6 +53,25 @@ const ROUTES = [
name: 'metric',
component: './SemanticModel/Metric',
envEnableList: [ENV_KEY.SEMANTIC],
routes: [
{
path: '/metric',
redirect: '/metric/market',
},
{
path: '/metric/market',
component: './SemanticModel/Metric/Market',
hideInMenu: true,
envEnableList: [ENV_KEY.SEMANTIC],
},
{
path: '/metric/detail/:metricId',
name: 'metricDetail',
hideInMenu: true,
component: './SemanticModel/Metric/Detail',
envEnableList: [ENV_KEY.SEMANTIC],
},
],
},
{
path: '/plugin',

View File

@@ -24,6 +24,7 @@ type Props = {
showCurrentDataRangeString?: boolean;
onDateRangeChange: (value: string[], from: any) => void;
onDateRangeTypeChange?: (dateRangeType: DateRangeType) => void;
onInit?: (params: { dateStringRange: string[] }) => void;
};
const { CheckableTag } = Tag;
@@ -33,6 +34,7 @@ const MDatePicker: React.FC<Props> = ({
showCurrentDataRangeString = true,
onDateRangeChange,
onDateRangeTypeChange,
onInit,
}: any) => {
const getDynamicDefaultConfig = (dateRangeType: DateRangeType) => {
const dynamicDefaultConfig = {
@@ -151,6 +153,10 @@ const MDatePicker: React.FC<Props> = ({
}
}
}
useEffect(() => {
onInit?.({ dateRange: currentDateRange });
}, []);
useEffect(() => {
setSelectedDateRangeString(getSelectedDateRangeString());
}, [staticParams, dynamicParams, currentDateRange]);

View File

@@ -80,7 +80,6 @@ const DebounceSelect = forwardRef(
if (disabledSearch) {
return;
}
console.log(!allowEmptyValue && !value, value, allowEmptyValue, 333);
if (!allowEmptyValue && !value) return;
fetchRef.current += 1;
const fetchId = fetchRef.current;

View File

@@ -7,11 +7,10 @@ export default {
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
'menu.exception.server-error': '500',
'menu.semanticModel': '语义模',
'menu.semanticModel.model': '模型管理',
'menu.semanticModel.database': '数据库连接',
'menu.semanticModel': '语义模',
'menu.metric': '指标市场',
'menu.database': '数据库连接',
'menu.metric.metricDetail': '指标详情页',
'menu.database': '数据库管理',
'menu.chatSetting': '问答设置',
'menu.plugin': '插件市场',
'menu.login': '登录',

View File

@@ -35,7 +35,7 @@ const ChatSettingSection: React.FC<Props> = () => {
// ];
return (
<div style={{ width: 900, margin: '0 auto' }}>
<div style={{ width: 900, margin: '20px auto' }}>
{/* <Tabs
className={styles.chatSettingSectionTab}
items={isModelItem}

View File

@@ -0,0 +1,316 @@
import { message, Tag, Space, Layout, Tabs, Tooltip } from 'antd';
import React, { useState, useEffect, ReactNode } from 'react';
import { getMetricData } from '../service';
import { connect, useParams, history } from 'umi';
import type { StateType } from '../model';
import moment from 'moment';
import {
LeftOutlined,
UserOutlined,
CalendarOutlined,
InfoCircleOutlined,
} from '@ant-design/icons';
import styles from './style.less';
import MetricTrendSection from '@/pages/SemanticModel/Metric/components/MetricTrendSection';
import { SENSITIVE_LEVEL_ENUM, SENSITIVE_LEVEL_COLOR } from '../constant';
import type { TabsProps } from 'antd';
import { ISemantic } from '../data';
const { Content } = Layout;
type Props = {
metircData: any;
domainManger: StateType;
onNodeChange: (params?: { eventName?: string }) => void;
onEditBtnClick?: (metircData: any) => void;
[key: string]: any;
};
interface DescriptionItemProps {
title: string | ReactNode;
content: React.ReactNode;
icon: ReactNode;
}
// type InfoListItemChildrenItem = {
// label: string;
// value: string;
// content?: ReactNode;
// hideItem?: boolean;
// };
// type InfoListItem = {
// title: string;
// hideItem?: boolean;
// render?: () => ReactNode;
// children?: InfoListItemChildrenItem[];
// };
const DescriptionItem = ({ title, content, icon }: DescriptionItemProps) => (
<Tooltip title={title}>
<div style={{ width: 'max-content', fontSize: 14, color: '#546174' }}>
<Space>
<span style={{ width: 'max-content' }}>{icon}</span>
{content}
</Space>
</div>
</Tooltip>
);
const MetricDetail: React.FC<Props> = ({ domainManger }) => {
const params: any = useParams();
const metricId = params.metricId;
// const bizName = params.bizName;
// const [infoList, setInfoList] = useState<InfoListItem[]>([]);
// const { selectModelName } = domainManger;
const [metircData, setMetircData] = useState<ISemantic.IMetricItem>();
useEffect(() => {
queryMetricData(metricId);
}, [metricId]);
const queryMetricData = async (metricId: string) => {
const { code, data, msg } = await getMetricData(metricId);
if (code === 200) {
setMetircData(data);
return;
}
message.error(msg);
};
// useEffect(() => {
// if (!metircData) {
// return;
// }
// const {
// alias,
// bizName,
// createdBy,
// createdAt,
// updatedAt,
// description,
// sensitiveLevel,
// modelName,
// } = metircData;
// const list = [
// {
// title: '基本信息',
// children: [
// {
// label: '字段名称',
// value: bizName,
// },
// {
// label: '别名',
// hideItem: !alias,
// value: alias || '-',
// },
// {
// label: '所属模型',
// value: modelName,
// content: <Tag>{modelName || selectModelName}</Tag>,
// },
// {
// label: '描述',
// value: description,
// },
// ],
// },
// {
// title: '应用信息',
// children: [
// {
// label: '敏感度',
// value: SENSITIVE_LEVEL_ENUM[sensitiveLevel],
// },
// ],
// },
// // {
// // title: '指标趋势',
// // render: () => (
// // <Row key={`metricTrendSection`} style={{ marginBottom: 10, display: 'flex' }}>
// // <Col span={24}>
// // <MetricTrendSection nodeData={metircData} />
// // </Col>
// // </Row>
// // ),
// // },
// {
// title: '创建信息',
// children: [
// {
// label: '创建人',
// value: createdBy,
// },
// {
// label: '创建时间',
// value: createdAt ? moment(createdAt).format('YYYY-MM-DD HH:mm:ss') : '',
// },
// {
// label: '更新时间',
// value: updatedAt ? moment(updatedAt).format('YYYY-MM-DD HH:mm:ss') : '',
// },
// ],
// },
// ];
// setInfoList(list);
// }, [metircData]);
const tabItems: TabsProps['items'] = [
{
key: 'metricTrend',
label: '图表',
children: <MetricTrendSection metircData={metircData} />,
},
// {
// key: '2',
// label: 'Tab 2',
// children: 'Content of Tab Pane 2',
// },
];
const contentStyle: React.CSSProperties = {
minHeight: 120,
color: '#fff',
// marginRight: 15,
backgroundColor: '#fff',
};
// const siderStyle: React.CSSProperties = {
// width: '300px',
// backgroundColor: '#fff',
// };
return (
<Layout className={styles.metricDetail}>
<Layout>
<Content style={contentStyle}>
<h2 className={styles.title}>
<div className={styles.titleLeft}>
<div
className={styles.backBtn}
onClick={() => {
history.push(`/metric/market`);
}}
>
<LeftOutlined />
</div>
<div className={styles.navContainer}>
<Space>
<span style={{ color: '#296DF3' }}>
{metircData?.name}
{metircData?.alias && `[${metircData.alias}]`}
</span>
{metircData?.name && (
<>
<span style={{ position: 'relative', top: '-2px' }}> | </span>
<span style={{ fontSize: 16, color: '#296DF3' }}>{metircData?.bizName}</span>
</>
)}
{metircData?.sensitiveLevel !== undefined && (
<span style={{ position: 'relative', top: '-2px' }}>
<Tag color={SENSITIVE_LEVEL_COLOR[metircData.sensitiveLevel]}>
{SENSITIVE_LEVEL_ENUM[metircData.sensitiveLevel]}
</Tag>
</span>
)}
</Space>
{metircData?.description ? (
<div className={styles.description}>
<Tooltip title="指标描述">
<Space>
<InfoCircleOutlined />
{metircData?.description}
</Space>
</Tooltip>
</div>
) : (
<></>
)}
</div>
</div>
<div className={styles.titleRight}>
{metircData?.createdBy ? (
<>
{/* <div className={styles.info}>
<DescriptionItem
title="所属模型"
icon={<UserOutlined />}
content={metircData?.modelName}
/>
<DescriptionItem
title="更新时间"
icon={<CalendarOutlined />}
content={metircData?.description}
/>
</div> */}
<div className={styles.info}>
<DescriptionItem
title="创建人"
icon={<UserOutlined />}
content={metircData?.createdBy}
/>
<DescriptionItem
title="更新时间"
icon={<CalendarOutlined />}
content={moment(metircData?.updatedAt).format('YYYY-MM-DD HH:mm:ss')}
/>
</div>
</>
) : (
<></>
)}
</div>
</h2>
<div className={styles.tabContainer}>
<Tabs defaultActiveKey="metricTrend" items={tabItems} size="large" />
</div>
</Content>
</Layout>
{/* <Sider style={siderStyle} width={400}>
<>
<div key={metircData?.id} className={styles.metricInfoContent}>
{infoList.map((item) => {
const { children, title, render } = item;
return (
<div key={title} style={{ display: item.hideItem ? 'none' : 'block' }}>
<p className={styles.title}>{title}</p>
{render?.() ||
(Array.isArray(children) &&
children.map((childrenItem) => {
return (
<Row
key={`${childrenItem.label}-${childrenItem.value}`}
style={{
marginBottom: 10,
display: childrenItem.hideItem ? 'none' : 'flex',
}}
>
<Col span={24}>
<DescriptionItem
title={childrenItem.label}
content={childrenItem.content || childrenItem.value}
/>
</Col>
</Row>
);
}))}
<Divider />
</div>
);
})}
</div>
</>
</Sider> */}
</Layout>
);
};
export default connect(({ domainManger }: { domainManger: StateType }) => ({
domainManger,
}))(MetricDetail);

View File

@@ -0,0 +1,456 @@
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { message, Space, Popconfirm, Tag, Spin, Dropdown } from 'antd';
import React, { useRef, useState, useEffect } from 'react';
import type { Dispatch } from 'umi';
import { connect, history, useModel } from 'umi';
import type { StateType } from '../model';
import { SENSITIVE_LEVEL_ENUM } from '../constant';
import { queryMetric, deleteMetric, batchUpdateMetricStatus } from '../service';
import MetricFilter from './components/MetricFilter';
import MetricInfoCreateForm from '../components/MetricInfoCreateForm';
import MetricCardList from './components/MetricCardList';
import NodeInfoDrawer from '../SemanticGraph/components/NodeInfoDrawer';
import { SemanticNodeType, StatusEnum } from '../enum';
import moment from 'moment';
import styles from './style.less';
import { ISemantic } from '../data';
type Props = {
dispatch: Dispatch;
domainManger: StateType;
};
type QueryMetricListParams = {
id?: string;
name?: string;
bizName?: string;
sensitiveLevel?: string;
type?: string;
[key: string]: any;
};
const ClassMetricTable: React.FC<Props> = ({ domainManger, dispatch }) => {
const { initialState = {} } = useModel('@@initialState');
const { currentUser = {} } = initialState as any;
const { selectDomainId, selectModelId: modelId } = domainManger;
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
const defaultPagination = {
current: 1,
pageSize: 20,
total: 0,
};
const [pagination, setPagination] = useState(defaultPagination);
const [loading, setLoading] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<ISemantic.IMetricItem[]>([]);
const [metricItem, setMetricItem] = useState<ISemantic.IMetricItem>();
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [filterParams, setFilterParams] = useState<Record<string, any>>({
showType: localStorage.getItem('metricMarketShowType') === '1' ? true : false,
});
const [infoDrawerVisible, setInfoDrawerVisible] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
useEffect(() => {
queryMetricList(filterParams);
}, []);
const queryBatchUpdateStatus = async (ids: React.Key[], status: StatusEnum) => {
if (Array.isArray(ids) && ids.length === 0) {
return;
}
const { code, msg } = await batchUpdateMetricStatus({
ids,
status,
});
if (code === 200) {
queryMetricList(filterParams);
return;
}
message.error(msg);
};
const queryMetricList = async (params: QueryMetricListParams = {}, disabledLoading = false) => {
if (!disabledLoading) {
setLoading(true);
}
const { code, data, msg } = await queryMetric({
...pagination,
...params,
createdBy: params.onlyShowMe ? currentUser.name : null,
pageSize: params.showType ? 100 : params.pageSize || pagination.pageSize,
});
setLoading(false);
const { list, pageSize, pageNum, total } = data || {};
let resData: any = {};
if (code === 200) {
if (!params.showType) {
setPagination({
...pagination,
pageSize: Math.min(pageSize, 100),
current: pageNum,
total,
});
}
setDataSource(list);
resData = {
data: list || [],
success: true,
};
} else {
message.error(msg);
setDataSource([]);
resData = {
data: [],
total: 0,
success: false,
};
}
return resData;
};
const deleteMetricQuery = async (id: number) => {
const { code, msg } = await deleteMetric(id);
if (code === 200) {
setMetricItem(undefined);
queryMetricList(filterParams);
} else {
message.error(msg);
}
};
const handleMetricEdit = (metricItem: ISemantic.IMetricItem) => {
setMetricItem(metricItem);
setCreateModalVisible(true);
};
const columns: ProColumns[] = [
{
dataIndex: 'id',
title: 'ID',
},
{
dataIndex: 'name',
title: '指标名称',
render: (_, record: any) => {
return (
<a
onClick={() => {
// setMetricItem(record);
// setInfoDrawerVisible(true);
history.push(`/metric/detail/${record.id}`);
}}
>
{record.name}
</a>
);
},
},
{
dataIndex: 'modelName',
title: '所属模型',
render: (_, record: any) => {
if (record.hasAdminRes) {
return (
<a
onClick={() => {
history.replace(`/model/${record.domainId}/${record.modelId}/metric`);
}}
>
{record.modelName}
</a>
);
}
return <> {record.modelName}</>;
},
},
{
dataIndex: 'sensitiveLevel',
title: '敏感度',
valueEnum: SENSITIVE_LEVEL_ENUM,
},
{
dataIndex: 'status',
title: '状态',
width: 80,
search: false,
render: (status) => {
switch (status) {
case StatusEnum.ONLINE:
return <Tag color="success"></Tag>;
case StatusEnum.OFFLINE:
return <Tag color="warning"></Tag>;
case StatusEnum.INITIALIZED:
return <Tag color="processing"></Tag>;
case StatusEnum.DELETED:
return <Tag color="default"></Tag>;
default:
return <Tag color="default"></Tag>;
}
},
},
{
dataIndex: 'createdBy',
title: '创建人',
search: false,
},
{
dataIndex: 'tags',
title: '标签',
search: false,
render: (tags) => {
if (Array.isArray(tags)) {
return (
<Space size={2}>
{tags.map((tag) => (
<Tag color="blue" key={tag}>
{tag}
</Tag>
))}
</Space>
);
}
return <>--</>;
},
},
{
dataIndex: 'description',
title: '描述',
search: false,
},
{
dataIndex: 'updatedAt',
title: '更新时间',
search: false,
render: (value: any) => {
return value && value !== '-' ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '-';
},
},
{
title: '操作',
dataIndex: 'x',
valueType: 'option',
render: (_, record) => {
if (record.hasAdminRes) {
return (
<Space>
<a
key="metricEditBtn"
onClick={() => {
handleMetricEdit(record);
}}
>
</a>
<Popconfirm
title="确认删除?"
okText="是"
cancelText="否"
onConfirm={async () => {
deleteMetricQuery(record.id);
}}
>
<a
key="metricDeleteBtn"
onClick={() => {
setMetricItem(record);
}}
>
</a>
</Popconfirm>
</Space>
);
} else {
return <></>;
}
},
},
];
const handleFilterChange = async (filterParams: {
key: string;
sensitiveLevel: string;
type: string;
}) => {
const { sensitiveLevel, type } = filterParams;
const params: QueryMetricListParams = { ...filterParams };
const sensitiveLevelValue = sensitiveLevel?.[0];
const typeValue = type?.[0];
params.sensitiveLevel = sensitiveLevelValue;
params.type = typeValue;
setFilterParams(params);
await queryMetricList(params, filterParams.key ? false : true);
};
const rowSelection = {
onChange: (selectedRowKeys: React.Key[]) => {
setSelectedRowKeys(selectedRowKeys);
},
getCheckboxProps: (record: ISemantic.IMetricItem) => ({
disabled: !record.hasAdminRes,
}),
};
const dropdownButtonItems = [
{
key: 'batchStart',
label: '批量启用',
},
{
key: 'batchStop',
label: '批量停用',
},
{
key: 'batchDelete',
label: (
<Popconfirm
title="确定批量删除吗?"
onConfirm={() => {
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.DELETED);
}}
>
<a></a>
</Popconfirm>
),
},
];
const onMenuClick = ({ key }: { key: string }) => {
switch (key) {
case 'batchStart':
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.ONLINE);
break;
case 'batchStop':
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.OFFLINE);
break;
default:
break;
}
};
return (
<>
<div className={styles.metricFilterWrapper}>
<MetricFilter
initFilterValues={filterParams}
onFiltersChange={(_, values) => {
if (_.showType !== undefined) {
setLoading(true);
setDataSource([]);
}
handleFilterChange(values);
}}
/>
</div>
<>
{filterParams.showType ? (
<Spin spinning={loading} style={{ minHeight: 500 }}>
<MetricCardList
metricList={dataSource}
disabledEdit={true}
onMetricChange={(metricItem: ISemantic.IMetricItem) => {
history.push(`/metric/detail/${metricItem.modelId}/${metricItem.bizName}`);
}}
onDeleteBtnClick={(metricItem: ISemantic.IMetricItem) => {
deleteMetricQuery(metricItem.id);
}}
onEditBtnClick={(metricItem: ISemantic.IMetricItem) => {
setMetricItem(metricItem);
setCreateModalVisible(true);
}}
/>
</Spin>
) : (
<ProTable
className={`${styles.metricTable}`}
actionRef={actionRef}
rowKey="id"
search={false}
dataSource={dataSource}
columns={columns}
pagination={pagination}
tableAlertRender={() => {
return false;
}}
rowSelection={{
type: 'checkbox',
...rowSelection,
}}
toolBarRender={() => [
<Dropdown.Button
key="ctrlBtnList"
menu={{ items: dropdownButtonItems, onClick: onMenuClick }}
>
</Dropdown.Button>,
]}
loading={loading}
onChange={(data: any) => {
const { current, pageSize, total } = data;
const pagin = {
current,
pageSize,
total,
};
setPagination(pagin);
queryMetricList({ ...pagin, ...filterParams });
}}
size="small"
options={{ reload: false, density: false, fullScreen: false }}
/>
)}
</>
{createModalVisible && (
<MetricInfoCreateForm
domainId={Number(selectDomainId)}
createModalVisible={createModalVisible}
modelId={modelId}
metricItem={metricItem}
onSubmit={() => {
setCreateModalVisible(false);
queryMetricList(filterParams);
dispatch({
type: 'domainManger/queryMetricList',
payload: {
domainId: selectDomainId,
},
});
}}
onCancel={() => {
setCreateModalVisible(false);
}}
/>
)}
{infoDrawerVisible && (
<NodeInfoDrawer
nodeData={{ ...metricItem, nodeType: SemanticNodeType.METRIC }}
placement="right"
onClose={() => {
setInfoDrawerVisible(false);
}}
width="100%"
open={infoDrawerVisible}
mask={true}
getContainer={false}
onEditBtnClick={(nodeData: any) => {
handleMetricEdit(nodeData);
}}
maskClosable={true}
onNodeChange={({ eventName }: { eventName: string }) => {
setInfoDrawerVisible(false);
}}
/>
)}
</>
);
};
export default connect(({ domainManger }: { domainManger: StateType }) => ({
domainManger,
}))(ClassMetricTable);

View File

@@ -9,6 +9,7 @@ import { DownloadOutlined } from '@ant-design/icons';
import type { ECharts } from 'echarts';
import * as echarts from 'echarts';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { groupBy, sum } from 'lodash';
import styles from '../style.less';
import moment from 'moment';
@@ -17,8 +18,6 @@ type Props = {
tip?: string;
data: any[];
fields: any[];
// columnFieldName: string;
// valueFieldName: string;
loading: boolean;
isPer?: boolean;
isPercent?: boolean;
@@ -27,6 +26,8 @@ type Props = {
height?: number;
renderType?: string;
decimalPlaces?: number;
rowNumber?: number;
groupByDimensionFieldName?: string;
onDownload?: () => void;
};
@@ -38,9 +39,10 @@ const TrendChart: React.FC<Props> = ({
loading,
isPer,
isPercent,
dateFieldName,
dateFieldName = 'sys_imp_date',
// columnFieldName,
// valueFieldName,
rowNumber = 0,
groupByDimensionFieldName,
dateFormat,
height,
renderType,
@@ -64,32 +66,67 @@ const TrendChart: React.FC<Props> = ({
new Set(
data
.map((item) =>
moment(`${(dateFieldName && item[dateFieldName]) || item.sys_imp_date}`).format(
dateFormat ?? 'YYYY-MM-DD',
),
moment(`${dateFieldName && item[dateFieldName]}`).format(dateFormat ?? 'YYYY-MM-DD'),
)
.sort((a, b) => {
return moment(a).valueOf() - moment(b).valueOf();
}),
),
);
const seriesData = fields.map((field) => {
const fieldData = {
type: 'line',
name: field.name,
symbol: 'circle',
showSymbol: data.length === 1,
smooth: true,
data: data.reduce((itemData, item) => {
const target = item[field.column];
if (target) {
itemData.push(target);
}
return itemData;
}, []),
};
return fieldData;
});
const formatterSeriesData = () => {
if (groupByDimensionFieldName) {
const groupByMap = groupBy(data, groupByDimensionFieldName);
const seriesData = Object.keys(groupByMap).map((fieldKey: string) => {
const dimensionDataList = groupByMap[fieldKey];
const dimensionDataMapByDate = dimensionDataList.reduce((itemMap, item) => {
itemMap[item[dateFieldName]] = { ...item };
return itemMap;
}, {});
const dataList = xData.reduce((itemData: any[], dateString) => {
const dimensionDataMapItem = dimensionDataMapByDate[dateString];
if (dimensionDataMapItem) {
itemData.push(dimensionDataMapItem[fields?.[0]?.column]);
} else {
itemData.push(0);
}
return itemData;
}, []);
return {
type: 'line',
name: fieldKey,
symbol: 'circle',
smooth: true,
sortNum: sum(dataList),
data: dataList,
};
});
if (rowNumber) {
return seriesData.sort((a, b) => b.sortNum - a.sortNum).slice(0, rowNumber);
}
return seriesData;
}
const seriesData = fields.map((field) => {
const fieldData = {
type: 'line',
name: field.name,
symbol: 'circle',
showSymbol: data.length === 1,
smooth: true,
data: data.reduce((itemData, item) => {
const target = item[field.column];
if (target) {
itemData.push(target);
}
return itemData;
}, []),
};
return fieldData;
});
return seriesData;
};
const seriesData = formatterSeriesData();
instanceObj.setOption({
legend: {
@@ -178,7 +215,18 @@ const TrendChart: React.FC<Props> = ({
series: seriesData,
});
instanceObj.resize();
}, [data, fields, instance, isPer, isPercent, dateFieldName, decimalPlaces, renderType]);
}, [
data,
fields,
instance,
isPer,
isPercent,
dateFieldName,
decimalPlaces,
renderType,
rowNumber,
groupByDimensionFieldName,
]);
useEffect(() => {
if (!loading) {
@@ -203,7 +251,7 @@ const TrendChart: React.FC<Props> = ({
<Skeleton
className={styles.chart}
style={{ height, display: loading ? 'table' : 'none' }}
paragraph={{ rows: height && height > 300 ? 9 : 6 }}
paragraph={{ rows: height && height > 300 ? 15 : 6 }}
/>
<div
className={styles.chart}

View File

@@ -5,13 +5,13 @@ import RemoteSelect, { RemoteSelectImperativeHandle } from '@/components/RemoteS
import { queryDimValue } from '@/pages/SemanticModel/service';
import { OperatorEnum } from '@/pages/SemanticModel/enum';
import { isString } from 'lodash';
import styles from '../style.less';
const FormItem = Form.Item;
type Props = {
dimensionOptions: { value: string; label: string }[];
dimensionOptions: OptionsItem[];
modelId: number;
periodDate?: { startDate: string; endDate: string; dateField: string };
value?: FormData;
onChange?: (value: FormData) => void;
};
@@ -19,20 +19,19 @@ type Props = {
export type FormData = {
dimensionBizName: string;
operator: OperatorEnum;
dimensionValue: string | string[];
dimensionValue?: string | string[];
};
const MetricTrendDimensionFilter: React.FC<Props> = ({
dimensionOptions,
modelId,
value,
periodDate,
onChange,
}) => {
const [form] = Form.useForm();
const dimensionValueSearchRef = useRef<RemoteSelectImperativeHandle>();
const queryParams = useRef<{ dimensionBizName?: string }>({});
const [formData, setFormData] = useState<FormData>({ operator: OperatorEnum.IN } as FormData);
useEffect(() => {
@@ -47,6 +46,11 @@ const MetricTrendDimensionFilter: React.FC<Props> = ({
if (formData.dimensionBizName) {
queryParams.current = { dimensionBizName: formData.dimensionBizName };
dimensionValueSearchRef.current?.emitSearch('');
form.setFieldValue('dimensionValue', undefined);
setFormData({
...formData,
dimensionValue: undefined,
});
}
}, [formData.dimensionBizName]);
@@ -59,7 +63,17 @@ const MetricTrendDimensionFilter: React.FC<Props> = ({
...queryParams.current,
value: searchValue,
modelId,
// dateInfo: {},
limit: 50,
...(periodDate?.startDate
? {
dateInfo: {
dateMode: 'BETWEEN',
startDate: periodDate.startDate,
endDate: periodDate.endDate,
},
}
: {}),
});
if (code === 200 && Array.isArray(data?.resultList)) {
return data.resultList.slice(0, 50).map((item: any) => ({
@@ -109,7 +123,7 @@ const MetricTrendDimensionFilter: React.FC<Props> = ({
placeholder="请选择筛选维度"
/>
</FormItem>
<Tag color="processing" style={{ margin: 0, padding: 0 }}>
<Tag color="processing" style={{ margin: 0, padding: 0, height: 32 }}>
<FormItem name="operator" noStyle>
<Select
style={{ minWidth: 72 }}

View File

@@ -1,48 +1,95 @@
import { Form, Select, Space, Tag, Button, Tooltip } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import React, { useEffect, useState, useRef } from 'react';
import RemoteSelect, { RemoteSelectImperativeHandle } from '@/components/RemoteSelect';
import { queryDimValue } from '@/pages/SemanticModel/service';
import { OperatorEnum } from '@/pages/SemanticModel/enum';
import { Space, Tag } from 'antd';
import React, { useEffect, useState } from 'react';
import MetricTrendDimensionFilter from './MetricTrendDimensionFilter';
import type { FormData } from './MetricTrendDimensionFilter';
import { isString } from 'lodash';
import styles from '../style.less';
const FormItem = Form.Item;
type Props = {
dimensionOptions: { value: string; label: string }[];
dimensionOptions: OptionsItem[];
modelId: number;
value?: FormData;
onChange?: (value: FormData) => void;
periodDate?: { startDate: string; endDate: string; dateField: string };
onChange?: (value: FormData[]) => void;
};
type DimensionOptionsMapItem = {
dimensionBizName: string;
dimensionName: string;
};
const MetricTrendDimensionFilterContainer: React.FC<Props> = ({
dimensionOptions,
modelId,
periodDate,
value,
onChange,
}) => {
const [filterData, setFilterData] = useState<FormData[]>([]);
const [dimensionOptionsMap, setDimensionOptionsMap] = useState<
Record<string, DimensionOptionsMapItem>
>({});
useEffect(() => {
if (Array.isArray(dimensionOptions)) {
const dimensionDataMap = dimensionOptions.reduce(
(dimensionMap: Record<string, DimensionOptionsMapItem>, item: OptionsItem) => {
dimensionMap[item.value] = {
dimensionBizName: `${item.value}`,
dimensionName: item.label,
};
return dimensionMap;
},
{},
);
setDimensionOptionsMap(dimensionDataMap);
}
}, [dimensionOptions]);
return (
<div>
<MetricTrendDimensionFilter
modelId={modelId}
dimensionOptions={dimensionOptions}
value={value}
// value={value}
periodDate={periodDate}
onChange={(value) => {
setFilterData([...filterData, value]);
onChange?.(value);
const data = [...filterData, value];
setFilterData(data);
onChange?.(data);
}}
/>
<div>
<Tag>
{filterData.map((item: FormData) => {
return <Tag key={item.dimensionValue}>{item.dimensionValue}</Tag>;
})}
</Tag>
</div>
<Space size={8} wrap style={{ marginTop: 10 }}>
{filterData.map((item: FormData, index: number) => {
const { dimensionBizName, dimensionValue, operator } = item;
return (
// eslint-disable-next-line react/no-array-index-key
<Space key={`${dimensionBizName}-${dimensionValue}-${operator}-${Math.random()}`}>
<Tag
color="blue"
style={{ padding: 5 }}
closable
onClose={() => {
const newData = [...filterData];
newData.splice(index, 1);
setFilterData(newData);
onChange?.(newData);
}}
>
<span style={{ marginRight: 5 }}>
{dimensionOptionsMap?.[dimensionBizName]?.dimensionName}[{operator}]:
</span>
<Tag color="purple">
{Array.isArray(dimensionValue) ? dimensionValue.join('、') : dimensionValue}
</Tag>
</Tag>
{index !== filterData.length - 1 && (
<Tag color="blue" style={{ marginRight: 10 }}>
<span style={{ height: 32, display: 'flex', alignItems: 'center' }}>AND</span>
</Tag>
)}
</Space>
);
})}
</Space>
</div>
);
};

View File

@@ -1,31 +1,37 @@
import React, { useState, useEffect, useRef } from 'react';
import { SemanticNodeType } from '../../enum';
import moment from 'moment';
import { message, Row, Col, Button, Space, Select, Form } from 'antd';
import { message, Row, Col, Button, Space, Select, Form, Tooltip, Radio } from 'antd';
import {
queryStruct,
downloadCosFile,
getDrillDownDimension,
getDimensionList,
} from '@/pages/SemanticModel/service';
import {
InfoCircleOutlined,
LineChartOutlined,
TableOutlined,
DownloadOutlined,
} from '@ant-design/icons';
import DimensionAndMetricRelationModal from '../../components/DimensionAndMetricRelationModal';
import TrendChart from '@/pages/SemanticModel/Metric/components/MetricTrend';
import MetricTrendDimensionFilter from './MetricTrendDimensionFilter';
import MetricTrendDimensionFilterContainer from './MetricTrendDimensionFilterContainer';
import MDatePicker from '@/components/MDatePicker';
import { useModel } from 'umi';
import { DateRangeType, DateSettingType } from '@/components/MDatePicker/type';
import StandardFormRow from '@/components/StandardFormRow';
import MetricTable from './Table';
import { ColumnConfig } from '../data';
import { ISemantic } from '../../data';
const FormItem = Form.Item;
const { Option } = Select;
type Props = {
nodeData: any;
metircData?: ISemantic.IMetricItem;
[key: string]: any;
};
const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
const MetricTrendSection: React.FC<Props> = ({ metircData }) => {
const dateFieldMap = {
[DateRangeType.DAY]: 'sys_imp_date',
[DateRangeType.WEEK]: 'sys_imp_week',
@@ -35,6 +41,10 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
const [metricTrendData, setMetricTrendData] = useState<ISemantic.IMetricTrendItem[]>([]);
const [metricTrendLoading, setMetricTrendLoading] = useState<boolean>(false);
const [metricColumnConfig, setMetricColumnConfig] = useState<ISemantic.IMetricTrendColumn>();
const [metricRelationModalOpenState, setMetricRelationModalOpenState] = useState<boolean>(false);
const [drillDownDimensions, setDrillDownDimensions] = useState<
ISemantic.IDrillDownDimensionItem[]
>(metircData?.relateDimension?.drillDownDimensions || []);
const [authMessage, setAuthMessage] = useState<string>('');
const [downloadLoding, setDownloadLoding] = useState<boolean>(false);
const [relationDimensionOptions, setRelationDimensionOptions] = useState<
@@ -42,15 +52,21 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
>([]);
const [queryParams, setQueryParams] = useState<any>({});
const [downloadBtnDisabledState, setDownloadBtnDisabledState] = useState<boolean>(true);
// const [showDimensionOptions, setShowDimensionOptions] = useState<any[]>([]);
const [periodDate, setPeriodDate] = useState<{
startDate: string;
endDate: string;
dateField: string;
}>({
startDate: moment().subtract('7', 'days').format('YYYY-MM-DD'),
startDate: moment().subtract('6', 'days').format('YYYY-MM-DD'),
endDate: moment().format('YYYY-MM-DD'),
dateField: dateFieldMap[DateRangeType.DAY],
});
const [rowNumber, setRowNumber] = useState<number>(5);
const [chartType, setChartType] = useState<'chart' | 'table'>('chart');
const [tableColumnConfig, setTableColumnConfig] = useState<ColumnConfig[]>([]);
const [groupByDimensionFieldName, setGroupByDimensionFieldName] = useState<string>();
const getMetricTrendData = async (params: any = { download: false }) => {
const { download, dimensionGroup, dimensionFilters } = params;
@@ -59,8 +75,10 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
} else {
setMetricTrendLoading(true);
}
const { modelId, bizName, name } = nodeData;
if (!metircData) {
return;
}
const { modelId, bizName, name } = metircData;
indicatorFields.current = [{ name, column: bizName }];
const res = await queryStruct({
modelId,
@@ -81,6 +99,7 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
if (code === 200) {
const { resultList, columns, queryAuthorization } = data;
setMetricTrendData(resultList);
setTableColumnConfig(columns);
const message = queryAuthorization?.message;
if (message) {
setAuthMessage(message);
@@ -139,14 +158,15 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
};
useEffect(() => {
if (nodeData?.id && nodeData?.nodeType === SemanticNodeType.METRIC) {
getMetricTrendData();
initDimensionData(nodeData);
if (metircData?.id) {
getMetricTrendData({ ...queryParams });
initDimensionData(metircData);
setDrillDownDimensions(metircData?.relateDimension?.drillDownDimensions || []);
}
}, [nodeData, periodDate]);
}, [metircData, periodDate]);
return (
<>
<div style={{ backgroundColor: '#fff', marginTop: 20 }}>
<div style={{ marginBottom: 25 }}>
<Row>
<Col flex="1 1 200px">
@@ -158,57 +178,8 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
if (value.key) {
return;
}
// handleValuesChange(value, values);
}}
>
{/* <StandardFormRow key="dimensionSelected" title="维度下钻:">
<FormItem name="dimensionSelected">
<Select
style={{ minWidth: 150, maxWidth: 200 }}
options={relationDimensionOptions}
showSearch
filterOption={(input, option) =>
((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
}
mode="multiple"
placeholder="请选择下钻维度"
onChange={(value) => {
const params = { ...queryParams, dimensionGroup: value || [] };
setQueryParams(params);
getMetricTrendData({ ...params });
}}
/>
</FormItem>
</StandardFormRow>
<StandardFormRow key="dimensionFilter" title="维度筛选:">
<FormItem name="dimensionFilter">
<MetricTrendDimensionFilter
modelId={nodeData.modelId}
dimensionOptions={relationDimensionOptions}
onChange={(filterParams) => {
const {
dimensionBizName: bizName,
dimensionValue: value,
operator,
} = filterParams;
if (bizName && value && operator) {
const params = {
...queryParams,
dimensionFilters: [
{
bizName: 'user_name',
value: ['williamhliu', 'leooonli'],
operator: 'in',
},
],
};
setQueryParams(params);
getMetricTrendData({ ...params });
}
}}
/>
</FormItem>
</StandardFormRow> */}
<StandardFormRow key="metricDate" title="日期区间:">
<FormItem name="metricDate">
<MDatePicker
@@ -243,45 +214,209 @@ const MetricTrendSection: React.FC<Props> = ({ nodeData }) => {
/>
</FormItem>
</StandardFormRow>
<StandardFormRow key="dimensionSelected" title="维度下钻:">
<FormItem name="dimensionSelected">
<Select
style={{ minWidth: 150, maxWidth: 200 }}
options={relationDimensionOptions}
showSearch
filterOption={(input, option) =>
((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
}
mode="multiple"
placeholder="请选择下钻维度"
onChange={(value) => {
const params = { ...queryParams, dimensionGroup: value || [] };
setQueryParams(params);
getMetricTrendData({ ...params });
setGroupByDimensionFieldName(value[value.length - 1]);
}}
/>
</FormItem>
</StandardFormRow>
<StandardFormRow key="dimensionFilter" title="维度筛选:">
<FormItem name="dimensionFilter">
<MetricTrendDimensionFilterContainer
modelId={metircData?.modelId || 0}
dimensionOptions={relationDimensionOptions}
periodDate={periodDate}
onChange={(filterList) => {
const dimensionFilters = filterList.map((item) => {
const { dimensionBizName, dimensionValue, operator } = item;
return {
bizName: dimensionBizName,
value: dimensionValue,
operator,
};
});
const params = {
...queryParams,
dimensionFilters,
};
setQueryParams(params);
getMetricTrendData({ ...params });
}}
/>
</FormItem>
</StandardFormRow>
</Form>
</Col>
<Col flex="0 1">
<Button
type="primary"
loading={downloadLoding}
disabled={downloadBtnDisabledState}
onClick={() => {
getMetricTrendData({ download: true, ...queryParams });
}}
>
</Button>
<Space>
{metircData?.hasAdminRes && (
<Button
type="primary"
key="addDimension"
onClick={() => {
setMetricRelationModalOpenState(true);
}}
>
<Space>
<Tooltip title="配置下钻维度后,将可以在指标卡中进行下钻">
<InfoCircleOutlined />
</Tooltip>
</Space>
</Button>
)}
<Button
type="primary"
key="download"
loading={downloadLoding}
disabled={downloadBtnDisabledState}
onClick={() => {
getMetricTrendData({ download: true, ...queryParams });
}}
>
<Space>
<DownloadOutlined />
</Space>
</Button>
</Space>
</Col>
</Row>
</div>
{authMessage && <div style={{ color: '#d46b08', marginBottom: 15 }}>{authMessage}</div>}
<TrendChart
data={metricTrendData}
isPer={
metricColumnConfig?.dataFormatType === 'percent' &&
metricColumnConfig?.dataFormat?.needMultiply100 === false
? true
: false
}
isPercent={
metricColumnConfig?.dataFormatType === 'percent' &&
metricColumnConfig?.dataFormat?.needMultiply100 === true
? true
: false
}
fields={indicatorFields.current}
loading={metricTrendLoading}
dateFieldName={periodDate.dateField}
height={350}
renderType="clear"
decimalPlaces={metricColumnConfig?.dataFormat?.decimalPlaces || 2}
<Row style={{ marginBottom: 20 }}>
<Col flex="1 1 300px">
<Radio.Group
size="small"
buttonStyle="solid"
options={[
{
label: (
<Tooltip title="折线图">
<LineChartOutlined />
</Tooltip>
),
value: 'chart',
},
{
label: (
<Tooltip title="表格">
<TableOutlined />
</Tooltip>
),
value: 'table',
},
]}
onChange={(e) => {
setChartType(e.target.value);
}}
value={chartType}
optionType="button"
/>
{/* <Space>
<Select
style={{ minWidth: 150, maxWidth: 200 }}
options={showDimensionOptions}
value={groupByDimensionFieldName}
showSearch
filterOption={(input, option) =>
((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
}
placeholder="展示维度切换"
onChange={(value) => {
setGroupByDimensionFieldName(value);
}}
/>
</Space> */}
</Col>
<Col flex="0 1 100px">
<Space>
<Select
defaultValue={rowNumber}
style={{
width: 120,
display:
Array.isArray(queryParams.dimensionGroup) &&
queryParams.dimensionGroup.length > 0 &&
chartType === 'chart'
? 'block'
: 'none',
}}
onChange={(value) => {
setRowNumber(value);
}}
>
<Option value={5}>5</Option>
<Option value={10}>10</Option>
<Option value={15}>15</Option>
<Option value={20}>20</Option>
</Select>
</Space>
</Col>
</Row>
{chartType === 'chart' && (
<TrendChart
data={metricTrendData}
isPer={
metricColumnConfig?.dataFormatType === 'percent' &&
metricColumnConfig?.dataFormat?.needMultiply100 === false
? true
: false
}
isPercent={
metricColumnConfig?.dataFormatType === 'percent' &&
metricColumnConfig?.dataFormat?.needMultiply100 === true
? true
: false
}
rowNumber={rowNumber}
fields={indicatorFields.current}
loading={metricTrendLoading}
dateFieldName={periodDate.dateField}
groupByDimensionFieldName={groupByDimensionFieldName}
height={500}
renderType="clear"
decimalPlaces={metricColumnConfig?.dataFormat?.decimalPlaces || 2}
/>
)}
<div style={{ display: chartType === 'table' ? 'block' : 'none', marginBottom: 45 }}>
<MetricTable
loading={metricTrendLoading}
columnConfig={tableColumnConfig}
dataSource={metricTrendData}
dateFieldName={periodDate.dateField}
metricFieldName={indicatorFields.current?.[0]?.column}
/>
</div>
<DimensionAndMetricRelationModal
metricItem={metircData}
relationsInitialValue={drillDownDimensions}
open={metricRelationModalOpenState}
onCancel={() => {
setMetricRelationModalOpenState(false);
}}
onSubmit={(relations) => {
setDrillDownDimensions(relations);
setMetricRelationModalOpenState(false);
initDimensionData(metircData!);
}}
/>
</>
</div>
);
};

View File

@@ -0,0 +1,74 @@
import { Table } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import React, { useEffect, useState } from 'react';
import moment from 'moment';
import styles from '../style.less';
import { ColumnConfig } from '../data';
type Props = {
columnConfig?: ColumnConfig[];
dataSource: any;
metricFieldName: string;
dateFieldName?: string;
loading?: boolean;
};
const MetricTable: React.FC<Props> = ({
columnConfig,
dataSource,
dateFieldName = 'sys_imp_date',
metricFieldName,
loading = false,
}) => {
const [columns, setColumns] = useState<ColumnsType<any>>([]);
useEffect(() => {
if (Array.isArray(columnConfig)) {
const config: ColumnsType<any> = columnConfig.map((item: ColumnConfig) => {
const { name, nameEn } = item;
if (nameEn === dateFieldName) {
return {
title: '日期',
dataIndex: nameEn,
key: nameEn,
width: 120,
fixed: 'left',
defaultSortOrder: 'descend',
sorter: (a, b) => moment(a[nameEn]).valueOf() - moment(b[nameEn]).valueOf(),
};
}
if (nameEn === metricFieldName) {
return {
title: name,
dataIndex: nameEn,
key: nameEn,
sortDirections: ['descend'],
sorter: (a, b) => a[nameEn] - b[nameEn],
};
}
return {
title: name,
key: nameEn,
dataIndex: nameEn,
};
});
setColumns(config);
}
}, [columnConfig]);
return (
<div style={{ height: '100%' }}>
{Array.isArray(columns) && columns.length > 0 && (
<Table
columns={columns}
dataSource={dataSource}
scroll={{ x: 200, y: 700 }}
// pagination={{ defaultPageSize: 20 }}
loading={loading}
onChange={() => {}}
/>
)}
</div>
);
};
export default MetricTable;

View File

@@ -0,0 +1,9 @@
export type ColumnConfig = {
name: string;
type: string;
nameEn: string;
showType: string;
authorized: boolean;
dataFormatType: null;
dataFormat: null;
};

View File

@@ -1,456 +1,7 @@
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { message, Space, Popconfirm, Tag, Spin, Dropdown } from 'antd';
import React, { useRef, useState, useEffect } from 'react';
import type { Dispatch } from 'umi';
import { connect, history, useModel } from 'umi';
import type { StateType } from '../model';
import { SENSITIVE_LEVEL_ENUM } from '../constant';
import { queryMetric, deleteMetric, batchUpdateMetricStatus } from '../service';
import MetricFilter from './components/MetricFilter';
import MetricInfoCreateForm from '../components/MetricInfoCreateForm';
import MetricCardList from './components/MetricCardList';
import NodeInfoDrawer from '../SemanticGraph/components/NodeInfoDrawer';
import { SemanticNodeType, StatusEnum } from '../enum';
import moment from 'moment';
import styles from './style.less';
import { ISemantic } from '../data';
import React from 'react';
type Props = {
dispatch: Dispatch;
domainManger: StateType;
const market: React.FC = ({ children }) => {
return <>{children}</>;
};
type QueryMetricListParams = {
id?: string;
name?: string;
bizName?: string;
sensitiveLevel?: string;
type?: string;
[key: string]: any;
};
const ClassMetricTable: React.FC<Props> = ({ domainManger, dispatch }) => {
const { initialState = {} } = useModel('@@initialState');
const { currentUser = {} } = initialState as any;
const { selectDomainId, selectModelId: modelId } = domainManger;
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
const defaultPagination = {
current: 1,
pageSize: 20,
total: 0,
};
const [pagination, setPagination] = useState(defaultPagination);
const [loading, setLoading] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<ISemantic.IMetricItem[]>([]);
const [metricItem, setMetricItem] = useState<ISemantic.IMetricItem>();
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [filterParams, setFilterParams] = useState<Record<string, any>>({
showType: localStorage.getItem('metricMarketShowType') === '1' ? true : false,
});
const [infoDrawerVisible, setInfoDrawerVisible] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
useEffect(() => {
queryMetricList(filterParams);
}, []);
const queryBatchUpdateStatus = async (ids: React.Key[], status: StatusEnum) => {
if (Array.isArray(ids) && ids.length === 0) {
return;
}
const { code, msg } = await batchUpdateMetricStatus({
ids,
status,
});
if (code === 200) {
queryMetricList(filterParams);
return;
}
message.error(msg);
};
const queryMetricList = async (params: QueryMetricListParams = {}, disabledLoading = false) => {
if (!disabledLoading) {
setLoading(true);
}
const { code, data, msg } = await queryMetric({
...pagination,
...params,
createdBy: params.onlyShowMe ? currentUser.name : null,
pageSize: params.showType ? 100 : params.pageSize || pagination.pageSize,
});
setLoading(false);
const { list, pageSize, pageNum, total } = data || {};
let resData: any = {};
if (code === 200) {
if (!params.showType) {
setPagination({
...pagination,
pageSize: Math.min(pageSize, 100),
current: pageNum,
total,
});
}
setDataSource(list);
resData = {
data: list || [],
success: true,
};
} else {
message.error(msg);
setDataSource([]);
resData = {
data: [],
total: 0,
success: false,
};
}
return resData;
};
const deleteMetricQuery = async (id: number) => {
const { code, msg } = await deleteMetric(id);
if (code === 200) {
setMetricItem(undefined);
queryMetricList(filterParams);
} else {
message.error(msg);
}
};
const handleMetricEdit = (metricItem: ISemantic.IMetricItem) => {
setMetricItem(metricItem);
setCreateModalVisible(true);
};
const columns: ProColumns[] = [
{
dataIndex: 'id',
title: 'ID',
},
{
dataIndex: 'name',
title: '指标名称',
render: (_, record: any) => {
return (
<a
onClick={() => {
setMetricItem(record);
setInfoDrawerVisible(true);
}}
>
{record.name}
</a>
);
},
},
{
dataIndex: 'modelName',
title: '所属模型',
render: (_, record: any) => {
if (record.hasAdminRes) {
return (
<a
onClick={() => {
history.replace(`/model/${record.domainId}/${record.modelId}/metric`);
}}
>
{record.modelName}
</a>
);
}
return <> {record.modelName}</>;
},
},
{
dataIndex: 'sensitiveLevel',
title: '敏感度',
valueEnum: SENSITIVE_LEVEL_ENUM,
},
{
dataIndex: 'status',
title: '状态',
width: 80,
search: false,
render: (status) => {
switch (status) {
case StatusEnum.ONLINE:
return <Tag color="success"></Tag>;
case StatusEnum.OFFLINE:
return <Tag color="warning"></Tag>;
case StatusEnum.INITIALIZED:
return <Tag color="processing"></Tag>;
case StatusEnum.DELETED:
return <Tag color="default"></Tag>;
default:
return <Tag color="default"></Tag>;
}
},
},
{
dataIndex: 'createdBy',
title: '创建人',
search: false,
},
{
dataIndex: 'tags',
title: '标签',
search: false,
render: (tags) => {
if (Array.isArray(tags)) {
return (
<Space size={2}>
{tags.map((tag) => (
<Tag color="blue" key={tag}>
{tag}
</Tag>
))}
</Space>
);
}
return <>--</>;
},
},
{
dataIndex: 'description',
title: '描述',
search: false,
},
{
dataIndex: 'updatedAt',
title: '更新时间',
search: false,
render: (value: any) => {
return value && value !== '-' ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '-';
},
},
{
title: '操作',
dataIndex: 'x',
valueType: 'option',
render: (_, record) => {
if (record.hasAdminRes) {
return (
<Space>
<a
key="metricEditBtn"
onClick={() => {
handleMetricEdit(record);
}}
>
</a>
<Popconfirm
title="确认删除?"
okText="是"
cancelText="否"
onConfirm={async () => {
deleteMetricQuery(record.id);
}}
>
<a
key="metricDeleteBtn"
onClick={() => {
setMetricItem(record);
}}
>
</a>
</Popconfirm>
</Space>
);
} else {
return <></>;
}
},
},
];
const handleFilterChange = async (filterParams: {
key: string;
sensitiveLevel: string;
type: string;
}) => {
const { sensitiveLevel, type } = filterParams;
const params: QueryMetricListParams = { ...filterParams };
const sensitiveLevelValue = sensitiveLevel?.[0];
const typeValue = type?.[0];
params.sensitiveLevel = sensitiveLevelValue;
params.type = typeValue;
setFilterParams(params);
await queryMetricList(params, filterParams.key ? false : true);
};
const rowSelection = {
onChange: (selectedRowKeys: React.Key[]) => {
setSelectedRowKeys(selectedRowKeys);
},
getCheckboxProps: (record: ISemantic.IMetricItem) => ({
disabled: !record.hasAdminRes,
}),
};
const dropdownButtonItems = [
{
key: 'batchStart',
label: '批量启用',
},
{
key: 'batchStop',
label: '批量停用',
},
{
key: 'batchDelete',
label: (
<Popconfirm
title="确定批量删除吗?"
onConfirm={() => {
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.DELETED);
}}
>
<a></a>
</Popconfirm>
),
},
];
const onMenuClick = ({ key }: { key: string }) => {
switch (key) {
case 'batchStart':
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.ONLINE);
break;
case 'batchStop':
queryBatchUpdateStatus(selectedRowKeys, StatusEnum.OFFLINE);
break;
default:
break;
}
};
return (
<>
<div className={styles.metricFilterWrapper}>
<MetricFilter
initFilterValues={filterParams}
onFiltersChange={(_, values) => {
if (_.showType !== undefined) {
setLoading(true);
setDataSource([]);
}
handleFilterChange(values);
}}
/>
</div>
<>
{filterParams.showType ? (
<Spin spinning={loading} style={{ minHeight: 500 }}>
<MetricCardList
metricList={dataSource}
disabledEdit={true}
onMetricChange={(metricItem: ISemantic.IMetricItem) => {
setInfoDrawerVisible(true);
setMetricItem(metricItem);
}}
onDeleteBtnClick={(metricItem: ISemantic.IMetricItem) => {
deleteMetricQuery(metricItem.id);
}}
onEditBtnClick={(metricItem: ISemantic.IMetricItem) => {
setMetricItem(metricItem);
setCreateModalVisible(true);
}}
/>
</Spin>
) : (
<ProTable
className={`${styles.metricTable}`}
actionRef={actionRef}
rowKey="id"
search={false}
dataSource={dataSource}
columns={columns}
pagination={pagination}
tableAlertRender={() => {
return false;
}}
rowSelection={{
type: 'checkbox',
...rowSelection,
}}
toolBarRender={() => [
<Dropdown.Button
key="ctrlBtnList"
menu={{ items: dropdownButtonItems, onClick: onMenuClick }}
>
</Dropdown.Button>,
]}
loading={loading}
onChange={(data: any) => {
const { current, pageSize, total } = data;
const pagin = {
current,
pageSize,
total,
};
setPagination(pagin);
queryMetricList({ ...pagin, ...filterParams });
}}
size="small"
options={{ reload: false, density: false, fullScreen: false }}
/>
)}
</>
{createModalVisible && (
<MetricInfoCreateForm
domainId={Number(selectDomainId)}
createModalVisible={createModalVisible}
modelId={modelId}
metricItem={metricItem}
onSubmit={() => {
setCreateModalVisible(false);
queryMetricList(filterParams);
dispatch({
type: 'domainManger/queryMetricList',
payload: {
domainId: selectDomainId,
},
});
}}
onCancel={() => {
setCreateModalVisible(false);
}}
/>
)}
{infoDrawerVisible && (
<NodeInfoDrawer
nodeData={{ ...metricItem, nodeType: SemanticNodeType.METRIC }}
placement="right"
onClose={() => {
setInfoDrawerVisible(false);
}}
width="100%"
open={infoDrawerVisible}
mask={true}
getContainer={false}
onEditBtnClick={(nodeData: any) => {
handleMetricEdit(nodeData);
}}
maskClosable={true}
onNodeChange={({ eventName }: { eventName: string }) => {
setInfoDrawerVisible(false);
}}
/>
)}
</>
);
};
export default connect(({ domainManger }: { domainManger: StateType }) => ({
domainManger,
}))(ClassMetricTable);
export default market;

View File

@@ -114,4 +114,81 @@
}
}
}
}
}
.metricDetail {
height: calc(100vh - 50px);
.title {
margin-bottom: 0;
// padding: 20px;
font-size: 20px;
line-height: 34px;
border-bottom: 1px solid #d9d9d9;
display: flex;
.titleLeft {
display: flex;
flex: 1 1 auto;
.navContainer {
// display: flex;
padding: 20px;
padding-left: 30px;
.description {
font-size: 12px;
line-height: 12px;
padding-top: 12px;
color: #546174
}
}
.backBtn {
background-color: #f8f8f8;
padding: 5px;
color: #b0b4bc;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
&:hover {
background-color: #7599e5;
color: #fff;
}
}
}
.titleRight {
display: flex;
flex: 0 1 200px;
.info {
margin: 15px;
}
}
}
.tabContainer {
background-color: #fff;
padding: 0px 40px;
}
.metricInfoContent {
padding:25px;
.title {
margin-bottom: 12px;
font-size: 16px;
color: #0e73ff;
font-weight: bold;
position: relative;
&::before {
display: block;
position: absolute;
content: "";
left: -10px;
top: 10px;
height: 14px;
width: 3px;
font-size: 0;
background: #0e73ff;
border-radius: 2px;
border: 1px solid #0e73ff;
}
}
}
}

View File

@@ -202,109 +202,77 @@ const OverviewContainer: React.FC<Props> = ({ mode, domainManger, dispatch }) =>
<div className={styles.projectBody}>
<Helmet title={'语义模型-超音数'} />
<div className={styles.projectManger}>
<h2 className={styles.title}>
{!!selectModelId && (
<div
className={styles.backBtn}
onClick={() => {
cleanModelInfo(selectDomainId);
}}
>
<LeftOutlined />
</div>
)}
<div className={styles.navContainer}>
<Popover
zIndex={1000}
overlayInnerStyle={{
overflow: 'scroll',
maxHeight: '800px',
}}
content={
<DomainListTree
createDomainBtnVisible={mode === 'domain' ? true : false}
onTreeSelected={(domainData) => {
setOpen(false);
const { id, name } = domainData;
cleanModelInfo(id);
dispatch({
type: 'domainManger/setSelectDomain',
selectDomainId: id,
selectDomainName: name,
domainData,
});
<div className={styles.sider}>
<div className={styles.domainTitle}>
<Space>
{selectDomainName ? `${selectDomainName}` : '主题域信息'}
{selectModelName && (
<>
<span style={{ position: 'relative' }}> | </span>
<span style={{ fontSize: 16, color: '#296DF3' }}>{selectModelName}</span>
</>
)}
</Space>
</div>
<DomainListTree
createDomainBtnVisible={mode === 'domain' ? true : false}
onTreeSelected={(domainData) => {
setOpen(false);
const { id, name } = domainData;
cleanModelInfo(id);
dispatch({
type: 'domainManger/setSelectDomain',
selectDomainId: id,
selectDomainName: name,
domainData,
});
}}
onTreeDataUpdate={() => {
initProjectTree();
}}
/>
</div>
<div className={styles.content}>
{selectDomainId ? (
<>
{mode === 'domain' ? (
<DomainManagerTab
isModel={isModel}
activeKey={activeKey}
modelList={modelList}
handleModelChange={(model) => {
handleModelChange(model);
}}
onTreeDataUpdate={() => {
initProjectTree();
onBackDomainBtnClick={() => {
cleanModelInfo(selectDomainId);
}}
onMenuChange={(menuKey) => {
setActiveKey(menuKey);
pushUrlMenu(selectDomainId, selectModelId, menuKey);
}}
/>
}
trigger="click"
open={selectModelId ? false : open}
onOpenChange={handleOpenChange}
>
<div className={styles.domainSelector}>
<span className={styles.domainTitle}>
<Space>
{selectDomainName ? `${selectDomainName}` : '主题域信息'}
{selectModelName && (
<>
<span style={{ position: 'relative', top: '-2px' }}> | </span>
<span style={{ fontSize: 16, color: '#296DF3' }}>{selectModelName}</span>
</>
)}
</Space>
</span>
{!selectModelId && (
<span className={styles.downIcon}>
<DownOutlined />
</span>
)}
</div>
</Popover>
</div>
</h2>
{selectDomainId ? (
<>
{mode === 'domain' ? (
<DomainManagerTab
isModel={isModel}
activeKey={activeKey}
modelList={modelList}
handleModelChange={(model) => {
handleModelChange(model);
}}
onBackDomainBtnClick={() => {
cleanModelInfo(selectDomainId);
}}
onMenuChange={(menuKey) => {
setActiveKey(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>
)}
) : (
<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>
)}
</div>
</div>
</div>
);

View File

@@ -1,27 +1,44 @@
import React, { useEffect, useState } from 'react';
import { Modal, Button } from 'antd';
import { Modal, Button, message } from 'antd';
import DimensionMetricRelationTableTransfer from './DimensionMetricRelationTableTransfer';
import { ISemantic } from '../data';
import { updateExprMetric } from '../service';
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
type Props = {
onCancel: () => void;
open: boolean;
metricItem: ISemantic.IMetricItem;
metricItem?: ISemantic.IMetricItem;
relationsInitialValue?: ISemantic.IDrillDownDimensionItem[];
onSubmit: (relations: ISemantic.IDrillDownDimensionItem[]) => void;
};
const DimensionAndMetricRelationModal: React.FC<Props> = ({
open,
metricItem,
metricItem = {},
relationsInitialValue,
onCancel,
onSubmit,
}) => {
const [relationList, setRelationList] = useState<ISemantic.IDrillDownDimensionItem[]>([]);
const saveMetric = async (relationList: any) => {
const queryParams = {
...metricItem,
relateDimension: {
...(metricItem?.relateDimension || {}),
drillDownDimensions: relationList,
},
};
const { code, msg } = await updateExprMetric(queryParams);
if (code === 200) {
// message.success('编辑指标成功');
// onSubmit?.(queryParams);
return;
}
message.error(msg);
};
const renderFooter = () => {
return (
<>
@@ -30,6 +47,7 @@ const DimensionAndMetricRelationModal: React.FC<Props> = ({
type="primary"
onClick={() => {
onSubmit(relationList);
saveMetric(relationList);
}}
>

View File

@@ -33,7 +33,7 @@ const DimensionMetricRelationTableTransfer: React.FC<Props> = ({
onChange,
}) => {
const [targetKeys, setTargetKeys] = useState<string[]>([]);
const { selectModelId: modelId, selectDomainId } = domainManger;
const { selectModelId: modelId } = domainManger;
const [checkedMap, setCheckedMap] = useState<Record<string, ISemantic.IDrillDownDimensionItem>>(
{},
);
@@ -42,7 +42,7 @@ const DimensionMetricRelationTableTransfer: React.FC<Props> = ({
useEffect(() => {
queryDimensionList();
}, []);
}, [metricItem, relationsInitialValue]);
const queryDimensionList = async () => {
const { code, data, msg } = await getDimensionList({ modelId: metricItem?.modelId || modelId });

View File

@@ -1,5 +1,5 @@
import { DownOutlined, PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { Input, message, Tree, Popconfirm, Space, Tooltip, Row, Col } from 'antd';
import { Input, message, Tree, Popconfirm, Space, Tooltip, Row, Col, Button } from 'antd';
import type { DataNode } from 'antd/lib/tree';
import { useEffect, useState } from 'react';
import type { FC, Key } from 'react';
@@ -119,7 +119,7 @@ const DomainListTree: FC<DomainListProps> = ({
return (
<div className={styles.projectItem}>
<span
className={styles.title}
className={styles.projectItemTitle}
onClick={() => {
handleSelect(id, name);
}}
@@ -180,17 +180,31 @@ const DomainListTree: FC<DomainListProps> = ({
return (
<div className={styles.domainList}>
<Row>
<Col flex="1 1 200px">
<Col flex="1 1 auto">
{/* <Space> */}
<Search
allowClear
className={styles.search}
placeholder="请输入主题域名称进行查询"
onSearch={onSearch}
/>
{/* </Space> */}
</Col>
{createDomainBtnVisible && (
<Col flex="0 1 50px">
<Col flex="0 0 40px" style={{ display: 'flex', alignItems: 'center' }}>
<Tooltip title="新增顶级域">
<Button
type="primary"
icon={<PlusOutlined />}
size="small"
onClick={() => {
setProjectInfoParams({ type: 'top', modelType: 'add' });
setProjectInfoModalVisible(true);
onCreateDomainBtnClick?.();
}}
/>
</Tooltip>
{/* <Tooltip title="新增顶级域">
<PlusCircleOutlined
onClick={() => {
setProjectInfoParams({ type: 'top', modelType: 'add' });
@@ -199,7 +213,7 @@ const DomainListTree: FC<DomainListProps> = ({
}}
className={styles.addBtn}
/>
</Tooltip>
</Tooltip> */}
</Col>
)}
</Row>

View File

@@ -6,7 +6,6 @@ import ClassDataSourceTable from './ClassDataSourceTable';
import ClassDimensionTable from './ClassDimensionTable';
import ClassMetricTable from './ClassMetricTable';
import PermissionSection from './Permission/PermissionSection';
// import DatabaseSection from './Database/DatabaseSection';
import EntitySettingSection from './Entity/EntitySettingSection';
import ChatSettingSection from '../ChatSetting/ChatSettingSection';
import OverView from './OverView';
@@ -16,6 +15,7 @@ import { LeftOutlined } from '@ant-design/icons';
import { ISemantic } from '../data';
import SemanticGraphCanvas from '../SemanticGraphCanvas';
import RecommendedQuestionsSection from '../components/Entity/RecommendedQuestionsSection';
import DatabaseTable from '../components/Database/DatabaseTable';
import type { Dispatch } from 'umi';
@@ -39,10 +39,10 @@ const DomainManagerTab: React.FC<Props> = ({
onMenuChange,
}) => {
const defaultTabKey = 'xflow';
const { selectDomainId, domainList } = domainManger;
const { selectDomainId, domainList, selectModelId } = domainManger;
const tabItem = [
{
label: '模型',
label: '模型管理',
key: 'overview',
children: (
<OverView
@@ -53,16 +53,16 @@ const DomainManagerTab: React.FC<Props> = ({
/>
),
},
// {
// label: '数据库',
// key: 'dataBase',
// children: <DatabaseSection />,
// },
{
label: '权限管理',
key: 'permissonSetting',
children: <PermissionSection permissionTarget={'domain'} />,
},
{
label: '数据库管理',
key: 'database',
children: <DatabaseTable />,
},
].filter((item) => {
const target = domainList.find((domain) => domain.id === selectDomainId);
if (target?.hasEditPermission) {
@@ -76,7 +76,7 @@ const DomainManagerTab: React.FC<Props> = ({
label: '画布',
key: 'xflow',
children: (
<div style={{ width: '100%', marginTop: -20 }}>
<div style={{ width: '100%' }}>
<SemanticGraphCanvas />
</div>
),
@@ -131,20 +131,35 @@ const DomainManagerTab: React.FC<Props> = ({
items={!isModel ? tabItem : isModelItem}
activeKey={activeKey || defaultTabKey}
destroyInactiveTabPane
tabBarExtraContent={
isModel ? (
<Button
type="primary"
icon={<LeftOutlined />}
onClick={() => {
onBackDomainBtnClick?.();
}}
style={{ marginRight: 10 }}
>
</Button>
) : undefined
}
size="large"
tabBarExtraContent={{
left: (
<>
{!!selectModelId && (
<div
className={styles.backBtn}
onClick={() => {
onBackDomainBtnClick?.();
}}
>
<LeftOutlined />
</div>
)}
</>
),
// right: isModel ? (
// <Button
// type="primary"
// icon={<LeftOutlined />}
// onClick={() => {
// onBackDomainBtnClick?.();
// }}
// style={{ marginRight: 10, marginBottom: 5 }}
// >
// 返回主题域
// </Button>
// ) : undefined,
}}
onChange={(menuKey: string) => {
onMenuChange?.(menuKey);
}}

View File

@@ -43,7 +43,7 @@ const EntitySettingSection: React.FC<Props> = ({ domainManger }) => {
}, [modelId]);
return (
<div style={{ width: 800, margin: '0 auto' }}>
<div style={{ width: 800, margin: '20px auto' }}>
<Space direction="vertical" style={{ width: '100%' }} size={20}>
{
<ProCard title="实体" bordered>

View File

@@ -72,7 +72,7 @@ const RecommendedQuestionsSection: React.FC<Props> = ({ domainManger }) => {
}, [modelId]);
return (
<div style={{ width: 800, margin: '0 auto' }}>
<div style={{ width: 800, margin: '20px auto' }}>
<ProCard bordered title="问题推荐列表">
<TextAreaCommonEditList
value={questionData}

View File

@@ -144,6 +144,7 @@ const ModelCreateFormModal: React.FC<ModelCreateFormModalProps> = (props) => {
subTitle={'配置之后,可在指标主页和问答指标卡处选择用来对指标进行下钻和过滤'}
/>
}
hidden={!basicInfo?.id}
>
<Select
mode="multiple"

View File

@@ -10,9 +10,79 @@
min-height: calc(100vh - 48px);
// background: #f8f9fb;
background-color: #fff;
display: flex;
position: relative;
.sider {
flex: 0 0 350px;
border-right: 5px solid #eee;
.domainTitle {
margin-bottom: 0;
font-size: 20px;
border-bottom: 1px solid #f0f0f0;
display: flex;
font-weight: 500;
padding: 12px 0 12px 35px;
}
.addBtn {
cursor: pointer;
width: 100%;
font-size: 18px;
margin-top: 18px;
&:hover {
color: #296DF3;
}
}
.treeTitle {
margin-bottom: 0;
padding: 20px;
line-height: 34px;
text-align: right;
background: #fff;
// border-bottom: 1px solid #d9d9d9;
.title {
float: left;
}
}
.search {
width: calc(100% - 60px);
margin: 10px 0 10px 35px;
}
.tree {
flex: 1;
padding: 10px;
.projectItem {
display: flex;
width: 100%;
cursor: auto;
line-height: 30px;
height: 30px;
.projectItemTitle {
font-size: 16px;
flex: 1;
cursor: pointer;
}
.operation {
.icon {
margin-left: 6px;
cursor: pointer;
}
}
}
}
}
.content {
flex: 1 1 auto;
}
.collapseLeftBtn {
position: absolute;
top: calc(50% + 45px);
@@ -41,20 +111,20 @@
padding: 20px;
padding-left: 30px;
}
.backBtn {
background-color: #f8f8f8;
padding: 5px;
color: #b0b4bc;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
&:hover {
background-color: #7599e5;
color: #fff;
}
}
// .backBtn {
// background-color: #f8f8f8;
// padding: 5px;
// color: #b0b4bc;
// cursor: pointer;
// display: flex;
// justify-content: center;
// align-items: center;
// transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
// &:hover {
// background-color: #7599e5;
// color: #fff;
// }
// }
.tab {
:global {
.ant-tabs-tab-btn {
@@ -66,6 +136,24 @@
.ant-tabs-nav {
margin-bottom: 0;
}
.ant-tabs-tab {
padding-bottom:15px;
}
}
.backBtn {
height: 56px;
background-color: #f8f8f8;
padding: 5px;
color: #b0b4bc;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
&:hover {
background-color: #7599e5;
color: #fff;
}
}
}
.chatSettingSectionTab {
@@ -87,164 +175,42 @@
.ant-card-body {
padding: 0 !important;
}
.ant-tabs-content-holder {
padding-top: 20px;
}
}
.resource {
display: flex;
.tree {
flex: 1;
.headOperation {
.btn {
margin-right: 18px;
}
}
.resourceSearch {
margin: 10px 0;
}
}
.view {
width: 480px;
padding-left: 20px;
}
.selectTypesBtn {
margin-right: 8px;
}
}
}
}
.domainTreeSelect {
// width: 300px;
}
.domainList {
display: flex;
flex-direction: column;
width: 400px;
// width: 400px;
width: 100%;
overflow: hidden;
// min-height: calc(100vh - 48px);
.addBtn {
cursor: pointer;
width: 100%;
font-size: 18px;
margin-top: 18px;
&:hover {
color: #296DF3;
}
}
.treeTitle {
margin-bottom: 0;
padding: 20px;
line-height: 34px;
text-align: right;
background: #fff;
border-bottom: 1px solid #d9d9d9;
.title {
float: left;
}
}
.search {
width: calc(100% - 20px);
margin: 10px;
}
.tree {
flex: 1;
padding: 10px;
.projectItem {
display: flex;
width: 100%;
cursor: auto;
.title {
flex: 1;
cursor: pointer;
}
.operation {
.icon {
margin-left: 6px;
cursor: pointer;
}
}
}
}
}
.user {
display: grid;
}
// .user {
// display: grid;
// }
.search{
width: 50%;
margin-bottom: 20px;
}
.paramsName{
margin-right: 10px;
}
.deleteBtn{
margin-left: 5px;
}
.authBtn{
cursor: pointer;
}
.selectedResource{
font-size: 12px;
color: darkgrey;
margin-top: 4px;
}
// .search{
// width: 50%;
// margin-bottom: 20px;
// }
.switch{
// min-width: 900px;
// max-width: 1200px;
// width: 100%;
display: flex;
justify-content: flex-start;
.switchUser {
width: 200px;
margin-left: 33px;
:global {
.ant-select {
width: 100% !important;
}
}
}
}
.dimensionIntentionForm {
margin-bottom: -24px !important;
margin-top: 10px;
margin-left: 26px;
}
// .authBtn{
// cursor: pointer;
// }
.classTable {
:global {
.ant-pro-table-search-query-filter {
padding-left: 0 !important;
// padding-bottom: 24px !important;
.ant-pro-form-query-filter {
.ant-form-item {
// margin-bottom: 0;
}
}
}
.ant-table-tbody > tr.ant-table-row-selected > td {
background: none;
@@ -275,8 +241,6 @@
padding: 0 11px;
cursor: pointer;
position: relative;
// background-color: #fff;
// border: 1px solid #d9d9d9;
border-radius: 4px;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
color: #000a24d9;

View File

@@ -1,17 +1,23 @@
import { SemanticNodeType } from './enum';
export enum SENSITIVE_LEVEL {
LOW = 0,
MID = 1,
HIGH = 2,
}
export const SENSITIVE_LEVEL_OPTIONS = [
{
label: '低',
value: 0,
value: SENSITIVE_LEVEL.LOW,
},
{
label: '中',
value: 1,
value: SENSITIVE_LEVEL.MID,
},
{
label: '高',
value: 2,
value: SENSITIVE_LEVEL.HIGH,
},
];
@@ -24,6 +30,12 @@ export const SENSITIVE_LEVEL_ENUM = SENSITIVE_LEVEL_OPTIONS.reduce(
{},
);
export const SENSITIVE_LEVEL_COLOR = {
[SENSITIVE_LEVEL.LOW]: 'lime',
[SENSITIVE_LEVEL.MID]: 'warning',
[SENSITIVE_LEVEL.HIGH]: 'error',
};
export const SEMANTIC_NODE_TYPE_CONFIG = {
[SemanticNodeType.DATASOURCE]: {
label: '数据源',

View File

@@ -138,6 +138,10 @@ export function getMetricTags(): Promise<any> {
return request.get(`${process.env.API_BASE_URL}metric/getMetricTags`);
}
export function getMetricData(metricId: string | number): Promise<any> {
return request.get(`${process.env.API_BASE_URL}metric/getMetric/${metricId}`);
}
export function getDrillDownDimension(metricId: number): Promise<any> {
return request.get(`${process.env.API_BASE_URL}metric/getDrillDownDimension`, {
params: { metricId },
@@ -453,7 +457,7 @@ export async function queryStruct({
period: 'DAY',
text: 'null',
},
limit: 365,
limit: 2000,
nativeQuery: false,
},
},

View File

@@ -57,3 +57,8 @@ type PaginationResponse<T> = Result<{
pageSize: number;
total: number;
}>;
type OptionsItem = {
value: string | number;
label: string;
};