aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/views/Rules.js
blob: 342441083223a6d8dac5d4d1a59ba9d98e52a5b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React, {Component} from 'react';
import './Services.scss';
import {Button, ButtonGroup, Col, Container, Form, FormControl, InputGroup, Modal, Row, Table} from "react-bootstrap";
import axios from "axios";

class Rules extends Component {

    constructor(props) {
        super(props);

        this.state = {
            rules: []
        };
    }

    componentDidMount() {
        this.loadRules();
    }

    loadRules() {
        axios.get("/api/rules").then(res => this.setState({rules: res.data}));
    }

    render() {
        let rulesRows = this.state.rules.map(rule =>
            <tr key={rule.id}>
                <td><Button variant="btn-edit" size="sm"
                            style={{"backgroundColor": rule.color}}>edit</Button></td>
                <td>{rule.name}</td>
            </tr>
        );


        return (
            <Modal
                {...this.props}
                show="true"
                size="lg"
                aria-labelledby="rules-dialog"
                centered
            >
                <Modal.Header>
                    <Modal.Title id="rules-dialog">
                        ~/rules
                    </Modal.Title>
                </Modal.Header>
                <Modal.Body>
                    <Container>
                        <Row>
                            <Col md={7}>
                                <Table borderless size="sm" className="rules-list">
                                    <thead>
                                    <tr>
                                        <th><Button size="sm" >new</Button></th>
                                        <th>name</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {rulesRows}

                                    </tbody>
                                </Table>
                            </Col>
                            <Col md={5}>
                                <Form>
                                    <Form.Group controlId="servicePort">
                                        <Form.Label>port:</Form.Label>
                                        <Form.Control type="text"  />
                                    </Form.Group>

                                    <Form.Group controlId="serviceName">
                                        <Form.Label>name:</Form.Label>
                                        <Form.Control type="text"  />
                                    </Form.Group>

                                    <Form.Group controlId="serviceColor">
                                        <Form.Label>color:</Form.Label>
                                        <ButtonGroup aria-label="Basic example">

                                        </ButtonGroup>
                                        <ButtonGroup aria-label="Basic example">

                                        </ButtonGroup>
                                    </Form.Group>

                                    <Form.Group controlId="serviceNotes">
                                        <Form.Label>notes:</Form.Label>
                                        <Form.Control as="textarea" rows={3} />
                                    </Form.Group>
                                </Form>


                            </Col>

                        </Row>

                        <Row>
                            <Col md={12}>
                                <InputGroup>
                                    <FormControl as="textarea" rows={4} className="curl-output" readOnly={true}
                                                 />
                                </InputGroup>

                            </Col>
                        </Row>


                    </Container>
                </Modal.Body>
                <Modal.Footer className="dialog-footer">
                    <Button variant="red" onClick={this.props.onHide}>close</Button>
                </Modal.Footer>
            </Modal>
        );
    }
}

export default Rules;