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
106
107
108
109
110
111
112
113
114
|
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import Player from '../common/player.component'
import Group from '../common/group.component'
import Slider from '../common/slider.component'
import Select from '../common/select.component'
import Button from '../common/button.component'
import DashboardHeader from './dashboardheader.component'
import TaskList from './tasklist.component'
import { FolderList, FileList } from '../common'
import Gallery from '../common/gallery.component'
import * as dashboardActions from './dashboard.actions'
import * as audioPlayerActions from '../common/audioPlayer/audioPlayer.actions'
import modules from '../modules'
import actions from '../actions'
class Dashboard extends Component {
constructor(props){
super()
console.log(props)
props.actions.load()
}
componentWillUpdate(nextProps) {
// if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) {
// this.props.actions.list_epochs(nextProps.opt.checkpoint_name)
}
render(){
const { site, foldersByModule, renders, queue, images } = this.props
const { tasks } = queue
const folders = foldersByModule && Object.keys(modules).sort().map(key => {
if (! foldersByModule[key]) return null
const path = key === 'samplernn' ? '/samplernn/datasets/' : '/' + key + '/sequences/'
const folders = foldersByModule[key].map(folder => {
return (
<div key={folder.id}>
<Link to={path + folder.id + '/'}>{folder.name}</Link>
</div>
)
})
let files = renders[key] && (
<FileList
linkFiles
files={renders[key]}
orderBy='date desc'
fields={'name date epoch size'}
onClick={(file, e) => {
e.preventDefault()
e.stopPropagation()
console.log('picked a file', file)
this.handlePick(file)
}}
/>
);
return (
<div className='dashboardModule' key={key}>
<div className='row moduleHeading'>
<h3>{key}</h3>
<div>
<Link to={'/' + key + '/new/'}>new</Link>
</div>
{folders}
</div>
{files}
</div>
)
}).filter(a => !!a)
return (
<div className='app dashboard'>
<DashboardHeader />
<div className='params row'>
<div className='column'>
{!!queue.queue.length &&
<Group title='Upcoming Tasks'>
<TaskList tasks={queue.queue.map(id => tasks[id])} />
</Group>
}
{!!queue.completed.length &&
<Group title='Completed Tasks'>
<TaskList tasks={queue.completed.map(id => tasks[id])} />
</Group>
}
</div>
<div className='column'>
{folders}
</div>
</div>
</div>
)
}
handlePick(file){
this.props.audioPlayer.play(file)
}
}
const mapStateToProps = state => ({
site: state.system.site,
foldersByModule: state.dashboard.data.foldersByModule,
renders: state.dashboard.data.renders,
images: state.dashboard.images,
files: state.dashboard.files,
queue: state.queue,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: bindActionCreators(dashboardActions, dispatch),
audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(Dashboard)
|