Add date filters and refactor quality metrics#111
Conversation
55360ac to
3ecb559
Compare
| const [dataFetching, setDataFetching] = useState(false); | ||
| const [imageIds, setImageIds] = useState<string[]>([]); | ||
| const [allData, setAllData] = useState<any[]>([]); | ||
| const [imageIds, setImageIds] = useState<Record<string, ImageData>>({}); |
There was a problem hiding this comment.
This is a leftover from previous iteration of this PR. We should rename this variable from imageIds to imagesRecords or something similar.
559c73b to
c36bb5f
Compare
| const response = await this.axiosInstance.get( | ||
| `v1/${realm}/devices/${deviceId}/interfaces/com.oobe.quality.Inspection`, | ||
| { params }, | ||
| ); | ||
|
|
||
| return response.data?.data ?? {}; |
There was a problem hiding this comment.
Add params without changing data handling logic.
| ): Promise<Record<string, ImageData>> { | ||
| const { realm } = this.config; | ||
|
|
||
| const params: any = {}; |
There was a problem hiding this comment.
| const params: any = {}; | |
| const params: Record<string, string> = {}; |
| import { isRangePreset, presetToDateRange } from "./components/RangeSelect"; | ||
| import StatsOverview from "./components/StatsOverview"; | ||
| import IndustrialBarChart from "./components/IndustrialBarChart"; | ||
| import { ImageData as AstarteImageData } from "types"; |
There was a problem hiding this comment.
Name ImageData does not clash with anything, we don't need an alias for it. Same goes for its import in other files.
| const [dataFetching, setDataFetching] = useState(false); | ||
| const [imagesData, setImagesData] = useState<Record<string, ImageData>>({}); | ||
| const [allData, setAllData] = useState<AstarteImageData[]>([]); | ||
| const [imagesRecords, setImageRecord] = useState< |
There was a problem hiding this comment.
Revert renaming this state variable.
| try { | ||
| const imageRecords = await astarteClient.getImagesData( | ||
| deviceId, | ||
| since, | ||
| to, | ||
| ); | ||
| setImageRecord(imageRecords); | ||
| const keys = Object.keys(imageRecords); | ||
| if (keys.length === 0) { | ||
| setAllData([]); | ||
| return; | ||
| } | ||
| const formattedData = Object.values(imageRecords); | ||
| setAllData(formattedData); | ||
| } catch (e: any) { | ||
| setError(e.message || "Error fetching data"); | ||
| } finally { | ||
| setDataFetching(false); | ||
| } |
There was a problem hiding this comment.
I like the idea of extracting fetching data to its own function outside of useEffect, but you should build your code on top of existing code for calling astarteClient.getImagesData().
| <Container | ||
| fluid | ||
| className="p-4" | ||
| style={{ backgroundColor: "#fbfbfc", minHeight: "100vh" }} |
There was a problem hiding this comment.
Specifying backgroundColor is unnecessary.
| "@formatjs/intl": "^4.1.2", | ||
| "@fortawesome/fontawesome-svg-core": "^6.6.0", | ||
| "@fortawesome/free-solid-svg-icons": "^6.6.0", | ||
| "@fortawesome/react-fontawesome": "^0.2.2", |
There was a problem hiding this comment.
Use a newer version of this package because this one gives a deprecated warning.
c4899ab to
905df54
Compare
Integrated date range presets (Day, Week, Month, Year).Refactored quality statistics into a standalone StatsOverview component Signed-off-by: AmerMesanovic <amer.mesanovic@secomind.com>
905df54 to
c63ac82
Compare
Integrated date range presets (Day, Week, Month, Year).Refactored quality statistics into a standalone StatsOverview component
Screen:

Closes #81