Implement webpack build for web interface

Set up webpack for the master server's web interface and fix the issues
from the imported interface source files.  The .jsx files in
package/master/web are bundled together into package/master/static and
served by the master server via express.
This commit is contained in:
Hornwitser committed 2020-09-28 04:23:45 +02:00
1 parent 2382f4bbdc
commit 701ff87bcd
25 files changed
+219 -191

No files matched your search

@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Table, Button, List, Popover, Select, Divider, Input, Form, Col, Row, Checkbox, Space } from "antd"
import { Card, Button, Popover, Select, Divider, Input, Form, Col, Row, Checkbox, Space } from "antd"
import {
listSlaves,
listInstances,
@@ -15,7 +15,9 @@ import {
} from "../../util/wslink"
import DataTable from "../../components/data-table"
import notify from "../../util/notify"
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons"
import DeleteOutlined from "@ant-design/icons/DeleteOutlined"
import EditOutlined from "@ant-design/icons/EditOutlined"
import PlusOutlined from "@ant-design/icons/PlusOutlined"
const { Option } = Select
@@ -27,8 +29,8 @@ export class InstanceView extends Component {
slaves: [],
logLines: [{ message: "Logviewer. Follows the latest logs if you scroll to the bottom. Does not store logs past the lifetime of this tab" }],
}
this.messagesEndRef = React.createRef()
}
messagesEndRef = React.createRef()
navigate(url) {
this.props.history.push(url);
}
@@ -50,7 +52,7 @@ export class InstanceView extends Component {
// this.messagesEndRef.current.scrollIntoView({ behavior: 'smooth' })
}
}
getData = async () => {
async getData() {
let id = this.props.match.params.id
let instances = await listInstances()
@@ -67,7 +69,7 @@ export class InstanceView extends Component {
config
})
}
start = async () => {
async start() {
this.setState({
starting: true,
})
@@ -88,7 +90,7 @@ export class InstanceView extends Component {
})
this.getData()
}
stop = async () => {
async stop() {
this.setState({
stopping: true,
})
@@ -108,7 +110,7 @@ export class InstanceView extends Component {
})
this.getData()
}
createSave = async () => {
async createSave() {
this.setState({
creatingSave: true,
})
@@ -127,7 +129,7 @@ export class InstanceView extends Component {
creatingSave: false,
})
}
onConfigEditFinish = async values => {
async onConfigEditFinish(values) {
console.log("Completed config edit with", values)
for (let k in values) {
if (values[k] !== this.getInstanceConfigAsKvObject(this.state.config)[k]) {
@@ -150,28 +152,29 @@ export class InstanceView extends Component {
render() {
console.log(this.state)
let { instance, slaves } = this.state
let slave = slaves && slaves.find(x => x.id === instance.assigned_slave);
return <Card>
<h2>{instance.name}</h2>
<p>ID: {instance.id}</p>
<p>Slave: {slaves?.find(x => x.id === instance.assigned_slave)?.name}</p>
<p>Slave: {slave && slave.name}</p>
{instance.status !== "running" && <Button
loading={this.state.starting}
type="primary"
onClick={this.start}
onClick={this.start.bind(this)}
>
Start server
</Button>}
{instance.status !== "stopped" && <Button
loading={this.state.stopping}
type="primary"
onClick={this.stop}
onClick={this.stop.bind(this)}
>
Stop server
</Button>}
{instance.status !== "running" && <Button
loading={this.state.creatingSave}
type="primary"
onClick={this.createSave}
onClick={this.createSave.bind(this)}
>
Create save
</Button>}
@@ -283,7 +286,7 @@ export class InstanceView extends Component {
<Form
{...layout}
initialValues={this.getInstanceConfigAsKvObject(config)}
onFinish={this.onConfigEditFinish}
onFinish={this.onConfigEditFinish.bind(this)}
>
{this.state.editingConfig ?
<Form.Item>
@@ -1,8 +1,8 @@
import React, { Component } from "react"
import { Card, Table } from "antd"
import { Card } from "antd"
import { listSlaves, listInstances, createInstance } from "../../util/wslink"
import DataTable from "../../components/data-table"
const config = require("../../lib/config")
const config = require("@clusterio/lib/config")
export class InstancesTable extends Component {
constructor(props) {
@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Table } from "antd"
import { Card } from "antd"
import { listSlaves, listInstances, listPermissions } from "../../util/wslink"
import DataTable from "../../components/data-table"
+9 -7
View File
@@ -1,5 +1,8 @@
import React, { Component } from "react"
import { Card, Table, Button, List, Popover, Select, Divider, Input, Form, Col, Row, Checkbox, Space, Transfer } from "antd"
import { Card, Button, Popover, Select, Transfer } from "antd"
import DeleteOutlined from "@ant-design/icons/DeleteOutlined"
import {
listSlaves,
listInstances,
@@ -21,7 +24,6 @@ import {
} from "../../util/wslink"
import DataTable from "../../components/data-table"
import notify from "../../util/notify"
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons"
const { Option } = Select
@@ -31,15 +33,15 @@ export class RoleView extends Component {
this.state = {
role: {}
}
this.messagesEndRef = React.createRef()
}
messagesEndRef = React.createRef()
navigate(url) {
this.props.history.push(url);
}
async componentDidMount() {
await this.getData()
}
getData = async () => {
async getData() {
let id = this.props.match.params.id
let roles = await listRoles()
@@ -50,7 +52,7 @@ export class RoleView extends Component {
permissions,
})
}
handleChange = async targetKeys => {
async handleChange(targetKeys) {
this.setState({
role: {
...this.state.role,
@@ -62,7 +64,7 @@ export class RoleView extends Component {
permissions: targetKeys,
})
console.log("Updated user roles", response)
};
}
render() {
console.log(this.state)
let { role, permissions } = this.state
@@ -103,7 +105,7 @@ export class RoleView extends Component {
showSearch
filterOption={(inputValue, option) => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1}
targetKeys={role.permissions}
onChange={this.handleChange}
onChange={this.handleChange.bind(this)}
render={item => item.name}
/>
</Card>
@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Table } from "antd"
import { Card } from "antd"
import { listSlaves, listInstances, listRoles, createRole } from "../../util/wslink"
import DataTable from "../../components/data-table"
@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Button, Select, Input, Form } from "antd"
import { Card, Button, Input, Form } from "antd"
const layout = {
labelCol: {
@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Table } from "antd"
import { Card } from "antd";
import { listSlaves, listInstances } from "../../util/wslink"
import DataTable from "../../components/data-table"
+6 -17
View File
@@ -1,17 +1,6 @@
import React, { Component } from "react"
import { Card, Table, Button, List, Popover, Select, Divider, Input, Form, Col, Row, Checkbox, Space, Transfer } from "antd"
import { Card, Button, Popover, Select, Transfer } from "antd";
import {
listSlaves,
listInstances,
startInstance,
stopInstance,
setInstanceOutputSubscriptions,
deleteInstance,
assignInstance,
createSave,
getInstanceConfig,
setInstanceConfigField,
sendRcon,
deleteUser,
listUsers,
listRoles,
@@ -19,7 +8,7 @@ import {
} from "../../util/wslink"
import DataTable from "../../components/data-table"
import notify from "../../util/notify"
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons"
import DeleteOutlined from "@ant-design/icons/DeleteOutlined"
const { Option } = Select
@@ -29,15 +18,15 @@ export class UserView extends Component {
this.state = {
user: {}
}
this.messagesEndRef = React.createRef();
}
messagesEndRef = React.createRef()
navigate(url) {
this.props.history.push(url);
}
async componentDidMount() {
await this.getData()
}
getData = async () => {
async getData() {
let name = this.props.match.params.id
let users = await listUsers()
@@ -48,7 +37,7 @@ export class UserView extends Component {
roles,
})
}
handleChange = async targetKeys => {
async handleChange(targetKeys) {
this.setState({
user: {
...this.state.user,
@@ -73,7 +62,7 @@ export class UserView extends Component {
showSearch
filterOption={(inputValue, option) => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1}
targetKeys={user.roles}
onChange={this.handleChange}
onChange={this.handleChange.bind(this)}
render={item => item.name}
/>
<Popover
@@ -1,5 +1,5 @@
import React, { Component } from "react"
import { Card, Table } from "antd"
import { Card } from "antd"
import { listSlaves, listInstances, listUsers, createUser } from "../../util/wslink"
import DataTable from "../../components/data-table"