From a83be1bca7c4dbcb0a3ae396c7b6c2b5cfbdc60f Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 18 Sep 2024 18:33:49 +0200 Subject: [PATCH 1/3] fetch module list periodicaly --- .../src/components/pages/Modules/Modules.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx index 10167665..31655b77 100644 --- a/cyclops-ui/src/components/pages/Modules/Modules.tsx +++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx @@ -45,6 +45,7 @@ const Modules = () => { useEffect(() => { setLoadingModules(true); + axios .get(`/api/modules/list`) .then((res) => { @@ -56,7 +57,27 @@ const Modules = () => { setError(mapResponseError(error)); setLoadingModules(false); }); + + function fetchModules() { + axios + .get(`/api/modules/list`) + .then((res) => { + setAllData(res.data); + setLoadingModules(false); + }) + .catch((error) => { + setError(mapResponseError(error)); + setLoadingModules(false); + }); + } + + fetchModules(); + const interval = setInterval(() => fetchModules(), 10000); + return () => { + clearInterval(interval); + }; }, []); + useEffect(() => { var updatedList = [...allData]; updatedList = updatedList.filter((module: any) => { From 3e213422b3b8252b524ca274cac4f33c715162ac Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 18 Sep 2024 18:34:59 +0200 Subject: [PATCH 2/3] fetch module list periodicaly --- cyclops-ui/src/components/pages/Modules/Modules.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx index 31655b77..463e08b8 100644 --- a/cyclops-ui/src/components/pages/Modules/Modules.tsx +++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx @@ -63,11 +63,9 @@ const Modules = () => { .get(`/api/modules/list`) .then((res) => { setAllData(res.data); - setLoadingModules(false); }) .catch((error) => { setError(mapResponseError(error)); - setLoadingModules(false); }); } From 06db480e7be213df389cbbd9edf00fa1275afca2 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Thu, 19 Sep 2024 10:47:21 +0200 Subject: [PATCH 3/3] single fetching func --- .../src/components/pages/Modules/Modules.tsx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx index 463e08b8..d58ea970 100644 --- a/cyclops-ui/src/components/pages/Modules/Modules.tsx +++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx @@ -46,26 +46,16 @@ const Modules = () => { useEffect(() => { setLoadingModules(true); - axios - .get(`/api/modules/list`) - .then((res) => { - setAllData(res.data); - setFilteredData(res.data); - setLoadingModules(false); - }) - .catch((error) => { - setError(mapResponseError(error)); - setLoadingModules(false); - }); - function fetchModules() { axios .get(`/api/modules/list`) .then((res) => { setAllData(res.data); + setLoadingModules(false); }) .catch((error) => { setError(mapResponseError(error)); + setLoadingModules(false); }); }