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

+19 -27
View File
@@ -1,20 +1,9 @@
import React, { Component } from "react";
import {
Collapse, Row, Col, Modal, Table,
Form,
Input,
Button,
Radio,
Select,
Cascader,
DatePicker,
InputNumber,
TreeSelect,
Switch,
Popover
} from "antd";
import { Collapse, Row, Col, Modal, Table, Form, Input, Button, Popover } from "antd";
import PlusOutlined from "@ant-design/icons/PlusOutlined"
import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
import notify from "../util/notify";
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
const { Panel } = Collapse;
@@ -45,10 +34,12 @@ class DataTable extends Component {
record: {},
}
}
componentDidMount() {
this.getData()
}
getData = async (pagination, filters, sorter) => {
async getData(pagination, filters, sorter) {
/*
pagination = {
pageSize: 10, // items per page
@@ -84,21 +75,22 @@ class DataTable extends Component {
filters,
})
}
showEditModal = (record, index) => {
showEditModal(record, index) {
if (!this.state.showEditModal)
this.setState({
record: record,
showEditModal: true,
})
}
hideEditModal = () => {
hideEditModal() {
this.setState({
showEditModal: false,
inserting: false,
record: {}
})
}
onEditFinish = async values => {
async onEditFinish(values) {
console.log("Finished editing", values)
if (this.state.inserting) { // Create new record
@@ -116,7 +108,7 @@ class DataTable extends Component {
// Force refresh of data
this.getData()
}
deleteRecord = async record => {
async deleteRecord(record) {
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
for (let key in record) {
@@ -148,7 +140,7 @@ class DataTable extends Component {
object. This way the end user isn't affected by our event handlers.
*/
let externalOnRow = {
...this.props.TableProps?.onRow?.(record, rowIndex),
...(this.props.TableProps && this.props.TableProps.onRow && this.props.TableProps.onRow(record, rowIndex)),
}
return {
onClick: event => {
@@ -219,7 +211,7 @@ class DataTable extends Component {
})}
dataSource={this.state.tableData}
pagination={this.state.pagination.total > 10 ? this.state.pagination : false}
onChange={this.getData}
onChange={this.getData.bind(this)}
/>
{this.props.AddRecord && <Button type="primary" onClick={() => this.setState({
showEditModal: true,
@@ -244,18 +236,18 @@ class DataTable extends Component {
span: 12,
}}
layout="horizontal"
onFinish={this.onEditFinish}
onFinish={this.onEditFinish.bind(this)}
initialValues={this.state.record}
>
{
(
(this.state.inserting && this.props.AddRecord?.fields) // Use externally supplied form input fields
|| this.props.columns?.filter(x => x.dataIndex !== "notInUse") // Generate input fields from external columns
(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.inferColumns(this.state.tableData)).map(col => { // Generate input fields from autogenerated columns (only works with existing data)
console.log(this.state.record)
return <Form.Item key={col.dataIndex} label={col.title} name={col.dataIndex}>
{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
placeholder={this.state.record[col.dataIndex]}
/>}
</Form.Item>
@@ -271,7 +263,7 @@ class DataTable extends Component {
</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
let columns = []
data.forEach(row => {