import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import {
ParamGroup, Param, Player, Group,
Slider, SelectGroup, Select, TextInput, Button, Loading
} from '../../../common/'
import { startRecording, stopRecording, saveFrame, toggleFPS } from '../../../live/player'
import * as liveActions from '../../../live/live.actions'
import * as queueActions from '../../../queue/queue.actions'
import * as bigganTasks from '../biggan.tasks'
import * as bigganActions from '../biggan.actions'
class BigGANLive extends Component {
constructor(props) {
super()
props.actions.live.get_params()
}
start(){
console.log(this.props.opt)
console.log('starting up!')
this.props.actions.tasks.live_task({
// folder_id: this.props.biggan.data.resultsFolder.id,
})
}
interrupt(){
this.props.actions.queue.stop_task('gpu')
}
render() {
const { biggan, actions } = this.props
console.log(actions)
// if (biggan.loading) {
// return
// }
return (
{this.renderRestartButton()}
{this.props.last_message}
)
}
renderRestartButton(){
// console.log(this.props.runner.gpu)
const { i18n } = this.props
if (this.props.runner.gpu.status === 'IDLE') {
return (
)
}
if (this.props.runner.gpu.task.module !== 'biggan') {
return (
)
}
if (! this.props.opt.processing) {
return (
)
}
return (
)
}
}
const mapStateToProps = state => ({
last_message: state.live.last_message,
fullscreen: state.live.fullscreen,
opt: state.live.opt,
frame: state.live.frame,
runner: state.system.runner,
i18n: state.system.i18n.strings,
biggan: state.module.biggan,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: {
live: bindActionCreators(liveActions, dispatch),
queue: bindActionCreators(queueActions, dispatch),
biggan: bindActionCreators(bigganActions, dispatch),
tasks: bindActionCreators(bigganTasks, dispatch),
}
})
export default connect(mapStateToProps, mapDispatchToProps)(BigGANLive)