Browse Source

start on async file mapping

master
cinnaboot 7 years ago
parent
commit
66a809c560
  1. 23
      video_metadata/static/file_listing.js
  2. 1
      video_metadata/views/tmdb.py

23
video_metadata/static/file_listing.js

@ -75,8 +75,9 @@ function openQueryDialog(dataset) {
description.appendChild(document.createTextNode(result.overview));
let map_link = qtclone.querySelector('.mapping_link');
map_link.href = CREATE_MAPPING_PATH + '?movie_id=' + json.id
+ '&rel_path=' + dataset.rel_path;
map_link.addEventListener('click', function(e) {
submitFileMapping(e, result.id, dataset.rel_path);
});
tclone.querySelector('#query_result_container').appendChild(qtclone);
}
@ -86,6 +87,23 @@ function openQueryDialog(dataset) {
});
}
function submitFileMapping(click_event, movie_id, rel_path) {
click_event.preventDefault();
console.log('movie_id: ' + movie_id);
console.log('rel_path: ' + rel_path);
// TODO:
// - make query with POST
// - display errors
// - display success
// - update link class to file_stored
// - close query box
query_str = CREATE_MAPPING_PATH + '?movie_id=' + movie_id + '&rel_path=' + rel_path;
fetchJSON(query_str, function(json) {
console.log(json);
});
}
function parseResponse(json, node) {
if (node == null) {
logError('parent node cannot be null');
@ -151,6 +169,7 @@ function fetchJSON(url, responseFunc, node=null) {
.then(function(json) {
(node == null) ? responseFunc(json) : responseFunc(json, node);
})
// TODO: don't catch errors in responseFunc
.catch(function(error) {
logError('fetch error: ' + error);
return null;

1
video_metadata/views/tmdb.py

@ -202,7 +202,6 @@ def create_mapping():
current_app.logger.error(e)
return jsonify({'errors':errors, 'message':message})
# TODO: query_movie() will no longer need rel_path argument
###################

Loading…
Cancel
Save