Added small web interface with the most vital stats

This commit is contained in:
Daniel committed 2021-07-12 22:05:54 +02:00
1 parent 86bd07666f
commit 8a85cfc8da
3 files changed
+21 -7

No files matched your search

+1 -1
View File
@@ -63,7 +63,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
}))
.sort((a, b) => a.stringified.length - b.stringified.length)
return {
database_size: inventories.reduce((a, b) => b - a, 0),
database_size: inventories.map(x => x.length).reduce((a, b) => b - a, 0),
database_entries: inventories.length,
largest_entry: {
name: inventories[0].name,
+17 -6
View File
@@ -1,19 +1,30 @@
import React, { useContext } from "react";
import { Typography } from "antd";
import React, { useContext, useEffect, useState } from "react";
import libPlugin from "@clusterio/lib/plugin";
import { notifyErrorHandler, PageLayout, ControlContext } from "@clusterio/web_ui";
import { PageLayout, ControlContext } from "@clusterio/web_ui";
import info from "../info";
import "./index.css";
const { Paragraph } = Typography;
function InventoryPage() {
// let control = useContext(ControlContext);
let control = useContext(ControlContext);
let [statsData, updateStatsData] = useState()
useEffect(() => {
(async () => {
// Get statistics
updateStatsData(await info.messages.databaseStats.send(control, {}))
})()
}, [])
return <PageLayout nav={[{ name: "Inventory sync" }]}>
<h2>Inventory sync</h2>
{statsData && <>
<p>Database size: {Math.round(statsData.database_size / 1000)}kB</p>
<p>Database entries: {statsData.database_entries}</p>
<p>Largest entry is {statsData.largest_entry.name} with {(statsData.largest_entry.size / 1000)}kB</p>
</>}
</PageLayout>;
}
+3
View File
@@ -28,6 +28,9 @@ module.exports = (env = {}) => merge(common(env), {
"@clusterio/lib/link": { import: false },
"@clusterio/web_ui": { import: false },
"ajv": { import: false },
"antd": { import: false },
"react": { import: false },
"react-dom": { import: false },
},
}),
],