import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import util from '../../../util' import * as pix2wavActions from '../pix2wav.actions' import * as pix2wavTasks from '../pix2wav.tasks' import Loading from '../../../common/loading.component' import DatasetForm from '../../../dataset/dataset.form' import NewDatasetForm from '../../../dataset/dataset.new' import UploadStatus from '../../../dataset/upload.status' import { FileList, FileRow } from '../../../common/fileList.component' import SpectrogramUpload from './spectrogram.upload' import DatasetComponent from '../../../dataset/dataset.component' import pix2wavModule from '../pix2wav.module' class Pix2wavShow extends Component { constructor(props){ super(props) this.datasetActions = this.datasetActions.bind(this) } componentWillMount(){ const id = this.props.match.params.id || localStorage.getItem('pix2wav.last_id') console.log('load dataset:', id) const { match, pix2wav, actions } = this.props if (id === 'new') return if (id) { if (parseInt(id)) localStorage.setItem('pix2wav.last_id', id) if (! pix2wav.folder || pix2wav.folder.id !== id) { actions.load_directories(id) } } else { this.props.history.push('/pix2wav/new/') } } render(){ const { pix2wav, match, history } = this.props const { folderLookup } = (pix2wav.data || {}) const folder = (folderLookup || {})[pix2wav.folder_id] || {} return (