aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/views/MainPane.js
blob: e84f94cd824531af78ae87f4e75087b316c5d1b2 (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
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 = {
            id: null,
        };
    }

    componentDidUpdate() {
        if (this.props.match.params.id !== this.state.id) {
            const id = this.props.match.params.id;
            this.setState({id: id});

            axios.get(`/api/streams/${id}`).then(res => this.setState({connectionContent: res.data}));
        }
    }

    componentDidMount() {
        if (this.props.match.params.id !== this.state.id) {
            const id = this.props.match.params.id;
            this.setState({id: id});

            axios.get(`/api/streams/${id}`).then(res => this.setState({connectionContent: res.data}));
        }
    }

    render() {
        return (
            <div className="main-pane">
                <div className="container-fluid">
                    <div className="row">
                        <div className="col-md-6 pane">
                            <Connections/>
                        </div>
                        <div className="col-md-6 pl-0 pane">
                            <ConnectionContent connectionPayload={this.state.connectionContent}/>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

export default withRouter(MainPane);