Skip to content

Commit

Permalink
react data grid test
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Feb 14, 2024
1 parent 87f86e3 commit 9c4dbbb
Show file tree
Hide file tree
Showing 9 changed files with 11,339 additions and 13 deletions.
123 changes: 119 additions & 4 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@mui/material": "5.14.11",
"@mui/x-date-pickers": "6.18.3",
"@reduxjs/toolkit": "1.9.6",
"@silevis/reactgrid": "^4.1.3",
"axios": "1.5.1",
"clsx": "2.0.0",
"d3": "5.16.0",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import ThermalForm from "./Singlestudy/explore/Modelization/Areas/Thermal/Form";
import RenewablesForm from "./Singlestudy/explore/Modelization/Areas/Renewables/Form";
import SplitHydroMatrix from "./Singlestudy/explore/Modelization/Areas/Hydro/SplitHydroMatrix";
import GlideDataGrid from "../common/Glide";
import ReactDataGrid from "../common/ReactGrid";

function App() {
return (
Expand Down Expand Up @@ -186,7 +187,7 @@ function App() {
</Route>
<Route path="debug" element={<Debug />} />
<Route path="glide" element={<GlideDataGrid />} />
<Route path="react-grid" element={<Debug />} />
<Route path="react-grid" element={<ReactDataGrid />} />
<Route path="*" element={<Modelization />}>
<Route index element={<Map />} />
</Route>
Expand Down
15 changes: 11 additions & 4 deletions webapp/src/components/common/Glide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,22 @@ function GlideDataGrid(props: GlideDataGridProps) {
const { startMeasurement, endMeasurement } =
usePerformanceMeasure("DataFetchAndRender");

useEffect(() => {
const fetchData = useCallback(async () => {
const fetchedData = await generateRandomData(1000);

startMeasurement();

generateRandomData(1000000).then((fetchedData) => {
setData(fetchedData);
endMeasurement();
setData(fetchedData);

requestAnimationFrame(() => {
requestAnimationFrame(endMeasurement);
});
}, [startMeasurement, endMeasurement]);

useEffect(() => {
fetchData();
}, [fetchData]);

const [selection, setSelection] = useState<GridSelection>({
columns: CompactSelection.empty(),
rows: CompactSelection.empty(),
Expand Down
6 changes: 2 additions & 4 deletions webapp/src/components/common/Glide/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useCallback } from "react";
import { useCallback } from "react";
import { Person } from ".";

export const generateRandomData = (
Expand Down Expand Up @@ -42,11 +42,9 @@ export const generateRandomData = (
randomData.push({ name, company, email, phone });
}

// to simulate a network request delay increase the timeout
setTimeout(() => resolve(randomData), 0);
resolve(randomData);
});
};

export function usePerformanceMeasure(measureName: string) {
const startMeasurement = useCallback(() => {
performance.mark(`${measureName}-start`);
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/components/common/ReactGrid/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.reactgrid {
background-color: #f5f5f5;
}
Loading

0 comments on commit 9c4dbbb

Please sign in to comment.