summaryrefslogtreecommitdiff
path: root/app/client
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-01-16 02:05:42 +0100
committerJules Laplace <julescarbon@gmail.com>2019-01-16 02:05:42 +0100
commit0b3dc585a0b02a3426b45f5cd474f81a31d5bd7b (patch)
tree1362d4d5cb92b7f36a2fac4f9c34dc2d42142009 /app/client
parent477947fe83a37e82bced4d8e060f374aba287eb0 (diff)
uprez ui
Diffstat (limited to 'app/client')
-rw-r--r--app/client/common/fileList.component.js8
-rw-r--r--app/client/modules/pix2pixhd/index.js3
-rw-r--r--app/client/modules/pix2pixhd/pix2pixhd.actions.js33
-rw-r--r--app/client/modules/pix2pixhd/pix2pixhd.reducer.js5
-rw-r--r--app/client/modules/pix2pixhd/pix2pixhd.tasks.js18
-rw-r--r--app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js114
-rw-r--r--app/client/types.js2
7 files changed, 175 insertions, 8 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js
index 12f6865..c4da4d7 100644
--- a/app/client/common/fileList.component.js
+++ b/app/client/common/fileList.component.js
@@ -17,7 +17,8 @@ export const FileList = props => {
orderBy='name asc',
className='',
fileListClassName='filelist',
- rowClassName='row file'
+ rowClassName='row file',
+ options,
} = props
const { mapFn, sortFn } = util.sort.orderByFn(orderBy)
let sortedFiles = (files || [])
@@ -36,6 +37,7 @@ export const FileList = props => {
linkFiles={linkFiles}
onDelete={onDelete}
onClick={onClick}
+ options={options}
/>
})
if (!fileList || !fileList.length) {
@@ -73,7 +75,7 @@ export const FileList = props => {
}
export const FileRow = props => {
- const { file, linkFiles, onDelete, onClick, className='row file', username='' } = props
+ const { file, linkFiles, onDelete, onClick, className='row file', username='', options } = props
const fields = fieldSet(props.fields)
const size = util.hush_size(file.size)
@@ -146,7 +148,7 @@ export const FileRow = props => {
{fields.has('delete') && onDelete && file.id &&
<div className='destroy' onClick={(e) => onDelete(file)}>x</div>
}
- {props.options && props.options(file)}
+ {options && props.options(file)}
</div>
)
}
diff --git a/app/client/modules/pix2pixhd/index.js b/app/client/modules/pix2pixhd/index.js
index cbd3136..511f4a0 100644
--- a/app/client/modules/pix2pixhd/index.js
+++ b/app/client/modules/pix2pixhd/index.js
@@ -8,6 +8,7 @@ import util from '../../util'
import Pix2PixHDNew from './views/pix2pixhd.new'
import Pix2PixHDShow from './views/pix2pixhd.show'
import Pix2PixHDResults from './views/pix2pixhd.results'
+import Pix2PixHDUprez from './views/pix2pixhd.uprez'
import Pix2PixHDTrain from './views/pix2pixhd.train'
import Pix2PixHDLive from './views/pix2pixhd.live'
@@ -28,6 +29,7 @@ class router {
<Route exact path='/pix2pixhd/sequences/:id/' component={Pix2PixHDShow} />
<Route exact path='/pix2pixhd/train/' component={Pix2PixHDTrain} />
<Route exact path='/pix2pixhd/results/' component={Pix2PixHDResults} />
+ <Route exact path='/pix2pixhd/uprez/' component={Pix2PixHDUprez} />
<Route exact path='/pix2pixhd/live/' component={Pix2PixHDLive} />
</section>
)
@@ -40,6 +42,7 @@ function links(){
{ url: '/pix2pixhd/sequences/', name: 'sequences' },
{ url: '/pix2pixhd/train/', name: 'checkpoints' },
{ url: '/pix2pixhd/results/', name: 'results' },
+ { url: '/pix2pixhd/uprez/', name: 'uprez' },
{ url: '/pix2pixhd/live/', name: 'live' },
]
}
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js
index 68119e1..5a00741 100644
--- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js
+++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js
@@ -157,8 +157,8 @@ export const load_results = (id) => (dispatch) => {
util.allProgress([
actions.folder.index({ name: 'results' }),
actions.file.index({ module, generated: 1 }),
- actions.socket.list_sequences({ module, dir: 'results' }),
actions.socket.list_directory({ module, dir: 'renders' }),
+ actions.socket.list_sequences({ module, dir: 'results' }),
], (percent, i, n) => {
console.log('pix2pixhd load progress', i, n)
dispatch({
@@ -167,15 +167,42 @@ export const load_results = (id) => (dispatch) => {
data: { module: 'pix2pixhd' },
})
}).then(res => {
- const [folders, files, results, renders] = res //, datasets, results, output, datasetUsage, lossReport] = res
+ const [folders, files, renders, results] = res //, datasets, results, output, datasetUsage, lossReport] = res
// console.log(files, results, renders)
dispatch({
type: types.pix2pixhd.load_results,
results: {
resultsFolder: folders[0],
files,
- results,
renders,
+ results,
+ }
+ })
+ })
+}
+
+export const load_uprez = (id) => (dispatch) => {
+ const module = pix2pixhdModule.name
+ util.allProgress([
+ actions.folder.index({ name: 'results' }),
+ actions.socket.list_sequences({ module, dir: 'results' }),
+ actions.file.index({ module, activity: 'uprez' }),
+ ], (percent, i, n) => {
+ console.log('pix2pixhd load progress', i, n)
+ dispatch({
+ type: types.app.load_progress,
+ progress: { i, n },
+ data: { module: 'pix2pixhd' },
+ })
+ }).then(res => {
+ const [folders, results, files,] = res //, datasets, results, output, datasetUsage, lossReport] = res
+ // console.log(files, results, renders)
+ dispatch({
+ type: types.pix2pixhd.load_uprez,
+ uprez: {
+ resultsFolder: folders[0],
+ results,
+ files,
}
})
})
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
index 5a2afc0..7d6f6f3 100644
--- a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
+++ b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
@@ -26,6 +26,11 @@ const pix2pixhdReducer = (state = pix2pixhdInitialState, action) => {
...state,
results: action.results,
}
+ case types.pix2pixhd.load_uprez:
+ return {
+ ...state,
+ uprez: action.uprez,
+ }
case types.pix2pixhd.load_dataset_count:
return {
...state,
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js
index 36c0f36..ec864e3 100644
--- a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js
+++ b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js
@@ -89,4 +89,20 @@ export const splice_task = (opt) => dispatch => {
console.log(task)
console.log('add splice task')
return actions.queue.add_task(task)
-} \ No newline at end of file
+}
+
+export const uprez_task = (opt) => dispatch => {
+ const task = {
+ module: module.name,
+ activity: 'uprez',
+ dataset: opt.dataset,
+ folder_id: opt.folder_id,
+ opt: {
+ ...opt,
+ }
+ }
+ console.log(task)
+ console.log('add uprez task')
+ return actions.queue.add_task(task)
+}
+
diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js b/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js
new file mode 100644
index 0000000..b26eae9
--- /dev/null
+++ b/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js
@@ -0,0 +1,114 @@
+import { h, Component } from 'preact'
+import { bindActionCreators } from 'redux'
+import { Link } from 'react-router-dom';
+import { connect } from 'react-redux'
+import util from '../../../util'
+
+import actions from '../../../actions'
+
+import * as pix2pixhdActions from '../pix2pixhd.actions'
+import * as pix2pixhdTasks from '../pix2pixhd.tasks'
+
+import Loading from '../../../common/loading.component'
+import { FileList, FileRow } from '../../../common/fileList.component'
+
+let yes_count = 0
+
+class Pix2pixHDUprez extends Component {
+ constructor(props){
+ super()
+ if (!props.pix2pixhd.uprez) props.actions.load_uprez()
+ }
+ componentDidMount(){
+ yes_count = 0
+ }
+ render(){
+ if (! this.props.pix2pixhd.uprez) return <Loading progress={this.props.pix2pixhd.progress} />
+
+ const { resultsFolder, results, renders, files } = this.props.pix2pixhd.uprez
+ // console.log(resultsFolder, results)
+
+ return (
+ <div className='app pix2pixhd'>
+ <div className='heading row middle'>
+ <h1>Pix2PixHD Uprez</h1>
+ </div>
+ <div class='rows params renders'>
+
+ <h3>folders on server</h3>
+ <FileList
+ files={results}
+ orderBy='date desc'
+ fields={'name date count'}
+ onClick={(file, e) => {
+ e.preventDefault()
+ e.stopPropagation()
+ console.log('picked a result', file)
+ this.handlePick(file)
+ }}
+ options={file => {
+ console.log(file)
+ // create uprez task
+ return (
+ <div>
+ {' ~ '}
+ <a href='#' onClick={() => this.handleUprez(file, { end: 250 })}>Uprez 10 seconds</a>
+ {' ~ '}
+ <a href='#' onClick={() => this.handleUprez(file, { end: 1500 })}>Uprez 1 minute</a>
+ {' ~ '}
+ <a href='#' onClick={() => this.handleUprez(file)}>Uprez whole thing</a>
+ </div>
+ )
+ }}
+ />
+ <br />
+
+ <h3>uprezzed videos</h3>
+ <FileList
+ linkFiles
+ files={files}
+ orderBy='date desc'
+ fields={'name date size delete'}
+ onDelete={file => {
+ let yes;
+ if (yes_count < 3) {
+ yes = confirm('Are you sure you want to delete this file?')
+ } else {
+ yes = true
+ }
+ if (yes) {
+ yes_count += 1
+ console.log('delete: confirmed')
+ actions.file.destroy(file)
+ }
+ }}
+ />
+
+ </div>
+ </div>
+ )
+ }
+ handlePick(file){
+ // this.props.audioPlayer.play(file)
+ }
+ handleUprez(file, opt){
+ console.log(file)
+ this.props.remote.uprez_task({
+ is_result: true,
+ dataset: file.name,
+ ...opt
+ })
+ }
+}
+
+const mapStateToProps = state => ({
+ pix2pixhd: state.module.pix2pixhd,
+})
+
+const mapDispatchToProps = (dispatch, ownProps) => ({
+ actions: bindActionCreators(pix2pixhdActions, dispatch),
+ remote: bindActionCreators(pix2pixhdTasks, dispatch),
+ // audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(Pix2pixHDUprez)
diff --git a/app/client/types.js b/app/client/types.js
index cfb590a..d00ade5 100644
--- a/app/client/types.js
+++ b/app/client/types.js
@@ -119,7 +119,7 @@ export default {
'init', 'set_folder'
]),
pix2pixhd: with_type('pix2pixhd', [
- 'init', 'set_folder', 'load_results', 'load_dataset_count'
+ 'init', 'set_folder', 'load_results', 'load_dataset_count', 'load_uprez'
]),
pix2wav: with_type('pix2wav', [
'init', 'set_folder'