diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-16 14:03:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-16 14:03:04 +0200 |
| commit | 3504248ae4db51380413c45699e4453efb314561 (patch) | |
| tree | 07a4e906ae37e0967c3ecb1b53732537badcda0a /app/client/dashboard | |
| parent | 8955da42bd3b66543ecea80f00ec979a6140f5bc (diff) | |
load folders into dashboard...
Diffstat (limited to 'app/client/dashboard')
| -rw-r--r-- | app/client/dashboard/dashboard.actions.js | 30 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.component.js | 23 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.reducer.js | 26 | ||||
| -rw-r--r-- | app/client/dashboard/dashboardHeader.component.js | 6 | ||||
| -rw-r--r-- | app/client/dashboard/tasklist.component.js | 15 |
5 files changed, 72 insertions, 28 deletions
diff --git a/app/client/dashboard/dashboard.actions.js b/app/client/dashboard/dashboard.actions.js index 01c0a96..319c164 100644 --- a/app/client/dashboard/dashboard.actions.js +++ b/app/client/dashboard/dashboard.actions.js @@ -1 +1,31 @@ import types from '../types' +import actions from '../actions' +import util from '../util' + +export const load = () => (dispatch) => { + util.allProgress([ + actions.task.index(), + actions.folder.index(), + ], (percent, i, n) => { + console.log('dashboard load progress', i, n) + dispatch({ type: types.app.load_progress, progress: { i, n }}) + }).then(res => { + const [ tasks, folders ] = res + const { mapFn, sortFn } = util.sort.orderByFn('date desc') + const foldersByModule = folders.map(mapFn).sort(sortFn).reduce((a,b) => { + const module = b[1].module + a[module] = a[module] || [] + a[module].push(b[1]) + return a + }, {}) + dispatch({ + type: types.dashboard.load, + data: { + tasks, + folders, + foldersByModule, + }, + }) + + }) +}
\ No newline at end of file diff --git a/app/client/dashboard/dashboard.component.js b/app/client/dashboard/dashboard.component.js index b248062..58808a3 100644 --- a/app/client/dashboard/dashboard.component.js +++ b/app/client/dashboard/dashboard.component.js @@ -10,29 +10,38 @@ import Button from '../common/button.component' import DashboardHeader from './dashboardheader.component' import TaskList from './tasklist.component' -import { FileList } from '../common/fileList.component' +import { FileList } from '../common' import Gallery from '../common/gallery.component' import * as dashboardActions from './dashboard.actions' +import modules from '../modules' import actions from '../actions' class Dashboard extends Component { constructor(props){ super() - actions.task.index() + console.log(props) + props.actions.load() } componentWillUpdate(nextProps) { // if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { // this.props.actions.list_epochs(nextProps.opt.checkpoint_name) - // } } render(){ - const { site, queue, images } = this.props + const { site, foldersByModule, queue, images } = this.props const { tasks } = queue + const folders = foldersByModule && Object.keys(modules).sort().map(key => { + console.log(key) + console.log(foldersByModule[key]) + return ( + <div> + </div> + ) + }) return ( <div className='app dashboard'> <DashboardHeader /> - <div className='params'> + <div className='params row'> <div className='column'> {!!queue.queue.length && <Group title='Upcoming Tasks'> @@ -45,6 +54,9 @@ class Dashboard extends Component { </Group> } </div> + <div className='column'> + {folders} + </div> </div> </div> ) @@ -52,6 +64,7 @@ class Dashboard extends Component { } const mapStateToProps = state => ({ site: state.system.site, + foldersByModule: state.dashboard.data.foldersByModule, images: state.dashboard.images, files: state.dashboard.files, queue: state.queue, diff --git a/app/client/dashboard/dashboard.reducer.js b/app/client/dashboard/dashboard.reducer.js index 067b1ab..812a501 100644 --- a/app/client/dashboard/dashboard.reducer.js +++ b/app/client/dashboard/dashboard.reducer.js @@ -1,26 +1,13 @@ +import types from '../types' + import moment from 'moment/min/moment.min' let FileSaver = require('file-saver') const dashboardInitialState = { loading: false, error: null, - + data: {}, images: [ - { - url: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4282/woodscaled_4_true_20180521_2125.png', - }, - { - url: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4282/woodscaled_4_true_20180521_2146%20(1).png', - }, - { - url: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4282/woodscaled_4_true_20180521_2149.png', - }, - { - url: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4282/woodscaled_4_true_20180521_2150.png', - }, - { - url: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4282/woodscaled_4_true_20180521_2146%20(1).png', - }, ], files: [ ] @@ -28,6 +15,13 @@ const dashboardInitialState = { const dashboardReducer = (state = dashboardInitialState, action) => { switch(action.type) { + case types.dashboard.load: + return { + ...state, + loading: false, + error: null, + data: action.data, + } default: return state } diff --git a/app/client/dashboard/dashboardHeader.component.js b/app/client/dashboard/dashboardHeader.component.js index d27a324..9acee35 100644 --- a/app/client/dashboard/dashboardHeader.component.js +++ b/app/client/dashboard/dashboardHeader.component.js @@ -28,7 +28,9 @@ class DashboardHeader extends Component { return null } const task = gpu.task - const eta = ((task.epochs - (task.epoch || 0)) * 180 / 60) + " minutes" + const eta = task.epoch + ? ((task.epochs - (task.epoch || 0)) * 1000 / 60) + " minutes" + : null let activityPhrase, liveMessage if (task.activity === 'live') { return ( @@ -41,7 +43,7 @@ class DashboardHeader extends Component { return ( <div> Currently {util.gerund(task.activity)} {task.module} on {task.dataset}<br/> - Epoch: {task.epoch} / {task.epochs}, ETA {eta}<br/> + {eta && <span>Epoch: {task.epoch} / {task.epochs}, ETA {eta}<br/></span>} <br /> Want to play live? <button>Pause at the end of this epoch</button> </div> diff --git a/app/client/dashboard/tasklist.component.js b/app/client/dashboard/tasklist.component.js index 8817096..3de6efe 100644 --- a/app/client/dashboard/tasklist.component.js +++ b/app/client/dashboard/tasklist.component.js @@ -16,15 +16,20 @@ class TaskList extends Component { const { mapFn, sortFn } = util.sort.orderByFn('date desc') const taskList = tasks.map(mapFn).sort(sortFn).map(pair => { const task = pair[1] - console.log(task) const { dataset } = task - const href = '/' + task.module + - '/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') + - '/' + task.folder_id + '/' + let dataset_link; + if (task.folder_id) { + const href = '/' + task.module + + '/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') + + '/' + task.folder_id + '/' + dataset_link = <Link to={href}>{dataset}</Link> + } else { + dataset_link = dataset + } return ( <div class='row'> <div class='activity'>{task.activity} {task.module}</div> - <div class='dataset'><Link to={href}>{dataset}</Link></div> + <div class='dataset'>{dataset_link}</div> <div className={"age " + util.carbon_date(task.updated_at)}>{util.get_age(task.updated_at)}</div> <div class='options'> <span class='destroy' onClick={() => this.handleDestroy(task)}>x</span> |
