diff options
Diffstat (limited to 'animism-align/frontend/app')
3 files changed, 38 insertions, 11 deletions
diff --git a/animism-align/frontend/app/utils/index.js b/animism-align/frontend/app/utils/index.js index 03c484c..ac4b83b 100644 --- a/animism-align/frontend/app/utils/index.js +++ b/animism-align/frontend/app/utils/index.js @@ -231,16 +231,22 @@ export const post = (dispatch, type=api_type, tag, url, data) => { headers, }) .then(res => res.json()) - .then(res => dispatch({ - type: type.loaded, - tag, - data: res, - })) - .catch(err => dispatch({ - type: type.error, - tag, - err, - })) + .then(res => { + dispatch({ + type: type.loaded, + tag, + data: res, + }) + return res + }) + .catch(err => { + dispatch({ + type: type.error, + tag, + err, + }) + return err + }) } export const api = (dispatch, type=api_type, tag, url, data) => { diff --git a/animism-align/frontend/app/views/align/align.actions.js b/animism-align/frontend/app/views/align/align.actions.js index 6eca0a7..524de07 100644 --- a/animism-align/frontend/app/views/align/align.actions.js +++ b/animism-align/frontend/app/views/align/align.actions.js @@ -6,6 +6,7 @@ import throttle from 'lodash.throttle' import debounce from 'lodash.debounce' import { ZOOM_STEPS } from 'app/constants' +import { timestampToSeconds, post } from 'app/utils' import { cutFirstSentence } from 'app/utils/align.utils' export const setScrollPosition = start_ts => dispatch => ( @@ -90,3 +91,21 @@ export const hideAnnotationForm = () => dispatch => { data: {} }) } + + +export const spliceTime = start_ts => dispatch => { + let duration = timestampToSeconds(prompt("How many seconds to add or remove? Enter a positive / negative number")) + if (!duration) { + return + } + console.log(start_ts, duration) + const data = { + start_ts, duration, + } + post(dispatch, types.api, 'splice', '/api/v1/annotation/splice', data) + .then(res => { + console.log(res) + alert(res.count + ' records updated!') + actions.annotation.index() + }) +}
\ No newline at end of file diff --git a/animism-align/frontend/app/views/align/containers/timeline.container.js b/animism-align/frontend/app/views/align/containers/timeline.container.js index d1917b5..3db658c 100644 --- a/animism-align/frontend/app/views/align/containers/timeline.container.js +++ b/animism-align/frontend/app/views/align/containers/timeline.container.js @@ -127,7 +127,9 @@ class Timeline extends Component { } handleTimelineClick(e) { const play_ts = positionToTime(e.pageY, this.props.timeline) - if (e.pageX < WAVEFORM_SIZE * 0.67) { + if (e.metaKey) { + actions.align.spliceTime(play_ts) + } else if (e.pageX < WAVEFORM_SIZE * 0.67) { actions.audio.seek(play_ts) } else { actions.align.showNewAnnotationForm(play_ts, this.props.text) |
