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) {
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 wubData = {
@ -104,15 +100,16 @@ thrimbletrimmerSubmit = function(state) {
video_end:getRealTimeForPlayerTime(discontinuities, player.trimmingControls().options.endTrim).replace('Z',''),
video_title:document.getElementById("VideoTitle").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,
video_channel:document.getElementById("StreamName").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),
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(JSON.stringify(wubData));
@ -126,10 +123,16 @@ thrimbletrimmerSubmit = function(state) {
},
body: JSON.stringify(wubData)
})
.then(response => { if (!response.ok) { throw Error(response.statusText); }; return response; })
.then(data => { console.log(data); setTimeout(() => { window.location.href = '/thrimbletrimmer/dashboard.html'; }, 500); })
.catch(error => { console.log(error); alert(error); });
.then(response => response.text().then(text => {
if (!response.ok) {
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() {

Loading…
Cancel
Save