summaryrefslogtreecommitdiff
path: root/app/client
diff options
context:
space:
mode:
Diffstat (limited to 'app/client')
-rw-r--r--app/client/auth/auth.gate.js2
-rw-r--r--app/client/modules/biggan/biggan.tasks.js20
-rw-r--r--app/client/modules/biggan/index.js10
-rw-r--r--app/client/modules/biggan/views/biggan.new.js33
-rw-r--r--app/client/modules/biggan/views/biggan.results.js105
-rw-r--r--app/client/modules/biggan/views/biggan.show.js119
6 files changed, 287 insertions, 2 deletions
diff --git a/app/client/auth/auth.gate.js b/app/client/auth/auth.gate.js
index 40f244f..a75b22e 100644
--- a/app/client/auth/auth.gate.js
+++ b/app/client/auth/auth.gate.js
@@ -48,7 +48,7 @@ class AuthGate extends Component {
render(){
const { auth, env, actions } = this.props
if (env.production && !auth.initialized) {
- console.log('loading auth')
+ // console.log('loading auth')
return <div className='loading'>Loading</div>
}
if (env.development || auth.isAuthenticated) {
diff --git a/app/client/modules/biggan/biggan.tasks.js b/app/client/modules/biggan/biggan.tasks.js
index 827add5..2aed088 100644
--- a/app/client/modules/biggan/biggan.tasks.js
+++ b/app/client/modules/biggan/biggan.tasks.js
@@ -7,6 +7,25 @@ import actions from '../../actions'
import module from './biggan.module'
+export const invert_task = (dataset, folder_id, epochs=1) => dispatch => {
+ dataset = dataset.name || dataset
+ if (dataset === 'PLACEHOLDER') return
+ const task = {
+ module: module.name,
+ activity: 'invert',
+ dataset,
+ opt: {
+ folder_id: folder_id,
+ }
+ }
+ if (!task.dataset) {
+ console.error("invert task: no dataset specified")
+ return
+ }
+ console.log(task)
+ return actions.queue.add_task(task)
+}
+
export const live_task = (opt) => dispatch => {
const task = {
module: module.name,
@@ -14,7 +33,6 @@ export const live_task = (opt) => dispatch => {
dataset: 'biggan',
opt
}
- console.log(task)
console.log('add live task')
return actions.queue.add_task(task)
}
diff --git a/app/client/modules/biggan/index.js b/app/client/modules/biggan/index.js
index 6c94008..05d0213 100644
--- a/app/client/modules/biggan/index.js
+++ b/app/client/modules/biggan/index.js
@@ -5,6 +5,9 @@ import actions from '../../actions'
import util from '../../util'
+import BigGANNew from './views/biggan.new'
+import BigGANShow from './views/biggan.show'
+import BigGANResults from './views/biggan.results'
import BigGANLive from './views/biggan.live'
class router {
@@ -19,6 +22,10 @@ class router {
render(){
return (
<section>
+ <Route exact path='/biggan/new/' component={BigGANNew} />
+ <Route exact path='/biggan/datasets/' component={BigGANShow} />
+ <Route exact path='/biggan/datasets/:id/' component={BigGANShow} />
+ <Route exact path='/biggan/results/' component={BigGANResults} />
<Route exact path='/biggan/live/' component={BigGANLive} />
</section>
)
@@ -27,6 +34,9 @@ class router {
function links(){
return [
+ { url: '/biggan/new/', name: 'folders' },
+ { url: '/biggan/datasets/', name: 'datasets' },
+ { url: '/biggan/results/', name: 'results' },
{ url: '/biggan/live/', name: 'live' },
]
}
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 (
+ <Views.New
+ db={props.biggan}
+ path='/biggan/sequences/'
+ actions={props.actions}
+ module={bigganModule}
+ history={props.history}
+ />
+ )
+}
+
+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 <Loading progress={this.props.biggan.progress} />
+
+ const { resultsFolder, results, renders, files } = this.props.biggan.results
+ // console.log(resultsFolder, results)
+
+ return (
+ <div className='app biggan'>
+ <div className='heading row middle'>
+ <h1>BigGAN Results</h1>
+ </div>
+ <div class='rows params renders'>
+
+ <FileList
+ linkFiles
+ files={files}
+ orderBy='date desc'
+ fields={'name date size delete'}
+ onDelete={file => {
+ 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)
+ }
+ }}
+ />
+ <br />
+
+ <h3>renders on server</h3>
+ <FileList
+ files={renders}
+ orderBy='date desc'
+ fields={'name date size'}
+ onClick={(file, e) => {
+ e.preventDefault()
+ e.stopPropagation()
+ console.log('picked a result', file)
+ this.handlePick(file)
+ }}
+ />
+ <br />
+
+ <h3>folders on server</h3>
+ <FileList
+ files={results}
+ orderBy='date desc'
+ fields={'name date count'}
+ onClick={(file, e) => {
+ e.preventDefault()
+ e.stopPropagation()
+ console.log('picked a result', file)
+ this.handlePick(file)
+ }}
+ />
+
+ </div>
+ </div>
+ )
+ }
+ 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 (
+ <div className='app biggan'>
+ <div class='heading'>
+ <div class='spaced'>
+ <h1>{folder ? folder.name : <Loading />}</h1>
+ <UploadStatus />
+ </div>
+ </div>
+ <div className='row'>
+ {folder && folder.name && folder.name !== 'unsorted' &&
+ <DatasetForm
+ title='Add Files'
+ module={bigganModule}
+ folder={folder}
+ canUpload canAddURL
+ />
+ }
+ <div>
+ <UploadStatus />
+ <CurrentTask />
+ </div>
+ </div>
+
+ <DatasetComponent
+ loading={biggan.loading}
+ progress={biggan.progress}
+ id={biggan.folder_id}
+ module={bigganModule}
+ data={biggan.data}
+ folder={folder}
+ history={history}
+ onPickFile={(file, e) => {
+ e.preventDefault()
+ e.stopPropagation()
+ console.log('picked a file', file)
+ }}
+ datasetActions={this.datasetActions}
+ />
+ </div>
+ )
+ }
+ 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 (
+ <div>
+ <div class={'actions'}>
+ </div>
+ {dataset.isBuilt
+ ? <div class='subtext'>
+ {'fetched '}
+ <span class='link' onClick={() => remote.clear_cache_task(dataset)}>rm</span>
+ </div>
+ : isFetching
+ ? <div class='subtext'>
+ {'fetching'}
+ </div>
+ : <div class='subtext'>
+ <span class='link' onClick={() => remote.fetch_task(input.url, input.id, dataset.name)}>fetch</span>
+ </div>
+ }
+ </div>
+ )
+ }
+}
+
+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)