thrimbletrimmer: submit button: clean up, error handling, no-auth mode

pull/116/head
Mike Lang 5 years ago
parent cdd286c0ee
commit 93fc202394

@ -93,10 +93,6 @@ loadPlaylist = function(startTrim, endTrim) {
thrimbletrimmerSubmit = function(state) { thrimbletrimmerSubmit = function(state) {
document.getElementById('SubmitButton').disabled = true; document.getElementById('SubmitButton').disabled = true;
if(player.trimmingControls().options.startTrim >= player.trimmingControls().options.endTrim) {
alert("End Time must be greater than Start Time");
document.getElementById('SubmitButton').disabled = false;
} else {
var discontinuities = mapDiscontinuities(); var discontinuities = mapDiscontinuities();
var wubData = { var wubData = {
@ -104,15 +100,16 @@ thrimbletrimmerSubmit = function(state) {
video_end:getRealTimeForPlayerTime(discontinuities, player.trimmingControls().options.endTrim).replace('Z',''), video_end:getRealTimeForPlayerTime(discontinuities, player.trimmingControls().options.endTrim).replace('Z',''),
video_title:document.getElementById("VideoTitle").value, video_title:document.getElementById("VideoTitle").value,
video_description:document.getElementById("VideoDescription").value, video_description:document.getElementById("VideoDescription").value,
allow_holes:String(document.getElementById('AllowHoles').checked), allow_holes:document.getElementById('AllowHoles').checked,
upload_location:document.getElementById('uploadLocation').value, upload_location:document.getElementById('uploadLocation').value,
video_channel:document.getElementById("StreamName").value, video_channel:document.getElementById("StreamName").value,
video_quality:document.getElementById('qualityLevel').options[document.getElementById('qualityLevel').options.selectedIndex].value, video_quality:document.getElementById('qualityLevel').options[document.getElementById('qualityLevel').options.selectedIndex].value,
uploader_whitelist:(document.getElementById('uploaderWhitelist').value ? document.getElementById('uploaderWhitelist').value.split(','):null), uploader_whitelist:(document.getElementById('uploaderWhitelist').value ? document.getElementById('uploaderWhitelist').value.split(','):null),
state:state, state:state,
token: user.getAuthResponse().id_token
}; };
// state_columns = ['state', 'uploader', 'error', 'video_link'] if (!!user) {
wubData.token = user.getAuthResponse().id_token
}
console.log(wubData); console.log(wubData);
console.log(JSON.stringify(wubData)); console.log(JSON.stringify(wubData));
@ -126,10 +123,16 @@ thrimbletrimmerSubmit = function(state) {
}, },
body: JSON.stringify(wubData) body: JSON.stringify(wubData)
}) })
.then(response => { if (!response.ok) { throw Error(response.statusText); }; return response; }) .then(response => response.text().then(text => {
.then(data => { console.log(data); setTimeout(() => { window.location.href = '/thrimbletrimmer/dashboard.html'; }, 500); }) if (!response.ok) {
.catch(error => { console.log(error); alert(error); }); error = response.statusText + ": " + text;
console.log(error);
alert(error);
document.getElementById('SubmitButton').disabled = false;
} else {
setTimeout(() => window.location.href = '/thrimbletrimmer/dashboard.html'; }, 500);
} }
}));
}; };
thrimbletrimmerDownload = function() { thrimbletrimmerDownload = function() {

Loading…
Cancel
Save