Quellcode durchsuchen

temporary integration

Alexander Belanger vor 3 Jahren
Ursprung
Commit
e5d7730f10

+ 7 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/LogsSection.tsx

@@ -19,6 +19,10 @@ type Props = {
   setIsFullscreen: (x: boolean) => void;
 };
 
+const escapeRegExp = (str: string) => {
+  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+};
+
 const LogsSection: React.FC<Props> = ({
   currentChart,
   isFullscreen,
@@ -35,7 +39,8 @@ const LogsSection: React.FC<Props> = ({
   const { logs, refresh } = useLogs(
     podFilter,
     currentChart.namespace,
-    enteredSearchText
+    enteredSearchText,
+    startDate.toISOString()
   );
 
   useEffect(() => {
@@ -94,7 +99,7 @@ const LogsSection: React.FC<Props> = ({
                   }}
                   onKeyPress={(event) => {
                     if (event.key === "Enter") {
-                      setEnteredSearchText(searchText);
+                      setEnteredSearchText(escapeRegExp(searchText));
                     }
                   }}
                   placeholder="Search logs..."

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/useAgentLogs.ts

@@ -11,6 +11,7 @@ export const useLogs = (
   currentPod: string,
   namespace: string,
   searchParam: string,
+  startDate: string,
   scroll?: (smooth: boolean) => void
 ) => {
   const { currentCluster, currentProject } = useContext(Context);
@@ -25,11 +26,9 @@ export const useLogs = (
     closeWebsocket,
   } = useWebsockets();
 
-  console.log("SEARCH PARAM IS", searchParam);
-
   useEffect(() => {
     refresh();
-  }, [currentPod, namespace, searchParam]);
+  }, [currentPod, namespace, searchParam, startDate]);
 
   const setupWebsocket = (websocketKey: string) => {
     const endpoint = `/api/projects/${currentProject.id}/clusters/${currentCluster.id}/namespaces/${namespace}/logs/loki?pod_selector=${currentPod}&namespace=${namespace}&search_param=${searchParam}`;
@@ -77,6 +76,7 @@ export const useLogs = (
           pod_selector: currentPod,
           namespace: namespace,
           search_param: searchParam,
+          end_range: startDate,
         },
         {
           cluster_id: currentCluster.id,