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

Kai Reinhard
14.02.2019 0a89b14ec29e52e806e0aefc069f3f6dfde5c3a2
Auto-install borg...
3 files modified
107 ■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/config/Configuration.java 7 ●●●●● patch | view | raw | blame | history
borgbutler-webapp/src/components/views/config/ConfigurationPage.jsx 24 ●●●●● patch | view | raw | blame | history
borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx 76 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/config/Configuration.java
@@ -21,6 +21,13 @@
     */
    private static final String RESTORE_DIRNAME = "restore";
    @Getter
    private String[][] binaries = {
            {"freebsd64", "FreeBSD 64"},
            {"linux32", "Linux 32"},
            {"linux64", "Linux 64"},
            {"macosx64", "MacOS X 64"}};
    @JsonIgnore
    @Setter(AccessLevel.PACKAGE)
    private File workingDir;
borgbutler-webapp/src/components/views/config/ConfigurationPage.jsx
@@ -8,6 +8,7 @@
import ConfigAccountTab from "./ConfigurationAccountTab";
import ConfigServerTab from "./ConfigurationServerTab";
import LoadingOverlay from '../../general/loading/LoadingOverlay';
import ConfirmModal from '../../general/modal/ConfirmModal';
class ConfigurationPage
    extends React
@@ -20,11 +21,13 @@
        this.state = {
            activeTab: '1',
            loading: false,
            reload: false
            reload: false,
            confirmModal: false
        };
        this.onSave = this.onSave.bind(this);
        this.onCancel = this.onCancel.bind(this);
        this.toggleModal = this.toggleModal.bind(this);
    }
    toggleTab = tab => () => {
@@ -58,6 +61,12 @@
        this.setReload();
    }
    toggleModal() {
        this.setState({
            confirmModal: !this.state.confirmModal
        })
    }
    render() {
        // https://codepen.io/_arpy/pen/xYoyPW
        if (this.state.reload) {
@@ -65,6 +74,17 @@
        }
        return (
            <React.Fragment>
                <ConfirmModal
                    onConfirm={ConfigServerTab.clearAllCaches}
                    title={'Are you sure?'}
                    toggle={this.toggleModal}
                    open={this.state.confirmModal}
                >
                    Do you really want to clear all caches? All Archive file lists and caches for repo and archive
                    information will be cleared.
                    <br/>
                    This is a safe option but it may take some time to re-fill the caches (on demand) again.
                </ConfirmModal>
                <PageHeader><I18n name={'configuration'}/></PageHeader>
                <Nav tabs>
                    <NavLink
@@ -92,6 +112,8 @@
                </TabContent>
                <FormGroup>
                    <FormField length={12}>
                        <FormButton id={'clearAllCaches'} onClick={this.toggleModal}> Clear all caches
                        </FormButton>
                        <FormButton onClick={this.onCancel}
                                    hintKey="configuration.cancel.hint"><I18n name={'common.cancel'}/>
                        </FormButton>
borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx
@@ -1,10 +1,20 @@
import React from 'react';
import {FormButton, FormCheckbox, FormLabelField, FormLabelInputField} from '../../general/forms/FormComponents';
import {Button} from 'reactstrap';
import {
    FormCheckbox,
    FormField,
    FormGroup,
    FormInput,
    FormLabel,
    FormLabelField,
    FormLabelInputField,
    FormOption,
    FormSelect
} from '../../general/forms/FormComponents';
import {getRestServiceUrl} from '../../../utilities/global';
import I18n from '../../general/translation/I18n';
import ErrorAlertGenericRestFailure from '../../general/ErrorAlertGenericRestFailure';
import Loading from '../../general/Loading';
import ConfirmModal from '../../general/modal/ConfirmModal';
class ConfigServerTab extends React.Component {
    loadConfig = () => {
@@ -48,13 +58,12 @@
            showDemoRepos: true,
            maxArchiveContentCacheCapacityMb: 100,
            redirect: false,
            confirmModal: false
            binary: 'manual'
        };
        this.handleTextChange = this.handleTextChange.bind(this);
        this.handleCheckboxChange = this.handleCheckboxChange.bind(this);
        this.loadConfig = this.loadConfig.bind(this);
        this.toggleModal = this.toggleModal.bind(this);
    }
    componentDidMount() {
@@ -73,7 +82,7 @@
    save() {
        var config = {
            port: this.state.port,
            maxArchiveContentCacheCapacityMb : this.state.maxArchiveContentCacheCapacityMb,
            maxArchiveContentCacheCapacityMb: this.state.maxArchiveContentCacheCapacityMb,
            webDevelopmentMode: this.state.webDevelopmentMode,
            showDemoRepos: this.state.showDemoRepos
        };
@@ -96,12 +105,6 @@
        })
    }
    toggleModal() {
        this.setState({
            confirmModal: !this.state.confirmModal
        })
    }
    render() {
        if (this.state.loading) {
            return <Loading/>;
@@ -113,27 +116,38 @@
        return (
            <div>
                <ConfirmModal
                    onConfirm={ConfigServerTab.clearAllCaches}
                    title={'Are you sure?'}
                    toggle={this.toggleModal}
                    open={this.state.confirmModal}
                >
                    Do you really want to clear all caches? All Archive file lists and caches for repo and archive
                    information will be cleared.
                    <br/>
                    This is a safe option but it may take some time to re-fill the caches (on demand) again.
                </ConfirmModal>
                <form>
                    <FormLabelField>
                        <FormButton id={'clearAllCaches'} onClick={this.toggleModal}> Clear all caches
                        </FormButton>
                    </FormLabelField>
                    <FormGroup>
                        <FormLabel>{'Borg command'}</FormLabel>
                        <FormField length={2}>
                            <FormSelect
                                value={this.state.binary}
                                name={'binary'}
                                onChange={this.handleTextChange}
                                hint={'Choose your OS and BorgButler will download and use a ready to run borg binary from https://github.com/borgbackup/borg/releases or choose a manual installed version.'}
                            >
                                {this.state.binaries
                                    .map((binary, index) => <FormOption label={binary[1]} value={binary[0]}
                                                                        key={index}/>)}
                                <FormOption label={'Manual'} value={'manual'}/>
                            </FormSelect>
                        </FormField>
                        <FormField length={6}>
                            <FormInput name={'borgCommand'} value={this.state.borgCommand}
                                       onChange={this.handleTextChange}
                                       placeholder="Enter path of borg command"/>
                        </FormField>
                        <FormField length={2}>
                            <Button className={'outline-primary'} onClick={this.onCancel}
                                    hint={'Tests the borg version.'}>Test
                            </Button>
                        </FormField>
                    </FormGroup>
                    <FormLabelInputField label={'Port'} fieldLength={2} type="number" min={0} max={65535}
                                         step={1}
                                         name={'port'} value={this.state.port}
                                         onChange={this.handleTextChange}
                                         placeholder="Enter port" />
                                         placeholder="Enter port"/>
                    <FormLabelInputField label={'Maximum disc capacity (MB)'} fieldLength={2} type="number" min={50}
                                         max={10000}
                                         step={50}
@@ -141,18 +155,18 @@
                                         value={this.state.maxArchiveContentCacheCapacityMb}
                                         onChange={this.handleTextChange}
                                         placeholder="Enter maximum Capacity"
                                         hint={`Limits the cache size of archive file lists in the local cache directory: ${this.state.cacheDir}`} />
                                         hint={`Limits the cache size of archive file lists in the local cache directory: ${this.state.cacheDir}`}/>
                    <FormLabelField label={'Show demo repositories'} fieldLength={2}>
                        <FormCheckbox checked={this.state.showDemoRepos}
                                      hint={'If true, some demo repositories are shown for testing the functionality of BorgButler without any further configuration and running borg backups.'}
                                      name="showDemoRepos"
                                      onChange={this.handleCheckboxChange} />
                                      onChange={this.handleCheckboxChange}/>
                    </FormLabelField>
                    <FormLabelField label={<I18n name={'configuration.webDevelopmentMode'} />} fieldLength={2}>
                    <FormLabelField label={<I18n name={'configuration.webDevelopmentMode'}/>} fieldLength={2}>
                        <FormCheckbox checked={this.state.webDevelopmentMode}
                                      hintKey={'configuration.webDevelopmentMode.hint'}
                                      name="webDevelopmentMode"
                                      onChange={this.handleCheckboxChange} />
                                      onChange={this.handleCheckboxChange}/>
                    </FormLabelField>
                </form>
            </div>