1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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)
|