From 3504248ae4db51380413c45699e4453efb314561 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 16 Jun 2018 14:03:04 +0200 Subject: load folders into dashboard... --- app/client/dashboard/dashboard.actions.js | 30 +++++++++++++++++++++++ app/client/dashboard/dashboard.component.js | 23 +++++++++++++---- app/client/dashboard/dashboard.reducer.js | 26 ++++++++------------ app/client/dashboard/dashboardHeader.component.js | 6 +++-- app/client/dashboard/tasklist.component.js | 15 ++++++++---- 5 files changed, 72 insertions(+), 28 deletions(-) (limited to 'app/client/dashboard') 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 ( +
+
+ ) + }) return (
-
+
{!!queue.queue.length && @@ -45,6 +54,9 @@ class Dashboard extends Component { }
+
+ {folders} +
) @@ -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 (
Currently {util.gerund(task.activity)} {task.module} on {task.dataset}
- Epoch: {task.epoch} / {task.epochs}, ETA {eta}
+ {eta && Epoch: {task.epoch} / {task.epochs}, ETA {eta}
}
Want to play live?
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 = {dataset} + } else { + dataset_link = dataset + } return (
{task.activity} {task.module}
-
{dataset}
+
{dataset_link}
{util.get_age(task.updated_at)}
this.handleDestroy(task)}>x -- cgit v1.2.3-70-g09d2