From 1708fed30ef337ed58c3d18801606f4a897e3e1c Mon Sep 17 00:00:00 2001 From: mildrette Date: Thu, 18 Jul 2024 21:15:12 +0100 Subject: [PATCH 1/3] update to the page and tables and filters --- src/Pages/OpenTelemetry.js | 193 +++++++++++++++++++++---------------- 1 file changed, 109 insertions(+), 84 deletions(-) diff --git a/src/Pages/OpenTelemetry.js b/src/Pages/OpenTelemetry.js index 8d0c1c4..a032f53 100644 --- a/src/Pages/OpenTelemetry.js +++ b/src/Pages/OpenTelemetry.js @@ -20,6 +20,8 @@ import { TableHead, TableRow, Paper, + Stack, + Button, FormLabel } from "@mui/material"; import { BarChart as BarChartIcon, LocationOn as LocationOnIcon } from "@mui/icons-material"; @@ -53,6 +55,17 @@ const OpenTelemetry = () => { } }, [data]); + useEffect(() => { + if (chart) { + try { + const apexChart = new ApexCharts(document.querySelector("#chart"), chart); + apexChart.render(); + } catch (error) { + console.error("Error rendering chart:", error); + } + } + }, [chart]); + const fetchData = async (start, end, type, format) => { try { const response = await axios.get( @@ -67,6 +80,14 @@ const OpenTelemetry = () => { } }; + const handleData = (data) => { + if (displayType === "signup") { + setTotalUsers(data.total_signups || 0); // Set total signups for the "Sign Up Users" display type + } else { + setTotalUsers(data.total_users || 0); // Set total users for the "Total Users" display type + } + }; + const extractChartData = (data) => { if (!data || !data[displayType]) { console.error(`Data for display type '${displayType}' is undefined.`); @@ -98,34 +119,17 @@ const OpenTelemetry = () => { chart: { height: 350, type: "line", - zoom: { - enabled: false - } - }, - series: [ - { - name: displayType, - data: chartData - } - ], - dataLabels: { - enabled: false - }, - stroke: { - curve: "smooth" + zoom: { enabled: false } }, - xaxis: { - categories - } + series: [{ name: displayType, data: chartData }], + dataLabels: { enabled: false }, + stroke: { curve: "smooth" }, + xaxis: { categories } }; setChart(options); }; - const handleData = (data) => { - setTotalUsers(data.total_users || 0); - }; - const handleDisplayTypeChange = (e) => { const newDisplayType = e.target.value; setDisplayType(newDisplayType); @@ -150,29 +154,22 @@ const OpenTelemetry = () => { fetchData(startDate, newEndDate, displayType, format); }; - useEffect(() => { - if (chart) { - try { - const apexChart = new ApexCharts(document.querySelector("#chart"), chart); - apexChart.render(); - } catch (error) { - console.error("Error rendering chart:", error); - } - } - }, [chart]); + const handleRefresh = () => { + fetchData(startDate, endDate, displayType, format); + }; return ( - {/* Container Grid for Main Layout */} - {/* Sidebar Section */} { }} > - {/* Main Content Area */} { }} > - {/* Total and Country Cards */} {/* Total Card */} @@ -218,27 +213,30 @@ const OpenTelemetry = () => { - {/* Country Total Card */} - - - - - - - - - {data ? data.total_countries || 0 : 0} - COUNTRY TOTAL + {/* Conditional Country Total Card */} + {displayType === "available" && ( + + + + + + + + + + {data ? data.total_countries || 0 : 0} + + COUNTRY TOTAL + - - - - + + + + )} - {/* Form Controls for Filtering Data */} - {/* Type Select */} + {/* Display Type Select */} Display Type @@ -257,21 +255,19 @@ const OpenTelemetry = () => { {/* Format Radio Buttons */} - - - Format - - } label="Month" /> - } label="Day" /> - - - + + Format + + } label="Month" /> + } label="Day" /> + + {/* Start Date Picker */} @@ -282,9 +278,7 @@ const OpenTelemetry = () => { type="date" value={startDate} onChange={handleStartDateChange} - InputLabelProps={{ - shrink: true - }} + InputLabelProps={{ shrink: true }} fullWidth /> @@ -297,16 +291,23 @@ const OpenTelemetry = () => { type="date" value={endDate} onChange={handleEndDateChange} - InputLabelProps={{ - shrink: true - }} + InputLabelProps={{ shrink: true }} fullWidth /> - {/* Add the map, table, chart, and other sections here */} - + {/* Refresh Button */} + + + + + + + {/* Data Table */} + @@ -317,12 +318,12 @@ const OpenTelemetry = () => { - {data && data.countries && data.countries.length > 0 ? ( - data.countries.map((country, index) => ( + {data && data[displayType] && data[displayType].length > 0 ? ( + data[displayType].map((item, index) => ( - {country[0]} - {country[2]} - {((country[2] / totalUsers) * 100).toFixed(2)}% + {item[0]} + {item[2]} + {((item[2] / totalUsers) * 100).toFixed(2)}% )) ) : ( @@ -336,9 +337,33 @@ const OpenTelemetry = () => {
- - - + + + + + COUNTRY + USERS + PERCENTAGE + + + + {data && data.countries && data.countries.length > 0 ? ( + data.countries.map((country, index) => ( + + {country[0]} + {country[2]} + {((country[2] / totalUsers) * 100).toFixed(2)}% + + )) + ) : ( + + + No data available + + + )} + + From 1e9a33ea5a1a9720a07c198bbd440c23424160f7 Mon Sep 17 00:00:00 2001 From: mildrette Date: Thu, 18 Jul 2024 21:17:49 +0100 Subject: [PATCH 2/3] update to the page and tables and filters --- src/Pages/OpenTelemetry.js | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/Pages/OpenTelemetry.js b/src/Pages/OpenTelemetry.js index a032f53..136400d 100644 --- a/src/Pages/OpenTelemetry.js +++ b/src/Pages/OpenTelemetry.js @@ -307,36 +307,7 @@ const OpenTelemetry = () => {
{/* Data Table */} - - - - - - COUNTRY - USERS - PERCENTAGE - - - - {data && data[displayType] && data[displayType].length > 0 ? ( - data[displayType].map((item, index) => ( - - {item[0]} - {item[2]} - {((item[2] / totalUsers) * 100).toFixed(2)}% - - )) - ) : ( - - - No data available - - - )} - -
-
-
+ From 6db427afc81198548bffa4162752592c898ae7fc Mon Sep 17 00:00:00 2001 From: mildrette Date: Thu, 18 Jul 2024 21:20:21 +0100 Subject: [PATCH 3/3] update to the page and tables and filters --- src/Pages/OpenTelemetry.js | 50 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Pages/OpenTelemetry.js b/src/Pages/OpenTelemetry.js index 136400d..6f2af85 100644 --- a/src/Pages/OpenTelemetry.js +++ b/src/Pages/OpenTelemetry.js @@ -307,35 +307,37 @@ const OpenTelemetry = () => { {/* Data Table */} - - - - - COUNTRY - USERS - PERCENTAGE - - - - {data && data.countries && data.countries.length > 0 ? ( - data.countries.map((country, index) => ( - - {country[0]} - {country[2]} - {((country[2] / totalUsers) * 100).toFixed(2)}% - - )) - ) : ( + + + - - No data available - + COUNTRY + USERS + PERCENTAGE - )} - + + + {data && data.countries && data.countries.length > 0 ? ( + data.countries.map((country, index) => ( + + {country[0]} + {country[2]} + {((country[2] / totalUsers) * 100).toFixed(2)}% + + )) + ) : ( + + + No data available + + + )} + +
+