-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add current version statistics as a pie chart
Closes #60
- Loading branch information
1 parent
dac6865
commit 0207e91
Showing
8 changed files
with
152 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
express/frontend/src/tools/adapter/statistics/CurrentVersions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Chart from "react-google-charts"; | ||
import { Box, CircularProgress, Typography } from "@mui/material"; | ||
import { useAdapter } from "../../../contexts/AdapterContext"; | ||
import { useEffect, useState } from "react"; | ||
import { getCurrentVersions } from "../../../lib/ioBroker"; | ||
|
||
type GraphData = [string, string | number][]; | ||
|
||
export function CurrentVersions() { | ||
const { name } = useAdapter(); | ||
const [graphData, setGraphData] = useState<GraphData>(); | ||
|
||
useEffect(() => { | ||
setGraphData(undefined); | ||
const loadHistory = async () => { | ||
const stats = await getCurrentVersions(name); | ||
const data: GraphData = [["Version", "Count"]]; | ||
for (const [version, count] of Object.entries( | ||
stats.versions, | ||
).reverse()) { | ||
data.push([version, count]); | ||
} | ||
setGraphData(data); | ||
}; | ||
loadHistory().catch((e) => { | ||
console.error(e); | ||
setGraphData(undefined); | ||
}); | ||
}, [name]); | ||
|
||
return ( | ||
<Box> | ||
<Typography variant="h6" gutterBottom> | ||
Currently installed versions | ||
</Typography> | ||
<Chart | ||
width="100%" | ||
height="300px" | ||
chartType="PieChart" | ||
loader={<CircularProgress size="200px" />} | ||
data={graphData} | ||
options={{ | ||
is3D: true, | ||
backgroundColor: "transparent", | ||
sliceVisibilityThreshold: 0.05, | ||
/*colors: [ | ||
iconStyles.error.color, | ||
iconStyles.warning.color, | ||
iconStyles.check.color, | ||
],*/ | ||
}} | ||
/> | ||
</Box> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
express/frontend/src/tools/adapter/statistics/Statistics.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Paper } from "@mui/material"; | ||
import { VersionHistory } from "./VersionHistory"; | ||
import { CurrentVersions } from "./CurrentVersions"; | ||
|
||
export function Statistics() { | ||
return ( | ||
<> | ||
<Paper sx={{ padding: 2 }}> | ||
<CurrentVersions /> | ||
</Paper> | ||
<Paper sx={{ padding: 2, marginTop: 2 }}> | ||
<VersionHistory /> | ||
</Paper> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters