Merge pull request #63 from itscooldani/show-size

Show Total Torrent Size
This commit is contained in:
CJ Ratliff 2024-03-01 21:45:25 -05:00 committed by GitHub
commit 70f0b0e2c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -242,6 +242,8 @@
<span id="error_div"></span>
<table style="position: absolute; right: 5px;">
<tr>
<td id="torrentsTotalSize"></td>
<td class="statusBarSeparator"></td>
<td id="freeSpaceOnDisk"></td>
<td class="statusBarSeparator"></td>
<td id="DHTNodes"></td>

View File

@ -842,6 +842,15 @@ window.addEvent('load', function() {
}
else
document.title = ("qBittorrent " + qbtVersion() + " Web UI");
let totalSize = 0;
for (const tr in torrentsTable.rows) {
if (torrentsTable.rows[tr].full_data){
totalSize += torrentsTable.rows[tr].full_data.size;
}
}
$('torrentsTotalSize').set('html', 'Total Downloads: %1 (%2\%)'.replace("%1", window.qBittorrent.Misc.friendlyUnit(totalSize)).replace("%2", ((totalSize/(totalSize + serverState.free_space_on_disk))*100).toFixed(2)));
$('freeSpaceOnDisk').set('html', 'Free space: %1'.replace("%1", window.qBittorrent.Misc.friendlyUnit(serverState.free_space_on_disk)));
$('DHTNodes').set('html', 'DHT: %1 nodes'.replace("%1", serverState.dht_nodes));