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 { Loading, FolderList, FileList, TaskList, Gallery } from '../common' 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 { loading, progress, site, foldersByModule, renders, queue, images } = this.props if (loading) { return } const { tasks } = queue const folders = foldersByModule && Object.keys(modules).sort().map(key => { let path = key === 'samplernn' ? '/samplernn/datasets/' : '/' + key + '/sequences/' let folder_list = (foldersByModule[key] || []).map(folder => { return (
{folder.name}
) }) let files = renders[key] && ( { e.preventDefault() e.stopPropagation() console.log('picked a file', file) this.handlePick(file) } : null} /> ); return (

{key}

new
{folder_list}
{files}
) }).filter(a => !!a) return (
{!!queue.queue.length && tasks[id])} /> } {!!queue.completed.length && tasks[id])} /> }
{folders}
) } handlePick(file){ this.props.audioPlayer.play(file) } } const mapStateToProps = state => ({ loading: state.dashboard.loading, progress: state.dashboard.progress, 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)