mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Finish linting web interface
Fix remaining linter errors detected in web interface code.
This commit is contained in:
1 parent
03b7d22ba6
commit
bccc89fa0b
16 files changed
+201
-187
No files matched your search
+15
-2
@@ -2,7 +2,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"browser": true,
|
|
||||||
"commonjs": true,
|
"commonjs": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
},
|
},
|
||||||
@@ -21,6 +20,18 @@ module.exports = {
|
|||||||
"no-invalid-this": "off",
|
"no-invalid-this": "off",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"files": ["packages/master/web/**/*.jsx"],
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
@@ -44,6 +55,8 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
"arrays": "always-multiline",
|
"arrays": "always-multiline",
|
||||||
"objects": "always-multiline",
|
"objects": "always-multiline",
|
||||||
|
"imports": "always-multiline",
|
||||||
|
"exports": "always-multiline",
|
||||||
"functions": "only-multiline",
|
"functions": "only-multiline",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -229,7 +242,7 @@ module.exports = {
|
|||||||
"semi": "error",
|
"semi": "error",
|
||||||
"semi-spacing": "error",
|
"semi-spacing": "error",
|
||||||
"semi-style": "off",
|
"semi-style": "off",
|
||||||
"sort-imports": "error",
|
"sort-imports": "off",
|
||||||
"sort-keys": "off",
|
"sort-keys": "off",
|
||||||
"sort-vars": "error",
|
"sort-vars": "error",
|
||||||
"space-before-blocks": "warn",
|
"space-before-blocks": "warn",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { Panel } = Collapse;
|
|||||||
/**
|
/**
|
||||||
* Display data in table. Allows for editing data by clicking rows in the table.
|
* Display data in table. Allows for editing data by clicking rows in the table.
|
||||||
* Basic usage: <DataTable Server="SQL08" DataSource="sql" Database="HDG1" Table="[dbo].[ReportInfo]" />
|
* Basic usage: <DataTable Server="SQL08" DataSource="sql" Database="HDG1" Table="[dbo].[ReportInfo]" />
|
||||||
*
|
*
|
||||||
* DataFunction - String, corresponds to export from util/wslink. Same as ws message name.
|
* DataFunction - String, corresponds to export from util/wslink. Same as ws message name.
|
||||||
* columns - Array of objects, optional, same as <Table />. Note the lowercase c
|
* columns - Array of objects, optional, same as <Table />. Note the lowercase c
|
||||||
* Editable - Boolean - Allow editing
|
* Editable - Boolean - Allow editing
|
||||||
@@ -25,7 +25,7 @@ class DataTable extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
pagination: {
|
pagination: {
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
current: 1
|
current: 1,
|
||||||
},
|
},
|
||||||
filters: this.props.Filters,
|
filters: this.props.Filters,
|
||||||
sorter: {},
|
sorter: {},
|
||||||
@@ -41,16 +41,16 @@ class DataTable extends Component {
|
|||||||
|
|
||||||
async getData(pagination, filters, sorter) {
|
async getData(pagination, filters, sorter) {
|
||||||
/*
|
/*
|
||||||
pagination = {
|
pagination = {
|
||||||
pageSize: 10, // items per page
|
pageSize: 10, // items per page
|
||||||
current: 1, // page number
|
current: 1, // page number
|
||||||
total: 123, // Total amount of items
|
total: 123, // Total amount of items
|
||||||
}
|
}
|
||||||
filters = {
|
filters = {
|
||||||
ReportId: 123
|
ReportId: 123
|
||||||
}
|
}
|
||||||
sorter = {}
|
sorter = {}
|
||||||
*/
|
*/
|
||||||
pagination = pagination || this.state.pagination;
|
pagination = pagination || this.state.pagination;
|
||||||
filters = filters || this.state.filters;
|
filters = filters || this.state.filters;
|
||||||
sorter = sorter || this.state.sorter;
|
sorter = sorter || this.state.sorter;
|
||||||
@@ -77,27 +77,28 @@ class DataTable extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showEditModal(record, index) {
|
showEditModal(record, index) {
|
||||||
if (!this.state.showEditModal)
|
if (!this.state.showEditModal) {
|
||||||
this.setState({
|
this.setState({
|
||||||
record: record,
|
record: record,
|
||||||
showEditModal: true,
|
showEditModal: true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideEditModal() {
|
hideEditModal() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showEditModal: false,
|
showEditModal: false,
|
||||||
inserting: false,
|
inserting: false,
|
||||||
record: {}
|
record: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async onEditFinish(values) {
|
async onEditFinish(values) {
|
||||||
console.log("Finished editing", values);
|
console.log("Finished editing", values);
|
||||||
|
|
||||||
if (this.state.inserting) { // Create new record
|
if (this.state.inserting) { // Create new record
|
||||||
var status = {};
|
|
||||||
await this.props.AddRecord.insert(values);
|
await this.props.AddRecord.insert(values);
|
||||||
} else { // Edit existing record, capable of doing sparse updates
|
} else { // Edit existing record, capable of doing sparse updates
|
||||||
var status = {};
|
|
||||||
await this.props.Editable.insert(values);
|
await this.props.Editable.insert(values);
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -108,6 +109,7 @@ class DataTable extends Component {
|
|||||||
// Force refresh of data
|
// Force refresh of data
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteRecord(record) {
|
async deleteRecord(record) {
|
||||||
delete record.key;
|
delete record.key;
|
||||||
// Delete "null" values as they seem to cause deletes to fail silently when the value is null and field type is float
|
// Delete "null" values as they seem to cause deletes to fail silently when the value is null and field type is float
|
||||||
@@ -130,15 +132,16 @@ class DataTable extends Component {
|
|||||||
// Force refresh of data
|
// Force refresh of data
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let tableProps = {
|
let tableProps = {
|
||||||
...this.props.TableProps || {},
|
...this.props.TableProps || {},
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => {
|
||||||
/*
|
/*
|
||||||
To allow for extending functionality, we take a TableProps argument from props and pass it through to the Table component.
|
To allow for extending functionality, we take a TableProps argument from props and pass it through to the Table component.
|
||||||
Since we are also using onRow internaly here, we handle the externally provided events ourselves by passing along the event
|
Since we are also using onRow internaly here, we handle the externally provided events ourselves by passing along the event
|
||||||
object. This way the end user isn't affected by our event handlers.
|
object. This way the end user isn't affected by our event handlers.
|
||||||
*/
|
*/
|
||||||
let externalOnRow = {
|
let externalOnRow = {
|
||||||
...(this.props.TableProps && this.props.TableProps.onRow && this.props.TableProps.onRow(record, rowIndex)),
|
...(this.props.TableProps && this.props.TableProps.onRow && this.props.TableProps.onRow(record, rowIndex)),
|
||||||
};
|
};
|
||||||
@@ -163,7 +166,7 @@ class DataTable extends Component {
|
|||||||
if (externalOnRow.onMouseLeave) externalOnRow.onMouseLeave(event);
|
if (externalOnRow.onMouseLeave) externalOnRow.onMouseLeave(event);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
let columns = this.props.columns || this.inferColumns(this.state.tableData);
|
let columns = this.props.columns || this.inferColumns(this.state.tableData);
|
||||||
if (this.props.DeleteRecord && !columns.find(x => x.dataIndex === "notInUse")) columns.push({
|
if (this.props.DeleteRecord && !columns.find(x => x.dataIndex === "notInUse")) columns.push({
|
||||||
@@ -179,7 +182,7 @@ class DataTable extends Component {
|
|||||||
this.deleteRecord(record);
|
this.deleteRecord(record);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Slett permanent
|
Slett permanent
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
@@ -187,7 +190,7 @@ class DataTable extends Component {
|
|||||||
<Button danger style={{ float: "right", fontSize: "16px" }}>
|
<Button danger style={{ float: "right", fontSize: "16px" }}>
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
</Popover>
|
</Popover>,
|
||||||
});
|
});
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
@@ -195,27 +198,25 @@ class DataTable extends Component {
|
|||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
<style>
|
<style>
|
||||||
{`
|
{`
|
||||||
.editableTable .ant-table-tbody > tr {
|
.editableTable .ant-table-tbody > tr {
|
||||||
cursor:pointer
|
cursor:pointer
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
</style>
|
</style>
|
||||||
<Table
|
<Table
|
||||||
className={this.props.Editable && "editableTable"}
|
className={this.props.Editable && "editableTable"}
|
||||||
{...tableProps}
|
{...tableProps}
|
||||||
columns={columns.map(x => {
|
columns={columns.map(x => ({
|
||||||
return {
|
...x, // Add a 4th parameter to the stock render function with all of our table data
|
||||||
...x, // Add a 4th parameter to the stock render function with all of our table data
|
render: x.render ? (...originalParams) => x.render(...originalParams, this.state.tableData) : undefined,
|
||||||
render: x.render ? (...originalParams) => x.render(...originalParams, this.state.tableData) : undefined
|
}))}
|
||||||
};
|
|
||||||
})}
|
|
||||||
dataSource={this.state.tableData}
|
dataSource={this.state.tableData}
|
||||||
pagination={this.state.pagination.total > 10 ? this.state.pagination : false}
|
pagination={this.state.pagination.total > 10 ? this.state.pagination : false}
|
||||||
onChange={this.getData.bind(this)}
|
onChange={this.getData.bind(this)}
|
||||||
/>
|
/>
|
||||||
{this.props.AddRecord && <Button type="primary" onClick={() => this.setState({
|
{this.props.AddRecord && <Button type="primary" onClick={() => this.setState({
|
||||||
showEditModal: true,
|
showEditModal: true,
|
||||||
inserting: true
|
inserting: true,
|
||||||
})}>
|
})}>
|
||||||
<PlusOutlined />Add
|
<PlusOutlined />Add
|
||||||
</Button>}
|
</Button>}
|
||||||
@@ -243,8 +244,8 @@ class DataTable extends Component {
|
|||||||
|
|
||||||
(
|
(
|
||||||
(this.state.inserting && this.props.AddRecord && this.props.AddRecord.fields) // Use externally supplied form input fields
|
(this.state.inserting && this.props.AddRecord && this.props.AddRecord.fields) // Use externally supplied form input fields
|
||||||
|| this.props.columns.filter && this.props.columns.filter(x => x.dataIndex !== "notInUse") // Generate input fields from external columns
|
|| this.props.columns.filter && this.props.columns.filter(x => x.dataIndex !== "notInUse") // Generate input fields from external columns
|
||||||
|| this.inferColumns(this.state.tableData)).map(col => { // Generate input fields from autogenerated columns (only works with existing data)
|
|| this.inferColumns(this.state.tableData)).map(col => { // Generate input fields from autogenerated columns (only works with existing data)
|
||||||
console.log(this.state.record);
|
console.log(this.state.record);
|
||||||
return <Form.Item key={col.dataIndex} label={col.title} name={col.dataIndex}>
|
return <Form.Item key={col.dataIndex} label={col.title} name={col.dataIndex}>
|
||||||
{col.renderEdit && col.renderEdit(this.state.record[col.dataIndex], this.state.record, undefined /* Non spec compliant, is supposed to be index of record */, this.state.tableData) || <Input
|
{col.renderEdit && col.renderEdit(this.state.record[col.dataIndex], this.state.record, undefined /* Non spec compliant, is supposed to be index of record */, this.state.tableData) || <Input
|
||||||
@@ -263,6 +264,7 @@ class DataTable extends Component {
|
|||||||
</Row>
|
</Row>
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
inferColumns(data) {
|
inferColumns(data) {
|
||||||
// Look at the data and find columns and how to display them. Can be overridden by props.Columns if more customization is needed
|
// Look at the data and find columns and how to display them. Can be overridden by props.Columns if more customization is needed
|
||||||
let columns = [];
|
let columns = [];
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class SiteLayout extends Component {
|
|||||||
setTags: [],
|
setTags: [],
|
||||||
location,
|
location,
|
||||||
siteSettings: {},
|
siteSettings: {},
|
||||||
factoryModel: []
|
factoryModel: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,9 +153,9 @@ class SiteLayout extends Component {
|
|||||||
</Content>
|
</Content>
|
||||||
<Footer style={{
|
<Footer style={{
|
||||||
// background: "#F4F4F4",
|
// background: "#F4F4F4",
|
||||||
textAlign: "center"
|
textAlign: "center",
|
||||||
}}>
|
}}>
|
||||||
Clusterio 2.0 web interface https://github.com/clusterio
|
Clusterio 2.0 web interface https://github.com/clusterio
|
||||||
</Footer>
|
</Footer>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import React, {Component} from "react";
|
import React, {Component} from "react";
|
||||||
|
|
||||||
export class Dashboard extends Component {
|
export class Dashboard extends Component {
|
||||||
constructor(props){
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
render(){
|
render(){
|
||||||
return <h2>Dashboard</h2>;
|
return <h2>Dashboard</h2>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,9 +31,11 @@ export class InstanceView extends Component {
|
|||||||
};
|
};
|
||||||
this.messagesEndRef = React.createRef();
|
this.messagesEndRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
let id = this.props.match.params.id;
|
let id = this.props.match.params.id;
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ export class InstanceView extends Component {
|
|||||||
// this.messagesEndRef.current.scrollIntoView({ behavior: 'smooth' })
|
// this.messagesEndRef.current.scrollIntoView({ behavior: 'smooth' })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
let id = this.props.match.params.id;
|
let id = this.props.match.params.id;
|
||||||
|
|
||||||
@@ -66,9 +69,10 @@ export class InstanceView extends Component {
|
|||||||
let config = await getInstanceConfig({ instance_id: Number(id) });
|
let config = await getInstanceConfig({ instance_id: Number(id) });
|
||||||
console.log(config);
|
console.log(config);
|
||||||
this.setState({
|
this.setState({
|
||||||
config
|
config,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
this.setState({
|
this.setState({
|
||||||
starting: true,
|
starting: true,
|
||||||
@@ -80,9 +84,10 @@ export class InstanceView extends Component {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notify("Error starting instance", "error", e.message);
|
notify("Error starting instance", "error", e.message);
|
||||||
return this.setState({
|
this.setState({
|
||||||
starting: false,
|
starting: false,
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
notify("Instance started");
|
notify("Instance started");
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -90,6 +95,7 @@ export class InstanceView extends Component {
|
|||||||
});
|
});
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async stop() {
|
async stop() {
|
||||||
this.setState({
|
this.setState({
|
||||||
stopping: true,
|
stopping: true,
|
||||||
@@ -100,9 +106,10 @@ export class InstanceView extends Component {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notify("Error stopping instance", "error", e.message);
|
notify("Error stopping instance", "error", e.message);
|
||||||
return this.setState({
|
this.setState({
|
||||||
stopping: false,
|
stopping: false,
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
notify("Instance stopped");
|
notify("Instance stopped");
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -110,6 +117,7 @@ export class InstanceView extends Component {
|
|||||||
});
|
});
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSave() {
|
async createSave() {
|
||||||
this.setState({
|
this.setState({
|
||||||
creatingSave: true,
|
creatingSave: true,
|
||||||
@@ -120,15 +128,17 @@ export class InstanceView extends Component {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notify("Error creating save", "error", e.message);
|
notify("Error creating save", "error", e.message);
|
||||||
return this.setState({
|
this.setState({
|
||||||
creatingSave: false,
|
creatingSave: false,
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
notify("Save created", "success");
|
notify("Save created", "success");
|
||||||
this.setState({
|
this.setState({
|
||||||
creatingSave: false,
|
creatingSave: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async onConfigEditFinish(values) {
|
async onConfigEditFinish(values) {
|
||||||
console.log("Completed config edit with", values);
|
console.log("Completed config edit with", values);
|
||||||
for (let k in values) {
|
for (let k in values) {
|
||||||
@@ -145,10 +155,11 @@ export class InstanceView extends Component {
|
|||||||
}
|
}
|
||||||
notify("Set configuration fields", "success");
|
notify("Set configuration fields", "success");
|
||||||
this.setState({
|
this.setState({
|
||||||
editingConfig: false
|
editingConfig: false,
|
||||||
});
|
});
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.state);
|
console.log(this.state);
|
||||||
let { instance, slaves } = this.state;
|
let { instance, slaves } = this.state;
|
||||||
@@ -162,26 +173,26 @@ export class InstanceView extends Component {
|
|||||||
type="primary"
|
type="primary"
|
||||||
onClick={this.start.bind(this)}
|
onClick={this.start.bind(this)}
|
||||||
>
|
>
|
||||||
Start server
|
Start server
|
||||||
</Button>}
|
</Button>}
|
||||||
{instance.status !== "stopped" && <Button
|
{instance.status !== "stopped" && <Button
|
||||||
loading={this.state.stopping}
|
loading={this.state.stopping}
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={this.stop.bind(this)}
|
onClick={this.stop.bind(this)}
|
||||||
>
|
>
|
||||||
Stop server
|
Stop server
|
||||||
</Button>}
|
</Button>}
|
||||||
{instance.status !== "running" && <Button
|
{instance.status !== "running" && <Button
|
||||||
loading={this.state.creatingSave}
|
loading={this.state.creatingSave}
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={this.createSave.bind(this)}
|
onClick={this.createSave.bind(this)}
|
||||||
>
|
>
|
||||||
Create save
|
Create save
|
||||||
</Button>}
|
</Button>}
|
||||||
<Popover
|
<Popover
|
||||||
content={
|
content={
|
||||||
<Select style={{
|
<Select style={{
|
||||||
width: "200px"
|
width: "200px",
|
||||||
}}
|
}}
|
||||||
onChange={async newSlaveId => {
|
onChange={async newSlaveId => {
|
||||||
let result = await assignInstance({ instance_id: instance.id, slave_id: newSlaveId });
|
let result = await assignInstance({ instance_id: instance.id, slave_id: newSlaveId });
|
||||||
@@ -198,7 +209,7 @@ export class InstanceView extends Component {
|
|||||||
type={instance.status === "unassigned" ? "primary" : "default"}
|
type={instance.status === "unassigned" ? "primary" : "default"}
|
||||||
>
|
>
|
||||||
<Button>
|
<Button>
|
||||||
Assign to slave
|
Assign to slave
|
||||||
</Button>
|
</Button>
|
||||||
</Popover>
|
</Popover>
|
||||||
<Popover
|
<Popover
|
||||||
@@ -212,7 +223,7 @@ export class InstanceView extends Component {
|
|||||||
this.navigate("/instances");
|
this.navigate("/instances");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete this instance permanently
|
Delete this instance permanently
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
@@ -224,16 +235,16 @@ export class InstanceView extends Component {
|
|||||||
<style>
|
<style>
|
||||||
{/* Scroll sticks to bottom of terminal window after manually scrolling to the bottom */}
|
{/* Scroll sticks to bottom of terminal window after manually scrolling to the bottom */}
|
||||||
{`#scroller * {
|
{`#scroller * {
|
||||||
/* don't allow the children of the scrollable element to be selected as an anchor node */
|
/* don't allow the children of the scrollable element to be selected as an anchor node */
|
||||||
overflow-anchor: none;
|
overflow-anchor: none;
|
||||||
}
|
}
|
||||||
#anchor {
|
#anchor {
|
||||||
/* allow the final child to be selected as an anchor node */
|
/* allow the final child to be selected as an anchor node */
|
||||||
overflow-anchor: auto;
|
overflow-anchor: auto;
|
||||||
|
|
||||||
/* anchor nodes are required to have non-zero area */
|
/* anchor nodes are required to have non-zero area */
|
||||||
height: 1px;
|
height: 1px;
|
||||||
}`}
|
}`}
|
||||||
</style>
|
</style>
|
||||||
<div id="scroller" style={{
|
<div id="scroller" style={{
|
||||||
height: "300px",
|
height: "300px",
|
||||||
@@ -258,15 +269,17 @@ export class InstanceView extends Component {
|
|||||||
{this.state.config && this.renderConfig(this.state.config)}
|
{this.state.config && this.renderConfig(this.state.config)}
|
||||||
</Card>;
|
</Card>;
|
||||||
}
|
}
|
||||||
|
|
||||||
getInstanceConfigAsKvObject(config) {
|
getInstanceConfigAsKvObject(config) {
|
||||||
let object = {};
|
let object = {};
|
||||||
for (let group of config.serialized_config.groups) {
|
for (let group of config.serialized_config.groups) {
|
||||||
for (let fieldName in group.fields) {
|
for (let fieldName of Object.keys(group.fields)) {
|
||||||
object[group.name + "." + fieldName] = group.fields[fieldName];
|
object[group.name + "." + fieldName] = group.fields[fieldName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderConfig(config) {
|
renderConfig(config) {
|
||||||
const layout = {
|
const layout = {
|
||||||
labelCol: {
|
labelCol: {
|
||||||
@@ -291,7 +304,7 @@ export class InstanceView extends Component {
|
|||||||
{this.state.editingConfig ?
|
{this.state.editingConfig ?
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" htmlType="submit">
|
||||||
Save config changes
|
Save config changes
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
:
|
:
|
||||||
@@ -306,10 +319,10 @@ export class InstanceView extends Component {
|
|||||||
// orientation="left"
|
// orientation="left"
|
||||||
>{group.name}</Divider>
|
>{group.name}</Divider>
|
||||||
{/* {Object.keys(group.fields).map(field => <>
|
{/* {Object.keys(group.fields).map(field => <>
|
||||||
<span>{field}: </span>
|
<span>{field}: </span>
|
||||||
<span>{JSON.stringify(group.fields[field])}</span>
|
<span>{JSON.stringify(group.fields[field])}</span>
|
||||||
<br />
|
<br />
|
||||||
</>)} */}
|
</>)} */}
|
||||||
{console.log(group)}
|
{console.log(group)}
|
||||||
{Object.keys(group.fields).map(field => <ConfigFormItem field={field} group={group} editingConfig={this.state.editingConfig} />)}
|
{Object.keys(group.fields).map(field => <ConfigFormItem field={field} group={group} editingConfig={this.state.editingConfig} />)}
|
||||||
</Col>
|
</Col>
|
||||||
@@ -344,15 +357,16 @@ class ObjectInput extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
console.log(this.props);
|
console.log(this.props);
|
||||||
/*
|
/*
|
||||||
value: {
|
value: {
|
||||||
auto_pause: false,
|
auto_pause: false,
|
||||||
tags: ["clusterio"]
|
tags: ["clusterio"]
|
||||||
},
|
},
|
||||||
id: "factorio.settings",
|
id: "factorio.settings",
|
||||||
onChange: f()
|
onChange: f()
|
||||||
*/
|
*/
|
||||||
this.state = {};
|
this.state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(e, key) {
|
onChange(e, key) {
|
||||||
if (e.target.type === "checkbox") {
|
if (e.target.type === "checkbox") {
|
||||||
// if (e.target.checked !== undefined) {
|
// if (e.target.checked !== undefined) {
|
||||||
@@ -368,6 +382,7 @@ class ObjectInput extends Component {
|
|||||||
this.props.onChange(value);
|
this.props.onChange(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { value } = this.props;
|
let { value } = this.props;
|
||||||
let ret = [];
|
let ret = [];
|
||||||
@@ -418,10 +433,8 @@ class ObjectInput extends Component {
|
|||||||
return <Space direction="vertical">{ret}</Space>;
|
return <Space direction="vertical">{ret}</Space>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigFormItem extends Component {
|
class ConfigFormItem extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
render() {
|
render() {
|
||||||
let { field, group, editingConfig } = this.props;
|
let { field, group, editingConfig } = this.props;
|
||||||
return <Form.Item
|
return <Form.Item
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import DataTable from "../../components/data-table";
|
|||||||
const config = require("@clusterio/lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
|
|
||||||
export class InstancesTable extends Component {
|
export class InstancesTable extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Card>
|
return <Card>
|
||||||
<h2>Instances</h2>
|
<h2>Instances</h2>
|
||||||
@@ -18,7 +16,7 @@ export class InstancesTable extends Component {
|
|||||||
AddRecord={{
|
AddRecord={{
|
||||||
fields: [{
|
fields: [{
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
title: "Name"
|
title: "Name",
|
||||||
}],
|
}],
|
||||||
insert: async args => {
|
insert: async args => {
|
||||||
let instanceConfig = new config.InstanceConfig();
|
let instanceConfig = new config.InstanceConfig();
|
||||||
@@ -28,17 +26,15 @@ export class InstancesTable extends Component {
|
|||||||
let serialized_config = instanceConfig.serialize();
|
let serialized_config = instanceConfig.serialize();
|
||||||
let response = await createInstance(serialized_config);
|
let response = await createInstance(serialized_config);
|
||||||
console.log("Created instance", response);
|
console.log("Created instance", response);
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
DataFunction={listInstances}
|
DataFunction={listInstances}
|
||||||
TableProps={{
|
TableProps={{
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => ({
|
||||||
return {
|
onClick: event => {
|
||||||
onClick: event => {
|
this.navigate(`/instances/${record.id}/view`);
|
||||||
this.navigate(`/instances/${record.id}/view`);
|
},
|
||||||
}
|
}),
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>;
|
</Card>;
|
||||||
|
|||||||
@@ -4,25 +4,21 @@ import { listSlaves, listInstances, listPermissions } from "../../util/wslink";
|
|||||||
import DataTable from "../../components/data-table";
|
import DataTable from "../../components/data-table";
|
||||||
|
|
||||||
export class PermissionsTable extends Component {
|
export class PermissionsTable extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Card>
|
return <Card>
|
||||||
<h2>Permissions</h2>
|
<h2>Permissions</h2>
|
||||||
<DataTable
|
<DataTable
|
||||||
DataFunction={listPermissions}
|
DataFunction={listPermissions}
|
||||||
TableProps={{
|
TableProps={{
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => ({
|
||||||
return {
|
onClick: event => {
|
||||||
onClick: event => {
|
this.navigate(`/permissions/${record.id}/view`);
|
||||||
this.navigate(`/permissions/${record.id}/view`);
|
},
|
||||||
}
|
}),
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>;
|
</Card>;
|
||||||
|
|||||||
@@ -31,16 +31,19 @@ export class RoleView extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
role: {}
|
role: {},
|
||||||
};
|
};
|
||||||
this.messagesEndRef = React.createRef();
|
this.messagesEndRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
await this.getData();
|
await this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
let id = this.props.match.params.id;
|
let id = this.props.match.params.id;
|
||||||
|
|
||||||
@@ -52,12 +55,13 @@ export class RoleView extends Component {
|
|||||||
permissions,
|
permissions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleChange(targetKeys) {
|
async handleChange(targetKeys) {
|
||||||
this.setState({
|
this.setState({
|
||||||
role: {
|
role: {
|
||||||
...this.state.role,
|
...this.state.role,
|
||||||
permissions: targetKeys
|
permissions: targetKeys,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
let response = await updateRole({
|
let response = await updateRole({
|
||||||
...this.state.role,
|
...this.state.role,
|
||||||
@@ -65,6 +69,7 @@ export class RoleView extends Component {
|
|||||||
});
|
});
|
||||||
console.log("Updated user roles", response);
|
console.log("Updated user roles", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.state);
|
console.log(this.state);
|
||||||
let { role, permissions } = this.state;
|
let { role, permissions } = this.state;
|
||||||
@@ -80,7 +85,7 @@ export class RoleView extends Component {
|
|||||||
this.navigate("/roles");
|
this.navigate("/roles");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete this role permanently
|
Delete this role permanently
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
@@ -93,11 +98,11 @@ export class RoleView extends Component {
|
|||||||
<h3>Assign roles</h3>
|
<h3>Assign roles</h3>
|
||||||
<style>
|
<style>
|
||||||
{`
|
{`
|
||||||
.ant-transfer-list{
|
.ant-transfer-list{
|
||||||
width: calc( 50% - 34px );
|
width: calc( 50% - 34px );
|
||||||
height: 500px;
|
height: 500px;
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
</style>
|
</style>
|
||||||
<Transfer
|
<Transfer
|
||||||
titles={["Available", "Assigned"]}
|
titles={["Available", "Assigned"]}
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import { listSlaves, listInstances, listRoles, createRole } from "../../util/wsl
|
|||||||
import DataTable from "../../components/data-table";
|
import DataTable from "../../components/data-table";
|
||||||
|
|
||||||
export class RolesTable extends Component {
|
export class RolesTable extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Card>
|
return <Card>
|
||||||
<h2>Roles</h2>
|
<h2>Roles</h2>
|
||||||
@@ -17,25 +15,23 @@ export class RolesTable extends Component {
|
|||||||
AddRecord={{
|
AddRecord={{
|
||||||
fields: [{
|
fields: [{
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
title: "Name"
|
title: "Name",
|
||||||
},{
|
},{
|
||||||
dataIndex: "description",
|
dataIndex: "description",
|
||||||
title: "Description"
|
title: "Description",
|
||||||
}],
|
}],
|
||||||
insert: async args => {
|
insert: async args => {
|
||||||
let response = await createRole({name: args.name, description: args.description});
|
let response = await createRole({name: args.name, description: args.description});
|
||||||
console.log("Created role",response);
|
console.log("Created role",response);
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
DataFunction={listRoles}
|
DataFunction={listRoles}
|
||||||
TableProps={{
|
TableProps={{
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => ({
|
||||||
return {
|
onClick: event => {
|
||||||
onClick: event => {
|
this.navigate(`/roles/${record.id}/view`);
|
||||||
this.navigate(`/roles/${record.id}/view`);
|
},
|
||||||
}
|
}),
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>;
|
</Card>;
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ export class Settings extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
role: {}
|
role: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.state);
|
console.log(this.state);
|
||||||
return <Card>
|
return <Card>
|
||||||
@@ -39,7 +41,7 @@ export class Settings extends Component {
|
|||||||
}}
|
}}
|
||||||
onFinish={values => {
|
onFinish={values => {
|
||||||
console.log("Saving settings",values);
|
console.log("Saving settings",values);
|
||||||
for(let key of Object.keys(values)){
|
for (let key of Object.keys(values)){
|
||||||
localStorage.setItem(key, values[key].replace("https://", "wss://").replace("http://", "ws://"));
|
localStorage.setItem(key, values[key].replace("https://", "wss://").replace("http://", "ws://"));
|
||||||
}
|
}
|
||||||
// Force refresh to apply changes
|
// Force refresh to apply changes
|
||||||
@@ -52,7 +54,7 @@ export class Settings extends Component {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: 'Please input master url, ex ws://localhost:8080 or wss://localhost:8443/ . For SSL connections, ensure you have a valid certificate.',
|
message: "Please input master url, ex ws://localhost:8080 or wss://localhost:8443/ . For SSL connections, ensure you have a valid certificate.",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@@ -64,7 +66,7 @@ export class Settings extends Component {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: 'Please input your user auth token from config-control.json',
|
message: "Please input your user auth token from config-control.json",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@@ -72,7 +74,7 @@ export class Settings extends Component {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item {...tailLayout}>
|
<Form.Item {...tailLayout}>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" htmlType="submit">
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -4,25 +4,21 @@ import { listSlaves, listInstances } from "../../util/wslink";
|
|||||||
import DataTable from "../../components/data-table";
|
import DataTable from "../../components/data-table";
|
||||||
|
|
||||||
export class SlavesTable extends Component {
|
export class SlavesTable extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Card>
|
return <Card>
|
||||||
<h2>Slaves</h2>
|
<h2>Slaves</h2>
|
||||||
<DataTable
|
<DataTable
|
||||||
DataFunction={listSlaves}
|
DataFunction={listSlaves}
|
||||||
TableProps={{
|
TableProps={{
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => ({
|
||||||
return {
|
onClick: event => {
|
||||||
onClick: event => {
|
this.navigate(`/slaves/${record.id}/view`);
|
||||||
this.navigate(`/slaves/${record.id}/view`);
|
},
|
||||||
}
|
}),
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>;
|
</Card>;
|
||||||
|
|||||||
@@ -16,16 +16,19 @@ export class UserView extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
user: {}
|
user: {},
|
||||||
};
|
};
|
||||||
this.messagesEndRef = React.createRef();
|
this.messagesEndRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
await this.getData();
|
await this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
let name = this.props.match.params.id;
|
let name = this.props.match.params.id;
|
||||||
|
|
||||||
@@ -37,12 +40,13 @@ export class UserView extends Component {
|
|||||||
roles,
|
roles,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleChange(targetKeys) {
|
async handleChange(targetKeys) {
|
||||||
this.setState({
|
this.setState({
|
||||||
user: {
|
user: {
|
||||||
...this.state.user,
|
...this.state.user,
|
||||||
roles: targetKeys
|
roles: targetKeys,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
let response = await setRoles({
|
let response = await setRoles({
|
||||||
name: this.state.user.name,
|
name: this.state.user.name,
|
||||||
@@ -50,6 +54,7 @@ export class UserView extends Component {
|
|||||||
});
|
});
|
||||||
console.log("Updated user roles",response);
|
console.log("Updated user roles",response);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.state);
|
console.log(this.state);
|
||||||
let { user, roles } = this.state;
|
let { user, roles } = this.state;
|
||||||
@@ -76,7 +81,7 @@ export class UserView extends Component {
|
|||||||
this.navigate("/users");
|
this.navigate("/users");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete this user from the cluster
|
Delete this user from the cluster
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import { listSlaves, listInstances, listUsers, createUser } from "../../util/wsl
|
|||||||
import DataTable from "../../components/data-table";
|
import DataTable from "../../components/data-table";
|
||||||
|
|
||||||
export class UsersTable extends Component {
|
export class UsersTable extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
navigate(url) {
|
navigate(url) {
|
||||||
this.props.history.push(url);
|
this.props.history.push(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Card>
|
return <Card>
|
||||||
<h2>Slaves</h2>
|
<h2>Slaves</h2>
|
||||||
@@ -17,22 +15,20 @@ export class UsersTable extends Component {
|
|||||||
AddRecord={{
|
AddRecord={{
|
||||||
fields: [{
|
fields: [{
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
title: "Name"
|
title: "Name",
|
||||||
}],
|
}],
|
||||||
insert: async args => {
|
insert: async args => {
|
||||||
let response = await createUser({name: args.name});
|
let response = await createUser({name: args.name});
|
||||||
console.log("Created user",response);
|
console.log("Created user",response);
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
DataFunction={listUsers}
|
DataFunction={listUsers}
|
||||||
TableProps={{
|
TableProps={{
|
||||||
onRow: (record, rowIndex) => {
|
onRow: (record, rowIndex) => ({
|
||||||
return {
|
onClick: event => {
|
||||||
onClick: event => {
|
this.navigate(`/users/${record.name}/view`);
|
||||||
this.navigate(`/users/${record.name}/view`);
|
},
|
||||||
}
|
}),
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>;
|
</Card>;
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { notification } from "antd";
|
import { notification } from "antd";
|
||||||
|
|
||||||
/**
|
export default function notify(message, type = "info", description = undefined) {
|
||||||
*
|
|
||||||
* @param {string} message
|
|
||||||
* @param {("info"|"error"|"success"|"warning"|"warn")} type
|
|
||||||
*/
|
|
||||||
export default function notify(message, type = "info", description) {
|
|
||||||
notification[type]({
|
notification[type]({
|
||||||
message: typeof message === "string" ? message : "ERROR: See console",
|
message: typeof message === "string" ? message : "ERROR: See console",
|
||||||
description,
|
description,
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ export class Control extends link.Link {
|
|||||||
link.attachAllMessages(this);
|
link.attachAllMessages(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of plugin names to their instance for loaded plugins.
|
* Mapping of plugin names to their instance for loaded plugins.
|
||||||
* @type {Map<string, module:lib/plugin.BaseControlPlugin>}
|
* @type {Map<string, module:lib/plugin.BaseControlPlugin>}
|
||||||
*/
|
*/
|
||||||
this.plugins = controlPlugins;
|
this.plugins = controlPlugins;
|
||||||
for (let controlPlugin of controlPlugins.values()) {
|
for (let controlPlugin of controlPlugins.values()) {
|
||||||
plugin.attachPluginMessages(this, controlPlugin.info, controlPlugin);
|
plugin.attachPluginMessages(this, controlPlugin.info, controlPlugin);
|
||||||
@@ -75,7 +75,9 @@ export class Control extends link.Link {
|
|||||||
async instanceOutputEventHandler(message) {
|
async instanceOutputEventHandler(message) {
|
||||||
let { instance_id, output } = message.data;
|
let { instance_id, output } = message.data;
|
||||||
console.log(formatOutput(output));
|
console.log(formatOutput(output));
|
||||||
window.instanceOutputEventHandler && window.instanceOutputEventHandler({instance_id, output});
|
if (window.instanceOutputEventHandler) {
|
||||||
|
window.instanceOutputEventHandler({instance_id, output});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async debugWsMessageEventHandler(message) {
|
async debugWsMessageEventHandler(message) {
|
||||||
|
|||||||
@@ -27,38 +27,38 @@ let listUsers = createListFunction("listUsers", "name");
|
|||||||
let listRoles = createListFunction("listRoles");
|
let listRoles = createListFunction("listRoles");
|
||||||
let listPermissions = createListFunction("listPermissions", "name");
|
let listPermissions = createListFunction("listPermissions", "name");
|
||||||
|
|
||||||
let startInstance = async function ({ instance_id, save = null }) {
|
async function startInstance({ instance_id, save = null }) {
|
||||||
return await link.messages.startInstance.send(control, { instance_id, save });
|
return await link.messages.startInstance.send(control, { instance_id, save });
|
||||||
};
|
};
|
||||||
let stopInstance = async function ({ instance_id }) {
|
async function stopInstance({ instance_id }) {
|
||||||
return await link.messages.stopInstance.send(control, { instance_id });
|
return await link.messages.stopInstance.send(control, { instance_id });
|
||||||
};
|
};
|
||||||
let createInstance = async function (serialized_config) {
|
async function createInstance(serialized_config) {
|
||||||
return await link.messages.createInstance.send(control, { serialized_config });
|
return await link.messages.createInstance.send(control, { serialized_config });
|
||||||
};
|
};
|
||||||
let deleteInstance = async function ({ instance_id }) {
|
async function deleteInstance({ instance_id }) {
|
||||||
return await link.messages.deleteInstance.send(control, { instance_id });
|
return await link.messages.deleteInstance.send(control, { instance_id });
|
||||||
};
|
};
|
||||||
let assignInstance = async function ({ instance_id, slave_id }) {
|
async function assignInstance({ instance_id, slave_id }) {
|
||||||
return await link.messages.assignInstanceCommand.send(control, {
|
return await link.messages.assignInstanceCommand.send(control, {
|
||||||
instance_id,
|
instance_id,
|
||||||
slave_id,
|
slave_id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
let createSave = async function ({ instance_id }) {
|
async function createSave({ instance_id }) {
|
||||||
return await link.messages.createSave.send(control, { instance_id });
|
return await link.messages.createSave.send(control, { instance_id });
|
||||||
};
|
};
|
||||||
let getInstanceConfig = async function ({ instance_id }) {
|
async function getInstanceConfig({ instance_id }) {
|
||||||
return await link.messages.getInstanceConfig.send(control, { instance_id });
|
return await link.messages.getInstanceConfig.send(control, { instance_id });
|
||||||
};
|
};
|
||||||
let setInstanceConfigField = async function ({ instance_id, field, value }) {
|
async function setInstanceConfigField({ instance_id, field, value }) {
|
||||||
return await link.messages.setInstanceConfigField.send(control, {
|
return await link.messages.setInstanceConfigField.send(control, {
|
||||||
instance_id,
|
instance_id,
|
||||||
field,
|
field,
|
||||||
value: typeof value === "object" ? JSON.stringify(value) : value,
|
value: typeof value === "object" ? JSON.stringify(value) : value,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
let setInstanceConfigProp = async function ({ instance_id, field, prop, value }) {
|
async function setInstanceConfigProp({ instance_id, field, prop, value }) {
|
||||||
return await link.messages.setInstanceConfigProp.send(control, {
|
return await link.messages.setInstanceConfigProp.send(control, {
|
||||||
instance_id,
|
instance_id,
|
||||||
field,
|
field,
|
||||||
@@ -66,32 +66,32 @@ let setInstanceConfigProp = async function ({ instance_id, field, prop, value })
|
|||||||
value, // JSON Object
|
value, // JSON Object
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
let sendRcon = async function ({ instance_id, command }) {
|
async function sendRcon({ instance_id, command }) {
|
||||||
return await link.messages.sendRcon.send(control, { instance_id, command });
|
return await link.messages.sendRcon.send(control, { instance_id, command });
|
||||||
};
|
};
|
||||||
let setInstanceOutputSubscriptions = async function ({ instance_id }) {
|
async function setInstanceOutputSubscriptions({ instance_id }) {
|
||||||
return await link.messages.setInstanceOutputSubscriptions.send(control, { instance_ids: [instance_id] });
|
return await link.messages.setInstanceOutputSubscriptions.send(control, { instance_ids: [instance_id] });
|
||||||
};
|
};
|
||||||
|
|
||||||
let createUser = async function ({ name }) {
|
async function createUser({ name }) {
|
||||||
return await link.messages.createUser.send(control, { name });
|
return await link.messages.createUser.send(control, { name });
|
||||||
};
|
};
|
||||||
let deleteUser = async function ({ name }) {
|
async function deleteUser({ name }) {
|
||||||
return await link.messages.deleteUser.send(control, { name });
|
return await link.messages.deleteUser.send(control, { name });
|
||||||
};
|
};
|
||||||
let setRoles = async function ({ name, roles }) {
|
async function setRoles({ name, roles }) {
|
||||||
return await link.messages.updateUserRoles.send(control, {
|
return await link.messages.updateUserRoles.send(control, {
|
||||||
name,
|
name,
|
||||||
roles,
|
roles,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let createRole = async function ({ name, description, permissions = [] }) {
|
async function createRole({ name, description, permissions = [] }) {
|
||||||
return await link.messages.createRole.send(control, { name, description, permissions });
|
return await link.messages.createRole.send(control, { name, description, permissions });
|
||||||
};
|
};
|
||||||
let updateRole = async function ({ id, name, description, permissions }) {
|
async function updateRole({ id, name, description, permissions }) {
|
||||||
return await link.messages.updateRole.send(control, {
|
return await link.messages.updateRole.send(control, {
|
||||||
id, name, description, permissions
|
id, name, description, permissions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,15 +120,15 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function createListFunction(name, key) {
|
function createListFunction(name, key) {
|
||||||
return async () => {
|
return async () => (
|
||||||
return (await link.messages[name].send(control)).list.map(addKey(key || "id"));
|
(await link.messages[name].send(control)).list.map(addKey(key || "id"))
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
function addKey(key) {
|
function addKey(key) {
|
||||||
return function (el) {
|
return function (el) {
|
||||||
return {
|
return {
|
||||||
...el,
|
...el,
|
||||||
key: el[key]
|
key: el[key],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user