mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
Add winston based logger for master, slave, ctl, lib, and web_ui code. Logging done from slaves and instances are sent to the master server and tagged with the instance and/or slave it originated from. This allows for example error messages to propagate back to the source that iniated the action. The master server also stores the log to allow it to be queried at a later point. For slaves a copy of the slave's log is also stored locally.
53 lines
1.4 KiB
React
53 lines
1.4 KiB
React
import React, { useContext } from "react";
|
|
import { useHistory } from "react-router-dom";
|
|
|
|
import libLink from "@clusterio/lib/link";
|
|
import libConfig from "@clusterio/lib/config";
|
|
|
|
import DataTable from "./data-table";
|
|
import ControlContext from "./ControlContext";
|
|
import PageLayout from "./PageLayout";
|
|
|
|
|
|
export default function InstancesPage() {
|
|
let control = useContext(ControlContext);
|
|
let history = useHistory();
|
|
|
|
async function listInstances() {
|
|
let result = await libLink.messages.listInstances.send(control);
|
|
return result["list"].map(item => ({
|
|
key: item["id"],
|
|
"Name": item["name"],
|
|
"Assigned Slave": item["assigned_slave"],
|
|
"Status": item["status"],
|
|
}));
|
|
}
|
|
|
|
return <PageLayout nav={[{ name: "Instances" }]}>
|
|
<h2>Instances</h2>
|
|
<DataTable
|
|
DataFunction={listInstances}
|
|
AddRecord={{
|
|
fields: [{
|
|
dataIndex: "name",
|
|
title: "Name",
|
|
}],
|
|
insert: async args => {
|
|
let instanceConfig = new libConfig.InstanceConfig();
|
|
await instanceConfig.init();
|
|
instanceConfig.set("instance.name", args.name);
|
|
let serialized_config = instanceConfig.serialize();
|
|
let response = await libLink.messages.createInstance.send(control, { serialized_config });
|
|
},
|
|
}}
|
|
TableProps={{
|
|
onRow: (record, rowIndex) => ({
|
|
onClick: event => {
|
|
history.push(`/instances/${record.key}/view`);
|
|
},
|
|
}),
|
|
}}
|
|
/>
|
|
</PageLayout>;
|
|
}
|