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

Kai Reinhard
16.43.2018 910202f57569955514572b4196de2b6b09d3ff2e
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import React from 'react'
import {Table} from 'reactstrap';
import {PageHeader} from '../../general/BootstrapComponents';
import {getRestServiceUrl, humanFileSize, humanSeconds} from '../../../utilities/global';
import ErrorAlert from '../../general/ErrorAlert';
import {IconRefresh} from "../../general/IconComponents";
 
class ArchiveView extends React.Component {
 
    state = {
        repoId: this.props.match.params.repoId,
        archiveId: this.props.match.params.archiveId,
        isFetching: false,
        activeTab: '1',
    };
 
    componentDidMount = () => {
        this.fetchArchive();
    };
 
 
    fetchArchive = (force) => {
        this.setState({
            isFetching: true,
            failed: false
        });
        fetch(getRestServiceUrl('archives', {
            repo: this.state.repoId,
            archive: this.state.archiveId,
            force: force
        }), {
            method: 'GET',
            headers: {
                'Accept': 'application/json'
            }
        })
            .then(response => response.json())
            .then(json => {
                this.setState({
                    isFetching: false,
                    archive: json
                })
            })
            .catch(() => this.setState({isFetching: false, failed: true}));
    };
 
    render = () => {
        let content = undefined;
        let archive = this.state.archive;
        let pageHeader = '';
 
        if (this.state.isFetching) {
            content = <i>Loading...</i>;
        } else if (this.state.failed) {
            content = <ErrorAlert
                title={'Cannot load Repositories'}
                description={'Something went wrong during contacting the rest api.'}
                action={{
                    handleClick: this.fetchArchive,
                    title: 'Try again'
                }}
            />;
        } else if (this.state.archive) {
            pageHeader = <React.Fragment>
                {archive.repoDisplayName}
                <div
                    className={'btn btn-outline-primary refresh-button-right'}
                    onClick={this.fetchArchive.bind(this, true)}
                >
                    <IconRefresh/>
                </div>
            </React.Fragment>;
            content = <React.Fragment>
                <Table hover>
                    <tbody>
                    <tr>
                        <td>Archive</td>
                        <td>{archive.name}</td>
                    </tr>
                    <tr>
                        <td>Start - end</td>
                        <td>{archive.start} - {archive.end} (Duration: {humanSeconds(archive.duration)})</td>
                    </tr>
                    <tr>
                        <td>Id</td>
                        <td>{archive.id}</td>
                    </tr>
                    <tr>
                        <td>Stats</td>
                        <td>
                            <table className="inline">
                                <tbody>
                                <tr>
                                    <td>Compressed size</td>
                                    <td>{humanFileSize(archive.stats.compressed_size)}</td>
                                </tr>
                                <tr>
                                    <td>Deduplicated size</td>
                                    <td>{humanFileSize(archive.stats.deduplicated_size)}</td>
                                </tr>
                                <tr>
                                    <td>Original size</td>
                                    <td>{humanFileSize(archive.stats.original_size)}</td>
                                </tr>
                                <tr>
                                    <td>Nfiles</td>
                                    <td>{Number(archive.stats.nfiles).toLocaleString()}</td>
                                </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>Comment</td>
                        <td>{archive.comment}</td>
                    </tr>
                    <tr>
                        <td>Command line</td>
                        <td>{archive.commandLine.join(' ')}</td>
                    </tr>
                    <tr>
                        <td>Host name</td>
                        <td>{archive.hostname}</td>
                    </tr>
                    <tr>
                        <td>User name</td>
                        <td>{archive.username}</td>
                    </tr>
                    <tr>
                        <td>Chunker params</td>
                        <td>{archive.chunkerParams.join(', ')}</td>
                    </tr>
                    <tr>
                        <td>Limits</td>
                        <td>
                            <table className="inline">
                                <tbody>
                                <tr>
                                    <td>max_archive_size</td>
                                    <td>{archive.limits.max_archive_size}</td>
                                </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    </tbody>
                </Table>
            </React.Fragment>;
 
        }
        return <React.Fragment>
            <PageHeader>
                {pageHeader}
            </PageHeader>
            {content}
        </React.Fragment>;
    };
 
    constructor(props) {
        super(props);
 
        this.fetchArchive = this.fetchArchive.bind(this);
    }
}
 
export default ArchiveView;