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.new.js | 33 ++++++ app/client/modules/biggan/views/biggan.results.js | 105 +++++++++++++++++++ app/client/modules/biggan/views/biggan.show.js | 119 ++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 app/client/modules/biggan/views/biggan.new.js create mode 100644 app/client/modules/biggan/views/biggan.results.js create mode 100644 app/client/modules/biggan/views/biggan.show.js (limited to 'app/client/modules/biggan/views') diff --git a/app/client/modules/biggan/views/biggan.new.js b/app/client/modules/biggan/views/biggan.new.js new file mode 100644 index 0000000..0d0f74f --- /dev/null +++ b/app/client/modules/biggan/views/biggan.new.js @@ -0,0 +1,33 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' +import util from '../../../util' + +import { Views } from '../../../common' + +import * as bigganActions from '../biggan.actions' +import bigganModule from '../biggan.module' + +function BigGANNew(props){ + return ( + + ) +} + +const mapStateToProps = state => ({ + biggan: state.module.biggan, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(bigganActions, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(BigGANNew) + diff --git a/app/client/modules/biggan/views/biggan.results.js b/app/client/modules/biggan/views/biggan.results.js new file mode 100644 index 0000000..d76b301 --- /dev/null +++ b/app/client/modules/biggan/views/biggan.results.js @@ -0,0 +1,105 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { Link } from 'react-router-dom'; +import { connect } from 'react-redux' +import util from '../../../util' + +import actions from '../../../actions' + +import * as bigganActions from '../biggan.actions' +import * as bigganTasks from '../biggan.tasks' + +import Loading from '../../../common/loading.component' +import { FileList, FileRow } from '../../../common/fileList.component' + +let yes_count = 0 + +class BigGANResults extends Component { + constructor(props){ + super() + if (!props.biggan.results) props.actions.load_results() + } + componentDidMount(){ + yes_count = 0 + } + render(){ + if (! this.props.biggan.results) return + + const { resultsFolder, results, renders, files } = this.props.biggan.results + // console.log(resultsFolder, results) + + return ( +
+
+

BigGAN Results

+
+
+ + { + let yes; + if (yes_count < 3) { + yes = confirm('Are you sure you want to delete this file?') + } else { + yes = true + } + if (yes) { + yes_count += 1 + console.log('delete: confirmed') + actions.file.destroy(file) + } + }} + /> +
+ +

renders on server

+ { + e.preventDefault() + e.stopPropagation() + console.log('picked a result', file) + this.handlePick(file) + }} + /> +
+ +

folders on server

+ { + e.preventDefault() + e.stopPropagation() + console.log('picked a result', file) + this.handlePick(file) + }} + /> + +
+
+ ) + } + handlePick(file){ + // this.props.audioPlayer.play(file) + } +} + +const mapStateToProps = state => ({ + biggan: state.module.biggan, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(bigganActions, dispatch), + remote: bindActionCreators(bigganTasks, dispatch), + // audioPlayer: bindActionCreators(audioPlayerActions, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(bigganResults) 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