From 3c9ccd38751501bbf5b9cd2c54dee370681fdb5b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 20 Sep 2018 02:52:55 +0200 Subject: stub file viewer --- app/client/browser/browser.component.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'app/client/browser') 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 (
@@ -65,6 +80,7 @@ class Browser extends Component { this.fetch(this.state.dir.split('/').slice(0, -1).join('') || '/') }} /> + {loadingFile && }
) } -- cgit v1.2.3-70-g09d2