From 15d5cea9d1d94a6893ef1a55a916e68a182e5394 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Sep 2018 22:49:55 +0200 Subject: browser is just a component --- .../modules/pix2pixhd/views/sequence.editor.js | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/client/modules/pix2pixhd/views/sequence.editor.js (limited to 'app/client/modules/pix2pixhd/views/sequence.editor.js') diff --git a/app/client/modules/pix2pixhd/views/sequence.editor.js b/app/client/modules/pix2pixhd/views/sequence.editor.js new file mode 100644 index 0000000..9693805 --- /dev/null +++ b/app/client/modules/pix2pixhd/views/sequence.editor.js @@ -0,0 +1,89 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { Route, Link } from 'react-router-dom' + +import { Loading, FileList, FileViewer } from '../../common' + +import actions from '../actions' + +class SequenceEditor extends Component { + state = { + dir: '/', + files: [], + loading: true + } + componentDidMount() { + this.fetch(this.state.dir) + } + handlePick(file) { + console.log(file) + 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) + const { tool: module } = this.props.app + this.setState({ dir, file: null, loading: true }) + actions.socket.list_directory({ module, dir }).then(files => { + console.log(files) + this.setState({ dir, files, loading: false }) + }) + } + fetchFile(fn) { + console.log('fetch file', fn) + const { tool: module } = this.props.app + this.setState({ file: null, loadingFile: true }) + actions.socket.read_file({ module, fn }).then(file => { + console.log(file) + this.setState({ file, loadingFile: false }) + }) + } + render() { + const { app } = this.props + const { + loading, dir, files, + loadingFile, file, + } = this.state + console.log(this.props, this.state) + // return ( + //
+ //

{dir}{dir[dir.length-1] !== '/' && '/'}

+ // {app.tool}
+ // {loading && } + // { + // e.preventDefault() + // e.stopPropagation() + // console.log('picked a result', file) + // this.handlePick(file) + // }} + // onClickParent={e => { + // console.log('navigate up') + // this.fetch(this.state.dir.split('/').slice(0, -1).join('/') || '/') + // }} + // /> + // {loadingFile && } + // {file && } + //
+ // ) + } +} + +const mapStateToProps = state => ({ + app: state.system.app, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators({}, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(SequenceEditor) -- cgit v1.2.3-70-g09d2