diff options
Diffstat (limited to 'app/client/modules/biggan')
| -rw-r--r-- | app/client/modules/biggan/biggan.actions.js | 37 | ||||
| -rw-r--r-- | app/client/modules/biggan/biggan.reducer.js | 6 | ||||
| -rw-r--r-- | app/client/modules/biggan/views/biggan.encodingList.js | 68 | ||||
| -rw-r--r-- | app/client/modules/biggan/views/biggan.live.js | 4 |
4 files changed, 114 insertions, 1 deletions
diff --git a/app/client/modules/biggan/biggan.actions.js b/app/client/modules/biggan/biggan.actions.js index df78481..f09510c 100644 --- a/app/client/modules/biggan/biggan.actions.js +++ b/app/client/modules/biggan/biggan.actions.js @@ -155,7 +155,7 @@ export const load_directories = (id) => (dispatch) => { export const load_results = (id) => (dispatch) => { const module = bigganModule.name util.allProgress([ - actions.folder.index({ name: 'results' }), + actions.folder.index({ module, name: 'results' }), actions.file.index({ module, generated: 1, limit: 250 }), // actions.socket.list_directory({ module, dir: 'renders' }), // actions.socket.list_sequences({ module, dir: 'results' }), @@ -178,3 +178,38 @@ export const load_results = (id) => (dispatch) => { }) }) } + +export const load_encodings = () => dispatch => { + const module = bigganModule.name + util.allProgress([ + actions.folder.index({ module }), + actions.file.index({ + module, + datatype: 'image', + generated: 1, + }), + ], (folders, files) => { + console.log(folders, files) + const folder_name_lookup = {} + const encodings = {} + folders.forEach(folder => { + folder_name_lookup[folder.id] = folder.name + encodings[folder.name] = [] + }) + files.forEach(file => { + folder_name = folder_name_lookup[file.folder_id] + encodings[folder_name].push(file) + }) + folders.forEach(folder => { + if (!encodings[folder.name].length) { + delete encodings[folder_name] + } + }) + dispatch({ + type: types.biggan.load_encodings, + encodings + }) + + }) +} + diff --git a/app/client/modules/biggan/biggan.reducer.js b/app/client/modules/biggan/biggan.reducer.js index a0c9842..d5b331c 100644 --- a/app/client/modules/biggan/biggan.reducer.js +++ b/app/client/modules/biggan/biggan.reducer.js @@ -8,6 +8,7 @@ const bigganInitialState = { folder_id: 0, data: null, results: null, + encodings: null, checkpoint: { name: '', sequenceCount: 0, @@ -26,6 +27,11 @@ const bigganReducer = (state = bigganInitialState, action) => { ...state, results: action.results, } + case types.biggan.load_encodings: + return { + ...state, + encodings: action.encodings, + } case types.file.destroy: console.log('file destroy', state.results) return { diff --git a/app/client/modules/biggan/views/biggan.encodingList.js b/app/client/modules/biggan/views/biggan.encodingList.js new file mode 100644 index 0000000..d041e2e --- /dev/null +++ b/app/client/modules/biggan/views/biggan.encodingList.js @@ -0,0 +1,68 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import { + Loading +} from '../../../common/' + +import actions from '../../../actions' +import * as bigganTasks from '../biggan.tasks' +import * as bigganActions from '../biggan.actions' + +const ALL_CATEGORIES = 'inversion/categories/biggan_all.json' + +class BigGANEncodingList extends Component { + constructor() { + super() + if (!this.props.encodings) { + this.actions.biggan.load_encodings() + } + } + + render() { + const { encodings } = this.props + if (!encodings) { + return <div>Loading encodings...</div> + } + return ( + <div> + <div> + <select> + </select> + </div> + <div className="categories" ref={ref => this.categoryRef = ref}> + {Object.keys(encodings).sort().map(name => { + return ( + <div key={name}> + {encodings[name].map(file => ( + <img + key={file.id} + src={file.url} + onClick={() => actions.live.send_command('setEncoding', 'id=' + file.id)} + /> + ))} + </div> + ) + })} + </div> + </div> + ) + } + +} + +const mapStateToProps = state => ({ + opt: state.live.opt, + frame: state.live.frame, + biggan: state.module.biggan, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: { + biggan: bindActionCreators(bigganActions, dispatch), + tasks: bindActionCreators(bigganTasks, dispatch), + } +}) + +export default connect(mapStateToProps, mapDispatchToProps)(BigGANCategoryList) diff --git a/app/client/modules/biggan/views/biggan.live.js b/app/client/modules/biggan/views/biggan.live.js index af1edea..8d4a234 100644 --- a/app/client/modules/biggan/views/biggan.live.js +++ b/app/client/modules/biggan/views/biggan.live.js @@ -14,6 +14,7 @@ import * as queueActions from '../../../queue/queue.actions' import * as bigganTasks from '../biggan.tasks' import * as bigganActions from '../biggan.actions' import BigGANCategoryList from './biggan.categoryList.js' +import BigGANEncodingList from './biggan.encodingList.js' class BigGANLive extends Component { constructor(props) { @@ -120,6 +121,9 @@ class BigGANLive extends Component { <div className='params column'> <BigGANCategoryList /> </div> + <div className='params column'> + <BigGANEncodingList /> + </div> </div> </div> ) |
