From ef78bc6a084f92b4794e987b5832240d85b6479e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 22 Jul 2020 14:05:15 +0200 Subject: refactor app using babel module-resolver --- .../components/annotations/annotation.form.js | 183 --------------------- .../components/annotations/annotation.index.js | 126 -------------- .../annotationForms/annotationForm.image.js | 27 --- .../annotationForms/annotationForm.video.js | 27 --- .../annotations/annotationForms/index.js | 12 -- .../annotationTypes/annotationTypes.image.js | 33 ---- .../annotationTypes/annotationTypes.text.js | 49 ------ .../annotationTypes/annotationTypes.util.js | 28 ---- .../annotationTypes/annotationTypes.video.js | 34 ---- .../annotations/annotationTypes/index.js | 22 --- .../components/player/playButton.component.js | 31 ---- .../align/components/timeline/cursor.component.js | 26 --- .../components/timeline/playCursor.component.js | 36 ---- .../align/components/timeline/ticks.component.js | 88 ---------- .../components/timeline/waveform.component.js | 99 ----------- 15 files changed, 821 deletions(-) delete mode 100644 animism-align/frontend/views/align/components/annotations/annotation.form.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotation.index.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.image.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/annotationForm.video.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationForms/index.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.image.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.text.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.util.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/annotationTypes.video.js delete mode 100644 animism-align/frontend/views/align/components/annotations/annotationTypes/index.js delete mode 100644 animism-align/frontend/views/align/components/player/playButton.component.js delete mode 100644 animism-align/frontend/views/align/components/timeline/cursor.component.js delete mode 100644 animism-align/frontend/views/align/components/timeline/playCursor.component.js delete mode 100644 animism-align/frontend/views/align/components/timeline/ticks.component.js delete mode 100644 animism-align/frontend/views/align/components/timeline/waveform.component.js (limited to 'animism-align/frontend/views/align/components') diff --git a/animism-align/frontend/views/align/components/annotations/annotation.form.js b/animism-align/frontend/views/align/components/annotations/annotation.form.js deleted file mode 100644 index 01b1663..0000000 --- a/animism-align/frontend/views/align/components/annotations/annotation.form.js +++ /dev/null @@ -1,183 +0,0 @@ -import React, { Component } from 'react' -// import { Link } from 'react-router-dom' -import { bindActionCreators } from 'redux' -import { connect } from 'react-redux' - -import actions from '../../../../actions' -// import * as alignActions from '../align.actions' - -import { ZOOM_STEPS } from '../../constants' -import { clamp, timestamp, capitalize } from '../../../../util' -import { timeToPosition } from '../../align.util' -import { Select } from '../../../../common' - -import { - AnnotationFormVideo, - AnnotationFormImage, -} from './annotationForms' - -const ANNOTATION_TYPES = [ - 'sentence', 'header', 'paragraph_end', 'video', 'image', 'image_carousel', -].map(name => ({ name, label: capitalize(name.replace('_', ' ')) })) - -class AnnotationForm extends Component { - constructor(props){ - 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.handleDestroy = this.handleDestroy.bind(this) - this.textareaRef = React.createRef() - } - componentDidMount() { - if (this.textareaRef && this.textareaRef.current) { - this.textareaRef.current.focus() - } - } - handleKeyDown(e) { - if (e.keyCode === 27) { // escape - actions.align.hideAnnotationForm() - return - } - // console.log(e.keyCode) - if (!e.metaKey && !e.ctrlKey) return - let { start_ts } = this.props.annotation - switch (e.keyCode) { - case 38: // up - e.preventDefault() - start_ts -= 0.1 - actions.align.updateAnnotationForm('start_ts', Math.max(0, start_ts)) - actions.audio.seek(start_ts) - actions.align.setCursor(start_ts) - break - case 40: // down - e.preventDefault() - start_ts += 0.1 - actions.align.updateAnnotationForm('start_ts', Math.max(0, start_ts)) - actions.audio.seek(start_ts) - actions.align.setCursor(start_ts) - break - case 83: // ctrl-S - e.preventDefault() - this.handleSubmit() - default: - break - } - } - handleChange(e) { - const { name, value } = e.target - this.handleSelect(name, value) - } - 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') { - annotation.text = '' - } - if (annotation.id === 'new') { - delete annotation.id - actions.annotation.create(annotation) - .then(response => { - console.log(response) - actions.align.hideAnnotationForm() - }) - } else { - actions.annotation.update(annotation) - .then(response => { - console.log(response) - actions.align.hideAnnotationForm() - }) - } - } - handleDestroy() { - const { annotation } = this.props - if (annotation.id === 'new') { - actions.align.hideAnnotationForm() - } else { - actions.annotation.destroy(annotation) - .then(response => { - console.log(response) - actions.align.hideAnnotationForm() - }) - } - } - render() { - const { timeline, annotation, media } = this.props - if (!annotation.start_ts) return
- return ( -
- {this.renderButtons()} - {annotation.type === 'sentence' && this.renderTextarea()} - {annotation.type === 'header' && this.renderTextarea()} - {annotation.type === 'video' && - - } - {annotation.type === 'image' && - - } - {annotation.type === 'image_carousel' && - - } -
- ) - } - renderButtons() { - const { annotation } = this.props - return ( -
-
-