diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-29 18:51:27 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-29 18:51:27 +0200 |
| commit | fe8cef1b709f09f508f17d0d6d06f204dd44a8bb (patch) | |
| tree | 75c03c0734106dda0a4e5b407778b58ec758d029 /app/client | |
| parent | 7d71a0248a8746088142bb51ce4248c76f274f30 (diff) | |
pushing files to s3.. filelist color
Diffstat (limited to 'app/client')
| -rw-r--r-- | app/client/api/crud.upload.js | 4 | ||||
| -rw-r--r-- | app/client/api/index.js | 1 | ||||
| -rw-r--r-- | app/client/api/util.js | 11 | ||||
| -rw-r--r-- | app/client/common/fileList.component.js | 2 | ||||
| -rw-r--r-- | app/client/common/header.component.js | 5 | ||||
| -rw-r--r-- | app/client/index.jsx | 3 | ||||
| -rw-r--r-- | app/client/live/live.reducer.js | 14 | ||||
| -rw-r--r-- | app/client/live/player.js | 43 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 1 |
9 files changed, 66 insertions, 18 deletions
diff --git a/app/client/api/crud.upload.js b/app/client/api/crud.upload.js index 97b6769..2e0269a 100644 --- a/app/client/api/crud.upload.js +++ b/app/client/api/crud.upload.js @@ -20,11 +20,13 @@ export function crud_upload(type, fd, data, dispatch) { dispatch && dispatch({ type: as_type(type, 'upload_loading')}) + let complete = false + function uploadProgress (e) { if (e.lengthComputable) { dispatch && dispatch({ type: as_type(type, 'upload_progress'), - percent: Math.round(e.loaded * 100 / e.total), + percent: Math.round(e.loaded * 100 / e.total) || 0, [type]: id, }) } diff --git a/app/client/api/index.js b/app/client/api/index.js index 82cd364..a0cae50 100644 --- a/app/client/api/index.js +++ b/app/client/api/index.js @@ -1,4 +1,5 @@ import { crud_actions } from './crud.actions' +import * as util from './util' /* for our crud events, create corresponding actions diff --git a/app/client/api/util.js b/app/client/api/util.js new file mode 100644 index 0000000..99d63b4 --- /dev/null +++ b/app/client/api/util.js @@ -0,0 +1,11 @@ +export const is_iphone = !!((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) +export const is_ipad = !!(navigator.userAgent.match(/iPad/i)) +export const is_android = !!(navigator.userAgent.match(/Android/i)) +export const is_mobile = is_iphone || is_ipad || is_android +export const is_desktop = ! is_mobile; + +const htmlClassList = document.body.parentNode.classList +htmlClassList.add(is_desktop ? 'desktop' : 'mobile') +htmlClassList.remove('loading') + +// window.debug = false diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 81eeddf..7f4e5fe 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -12,7 +12,7 @@ class FileList extends Component { const { files } = this.props const fileList = files.map(file => { return ( - <div class='row' key={file.name}> + <div class='row file' key={file.name}> <div className="filename">{file.name || file.url}</div> <div className="size">{file.size ? ((file.size) / 1024 / 1024).toFixed(1) + ' mb.' : ''}</div> <div className="date">{moment(file.created_at).format("YYYY-MM-DD H:mm")}</div> diff --git a/app/client/common/header.component.js b/app/client/common/header.component.js index 5c1c145..02d48b9 100644 --- a/app/client/common/header.component.js +++ b/app/client/common/header.component.js @@ -7,7 +7,7 @@ import * as systemActions from '../system/system.actions' import modules from '../modules' -function Header({ fps, app, actions }) { +function Header({ app, fps, playing, actions }) { const tool_list = Object.keys(modules).map((name, i) => { const label = name.replace(/_/, " ") return <option value={name} key={i}>{label}</option> @@ -24,7 +24,7 @@ function Header({ fps, app, actions }) { <span><Link to="/system">system</Link></span> <span><Link to="/dashboard">dashboard</Link></span> <Links /> - <span>{fps} fps</span> + {playing && <span>{fps} fps</span>} </header> ) } @@ -32,6 +32,7 @@ function Header({ fps, app, actions }) { const mapStateToProps = state => ({ app: state.system.app, fps: state.live.fps, + playing: state.live.playing, }) const mapDispatchToProps = (dispatch, ownProps) => ({ diff --git a/app/client/index.jsx b/app/client/index.jsx index eabf46e..8eb23ff 100644 --- a/app/client/index.jsx +++ b/app/client/index.jsx @@ -3,10 +3,9 @@ import { Provider } from 'react-redux' import { BrowserRouter, Route } from 'react-router-dom' // import client from './client' -window.debug = false - import { store, history } from './store' import * as socket from './socket' +import * as util from './util' import Header from './common/header.component' import System from './system/system.component' diff --git a/app/client/live/live.reducer.js b/app/client/live/live.reducer.js index 60bcb41..e7ef569 100644 --- a/app/client/live/live.reducer.js +++ b/app/client/live/live.reducer.js @@ -10,6 +10,7 @@ const liveInitialState = { epochs: ['latest'], sequences: [], fps: 0, + playing: false, frame: { i: 0, sequence_i: 0, sequence_len: '1' } } @@ -70,6 +71,18 @@ const liveReducer = (state = liveInitialState, action) => { frame: action.meta } : state + case types.player.pausing: + return { + ...state, + playing: false, + } + + case types.player.playing: + return { + ...state, + playing: true, + } + case types.player.start_recording: return { ...state, @@ -86,7 +99,6 @@ const liveReducer = (state = liveInitialState, action) => { recordFrames: (state.opt.recordFrames || 0) + 1, } } - case types.player.save_frame: FileSaver.saveAs( action.blob, diff --git a/app/client/live/player.js b/app/client/live/player.js index 808e79e..37f7cab 100644 --- a/app/client/live/player.js +++ b/app/client/live/player.js @@ -66,15 +66,36 @@ export function onFrame (data) { img.src = url } -setInterval(() => { - store.dispatch({ - type: types.player.set_fps, - fps: fps, - }) - store.dispatch({ - type: types.player.current_frame, - meta: last_frame, - }) - fps = 0 -}, 1000) +let previousValue, currentValue +function handleChange() { + let previousValue = currentValue + currentValue = store.getState().live.playing + + if (previousValue !== currentValue) { + if (currentValue) { + startWatchingFPS() + } else { + stopWatchingFPS() + } + } +} + +let fpsInterval; +function startWatchingFPS(){ + clearInterval(fpsInterval) + fpsInterval = setInterval(() => { + store.dispatch({ + type: types.player.set_fps, + fps: fps, + }) + store.dispatch({ + type: types.player.current_frame, + meta: last_frame, + }) + fps = 0 + }, 1000) +} +function stopWatchingFPS(){ + clearInterval(fpsInterval) +}
\ No newline at end of file diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index ed602ba..6a461a4 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -10,6 +10,7 @@ const samplernnInitialState = { } const samplernnReducer = (state = samplernnInitialState, action) => { + console.log(action) switch(action.type) { case types.socket.connect: return { |
