diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-21 22:49:55 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-21 22:49:55 +0200 |
| commit | 15d5cea9d1d94a6893ef1a55a916e68a182e5394 (patch) | |
| tree | b0d71498d2a0649c7180940a38d2fbfa595ca515 /app/client/browser | |
| parent | 270d9ccc3f93f29559dbf9c746070812a63e99e1 (diff) | |
browser is just a component
Diffstat (limited to 'app/client/browser')
| -rw-r--r-- | app/client/browser/browser.actions.js | 3 | ||||
| -rw-r--r-- | app/client/browser/browser.component.js | 90 | ||||
| -rw-r--r-- | app/client/browser/browser.reducer.js | 40 |
3 files changed, 0 insertions, 133 deletions
diff --git a/app/client/browser/browser.actions.js b/app/client/browser/browser.actions.js deleted file mode 100644 index 81b9c7c..0000000 --- a/app/client/browser/browser.actions.js +++ /dev/null @@ -1,3 +0,0 @@ -import types from '../types' -import actions from '../actions' -import util from '../util' diff --git a/app/client/browser/browser.component.js b/app/client/browser/browser.component.js deleted file mode 100644 index 076b4b4..0000000 --- a/app/client/browser/browser.component.js +++ /dev/null @@ -1,90 +0,0 @@ -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 Browser extends Component { - state = { - dir: '/', - module: 'pix2pixhd', - 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 { module } = this.state - 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 { module } = this.state - 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, module, files, - loadingFile, file, - } = this.state - console.log(this.props, this.state) - return ( - <div className='app browser'> - <h1>{dir}{dir[dir.length-1] !== '/' && '/'}</h1> - {app.tool}<br/> - {loading && <Loading />} - <FileList - files={files} - groupDirectories - parentDirectory={dir !== '/'} - orderBy='name asc' - fields={'name datetime size'} - onClick={(file, e) => { - 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 && <Loading />} - {file && <FileViewer file={file} />} - </div> - ) - } -} - -const mapStateToProps = state => ({ - app: state.system.app, -}) - -const mapDispatchToProps = (dispatch, ownProps) => ({ - actions: bindActionCreators({}, dispatch), -}) - -export default connect(mapStateToProps, mapDispatchToProps)(Browser) diff --git a/app/client/browser/browser.reducer.js b/app/client/browser/browser.reducer.js deleted file mode 100644 index 099176f..0000000 --- a/app/client/browser/browser.reducer.js +++ /dev/null @@ -1,40 +0,0 @@ -import types from '../types' - -import moment from 'moment/min/moment.min' -let FileSaver = require('file-saver') - -const browserInitialState = { - loading: false, - progress: null, - error: null, - data: {}, - images: [ - ], - files: [ - ] -} - -const browserReducer = (state = browserInitialState, action) => { - switch(action.type) { - case types.app.load_progress: - if (!action.data || action.data.module !== 'browser') { - return state - } - return { - ...state, - loading: true, - progress: action.progress, - } - case types.app.load: - return { - ...state, - loading: false, - error: null, - data: action.data, - } - default: - return state - } -} - -export default browserReducer |
