aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/views/MainPane.js
blob: 69de725fda4b2f5bdca1d73834108e439db399f5 (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
import React, {Component} from 'react';
import './MainPane.scss';
import Connections from "./Connections";
import ConnectionContent from "../components/ConnectionContent";
import {withRouter} from "react-router-dom";
import axios from 'axios';

class MainPane extends Component {

    constructor(props) {
        super(props);
        this.state = {
            selectedConnection: null
        };
    }

    componentDidMount() {
        if ('id' in this.props.match.params) {
            const id = this.props.match.params.id;
            axios.get(`/api/connections/${id}`).then(res => {
                if (res.status === 200) {
                    this.setState({selectedConnection: res.data});
                }
            });
        }
    }

    render() {
        return (
            <div className="main-pane">
                <div className="container-fluid">
                    <div className="row">
                        <div className="col-md-6 pane">
                            <Connections onSelected={(c) => this.setState({selectedConnection: c})} />
                        </div>
                        <div className="col-md-6 pl-0 pane">
                            <ConnectionContent connection={this.state.selectedConnection}/>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

export default withRouter(MainPane);