mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Added small web interface with the most vital stats
This commit is contained in:
1 parent
86bd07666f
commit
8a85cfc8da
3 files changed
+21
-7
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 },
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user