From ee2471bb4ad8e190c1f2c1c47817046a2c4d6b30 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 3 Jan 2020 15:35:26 +0100 Subject: adding biggan dataset stuff --- app/client/modules/biggan/views/biggan.show.js | 119 +++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 app/client/modules/biggan/views/biggan.show.js (limited to 'app/client/modules/biggan/views/biggan.show.js') diff --git a/app/client/modules/biggan/views/biggan.show.js b/app/client/modules/biggan/views/biggan.show.js new file mode 100644 index 0000000..8d85f87 --- /dev/null +++ b/app/client/modules/biggan/views/biggan.show.js @@ -0,0 +1,119 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import util from '../../../util' + +import * as bigganActions from '../biggan.actions' +import * as bigganTasks from '../biggan.tasks' + +import { Loading, CurrentTask, FileList, FileRow } from '../../../common' +import DatasetForm from '../../../dataset/dataset.form' +import NewDatasetForm from '../../../dataset/dataset.new' +import UploadStatus from '../../../dataset/upload.status' + +import DatasetComponent from '../../../dataset/dataset.component' + +import bigganModule from '../biggan.module' + +class BigGANShow extends Component { + constructor(props){ + super(props) + this.datasetActions = this.datasetActions.bind(this) + } + componentWillMount(){ + const id = this.props.match.params.id || localStorage.getItem('biggan.last_id') + console.log('load dataset:', id) + const { match, biggan, actions } = this.props + if (id === 'new') return + if (id) { + if (parseInt(id)) localStorage.setItem('biggan.last_id', id) + if (! biggan.folder || biggan.folder.id !== id) { + actions.load_directories(id) + } + } else { + this.props.history.push('/biggan/new/') + } + } + render(){ + const { biggan, match, history } = this.props + const { folderLookup } = (biggan.data || {}) + const folder = (folderLookup || {})[biggan.folder_id] || {} + + return ( +
+
+
+

{folder ? folder.name : }

+ +
+
+
+ {folder && folder.name && folder.name !== 'unsorted' && + + } +
+ + +
+
+ + { + e.preventDefault() + e.stopPropagation() + console.log('picked a file', file) + }} + datasetActions={this.datasetActions} + /> +
+ ) + } + datasetActions(dataset, isFetching=false, isProcessing=false){ + const { biggan, remote } = this.props + const input = biggan.data.fileLookup[dataset.input[0]] + if (! input) return null + if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null + return ( +
+
+
+ {dataset.isBuilt + ?
+ {'fetched '} + remote.clear_cache_task(dataset)}>rm +
+ : isFetching + ?
+ {'fetching'} +
+ :
+ remote.fetch_task(input.url, input.id, dataset.name)}>fetch +
+ } +
+ ) + } +} + +const mapStateToProps = state => ({ + biggan: state.module.biggan, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(bigganActions, dispatch), + remote: bindActionCreators(bigganTasks, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(BigGANShow) -- cgit v1.2.3-70-g09d2