#48: Support pinning files to cache [partial]

This commit is contained in:
2020-12-11 21:44:05 -06:00
parent 775b852f91
commit 0ddddec220
2 changed files with 64 additions and 56 deletions

View File

@@ -96,29 +96,29 @@ class Configuration extends IPCContainer {
createItemList = (config, template) => { createItemList = (config, template) => {
const objectList = []; const objectList = [];
const itemList = Object const itemList = Object
.keys(config) .keys(config)
.map(key => { .map(key => {
return { return {
advanced: template[key] ? template[key].advanced : false, advanced: template[key] ? template[key].advanced : false,
hide_remote: template[key] ? template[key].hide_remote : false, hide_remote: template[key] ? template[key].hide_remote : false,
label: key, label: key,
remote: template[key] ? template[key].remote : false, remote: template[key] ? template[key].remote : false,
type: template[key] ? template[key].type : null, type: template[key] ? template[key].type : null,
value: (template[key] && (template[key].type === 'object')) ? value: (template[key] && (template[key].type === 'object')) ?
config[key] :
(template[key] && (template[key].type === 'string_array')) ?
config[key] : config[key] :
(template[key] && (template[key].type === 'string_array')) ? config[key].toString(),
config[key] : };
config[key].toString(), })
}; .filter(i => {
}) let ret = template[i.label];
.filter(i=> { if (ret && (template[i.label].type === 'object')) {
let ret = template[i.label]; objectList.push(i);
if (ret && (template[i.label].type === 'object')) { ret = false;
objectList.push(i); }
ret = false; return ret;
} });
return ret;
});
return { return {
ObjectList: objectList, ObjectList: objectList,
ItemList: itemList, ItemList: itemList,
@@ -190,7 +190,7 @@ class Configuration extends IPCContainer {
if (arg.data.Success) { if (arg.data.Success) {
this.setState({ this.setState({
Template: arg.data.Template, Template: arg.data.Template,
}, ()=> { }, () => {
this.sendRequest(Constants.IPC_Get_Config, { this.sendRequest(Constants.IPC_Get_Config, {
Provider: this.props.DisplayConfiguration, Provider: this.props.DisplayConfiguration,
Remote: this.props.DisplayRemoteConfiguration, Remote: this.props.DisplayRemoteConfiguration,
@@ -214,7 +214,7 @@ class Configuration extends IPCContainer {
saveAndClose = () => { saveAndClose = () => {
this.setState({ this.setState({
Saving: true, Saving: true,
}, ()=> { }, () => {
const changedItems = []; const changedItems = [];
for (const item of this.state.ChangedItems) { for (const item of this.state.ChangedItems) {
changedItems.push({ changedItems.push({
@@ -274,12 +274,17 @@ class Configuration extends IPCContainer {
<Modal> <Modal>
<Box dxStyle={{width: '40vw', padding: 'var(--default_spacing)'}}> <Box dxStyle={{width: '40vw', padding: 'var(--default_spacing)'}}>
<h1 style={{width: '100%', textAlign: 'center'}}>Save Changes?</h1> <h1 style={{width: '100%', textAlign: 'center'}}>Save Changes?</h1>
<table width='100%'><tbody> <table width='100%'>
<tbody>
<tr> <tr>
<td align='center' width='50%'><Button clicked={this.saveAndClose} disabled={this.state.Saving}>Yes</Button></td> <td align='center' width='50%'><Button clicked={this.saveAndClose}
<td align='center' width='50%'><Button clicked={this.props.hideConfiguration} disabled={this.state.Saving}>No</Button></td> disabled={this.state.Saving}>Yes</Button>
</td>
<td align='center' width='50%'><Button clicked={this.props.hideConfiguration}
disabled={this.state.Saving}>No</Button></td>
</tr> </tr>
</tbody></table> </tbody>
</table>
</Box> </Box>
</Modal> </Modal>
); );
@@ -301,7 +306,7 @@ class Configuration extends IPCContainer {
(!k.advanced || (this.state.ShowAdvanced && k.advanced && !k.remote) || this.showRemoteConfigItem(k, this.state.ObjectLookup[key])) ? (!k.advanced || (this.state.ShowAdvanced && k.advanced && !k.remote) || this.showRemoteConfigItem(k, this.state.ObjectLookup[key])) ?
<ConfigurationItem advanced={k.advanced} <ConfigurationItem advanced={k.advanced}
autoFocus={shouldFocus} autoFocus={shouldFocus}
changed={e=>this.handleObjectItemChanged(e, key, i)} changed={e => this.handleObjectItemChanged(e, key, i)}
grouping={key} grouping={key}
items={this.state.Template[key].template[k.label].items} items={this.state.Template[key].template[k.label].items}
key={i} key={i}
@@ -318,23 +323,23 @@ class Configuration extends IPCContainer {
} }
const configurationItems = this.state.ItemList const configurationItems = this.state.ItemList
.map((k, i) => { .map((k, i) => {
const shouldFocus = autoFocus; const shouldFocus = autoFocus;
autoFocus = false; autoFocus = false;
return ( return (
((!this.state.IsRemoteMount || !k.hide_remote) && (!k.advanced || (this.state.ShowAdvanced && k.advanced))) ? ((!this.state.IsRemoteMount || !k.hide_remote) && (!k.advanced || (this.state.ShowAdvanced && k.advanced))) ?
<ConfigurationItem advanced={k.advanced} <ConfigurationItem advanced={k.advanced}
autoFocus={shouldFocus} autoFocus={shouldFocus}
changed={e=>this.handleItemChanged(e, i)} changed={e => this.handleItemChanged(e, i)}
grouping={'Settings'} grouping={'Settings'}
items={this.state.Template[k.label].items} items={this.state.Template[k.label].items}
key={i} key={i}
label={k.label} label={k.label}
template={this.state.Template[k.label]} template={this.state.Template[k.label]}
value={k.value}/> : value={k.value}/> :
null null
); );
}); });
return ( return (
<div className={'Configuration'}> <div className={'Configuration'}>
@@ -355,14 +360,16 @@ class Configuration extends IPCContainer {
<h1 style={{width: '100%', textAlign: 'center'}}>{( <h1 style={{width: '100%', textAlign: 'center'}}>{(
this.props.DisplayRemoteConfiguration ? this.props.DisplayRemoteConfiguration ?
this.props.DisplayConfiguration.substr(6) : this.props.DisplayConfiguration.substr(6) :
this.props.DisplayConfiguration) + ' Configuration '}<a href={'#'} this.props.DisplayConfiguration) + ' Configuration '}
className={'ConfigurationLink'}
onClick={() => {
this.props.displayPinnedManager(true);
return false;
}}><u>Pinned Files</u></a>
</h1> </h1>
<div style={{overflowY: 'auto', height: '90%'}}> <div style={{overflowY: 'auto', height: '90%'}}>
{this.props.MState.Mounted ? <Button
buttonStyles={{width: 'auto', height: 'auto', marginLeft: 'auto', marginRight: '4px'}}
clicked={() => {
this.props.displayPinnedManager(true);
return false;
}}>&nbsp;Pinned File Manager...&nbsp;</Button> : null}
<div style={{marginBottom: '4px'}}/>
{objectItems} {objectItems}
{(configurationItems.length > 0) ? <h2>Settings</h2> : null} {(configurationItems.length > 0) ? <h2>Settings</h2> : null}
{configurationItems} {configurationItems}
@@ -378,6 +385,7 @@ const mapStateToProps = state => {
DisplayConfiguration: state.mounts.DisplayConfiguration, DisplayConfiguration: state.mounts.DisplayConfiguration,
DisplayRemoteConfiguration: state.mounts.DisplayRemoteConfiguration, DisplayRemoteConfiguration: state.mounts.DisplayRemoteConfiguration,
DisplayS3Configuration: state.mounts.DisplayS3Configuration, DisplayS3Configuration: state.mounts.DisplayS3Configuration,
MState: state.mounts.MountState[state.mounts.DisplayConfiguration],
Platform: state.common.Platform, Platform: state.common.Platform,
} }
}; };

View File

@@ -25,7 +25,7 @@ const mapDispatchToProps = dispatch => {
return { return {
displayPinnedManager: display => dispatch(displayPinnedManager(display)), displayPinnedManager: display => dispatch(displayPinnedManager(display)),
notifyApplicationBusy: busy => dispatch(notifyApplicationBusy(busy, true)), notifyApplicationBusy: busy => dispatch(notifyApplicationBusy(busy, true)),
notifyError: msg => dispatch(notifyError(msg)), notifyError: (msg, cb) => dispatch(notifyError(msg, false, cb)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)), notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
} }
}; };
@@ -63,7 +63,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
.map(i => { .map(i => {
return { return {
...i, ...i,
name: i.path === '..' ? i.path : '\'' + i.path.substr(i.path.lastIndexOf('/') + 1) + '\'', name: i.path === '..' ? i.path : i.path.substr(i.path.lastIndexOf('/') + 1),
meta: { meta: {
...i.meta, ...i.meta,
pinned: i.meta.pinned === '1', pinned: i.meta.pinned === '1',
@@ -74,7 +74,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
items, items,
}); });
} else { } else {
this.props.notifyError(data.Error, false, () => { this.props.notifyError(data.Error, () => {
this.props.displayPinnedManager(false); this.props.displayPinnedManager(false);
}); });
} }
@@ -159,7 +159,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
style={{cursor: 'pointer'}}>X</a> style={{cursor: 'pointer'}}>X</a>
</div> </div>
<h1 style={{width: '100%', textAlign: 'center'}}>{'Pinned File Manager'}</h1> <h1 style={{width: '100%', textAlign: 'center'}}>{'Pinned File Manager'}</h1>
<h2 className={'PinnedManagerActiveDirectory'}>{this.state.active_directory}</h2> <div className={'PinnedManagerActiveDirectory'}><b>{this.state.active_directory}</b></div>
<div className={'PinnedManagerItems'}> <div className={'PinnedManagerItems'}>
{ {
this.state.items.map((i, k) => { this.state.items.map((i, k) => {