From 6a7c471f46aaa08fde9d74740b619972ce79d6d8 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 1 Oct 2019 17:11:07 -0500 Subject: [PATCH] #40: Support for remote Windows mounts - partial --- public/electron.js | 4 +-- src/App.js | 5 ++-- src/assets/settings.json | 6 +++++ .../AddRemoteMount/AddRemoteMount.css | 4 +++ .../AddRemoteMount/AddRemoteMount.js | 17 ++++++++++++ src/components/MountItem/MountItem.css | 7 +++++ src/components/MountItem/MountItem.js | 26 ++++++++++--------- src/containers/Configuration/Configuration.js | 5 ++-- src/containers/MountItems/MountItems.css | 2 ++ src/containers/MountItems/MountItems.js | 25 ++++++++++++++++-- src/redux/reducers/mount_reducer.js | 1 + 11 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 src/components/AddRemoteMount/AddRemoteMount.css create mode 100644 src/components/AddRemoteMount/AddRemoteMount.js diff --git a/public/electron.js b/public/electron.js index a4741d6..7d63e37 100644 --- a/public/electron.js +++ b/public/electron.js @@ -77,9 +77,9 @@ const createWindow = () => { } // Create the browser window. - const height = (process.env.ELECTRON_START_URL || (os.platform() === 'darwin') ? 294 : 274) - ((os.platform() === 'win32') ? 0 : 20); + const height = (process.env.ELECTRON_START_URL || (os.platform() === 'darwin') ? 294 : 274) + 30 - ((os.platform() === 'win32') ? 0 : 20); mainWindow = new BrowserWindow({ - width: 428 + ((os.platform() === 'win32') ? 0 : (os.platform() === 'darwin') ? 150 : 160), + width: 468 + ((os.platform() === 'win32') ? 0 : (os.platform() === 'darwin') ? 150 : 160), height: height, fullscreen: false, resizable: false, diff --git a/src/App.js b/src/App.js index 3e3447f..81808ee 100644 --- a/src/App.js +++ b/src/App.js @@ -141,7 +141,7 @@ class App extends IPCContainer { let key = 0; mainContent.push((
+ style={{'paddingBottom': '4px'}}>
@@ -152,7 +152,8 @@ class App extends IPCContainer { + noConsoleSupported={noConsoleSupported} + remoteSupported={remoteSupported}/> )); } } diff --git a/src/assets/settings.json b/src/assets/settings.json index 1dc9ee5..9aea911 100644 --- a/src/assets/settings.json +++ b/src/assets/settings.json @@ -6,6 +6,12 @@ "HostNameOrIp": "IP address or host name of Sia/ScPrime daemon.", "TimeoutMs": "Number of milliseconds to wait for Sia/ScPrime API responses before timing out." }, + "RemoteMount": { + "EnableRemoteMount": "Allow mounting this location over TCP.", + "RemoteHostNameOrIp": "Host name or IP of host to connect to for remote mounting.", + "RemotePort": "TCP port used for remote mounting.", + "RemoteToken": "Encryption token used for remote mounts. This value must be the same on local and remote systems." + }, "Settings": { "ApiAuth": "Password used to communicate with Repertory's API. Auto-generated by default.", "ApiPort": "Repertory API port to use for JSON-RPC requests.", diff --git a/src/components/AddRemoteMount/AddRemoteMount.css b/src/components/AddRemoteMount/AddRemoteMount.css new file mode 100644 index 0000000..5a01963 --- /dev/null +++ b/src/components/AddRemoteMount/AddRemoteMount.css @@ -0,0 +1,4 @@ +.AddRemoteMount { + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/src/components/AddRemoteMount/AddRemoteMount.js b/src/components/AddRemoteMount/AddRemoteMount.js new file mode 100644 index 0000000..f2329ec --- /dev/null +++ b/src/components/AddRemoteMount/AddRemoteMount.js @@ -0,0 +1,17 @@ +import React from 'react'; +import './AddRemoteMount.css'; +import {connect} from 'react-redux'; +import Button from '../UI/Button/Button'; + +const mapDispatchToProps = dispatch => { + return { + } +}; + +export default connect(null, mapDispatchToProps)(props => { + return ( +
+ +
+ ); +}); \ No newline at end of file diff --git a/src/components/MountItem/MountItem.css b/src/components/MountItem/MountItem.css index 98470e8..c1c4e26 100644 --- a/src/components/MountItem/MountItem.css +++ b/src/components/MountItem/MountItem.css @@ -1,3 +1,10 @@ +.MountItem { + padding: 0; + margin: 0; + height: 56px; + overflow: visible; +} + input.MountItemInput { margin: 0; padding: 4px; diff --git a/src/components/MountItem/MountItem.js b/src/components/MountItem/MountItem.js index e89d0f8..480ff72 100644 --- a/src/components/MountItem/MountItem.js +++ b/src/components/MountItem/MountItem.js @@ -140,17 +140,19 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => { ); return ( - - {configButton} - - {inputControls} - {actionsDisplay} - {autoMountControl} - {autoRestartControl} - +
+ + {configButton} + + {inputControls} + {actionsDisplay} + {autoMountControl} + {autoRestartControl} + +
); }); \ No newline at end of file diff --git a/src/containers/Configuration/Configuration.js b/src/containers/Configuration/Configuration.js index af5ffc4..34c4263 100644 --- a/src/containers/Configuration/Configuration.js +++ b/src/containers/Configuration/Configuration.js @@ -88,7 +88,9 @@ class Configuration extends IPCContainer { advanced: template[key] ? template[key].advanced : false, label: key, remote: template[key] ? template[key].remote : false, - value: config[key], + value: (template[key] && (template[key].type === 'object')) ? + config[key] : + config[key].toString(), }; }) .filter(i=> { @@ -99,7 +101,6 @@ class Configuration extends IPCContainer { } return ret; }); - return { ObjectList: objectList, ItemList: itemList, diff --git a/src/containers/MountItems/MountItems.css b/src/containers/MountItems/MountItems.css index d9fbcb3..f09dd95 100644 --- a/src/containers/MountItems/MountItems.css +++ b/src/containers/MountItems/MountItems.css @@ -1,6 +1,8 @@ .MountItems { padding: 0; margin: 0; + height: 161px; width: 100%; box-sizing: border-box; + overflow-x: scroll; } \ No newline at end of file diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index 209502c..7cfbff5 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -1,4 +1,5 @@ import React from 'react'; +import AddRemoteMount from '../../components/AddRemoteMount/AddRemoteMount'; import Box from '../../components/UI/Box/Box'; import Button from '../../components/UI/Button/Button'; import {connect} from 'react-redux'; @@ -298,16 +299,35 @@ class MountItems extends IPCContainer { for (const provider of Constants.PROVIDER_LIST) { items.push(( this.handleMountLocationChanged(provider, e.target.value)} clicked={this.handleMountUnMount} key={'mi_' + items.length} provider={provider}/> )); - if (items.length !== this.state.length) { + items.push(
) + } + + if (this.props.remoteSupported) { + for (const provider of this.props.RemoteMounts) { + items.push(( + this.handleMountLocationChanged(provider, e.target.value)} + clicked={this.handleMountUnMount} + key={'mi_' + items.length} + provider={provider}/> + )); items.push(
) + style={{paddingTop: '4px'}}/>) } + + items.push(); + } else { + items.splice(items.length - 1, 1) } return ( @@ -326,6 +346,7 @@ const mapStateToProps = state => { MountsBusy: state.mounts.MountsBusy, Platform: state.common.Platform, ProviderState: state.mounts.ProviderState, + RemoteMounts: state.mounts.RemoteMounts, } }; diff --git a/src/redux/reducers/mount_reducer.js b/src/redux/reducers/mount_reducer.js index 75e25a7..5843823 100644 --- a/src/redux/reducers/mount_reducer.js +++ b/src/redux/reducers/mount_reducer.js @@ -47,6 +47,7 @@ export const mountReducer = createReducer({ MountsBusy: false, MountState: mountState, ProviderState: providerState, + RemoteMounts: [], }, { [displayConfiguration]: (state, action) => { return {