Skip to content

Commit

Permalink
chore: oic extract
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Jul 4, 2024
1 parent 3f251aa commit 234d1e8
Show file tree
Hide file tree
Showing 30 changed files with 1,191 additions and 192 deletions.
64 changes: 57 additions & 7 deletions src/component/ExecuteSqlDetailModal/constant.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatMessage } from '@/util/intl';
import { ReactComponent as List } from '@/svgr/List.svg';
import { ReactComponent as Tree } from '@/svgr/Tree.svg';
import { ReactComponent as Text } from '@/svgr/Text.svg';
Expand Down Expand Up @@ -45,17 +46,66 @@ export const initTabViewConfig = {
};

export const traceViewOptions = [
{ value: TypeMap.TRACE, icon: <Icon component={TraceSvg} />, message: 'Trace 视图' },
{ value: TypeMap.TRACE_LIST, icon: <Icon component={List} />, message: '列表视图' },
{
value: TypeMap.TRACE,
icon: <Icon component={TraceSvg} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.3AAA9DF9',
defaultMessage: 'Trace 视图',
}),
},
{
value: TypeMap.TRACE_LIST,
icon: <Icon component={List} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.D1E28701',
defaultMessage: '列表视图',
}),
},
];

export const executeViewOptions = [
{ value: TypeMap.LIST, icon: <Icon component={List} />, message: '列表视图' },
{ value: TypeMap.TEXT, icon: <Icon component={Text} />, message: '文本视图' },
{
value: TypeMap.LIST,
icon: <Icon component={List} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.FB8B6D0B',
defaultMessage: '列表视图',
}),
},
{
value: TypeMap.TEXT,
icon: <Icon component={Text} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.052B3894',
defaultMessage: '文本视图',
}),
},
];

export const executeViewOptionsInPlan = [
{ value: TypeMap.TREE, icon: <Icon component={Tree} />, message: '树视图' },
{ value: TypeMap.LIST, icon: <Icon component={List} />, message: '列表视图' },
{ value: TypeMap.TEXT, icon: <Icon component={Text} />, message: '文本视图' },
{
value: TypeMap.TREE,
icon: <Icon component={Tree} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.0DAD5E44',
defaultMessage: '树视图',
}),
},
{
value: TypeMap.LIST,
icon: <Icon component={List} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.2129C7A3',
defaultMessage: '列表视图',
}),
},
{
value: TypeMap.TEXT,
icon: <Icon component={Text} />,
message: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.97782AAE',
defaultMessage: '文本视图',
}),
},
];
84 changes: 70 additions & 14 deletions src/component/ExecuteSqlDetailModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,47 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
const finished = data?.graph?.status === IProfileStatus.FINISHED;
const getExecuteRadioOption = () => {
return [
{ value: EXECUTE_PAGE_TYPE.EXECUTE_DETAIL, label: '执行详情' },
{ value: EXECUTE_PAGE_TYPE.EXECUTE_PLAN, label: '执行计划' },
{
value: EXECUTE_PAGE_TYPE.EXECUTE_DETAIL,
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.38BDF819',
defaultMessage: '执行详情',
}),
},
{
value: EXECUTE_PAGE_TYPE.EXECUTE_PLAN,
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.8A207B02',
defaultMessage: '执行计划',
}),
},
{
value: EXECUTE_PAGE_TYPE.FULL_TRACE,
label: '全链路诊断',
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.0B221F0A',
defaultMessage: '全链路诊断',
}),
disabled: !finished,
},
];
};

const planRadioOption = [{ value: PLAN_PAGE_TYPE.PLAN_DETAIL, label: '计划统计' }];
const planRadioOption = [
{
value: PLAN_PAGE_TYPE.PLAN_DETAIL,
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.14585364',
defaultMessage: '计划统计',
}),
},
];

const getDisabledTooltip = (val) => {
if (!finished) {
return '当前 SQL 正在执行中,执行完成后可查看';
return formatMessage({
id: 'src.component.ExecuteSqlDetailModal.D6886430',
defaultMessage: '当前 SQL 正在执行中,执行完成后可查看',
});
}
return val;
};
Expand All @@ -85,6 +111,7 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
disablePagination={true}
/>
),

[TypeMap.TEXT]: (
<pre
style={{
Expand Down Expand Up @@ -113,14 +140,20 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
}}
>
<div style={{ textAlign: 'end' }}>
<Tooltip title="复制">
<Tooltip
title={formatMessage({
id: 'src.component.ExecuteSqlDetailModal.68BF8995',
defaultMessage: '复制',
})}
>
<CopyOutlined style={{ cursor: 'pointer' }} />
</Tooltip>
</div>
</CopyToClipboard>
{data?.originalText}
</pre>
),

[TypeMap.TRACE]: (
<TraceComp
tabName={TraceTabsType.Trace}
Expand All @@ -130,6 +163,7 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
searchValue={searchValue}
/>
),

[TypeMap.TRACE_LIST]: (
<TraceComp
tabName={TraceTabsType.List}
Expand Down Expand Up @@ -158,8 +192,8 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
formatMessage({
id: 'odc.src.page.Workspace.components.Trace.ExportJson',
}) /*
导出 Json
*/
导出 Json
*/
}
</Button>
</Tooltip>
Expand Down Expand Up @@ -190,19 +224,28 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
}
const EXECUTE_PAGE_CONFIG = {
[EXECUTE_PAGE_TYPE.EXECUTE_DETAIL]: {
label: '执行详情',
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.69A79B8E',
defaultMessage: '执行详情',
}),
key: EXECUTE_PAGE_TYPE.EXECUTE_DETAIL,
children: viewContentConfig(viewType),
toolBar: <></>,
},
[EXECUTE_PAGE_TYPE.EXECUTE_PLAN]: {
label: '执行计划',
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.BF467954',
defaultMessage: '执行计划',
}),
key: EXECUTE_PAGE_TYPE.EXECUTE_PLAN,
children: viewContentConfig(viewType),
toolBar: getExecuteProfile(),
},
[EXECUTE_PAGE_TYPE.FULL_TRACE]: {
label: '全链路诊断',
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.D47F3410',
defaultMessage: '全链路诊断',
}),
key: EXECUTE_PAGE_TYPE.FULL_TRACE,
children: viewContentConfig(viewType),
toolBar: (
Expand All @@ -218,6 +261,7 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
}
onSearch={(e) => setSearchValue(e)}
/>

{getDownloadBtn()}
<Radio.Group
defaultValue={TypeMap.TREE}
Expand All @@ -240,7 +284,10 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {

const PLAN_PAGE_CONFIG = {
[PLAN_PAGE_TYPE.PLAN_DETAIL]: {
label: '计划统计',
label: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.D11F8620',
defaultMessage: '计划统计',
}),
key: PLAN_PAGE_TYPE.PLAN_DETAIL,
children: viewContentConfig(viewType),
toolBar: getExecuteProfile(true),
Expand All @@ -249,7 +296,13 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {

const executeInfo = {
[ProfileType.Execute]: {
title: `Trace ID 为 "${modalStore?.executeSqlDetailData?.traceId}" 的执行画像`,
title: formatMessage(
{
id: 'src.component.ExecuteSqlDetailModal.5B8FA08A',
defaultMessage: 'Trace ID 为 "${modalStore?.executeSqlDetailData?.traceId}" 的执行画像',
},
{ modalStoreExecuteSqlDetailDataTraceId: modalStore?.executeSqlDetailData?.traceId },
),
sql: modalStore?.executeSqlDetailData?.sql,
session: modalStore?.executeSqlDetailData?.session,
traceId: modalStore?.executeSqlDetailData?.traceId,
Expand All @@ -258,7 +311,10 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
radioOption: getExecuteRadioOption(),
},
[ProfileType.Plan]: {
title: '执行计划详情',
title: formatMessage({
id: 'src.component.ExecuteSqlDetailModal.A944EAD1',
defaultMessage: '执行计划详情',
}),
sql: modalStore?.executeSqlDetailData?.sql,
session: modalStore?.executeSqlDetailData?.session,
traceId: modalStore?.executeSqlDetailData?.traceId,
Expand Down
7 changes: 6 additions & 1 deletion src/component/ODCSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ const ODCSetting: React.FC<IProps> = ({ modalStore }) => {
serverData['odc.editor.shortcut.executeStatement'] ===
serverData['odc.editor.shortcut.executeCurrentStatement']
) {
message.warning('快捷键冲突, 请重新输入。');
message.warning(
formatMessage({
id: 'src.component.ODCSetting.CFC0C3E8',
defaultMessage: '快捷键冲突, 请重新输入。',
}),
);
return;
}
/**
Expand Down
16 changes: 13 additions & 3 deletions src/component/ProfileFlow/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatMessage } from '@/util/intl';
// reactFlow id
export const REACT_FLOW_ID = 'PROFILE_FLOW_BOX';
// 节点宽度
Expand All @@ -24,14 +25,23 @@ export const SUM = 'SUM';

export const subNodesSortMap = {
[subNodeSortType.BY_DURATION]: {
label: '按 DB 耗时排序',
label: formatMessage({
id: 'src.component.ProfileFlow.C966E64A',
defaultMessage: '按 DB 耗时排序',
}),
},
[subNodeSortType.BY_MAX_MEMORY]: {
label: '按内存排序',
label: formatMessage({
id: 'src.component.ProfileFlow.C4791007',
defaultMessage: '按内存排序',
}),
objectKey: 'Max memory',
},
[subNodeSortType.BY_OUTPUT]: {
label: '按吐行排序',
label: formatMessage({
id: 'src.component.ProfileFlow.6B28FD92',
defaultMessage: '按吐行排序',
}),
objectKey: 'Output rows',
},
};
Expand Down
29 changes: 25 additions & 4 deletions src/component/ProfileFlow/customComponents/Control.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatMessage } from '@/util/intl';
import { Controls, ControlButton, useReactFlow } from 'reactflow';
import {
ZoomInOutlined,
Expand All @@ -15,12 +16,22 @@ export default function Flow() {
<Controls>
<div className={styles.controls}>
<ControlButton onClick={() => zoomOut()}>
<Tooltip title="缩小">
<Tooltip
title={formatMessage({
id: 'src.component.ProfileFlow.customComponents.12BFFE42',
defaultMessage: '缩小',
})}
>
<ZoomInOutlined />
</Tooltip>
</ControlButton>
<ControlButton onClick={() => zoomIn()}>
<Tooltip title="放大">
<Tooltip
title={formatMessage({
id: 'src.component.ProfileFlow.customComponents.3057F753',
defaultMessage: '放大',
})}
>
<ZoomOutOutlined />
</Tooltip>
</ControlButton>
Expand All @@ -29,12 +40,22 @@ export default function Flow() {
initCenter(setCenter);
}}
>
<Tooltip title="实际尺寸">
<Tooltip
title={formatMessage({
id: 'src.component.ProfileFlow.customComponents.89BEEE9E',
defaultMessage: '实际尺寸',
})}
>
<OneToOneOutlined />
</Tooltip>
</ControlButton>
<ControlButton onClick={() => fitView()}>
<Tooltip title="适应宽度">
<Tooltip
title={formatMessage({
id: 'src.component.ProfileFlow.customComponents.B32C7D03',
defaultMessage: '适应宽度',
})}
>
{' '}
<CompressOutlined />
</Tooltip>
Expand Down
Loading

0 comments on commit 234d1e8

Please sign in to comment.