Browse Source

Add additional Tracker columns to WebUI

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
b8e4c6b0be
  1. 19
      src/webui/api/torrentscontroller.cpp
  2. 8
      src/webui/www/private/properties_content.html
  3. 19
      src/webui/www/private/scripts/prop-trackers.js

19
src/webui/api/torrentscontroller.cpp

@ -56,8 +56,12 @@ @@ -56,8 +56,12 @@
// Tracker keys
const char KEY_TRACKER_URL[] = "url";
const char KEY_TRACKER_STATUS[] = "status";
const char KEY_TRACKER_TIER[] = "tier";
const char KEY_TRACKER_MSG[] = "msg";
const char KEY_TRACKER_PEERS[] = "num_peers";
const char KEY_TRACKER_PEERS_COUNT[] = "num_peers";
const char KEY_TRACKER_SEEDS_COUNT[] = "num_seeds";
const char KEY_TRACKER_LEECHES_COUNT[] = "num_leeches";
const char KEY_TRACKER_DOWNLOADED_COUNT[] = "num_downloaded";
// Web seed keys
const char KEY_WEBSEED_URL[] = "url";
@ -295,7 +299,11 @@ void TorrentsController::propertiesAction() @@ -295,7 +299,11 @@ void TorrentsController::propertiesAction()
// The dictionary keys are:
// - "url": Tracker URL
// - "status": Tracker status
// - "num_peers": Tracker peer count
// - "tier": Tracker tier
// - "num_peers": Number of peers this torrent is currently connected to
// - "num_seeds": Number of peers that have the whole file
// - "num_leeches": Number of peers that are still downloading
// - "num_downloaded": Tracker downloaded count
// - "msg": Tracker message (last)
void TorrentsController::trackersAction()
{
@ -323,10 +331,15 @@ void TorrentsController::trackersAction() @@ -323,10 +331,15 @@ void TorrentsController::trackersAction()
case BitTorrent::TrackerEntry::NotWorking:
status = tr("Not working"); break;
}
trackerDict[KEY_TRACKER_TIER] = tracker.tier();
trackerDict[KEY_TRACKER_STATUS] = status;
trackerDict[KEY_TRACKER_PEERS] = data.numPeers;
trackerDict[KEY_TRACKER_PEERS_COUNT] = data.numPeers;
trackerDict[KEY_TRACKER_MSG] = data.lastMessage.trimmed();
trackerDict[KEY_TRACKER_SEEDS_COUNT] = tracker.nativeEntry().scrape_complete;
trackerDict[KEY_TRACKER_LEECHES_COUNT] = tracker.nativeEntry().scrape_incomplete;
trackerDict[KEY_TRACKER_DOWNLOADED_COUNT] = tracker.nativeEntry().scrape_downloaded;
trackerList.append(trackerDict);
}

8
src/webui/www/private/properties_content.html

@ -84,10 +84,14 @@ @@ -84,10 +84,14 @@
<table class="dynamicTable" style="width: 100%">
<thead>
<tr>
<th style="width: 5%;">QBT_TR(#)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 30%;">QBT_TR(URL)QBT_TR[CONTEXT=TrackerListWidget] <img src="images/qbt-theme/list-add.svg" id="addTrackersPlus" alt="Add Trackers" /></th>
<th style="width: 10%;">QBT_TR(Status)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 10%;">QBT_TR(Peers)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 50%;">QBT_TR(Message)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 5%;">QBT_TR(Peers)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 5%;">QBT_TR(Seeds)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 5%;">QBT_TR(Leeches)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 5%;">QBT_TR(Downloaded)QBT_TR[CONTEXT=TrackerListWidget]</th>
<th style="width: 35%;">QBT_TR(Message)QBT_TR[CONTEXT=TrackerListWidget]</th>
</tr>
</thead>
<tbody id="trackersTable"></tbody>

19
src/webui/www/private/scripts/prop-trackers.js

@ -32,7 +32,7 @@ var trackersDynTable = new Class({ @@ -32,7 +32,7 @@ var trackersDynTable = new Class({
},
insertRow: function(row) {
var url = row[0];
var url = row[1];
if (this.rows.has(url)) {
var tableRow = this.rows.get(url);
this.updateRow(tableRow, row);
@ -85,12 +85,17 @@ var loadTrackersData = function() { @@ -85,12 +85,17 @@ var loadTrackersData = function() {
if (trackers) {
// Update Trackers data
trackers.each(function(tracker) {
var row = [];
row.length = 4;
row[0] = escapeHtml(tracker.url);
row[1] = tracker.status;
row[2] = tracker.num_peers;
row[3] = escapeHtml(tracker.msg);
var row = [
tracker.tier,
escapeHtml(tracker.url),
tracker.status,
tracker.num_peers,
(tracker.num_seeds >= 0) ? tracker.num_seeds : "QBT_TR(N/A)QBT_TR[CONTEXT=TrackerListWidget]",
(tracker.num_leeches >= 0) ? tracker.num_leeches : "QBT_TR(N/A)QBT_TR[CONTEXT=TrackerListWidget]",
(tracker.num_downloaded >= 0) ? tracker.num_downloaded : "QBT_TR(N/A)QBT_TR[CONTEXT=TrackerListWidget]",
escapeHtml(tracker.msg)
];
tTable.insertRow(row);
});
}

Loading…
Cancel
Save