From d41070c7b00fafc974a1a6e7b6d1b42391fa57ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Jul 2017 04:48:52 +0200 Subject: all async paths working --- client/components/Browser/Files/FileListView.jsx | 4 +-- .../components/Browser/Folders/FolderListView.jsx | 4 +-- client/components/Tasks/TaskListView.jsx | 41 ++++++++++++++++++---- client/components/UI/AudioPlayerView.jsx | 19 +++------- client/components/UI/Link.jsx | 8 ++--- 5 files changed, 46 insertions(+), 30 deletions(-) (limited to 'client/components') diff --git a/client/components/Browser/Files/FileListView.jsx b/client/components/Browser/Files/FileListView.jsx index 4615cf7..df59a1d 100644 --- a/client/components/Browser/Files/FileListView.jsx +++ b/client/components/Browser/Files/FileListView.jsx @@ -21,7 +21,7 @@ export default function FileListView (props) { return (
{file.name} - {file.processed ? file.mime : 'working...'} + {file.processed ? file.mime : '(waiting)'} {file.duration ? (file.duration.toFixed(1) + 's') : ''} content @@ -39,7 +39,7 @@ export default function FileListView (props) {
-
+
{files}
diff --git a/client/components/Browser/Folders/FolderListView.jsx b/client/components/Browser/Folders/FolderListView.jsx index 0a0d0e2..e9d2d44 100644 --- a/client/components/Browser/Folders/FolderListView.jsx +++ b/client/components/Browser/Folders/FolderListView.jsx @@ -3,7 +3,7 @@ import { h, Component } from 'preact' export default function FolderListView (props) { const folders = props.folders.map( (folder, i) => (
props.openFolder(folder)}> - {folder.name} + {folder.name}
)) @@ -15,7 +15,7 @@ export default function FolderListView (props) { -
+
{folders}
diff --git a/client/components/Tasks/TaskListView.jsx b/client/components/Tasks/TaskListView.jsx index 47be794..b93ecc3 100644 --- a/client/components/Tasks/TaskListView.jsx +++ b/client/components/Tasks/TaskListView.jsx @@ -1,24 +1,51 @@ import { h, Component } from 'preact' +import format from '../../vendor/format.js' import FileLink from '../../containers/fileLink.js' export default function TaskListView (props) { const tasks = (props.tasks || []).map( (task, i) => { - return ( -
- {task.id} - {task.created_at} + const created_at = format.verboseDate(task.created_at) + let files = [] + let cancel + if (task.content_file) { + files.push( + ) + } + if (task.style_file) { + files.push( - α={task.alpha} - + ) + } + if (! task.output_file && ! task.processing) { + cancel = ( + props.cancelTask(task)}>x + ) + } + const completed = task.completed ? 'completed' : '' + let filename = task.output_file ? task.output_file.name : + task.processing ? '(processing)' : '(waiting)' + return ( +
+
+ {created_at.date} + {created_at.time} + {filename} + {cancel} +
+
+ α={task.alpha} + {files} +
) // {task.result_file.name} }) return ( -
+
{tasks}
) } + diff --git a/client/components/UI/AudioPlayerView.jsx b/client/components/UI/AudioPlayerView.jsx index d2c9982..e715c27 100644 --- a/client/components/UI/AudioPlayerView.jsx +++ b/client/components/UI/AudioPlayerView.jsx @@ -1,19 +1,21 @@ import { h, Component } from 'preact' - +import { pngpath, mp3path } from '../../vendor/paths' const audio = document.createElement('audio') export default function AudioPlayerView (props) { if (props.file) { document.body.style.backgroundImage = 'url(' + pngpath(props.file) + ')' audio.src = mp3path(props.file) + audio.currentTime = 0 audio.play() return ( -
+
audio.paused ? audio.play() : audio.pause()}> Playing {props.file.name}
) } else { + audio.pause() return (
Not Playing @@ -21,16 +23,3 @@ export default function AudioPlayerView (props) { ) } } - -function filepath (file) { - return '/data/' + file.folder_id + '/' + encodeURIComponent(file.name) -} -function mp3path (file) { - if (file.mime !== 'audio/mp3') { - return filepath(file) + '.mp3' - } - return filepath(file) -} -function pngpath (file) { - return filepath(file) + '.png' -} diff --git a/client/components/UI/Link.jsx b/client/components/UI/Link.jsx index d71582b..b4d2d28 100644 --- a/client/components/UI/Link.jsx +++ b/client/components/UI/Link.jsx @@ -2,15 +2,15 @@ import { h, Component } from 'preact' import React from 'react' // import PropTypes from 'prop-types' -const Link = ({ active, children, onClick, disabled }) => { +const Link = ({ href, active, children, onClick, selected, disabled }) => { if (active) { return {children} } - const className = disabled ? 'disabled' : '' - + const className = disabled ? 'disabled' : + selected ? 'selected' : '' return ( // eslint-disable-next-line - { e.preventDefault() -- cgit v1.2.3-70-g09d2