From 0a89b14ec29e52e806e0aefc069f3f6dfde5c3a2 Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Mon, 14 Jan 2019 22:02:44 +0000
Subject: [PATCH] Auto-install borg...

---
 borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx |   76 ++++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx b/borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx
index 84f0e2d..3143c7e 100644
--- a/borgbutler-webapp/src/components/views/config/ConfigurationServerTab.jsx
+++ b/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>

--
Gitblit v1.10.0