diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 12140902f..0d0f64f01 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -182,6 +182,7 @@ static const char KEY_FILE_PROGRESS[] = "progress"; static const char KEY_FILE_PRIORITY[] = "priority"; static const char KEY_FILE_IS_SEED[] = "is_seed"; static const char KEY_FILE_PIECE_RANGE[] = "piece_range"; +static const char KEY_FILE_AVAILABILITY[] = "availability"; // TransferInfo keys static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed"; @@ -954,12 +955,14 @@ QByteArray btjson::getFilesForTorrent(const QString& hash) const QVector priorities = torrent->filePriorities(); const QVector fp = torrent->filesProgress(); + const QVector fileAvailability = torrent->availableFileFractions(); const BitTorrent::TorrentInfo info = torrent->info(); for (int i = 0; i < torrent->filesCount(); ++i) { QVariantMap fileDict; fileDict[KEY_FILE_PROGRESS] = fp[i]; fileDict[KEY_FILE_PRIORITY] = priorities[i]; fileDict[KEY_FILE_SIZE] = torrent->fileSize(i); + fileDict[KEY_FILE_AVAILABILITY] = fileAvailability[i]; QString fileName = torrent->filePath(i); if (fileName.endsWith(QB_EXT, Qt::CaseInsensitive)) diff --git a/src/webui/www/public/properties_content.html b/src/webui/www/public/properties_content.html index d54689ed7..939a845ed 100644 --- a/src/webui/www/public/properties_content.html +++ b/src/webui/www/public/properties_content.html @@ -105,7 +105,9 @@ QBT_TR(Name)QBT_TR[CONTEXT=TorrentContentModel] QBT_TR(Size)QBT_TR[CONTEXT=TorrentContentModel] QBT_TR(Progress)QBT_TR[CONTEXT=TorrentContentModel] - QBT_TR(Download Priority)QBT_TR[CONTEXT=TorrentContentModel] + QBT_TR(Download Priority)QBT_TR[CONTEXT=TorrentContentModel] + QBT_TR(Remaining)QBT_TR[CONTEXT=TorrentContentModel] + QBT_TR(Availability)QBT_TR[CONTEXT=TorrentContentModel] diff --git a/src/webui/www/public/scripts/misc.js b/src/webui/www/public/scripts/misc.js index 9444507b3..6d60ef570 100644 --- a/src/webui/www/public/scripts/misc.js +++ b/src/webui/www/public/scripts/misc.js @@ -64,6 +64,15 @@ function friendlyDuration(seconds) { return "∞"; } +function friendlyPercentage(value) { + var percentage = (value * 100).round(1); + if (isNaN(percentage) || (percentage < 0)) + percentage = 0; + if (percentage > 100) + percentage = 100; + return percentage + "%"; +} + /* * From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString */ diff --git a/src/webui/www/public/scripts/prop-files.js b/src/webui/www/public/scripts/prop-files.js index 89b98a58f..41ec8d66e 100644 --- a/src/webui/www/public/scripts/prop-files.js +++ b/src/webui/www/public/scripts/prop-files.js @@ -317,6 +317,9 @@ var loadTorrentFilesData = function() { if (row[3] == 100.0 && file.progress < 1.0) row[3] = 99.9; row[4] = file.priority; + row[5] = friendlyUnit(file.size * (1.0 - file.progress)); + row[6] = friendlyPercentage(file.availability); + fTable.insertRow(i, row); i++; }.bind(this));