From c470a3d6406f2292732338fb79a89e66d812203a Mon Sep 17 00:00:00 2001
From: Gregory <117281520+gca-axelor@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:25:29 +0100
Subject: [PATCH 1/4] fix: return graph null when datalist is null
---
packages/core/src/dashboards/view/DashboardScreen.tsx | 8 ++++----
.../ui/src/components/templates/Dashboard/Dashboard.tsx | 3 +++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/packages/core/src/dashboards/view/DashboardScreen.tsx b/packages/core/src/dashboards/view/DashboardScreen.tsx
index e012998165..98e6209cd5 100644
--- a/packages/core/src/dashboards/view/DashboardScreen.tsx
+++ b/packages/core/src/dashboards/view/DashboardScreen.tsx
@@ -78,15 +78,15 @@ export const DashboardScreen = ({dashboardId}) => {
}));
}, [dashboard]);
- if (dashboard?.id !== dashboardId) {
- return ;
- }
-
if (!Array.isArray(dashboardData) || dashboardData.length === 0) {
return (
);
}
+ if (dashboard?.id !== dashboardId) {
+ return ;
+ }
+
return ;
};
diff --git a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
index 1bbb3059e6..edf36dc98b 100644
--- a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
+++ b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
@@ -118,6 +118,9 @@ const Dashboard = ({style, lineList}: DashboardProps) => {
return (
{limitedGraphList?.map((graph, indexGraph) => {
+ if (!graph.dataList?.[0]?.length) {
+ return null;
+ }
return renderChart(graph, indexGraph, nbGraphInLine);
})}
From c327bdbf6bffa13754b4f14310b248d070f2e21d Mon Sep 17 00:00:00 2001
From: Gregory <117281520+gca-axelor@users.noreply.github.com>
Date: Thu, 8 Feb 2024 15:31:47 +0100
Subject: [PATCH 2/4] fix: filter by validGraph to ajust width when one is null
---
.../ui/src/components/templates/Dashboard/Dashboard.tsx | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
index edf36dc98b..7bf28801d6 100644
--- a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
+++ b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
@@ -109,10 +109,11 @@ const Dashboard = ({style, lineList}: DashboardProps) => {
return (
{lineList?.map((line, indexLine) => {
- const nbGraphInLine = Math.min(
- line.graphList?.length,
- MAX_GRAPH_PER_LINE,
+ const validGraphs = line.graphList.filter(
+ graph => graph.dataList?.[0]?.length,
);
+ const nbGraphInLine = Math.min(validGraphs.length, MAX_GRAPH_PER_LINE);
+
const limitedGraphList = line.graphList?.slice(0, MAX_GRAPH_PER_LINE);
return (
From d41733f4ca23a024cc6daca423dd2c97e4605bf1 Mon Sep 17 00:00:00 2001
From: Gregory <117281520+gca-axelor@users.noreply.github.com>
Date: Thu, 8 Feb 2024 17:21:01 +0100
Subject: [PATCH 3/4] refactor: change logic condition
---
.../ui/src/components/templates/Dashboard/Dashboard.tsx | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
index 7bf28801d6..673cd5f529 100644
--- a/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
+++ b/packages/ui/src/components/templates/Dashboard/Dashboard.tsx
@@ -110,7 +110,7 @@ const Dashboard = ({style, lineList}: DashboardProps) => {
{lineList?.map((line, indexLine) => {
const validGraphs = line.graphList.filter(
- graph => graph.dataList?.[0]?.length,
+ graph => graph.dataList?.[0]?.length > 0,
);
const nbGraphInLine = Math.min(validGraphs.length, MAX_GRAPH_PER_LINE);
@@ -119,10 +119,10 @@ const Dashboard = ({style, lineList}: DashboardProps) => {
return (
{limitedGraphList?.map((graph, indexGraph) => {
- if (!graph.dataList?.[0]?.length) {
- return null;
+ if (graph.dataList?.[0]?.length > 0) {
+ return renderChart(graph, indexGraph, nbGraphInLine);
}
- return renderChart(graph, indexGraph, nbGraphInLine);
+ return null;
})}
);
From 0e008ed1bf8e3197459ee5823c6cb335fde8787d Mon Sep 17 00:00:00 2001
From: lme-axelor <102581501+lme-axelor@users.noreply.github.com>
Date: Fri, 9 Feb 2024 11:47:57 +0100
Subject: [PATCH 4/4] fix: restore loading on DashboardScreen
---
.../core/src/dashboards/view/DashboardScreen.tsx | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/packages/core/src/dashboards/view/DashboardScreen.tsx b/packages/core/src/dashboards/view/DashboardScreen.tsx
index 98e6209cd5..b4ee1972d6 100644
--- a/packages/core/src/dashboards/view/DashboardScreen.tsx
+++ b/packages/core/src/dashboards/view/DashboardScreen.tsx
@@ -28,13 +28,16 @@ export const DashboardScreen = ({dashboardId}) => {
const I18n = useTranslator();
const [dashboard, setDashboard] = useState({});
+ const [loading, setLoading] = useState(false);
const refresh = useCallback(() => {
+ setLoading(true);
fetchDashboard({id: dashboardId})
.then(response => {
setDashboard({...(response?.data?.object ?? {}), id: dashboardId});
})
- .catch(() => setDashboard({}));
+ .catch(() => setDashboard({}))
+ .finally(() => setLoading(false));
}, [dashboardId]);
useEffect(() => {
@@ -78,15 +81,15 @@ export const DashboardScreen = ({dashboardId}) => {
}));
}, [dashboard]);
+ if (loading) {
+ return ;
+ }
+
if (!Array.isArray(dashboardData) || dashboardData.length === 0) {
return (
);
}
- if (dashboard?.id !== dashboardId) {
- return ;
- }
-
return ;
};