mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
05.15.2019 e70f062550b0c611f076aa784f284a27e0ffe715
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
import React from 'react';
import {Button, Card, CardBody, Collapse, Progress} from 'reactstrap';
import {IconCancelJob} from '../../general/IconComponents'
 
class Job extends React.Component {
    constructor(props) {
        super(props);
        this.toggle = this.toggle.bind(this);
        this.state = {collapse: false};
    }
 
    toggle() {
        this.setState({collapse: !this.state.collapse});
    }
 
    render() {
        let content = undefined;
        let job = this.props.job;
        if (job.status === 'RUNNING') {
            let progressPercent = 100;
            if (job.progressPercent >= 0 && job.progressPercent <= 100) {
                progressPercent = job.progressPercent;
            }
            content = <Progress animated color={'success'} value={progressPercent}>{job.progressText}</Progress>;
        } else {
            content = <Progress color={'info'} value={100}>{job.status}</Progress>
        }
        return (
            <div>
                <Button color="link" onClick={this.toggle}>{job.description}</Button>
                <div>{content}<IconCancelJob/></div>
                <Collapse isOpen={this.state.collapse}>
                    <Card>
                        <CardBody>
                            <table><tbody><tr><th>Status</th><td>{job.status}</td></tr>
                            <tr><th>Command line</th><td>{job.commandLineAsString}</td></tr></tbody></table>
                        </CardBody>
                    </Card>
                </Collapse>
            </div>
        )
    }
}
 
export default Job;