mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-19 15:25:51 +00:00
add watch progress tiles
This commit is contained in:
parent
5acc1ea718
commit
4650963cc7
@ -9,7 +9,8 @@
|
||||
<div id="primaryBox" class="info-box info-box-4"></div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h2>Watch Progress</h2>
|
||||
<div id="watchBox" class="info-box info-box-3"></div>
|
||||
</div>
|
||||
<script type="text/javascript" src="{% static 'stats.js' %}"></script>
|
||||
{% endblock settings_content %}
|
||||
|
@ -70,8 +70,35 @@ function buildDownloadTile(responseData) {
|
||||
return tile;
|
||||
}
|
||||
|
||||
function watchStats() {
|
||||
let apiEndpoint = '/api/stats/watch/';
|
||||
let responseData = apiRequest(apiEndpoint, 'GET');
|
||||
let watchBox = document.getElementById('watchBox');
|
||||
|
||||
for (const property in responseData) {
|
||||
let tile = buildWatchTile(property, responseData[property]);
|
||||
watchBox.appendChild(tile);
|
||||
}
|
||||
}
|
||||
|
||||
function buildWatchTile(title, watchDetail) {
|
||||
let tile = buildTile(`Total ${title}`);
|
||||
let message = document.createElement('p');
|
||||
message.innerHTML = `
|
||||
${watchDetail.items} Videos<br>
|
||||
${watchDetail.duration} Seconds<br>
|
||||
${watchDetail.duration_str} Playback
|
||||
`;
|
||||
if (watchDetail.progress) {
|
||||
message.innerHTML += `<br>${Number(watchDetail.progress * 100).toFixed(2)}%`;
|
||||
}
|
||||
tile.appendChild(message);
|
||||
return tile;
|
||||
}
|
||||
|
||||
function buildStats() {
|
||||
primaryStats();
|
||||
watchStats();
|
||||
}
|
||||
|
||||
buildStats();
|
||||
|
Loading…
Reference in New Issue
Block a user