diff options
Diffstat (limited to 'app/client/browser/browser.component.js')
| -rw-r--r-- | app/client/browser/browser.component.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/client/browser/browser.component.js b/app/client/browser/browser.component.js index 767c5fb..5183161 100644 --- a/app/client/browser/browser.component.js +++ b/app/client/browser/browser.component.js @@ -27,7 +27,11 @@ class Browser extends Component { } handlePick(file) { console.log(file) - this.fetch([this.state.dir, file.name].join('/').replace('//','/')) + if (file.dir) { + this.fetch([this.state.dir, file.name].join('/').replace('//','/')) + } else { + this.fetchFile([this.state.dir, file.name].join('/').replace('//','/')) + } } fetch(dir) { console.log('fetch', dir) @@ -38,10 +42,21 @@ class Browser extends Component { this.setState({ dir, files, loading: false }) }) } + fetchFile(fn) { + console.log('fetch file', fn) + const { module } = this.state + this.setState({ file: null, loadingFile: true }) + actions.socket.read_file({ module, fn }).then(file => { + this.setState({ file, loadingFile: false }) + }) + } render() { const { app } = this.props - const { loading, dir, module, files } = this.state + const { + loading, dir, module, files, + loadingFile, file, + } = this.state console.log(this.props, this.state) return ( <div className='app browser'> @@ -65,6 +80,7 @@ class Browser extends Component { this.fetch(this.state.dir.split('/').slice(0, -1).join('') || '/') }} /> + {loadingFile && <Loading />} </div> ) } |
