Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-11183][Dashboard] Module audit page indicator items are merged with other items #11185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const getSourceDataWithCommas = sourceData => {

let endTimeVisible = true;

export const getFormContent = (initialValues, onSearch, onDataStreamSuccess) => [
export const getFormContent = (initialValues, onSearch, onDataStreamSuccess, auditData) => [
{
type: 'select',
label: i18n.t('pages.ModuleAudit.config.InlongGroupId'),
Expand Down Expand Up @@ -303,34 +303,16 @@ export const getFormContent = (initialValues, onSearch, onDataStreamSuccess) =>
allowClear: true,
showSearch: true,
dropdownMatchSelectWidth: false,
options: {
requestAuto: true,
requestTrigger: ['onOpen'],
requestService: () => {
return request({
url: '/audit/getAuditBases',
params: {
isMetric: true,
},
options: auditData?.reduce((accumulator, item) => {
const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
},
requestParams: {
formatResult: result => {
return result?.reduce((accumulator, item) => {
const existingItem = accumulator.find(
(i: { value: any }) => i.value === item.auditId,
);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []);
},
},
},
}
return accumulator;
}, []),
filterOption: (keyword: string, option: { label: any }) => {
return (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase());
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import {
} from './config';
import { Table } from 'antd';
import i18n from '@/i18n';
import { AuditProps } from '@/ui/pages/ModuleAudit';

export const auditModule = 'audit';
const Comp: React.FC = () => {
const Comp: React.FC<AuditProps> = ({ auditData }) => {
const [form] = useForm();

const [query, setQuery] = useState({
Expand Down Expand Up @@ -114,7 +115,7 @@ const Comp: React.FC = () => {
<FormGenerator
form={form}
layout="inline"
content={getFormContent(query, onSearch, onDataStreamSuccess)}
content={getFormContent(query, onSearch, onDataStreamSuccess, auditData)}
style={{ marginBottom: 30 }}
onFilter={allValues =>
setQuery({
Expand Down
68 changes: 21 additions & 47 deletions inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const toTableData = (source, sourceDataMap) => {
}));
};

export const getFormContent = (initialValues, onSearch) => [
export const getFormContent = (initialValues, onSearch, auditData) => [
{
type: 'select',
label: i18n.t('pages.ModuleAudit.config.InlongGroupId'),
Expand Down Expand Up @@ -138,29 +138,16 @@ export const getFormContent = (initialValues, onSearch) => [
allowClear: true,
showSearch: true,
dropdownMatchSelectWidth: false,
options: {
requestAuto: true,
requestTrigger: ['onOpen'],
requestService: () => {
return request('/audit/getAuditBases');
},
requestParams: {
formatResult: (result: any[]) => {
return result?.reduce((accumulator, item) => {
const existingItem = accumulator.find(
(i: { value: any }) => i.value === item.auditId,
);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []);
},
},
},
options: auditData?.reduce((accumulator, item) => {
const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []),
filterOption: (keyword: string, option: { label: any }) =>
(option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
},
Expand All @@ -173,29 +160,16 @@ export const getFormContent = (initialValues, onSearch) => [
allowClear: true,
showSearch: true,
dropdownMatchSelectWidth: false,
options: {
requestAuto: true,
requestTrigger: ['onOpen'],
requestService: () => {
return request('/audit/getAuditBases');
},
requestParams: {
formatResult: (result: any[]) => {
return result?.reduce((accumulator, item) => {
const existingItem = accumulator.find(
(i: { value: any }) => i.value === item.auditId,
);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []);
},
},
},
options: auditData?.reduce((accumulator, item) => {
const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []),
filterOption: (keyword: string, option: { label: any }) =>
(option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
},
Expand Down
6 changes: 3 additions & 3 deletions inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import HighTable, { useForm } from '@/ui/components/HighTable';
import { useRequest } from '@/ui/hooks';
import { timestampFormat } from '@/core/utils';
import { getFormContent, toTableData, getTableColumns } from './config';
import { AuditProps } from '@/ui/pages/ModuleAudit';

export const idModule = 'id';

const Comp: React.FC = () => {
const Comp: React.FC<AuditProps> = ({ auditData }) => {
const [form] = useForm();

const [query, setQuery] = useState({
Expand Down Expand Up @@ -101,7 +101,7 @@ const Comp: React.FC = () => {
<>
<HighTable
filterForm={{
content: getFormContent(query, onSearch),
content: getFormContent(query, onSearch, auditData),
onFilter,
}}
table={{
Expand Down
68 changes: 21 additions & 47 deletions inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const toTableData = (source, sourceDataMap) => {
}));
};

export const getFormContent = (initialValues, onSearch) => [
export const getFormContent = (initialValues, onSearch, auditData) => [
{
type: 'input',
label: i18n.t('pages.ModuleAudit.config.Ip'),
Expand Down Expand Up @@ -92,29 +92,16 @@ export const getFormContent = (initialValues, onSearch) => [
allowClear: true,
showSearch: true,
dropdownMatchSelectWidth: false,
options: {
requestAuto: true,
requestTrigger: ['onOpen'],
requestService: () => {
return request('/audit/getAuditBases');
},
requestParams: {
formatResult: (result: any[]) => {
return result?.reduce((accumulator, item) => {
const existingItem = accumulator.find(
(i: { value: any }) => i.value === item.auditId,
);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []);
},
},
},
options: auditData?.reduce((accumulator, item) => {
const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []),
filterOption: (keyword: any, option: { label: any }) =>
(option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
},
Expand All @@ -127,29 +114,16 @@ export const getFormContent = (initialValues, onSearch) => [
allowClear: true,
showSearch: true,
dropdownMatchSelectWidth: false,
options: {
requestAuto: true,
requestTrigger: ['onOpen'],
requestService: () => {
return request('/audit/getAuditBases');
},
requestParams: {
formatResult: (result: any[]) => {
return result?.reduce((accumulator, item) => {
const existingItem = accumulator.find(
(i: { value: any }) => i.value === item.auditId,
);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []);
},
},
},
options: auditData?.reduce((accumulator, item) => {
const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId);
if (!existingItem) {
accumulator.push({
label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish,
value: item.auditId,
});
}
return accumulator;
}, []),
filterOption: (keyword: string, option: { label: any }) =>
(option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
},
Expand Down
6 changes: 3 additions & 3 deletions inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import HighTable from '@/ui/components/HighTable';
import { useRequest } from '@/ui/hooks';
import { timestampFormat } from '@/core/utils';
import { getFormContent, toTableData, getTableColumns } from './config';
import { AuditProps } from '@/ui/pages/ModuleAudit';

export const ipModule = 'ip';

const Comp: React.FC = () => {
const Comp: React.FC<AuditProps> = ({ auditData }) => {
const [form] = useForm();

const [query, setQuery] = useState({
Expand Down Expand Up @@ -100,7 +100,7 @@ const Comp: React.FC = () => {
<>
<HighTable
filterForm={{
content: getFormContent(query, onSearch),
content: getFormContent(query, onSearch, auditData),
onFilter,
}}
table={{
Expand Down
24 changes: 20 additions & 4 deletions inlong-dashboard/src/ui/pages/ModuleAudit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/

import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Card } from 'antd';
import { PageContainer, Container } from '@/ui/components/PageContainer';
import { useHistory, useParams } from '@/ui/hooks';
import i18n from '@/i18n';
import IpModule, { ipModule as ipModuleName } from './IpModule';
import IdModule, { idModule as idModuleName } from './IdModule';
import AuditModule, { auditModule as auditModuleName } from '@/ui/pages/ModuleAudit/AuditModule';
import request from '@/core/utils/request';
const tabList = [
{
tab: i18n.t('pages.ModuleAudit.Id'),
Expand All @@ -50,7 +51,9 @@ const tabListMap = tabList.reduce(
}),
{},
);

export interface AuditProps {
auditData?: any[];
}
const Comp: React.FC = () => {
const history = useHistory();
const { type } = useParams<Record<string, string>>();
Expand All @@ -63,7 +66,20 @@ const Comp: React.FC = () => {
pathname: `/system/${value}`,
});
};

const [auditData, setAuditData] = useState([]);
useEffect(() => {
request('/audit/getAuditBases').then(res1 => {
request({
url: '/audit/getAuditBases',
params: {
isMetric: true,
},
}).then(res2 => {
res1.push(...res2);
setAuditData(res1);
});
});
}, []);
return (
<PageContainer useDefaultBreadcrumb={false} useDefaultContainer={false}>
<Container>
Expand All @@ -76,7 +92,7 @@ const Comp: React.FC = () => {
headStyle={{ border: 'none' }}
tabProps={{ size: 'middle' }}
>
{tabListMap[module]}
{React.cloneElement(tabListMap[module], { auditData: auditData })}
</Card>
</Container>
</PageContainer>
Expand Down
Loading