From 18472645a7879baf00332a7ee5be8c4338bb8d21 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 8 Jul 2020 23:37:40 +0200 Subject: adding annotations of type video --- animism-align/frontend/views/align/align.css | 7 +++ animism-align/frontend/views/align/align.util.js | 4 ++ .../components/annotations/annotation.form.js | 63 +++++++++++++++++----- .../components/annotations/annotation.index.js | 4 +- .../components/annotations/annotation.types.js | 41 +++++++++++++- .../frontend/views/audio/audio.actions.js | 2 +- .../views/media/components/media.formImage.js | 2 +- .../media/components/media.formImageSelection.js | 2 +- .../views/media/components/media.indexOptions.js | 4 ++ .../frontend/views/media/containers/media.index.js | 7 ++- .../frontend/views/media/media.actions.js | 1 - .../frontend/views/media/media.reducer.js | 2 +- 12 files changed, 115 insertions(+), 24 deletions(-) (limited to 'animism-align/frontend/views') diff --git a/animism-align/frontend/views/align/align.css b/animism-align/frontend/views/align/align.css index ec39cd8..38a2bc7 100644 --- a/animism-align/frontend/views/align/align.css +++ b/animism-align/frontend/views/align/align.css @@ -130,9 +130,16 @@ canvas { display: flex; align-items: center; } +.annotationForm .buttons { + margin-bottom: 0.5rem; +} .annotationForm .ts { color: #fff; } +.annotationForm .select.media_id { + width: 100%; + margin-right: 0; +} /* Annotation index */ diff --git a/animism-align/frontend/views/align/align.util.js b/animism-align/frontend/views/align/align.util.js index 91af64c..c99ff3b 100644 --- a/animism-align/frontend/views/align/align.util.js +++ b/animism-align/frontend/views/align/align.util.js @@ -58,3 +58,7 @@ export const cutFirstSentence = text => { actions.site.updateText(updatedText) return croppedText } + +export const thumbnailURL = data => { + if (data.type === 'video') return data.settings.video.thumbnail_url +} diff --git a/animism-align/frontend/views/align/components/annotations/annotation.form.js b/animism-align/frontend/views/align/components/annotations/annotation.form.js index 226bb45..0a71233 100644 --- a/animism-align/frontend/views/align/components/annotations/annotation.form.js +++ b/animism-align/frontend/views/align/components/annotations/annotation.form.js @@ -12,7 +12,7 @@ import { timeToPosition } from '../../align.util' import { Select } from '../../../../common' const ANNOTATION_TYPES = [ - 'sentence', 'header', 'paragraph_end' + 'sentence', 'header', 'paragraph_end', 'video', ].map(name => ({ name, label: name })) class AnnotationForm extends Component { @@ -20,6 +20,7 @@ class AnnotationForm extends Component { super(props) this.handleChange = this.handleChange.bind(this) this.handleSelect = this.handleSelect.bind(this) + this.handleSettingsSelect = this.handleSettingsSelect.bind(this) this.handleKeyDown = this.handleKeyDown.bind(this) this.handleSubmit = this.handleSubmit.bind(this) this.textareaRef = React.createRef() @@ -66,6 +67,10 @@ class AnnotationForm extends Component { handleSelect(name, value) { actions.align.updateAnnotationForm(name, value) } + handleSettingsSelect(name, value) { + if (name.indexOf('_id') !== -1) value = parseInt(value) || 0 + actions.align.updateAnnotationSettings(name, value) + } handleSubmit() { const { annotation } = this.props if (annotation.type === 'paragraph_end') { @@ -96,21 +101,28 @@ class AnnotationForm extends Component { top: timeToPosition(annotation.start_ts, timeline), }} > + {this.renderButtons()} {annotation.type === 'sentence' && this.renderTextarea()} {annotation.type === 'header' && this.renderTextarea()} -
-
- +
{timestamp(annotation.start_ts, 1, true)}
+
) } @@ -128,11 +140,36 @@ class AnnotationForm extends Component { ) } + renderVideo() { + const { annotation, media } = this.props + if (!media.lookup) return
+ const { lookup, order } = media + const video_list_items = order.filter(id => lookup[id].type === 'video').map(id => { + const video = lookup[id] + return { + name: video.id, + label: video.author + ' - ' + video.title + } + }) + return ( +
+