This is an automated email from the ASF dual-hosted git repository.

smqiu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 2401d33b69 [INLONG-11897][Dashboard] Clicking the audit page query 
will call this interface multiple times (#11898)
2401d33b69 is described below

commit 2401d33b69199025f140c7171274fd180c0a38ac
Author: kamianlaida <[email protected]>
AuthorDate: Wed Jun 18 18:12:31 2025 +0800

    [INLONG-11897][Dashboard] Clicking the audit page query will call this 
interface multiple times (#11898)
    
    * [INLONG-11897][Dashboard] Click on the audit page to query multiple calls 
to the interface
    
    * [INLONG-11897][Dashboard] Click on the audit page to query multiple calls 
to the interface
    
    * [INLONG-11897][Dashboard] Click on the audit page to query multiple calls 
to the interface
---
 .../src/ui/pages/GroupDetail/Audit/config.tsx      | 25 +-------
 .../src/ui/pages/GroupDetail/Audit/index.tsx       | 71 ++++++++++++++++------
 2 files changed, 53 insertions(+), 43 deletions(-)

diff --git a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx 
b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
index 1eef8494e2..d72b371f79 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
@@ -291,7 +291,7 @@ export const getFormContent = (
   inlongGroupId,
   initialValues,
   onSearch,
-  onDataStreamSuccess,
+  streamList,
   sourceData,
   csvData,
   fileName,
@@ -319,28 +319,7 @@ export const getFormContent = (
           onChange: (value, option) => {
             setInlongStreamID(value);
           },
-          options: {
-            requestAuto: true,
-            requestTrigger: ['onOpen', 'onSearch'],
-            requestService: keyword => ({
-              url: '/stream/list',
-              method: 'POST',
-              data: {
-                keyword,
-                pageNum: 1,
-                pageSize: 100,
-                inlongGroupId,
-              },
-            }),
-            requestParams: {
-              formatResult: result =>
-                result?.list.map(item => ({
-                  label: item.inlongStreamId,
-                  value: item.inlongStreamId,
-                })) || [],
-              onSuccess: onDataStreamSuccess,
-            },
-          },
+          options: streamList,
         },
         rules: [{ required: true }],
       },
diff --git a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/index.tsx 
b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/index.tsx
index 9b94eb2ff6..1dfaa2ed59 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/index.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/index.tsx
@@ -34,6 +34,7 @@ import {
 import { Table, Radio, Tabs, TabsProps } from 'antd';
 import i18n from '@/i18n';
 import './index.less';
+import { startCase } from 'lodash';
 type Props = CommonInterface;
 const initialQuery = {
   inlongStreamId: null,
@@ -46,9 +47,40 @@ const initialQuery = {
 const Comp: React.FC<Props> = ({ inlongGroupId }) => {
   const [form] = useForm();
   const [query, setQuery] = useState(initialQuery);
-  const [inlongStreamID, setInlongStreamID] = useState('');
+  const [inlongStreamID, setInlongStreamID] = useState(null);
   const [type, setType] = useState('count');
   const [subTab, setSubTab] = useState('stream');
+
+  const onDataStreamSuccess = data => {
+    const defaultDataStream = data[0]?.value;
+    if (defaultDataStream) {
+      setInlongStreamID(defaultDataStream);
+      form.setFieldsValue({ inlongStreamId: defaultDataStream });
+      setQuery(prev => ({ ...prev, inlongStreamId: defaultDataStream }));
+    }
+  };
+
+  const { data: streamList } = useRequest(
+    {
+      url: '/stream/list',
+      method: 'POST',
+      data: {
+        pageNum: 1,
+        pageSize: 9999,
+        inlongGroupId,
+      },
+    },
+    {
+      refreshDeps: [inlongGroupId],
+      formatResult: result =>
+        result?.list.map(item => ({
+          label: item.inlongStreamId,
+          value: item.inlongStreamId,
+        })) || [],
+      onSuccess: onDataStreamSuccess,
+    },
+  );
+
   const { data: sourceData = [], run } = useRequest(
     {
       url: '/audit/list',
@@ -58,10 +90,19 @@ const Comp: React.FC<Props> = ({ inlongGroupId }) => {
         startDate: timestampFormat(query.startDate, 'yyyy-MM-dd'),
         endDate: timestampFormat(query.endDate, 'yyyy-MM-dd'),
         inlongGroupId,
+        inlongStreamId: inlongStreamID,
       },
     },
     {
-      refreshDeps: [query],
+      ready: !!(subTab === 'group' || (subTab === 'stream' && inlongStreamID)),
+      refreshDeps: [
+        query.sinkId,
+        query.sinkType,
+        query.endDate,
+        query.startDate,
+        query.timeStaticsDim,
+        inlongStreamID,
+      ],
       formatResult: result => result.sort((a, b) => (a.auditId - b.auditId > 0 
? 1 : -1)),
     },
   );
@@ -120,16 +161,6 @@ const Comp: React.FC<Props> = ({ inlongGroupId }) => {
     run();
   };
 
-  const onDataStreamSuccess = data => {
-    const defaultDataStream = data[0]?.value;
-    if (defaultDataStream) {
-      setInlongStreamID(defaultDataStream);
-      form.setFieldsValue({ inlongStreamId: defaultDataStream });
-      setQuery(prev => ({ ...prev, inlongStreamId: defaultDataStream }));
-      run();
-    }
-  };
-
   const numToName = useCallback(
     num => {
       let obj = {};
@@ -171,18 +202,18 @@ const Comp: React.FC<Props> = ({ inlongGroupId }) => {
   }, [inlongGroupId, inlongStreamID]);
 
   const onChange = e => {
-    setSubTab(e.target.value);
-    setInlongStreamID(undefined);
-    const value = form.getFieldsValue();
-    console.log('form value', value);
     const tmp = { ...query };
     if (e.target.value === 'group') {
-      delete tmp.inlongStreamId;
-      delete tmp.sinkId;
+      tmp.inlongStreamId = null;
+      tmp.sinkId = null;
+      setInlongStreamID(undefined);
     } else {
-      delete tmp.sinkType;
+      tmp.sinkType = null;
+      tmp.inlongStreamId = streamList?.[0]?.value;
+      setInlongStreamID(streamList?.[0]?.value);
     }
     setQuery(tmp);
+    setSubTab(e.target.value);
   };
 
   return (
@@ -201,7 +232,7 @@ const Comp: React.FC<Props> = ({ inlongGroupId }) => {
             inlongGroupId,
             query,
             onSearch,
-            onDataStreamSuccess,
+            streamList,
             sourceData,
             csvData,
             fileName,

Reply via email to