first commit
This commit is contained in:
22
templates/index
Normal file
22
templates/index
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>Simple Downloader</h1>
|
||||
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="file" accept=".drmd">
|
||||
<input type="submit" value="Upload and Process">
|
||||
</form>
|
||||
<h2>Currently Running Jobs</h2>
|
||||
<ul>
|
||||
{{range $filename, $info := .Jobs}}
|
||||
<li>
|
||||
<a href="/progress?filename={{$filename}}">{{$filename}}</a>:
|
||||
{{printf "%.2f%%" $info.Percentage}}
|
||||
(Current file: {{$info.CurrentFile}})
|
||||
</li>
|
||||
{{else}}
|
||||
<li>No active jobs</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
27
templates/progress
Normal file
27
templates/progress
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>Processing {{.Filename}}</h1>
|
||||
<div id="progress">0%</div>
|
||||
<div id="currentFile"></div>
|
||||
<script>
|
||||
function updateProgress() {
|
||||
fetch('/progress?filename={{.Filename}}', {
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const progress = Math.round(data.Percentage);
|
||||
document.getElementById('progress').innerText = progress + '%';
|
||||
document.getElementById('currentFile').innerText = 'Current file: ' + (data.CurrentFile || 'None');
|
||||
if (progress < 100) {
|
||||
setTimeout(updateProgress, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
updateProgress();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user