Changes to dashboard, and adding reset/manual link functions.

pull/75/head
mg 5 years ago
parent 2611ec5916
commit dee140aec0

@ -66,6 +66,12 @@
display:inline-block;
}
</style>
<style>
/* Styles based on event category */
#QueueTable .RDP {
background-color: #f4cccc;
}
</style>
</head>
<body>
<div>
@ -132,8 +138,7 @@
<th>Description</th>
<th>State</th>
<th>Edit</th>
<th>Manual Link</th>
<th>Reset</th>
<th>Link</th>
</tr>
</table>
</div>
@ -142,10 +147,20 @@
// var startOfHour = new Date(new Date().setMinutes(0,0,0));
// document.getElementById("StreamStart").value = new Date(startOfHour.getTime() - 1000*60*60).toISOString().substring(0,19);
// document.getElementById("StreamEnd").value = startOfHour.toISOString().substring(0,19);
function sanitizeInput(input) {
let tempElement = document.createElement("SPAN");
tempElement.appendChild(document.createTextNode(input));
return tempElement.innerHTML;
}
async function getEvents() {
let response = await fetch("/thrimshim");
let data = await response.json();
//Sanitize user inputs that could be used for xss
data.forEach(event => {
event.category = sanitizeInput(event.category);
event.description = sanitizeInput(event.description);
})
return data;
}
@ -211,12 +226,11 @@
row.innerHTML = `
<td>${event.event_start}</td>
<td>${event.event_end}</td>
<td>${event.category}</td>
<td class="${event.category.replace(/ /g, "")}">${event.category}</td>
<td>${event.description}</td>
<td>${event.state}</td>
<td><a href="/thrimbletrimmer?id=${event.id}">Edit</a></td>
<td><a href="#">Reset</a></td>
<td><a href="#">Manual Link</a></td>
<td>${event.video_link ? "<a href='"+event.video_link+"'>"+event.video_link+"</a>":""}</td>
`;
document.getElementById('QueueTable').appendChild(row);
});

@ -52,7 +52,7 @@
<input type="radio" id="BusTimeToggleUTC" name="BusTimeToggle" value="UTC" onclick="toggleTimeInput(this.value)"> UTC
<input type="radio" id="BusTimeToggleBus" name="BusTimeToggle" value="BUSTIME" onclick="toggleTimeInput(this.value)" checked="checked"> Bustime
</td>
<td><a id="AdvancedOptionsButton" href="JavaScript:toggleAdvancedOptions();">Advanced Submit Options</a></td>
<td><a id="AdvancedOptionsButton" href="JavaScript:toggleHiddenPane('wubloaderAdvancedInputTable');">Advanced Submit Options</a></td>
</tr>
</table>
<table id="wubloaderAdvancedInputTable" style="display:none;">
@ -89,10 +89,15 @@
</div>
<input type="button" id="SubmitButton" value="Submit" onclick="thrimbletrimmerSubmit()"/>
<input type="button" id="DownloadButton" value="Download" onclick="thrimbletrimmerDownload()"/>
<a href="/thrimbletrimmer/dashboard.html">Go To Dashboard</a>
<a id="HelpButton" style="float:right;" href="JavaScript:toggleHelp();">Help</a>
<a href="/thrimbletrimmer/dashboard.html">Go To Dashboard</a> |
<a id="ManualLinkButton" href="JavaScript:toggleHiddenPane('ManualLinkPane');">Manual Link</a> |
<a id="ResetButton" href="JavaScript:thrimbletrimmerResetLink();">Reset Edits</a>
<a id="HelpButton" style="float:right;" href="JavaScript:toggleHiddenPane('HelpPane');">Help</a>
<a id="UltrawideButton" style="float:right;margin-right:10px;" href="JavaScript:toggleUltrawide();">Ultrawide</a>
</div>
<div id="ManualLinkPane" style="display:none">
<input id="ManualLink" /> <input type="button" onclick="thrimbletrimmerManualLink()" value="Set Link" />
</div>
<div id="HelpPane" style="display:none;">
<ul>
<li>J/K/L - Back 10 seconds, Play/Pause, Advance 10 seconds</li>
@ -111,13 +116,9 @@
<script>pageSetup();</script>
<script>
function toggleHelp() {
var helpPane = document.getElementById("HelpPane");
helpPane.style.display = (helpPane.style.display === "none") ? "block":"none";
}
function toggleAdvancedOptions() {
var helpPane = document.getElementById("wubloaderAdvancedInputTable");
helpPane.style.display = (helpPane.style.display === "none") ? "block":"none";
function toggleHiddenPane(paneID) {
var pane = document.getElementById(paneID);
pane.style.display = (pane.style.display === "none") ? "block":"none";
}
function toggleUltrawide() {
var body = document.getElementsByTagName("Body")[0];

@ -1,12 +1,11 @@
var desertBusStart = new Date("1970-01-01T00:00:00Z");
//var desertBusChannel = "gamesdonequick";
//document.getElementById("StreamName").value = desertBusChannel;
//var desertBusStart = new Date("1970-01-01T00:00:00Z");
var desertBusStart = new Date("2019-09-20T18:00:00");
pageSetup = function() {
//Get values from ThrimShim
if(/id=/.test(document.location.search)) {
var rowId = /id=(.*)(?:&|$)/.exec(document.location.search)[1];
fetch("/thrimshim/"+rowId).then(data => data.json()).then(function (data) { // {mode: 'cors'} ???
fetch("/thrimshim/"+rowId).then(data => data.json()).then(function (data) {
if (!data) {
alert("No video available for stream.");
return;
@ -59,7 +58,7 @@ loadPlaylist = function(startTrim, endTrim) {
//Get quality levels for advanced properties.
document.getElementById('qualityLevel').innerHTML = "";
fetch('/files/' + document.getElementById('StreamName').value).then(data => data.json()).then(function (data) { // {mode: 'cors'} ???
fetch('/files/' + document.getElementById('StreamName').value).then(data => data.json()).then(function (data) {
if (!data.length) {
console.log("Could not retrieve quality levels");
return;
@ -99,7 +98,7 @@ thrimbletrimmerSubmit = function() {
//Submit to thrimshim
var rowId = /id=(.*)(?:&|$)/.exec(document.location.search)[1];
fetch("/thrimshim/"+rowId, { // {mode: 'cors'} ???
fetch("/thrimshim/"+rowId, {
method: 'POST',
headers: {
'Accept': 'application/json',
@ -134,3 +133,38 @@ thrimbletrimmerDownload = function() {
document.getElementById('outputFile').src = targetURL;
}
};
thrimbletrimmerManualLink = function() {
var rowId = /id=(.*)(?:&|$)/.exec(document.location.search)[1];
fetch("/thrimshim/manual-link/"+rowId, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
link: document.getElementById("ManualLink").value,
token: user.getAuthResponse().id_token
})
})
.then(response => { if (!response.ok) { throw Error(response.statusText); }; return response; })
.then(data => { console.log(data); setTimeout(() => { alert("Manual link set"); }, 500); })
.catch(error => { console.log(error); alert(error); });
};
thrimbletrimmerResetLink = function() {
var rowId = /id=(.*)(?:&|$)/.exec(document.location.search)[1];
if(confirm('Are you sure you want to reset this event?')) {
fetch("/thrimshim/reset/"+rowId, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({token: user.getAuthResponse().id_token})
})
.then(response => { if (!response.ok) { throw Error(response.statusText); }; return response; })
.then(data => { console.log(data); setTimeout(() => { window.location.reload() }, 500); })
.catch(error => { console.log(error); alert(error); });
}
};
Loading…
Cancel
Save