-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempting to improve user experiance when using convert-library from…
… the Web UI
- Loading branch information
1 parent
24cbe2f
commit 93edaa0
Showing
3 changed files
with
71 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 32 additions & 12 deletions
44
root/app/calibre-web/cps/templates/cwa_convert_library.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
{% extends "layout.html" %} | ||
{% block script %} | ||
$(document).ready(function(){ | ||
var output = document.getElementById('output'); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', '{{ url_for('convert_library.cwa_library_convert') }}', true); | ||
xhr.send(); | ||
setInterval(function() { | ||
output.textContent = xhr.responseText; | ||
}, 500); | ||
}); | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<div class="discover"> | ||
<h2>{{title}}</h2> | ||
<div> | ||
<h3>CWA Library Convertor</h3><br> | ||
<div class="row"> | ||
<div class="logging_window"> | ||
<pre id="output"></pre> | ||
<h2 id="innerStatus">Loading...</h2> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script> | ||
var timeout; | ||
|
||
async function getStatus() { | ||
|
||
let get; | ||
|
||
try { | ||
const res = await fetch("/convert-library-status"); | ||
get = await res.json(); | ||
} catch (e) { | ||
console.error("Error: ", e); | ||
} | ||
|
||
document.getElementById("innerStatus").innerHTML = get.status.replace(/\n/g, "<br>"); // * 10 + "%" | ||
|
||
if (get.status == "Done!"){ | ||
document.getElementById("innerStatus").innerHTML; | ||
clearTimeout(timeout); | ||
return false; | ||
} | ||
|
||
timeout = setTimeout(getStatus, 1000); | ||
} | ||
|
||
getStatus(); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters