From 413a6b1455dc2176c4dc35cc6214369345db0f79 Mon Sep 17 00:00:00 2001 From: prisar Date: Sun, 23 Jul 2023 02:42:53 +0530 Subject: [PATCH] add analytics page for tests conducted - add robot.txt entry - fix graph render with new set of actions --- public/robots.txt | 2 +- scripts/merge_csv.py | 4 +- src/components/AbsorbanceGraph.js | 6 +- src/components/Devices.css | 19 +++- src/components/Devices.js | 25 +++-- src/components/TestAnalytics.js | 150 +++++++++++++++++++++++++++ src/components/TestAnalyticsGraph.js | 97 +++++++++++++++++ src/components/graph_icon.png | Bin 0 -> 2325 bytes src/index.js | 5 + 9 files changed, 293 insertions(+), 15 deletions(-) create mode 100644 src/components/TestAnalytics.js create mode 100644 src/components/TestAnalyticsGraph.js create mode 100644 src/components/graph_icon.png diff --git a/public/robots.txt b/public/robots.txt index e9e57dc..b21f088 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,3 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * -Disallow: +Disallow: / diff --git a/scripts/merge_csv.py b/scripts/merge_csv.py index cb7ee9e..d0276b9 100644 --- a/scripts/merge_csv.py +++ b/scripts/merge_csv.py @@ -50,9 +50,11 @@ def consolidate(curdir): # df_csv_append.to_csv("D8 Merged.csv", index=False) -for file in os.listdir(rootdir): +if __name__ == "__main__": + for file in os.listdir(rootdir): d = os.path.join(rootdir, file) if os.path.isdir(d): # print(d) # os.chdir(d) consolidate(d) + \ No newline at end of file diff --git a/src/components/AbsorbanceGraph.js b/src/components/AbsorbanceGraph.js index 1399af4..78a97f0 100644 --- a/src/components/AbsorbanceGraph.js +++ b/src/components/AbsorbanceGraph.js @@ -11,7 +11,7 @@ class AbsorbanceGraph extends Component { this.state = { url: this.props.url, show: this.props.show }; } componentDidMount() { - this.drawChart(this.props.url); + this.drawChart(this.state.url); } drawChart(url) { @@ -51,7 +51,9 @@ class AbsorbanceGraph extends Component { .then(response => response.data.text()) .then((text) => { const testData = d3.csvParse(text.replaceAll('"', '')).filter(x => { - if (x.NM > 350 && x.NM < 600 && x.CA !== "-Infinity" && x.CA !== "Infinity") return x; + if (x.NM > 350 && x.NM < 600 + && x.CA !== "-Infinity" && x.CA !== "Infinity" + && !isNaN(x.CA)) return x; }); const options = { diff --git a/src/components/Devices.css b/src/components/Devices.css index 4c0dd02..87839d7 100644 --- a/src/components/Devices.css +++ b/src/components/Devices.css @@ -1,3 +1,7 @@ +.dashboard-title::-webkit-scrollbar { + display: none; +} + .title { padding: 10px; text-align: center; @@ -72,11 +76,20 @@ } .clear-button { - background-color: aquamarine; - width: 3vw; + background-color: rgb(207, 235, 250); + width: 10vw; height: 5vh; margin: 5px; - border-radius: 50%; + border-radius: 10px; + font-size: medium; + font-weight: 600; + display: flex; + align-items: center; + justify-content: center; +} + +.graph-icon { + width: 20px; } table, diff --git a/src/components/Devices.js b/src/components/Devices.js index 4deb4ed..95d2c7e 100644 --- a/src/components/Devices.js +++ b/src/components/Devices.js @@ -69,14 +69,23 @@ const Devices = () => { } const changeTest = ({ value }) => { - setCurTest(null); setCurTestData(null); setShowGraph(false); - if (curTest) alert('Click clear button first'); + setCurTestData(null); setShowGraph(false); setCurTest(value); - setCurTestData(allTests.find(x => x._id === value)); + } + + const showTestGraph = () => { + if (!curTest) alert('Select a test'); + setCurTestData(allTests.find(x => x._id === curTest)); setShowGraph(true); } - const menuPortalTarget = document.getElementById('root'); + const toggleShowGraph = () => { + if (!curTestData) { + showTestGraph(); + } else { + setCurTest(null); setCurTestData(null); + } + } useEffect(() => { if (!allTests) { @@ -103,22 +112,22 @@ const Devices = () => { }, [curTestData, curTest, device, testDate]); return ( -
+
Insights
- + {/* { return { value: x, label: x }; })} menuPlacement='auto' maxMenuHeight={250} menuShouldScrollIntoView={true} onChange={changeTestDate} />