diff --git a/Changelog b/Changelog index 3fecd28c9..22942f092 100644 --- a/Changelog +++ b/Changelog @@ -33,7 +33,7 @@ - FEATURE: Include DHT traffic in the rate limiter (libtorrent >= v0.15 only) - FEATURE: Support for bitcomet padding files (libtorrent >= v0.15 only) - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) (libtorrent >= v0.15 only) - - WEB UI: Removed Web UI to match new qBittorrent UI + - WEB UI: Remodeled Web UI to match new qBittorrent UI (Properties and preferences available) - WEB UI: Added internationalization support - WEB UI: Reduced computation in Javascript (do this one server side instead) - COSMETIC: Merged download / upload lists diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 6c71e0418..6167883f2 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -44,6 +44,51 @@ QList EventManager::getEventList() const { return event_list.values(); } +QList EventManager::getPropTrackersInfo(QString hash) const { + QList trackersInfo; + QTorrentHandle h = BTSession->getTorrentHandle(hash); + if(h.is_valid()) { + QHash trackers_data = BTSession->getTrackersInfo(hash); + std::vector vect_trackers = h.trackers(); + std::vector::iterator it; + for(it = vect_trackers.begin(); it != vect_trackers.end(); it++) { + QVariantMap tracker; + QString tracker_url = misc::toQString(it->url); + tracker["url"] = tracker_url; + TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); + QString error_message = data.last_message.trimmed(); +#ifdef LIBTORRENT_0_15 + if(it->verified) { + tracker["status"] = tr("Working"); + } else { + if(it->updating && it->fails == 0) { + tracker["status"] = tr("Updating..."); + } else { + if(it->fails > 0) { + tracker["status"] = tr("Not working"); + } else { + tracker["status"] = tr("Not contacted yet"); + } + } + } +#else + if(data.verified) { + tracker["status"] = tr("Working"); + } else { + if(data.fail_count > 0) + tracker["status"] = tr("Not working"); + else + tracker["status"] = tr("Not contacted yet"); + } +#endif + tracker["num_peers"] = QString::number(trackers_data.value(tracker_url, TrackerInfos(tracker_url)).num_peers); + tracker["msg"] = error_message; + trackersInfo << tracker; + } + } + return trackersInfo; +} + QVariantMap EventManager::getPropGeneralInfo(QString hash) const { QVariantMap data; QTorrentHandle h = BTSession->getTorrentHandle(hash); diff --git a/src/eventmanager.h b/src/eventmanager.h index d431b492f..299567807 100644 --- a/src/eventmanager.h +++ b/src/eventmanager.h @@ -52,6 +52,7 @@ class EventManager : public QObject EventManager(QObject *parent, Bittorrent* BTSession); QList getEventList() const; QVariantMap getPropGeneralInfo(QString hash) const; + QList getPropTrackersInfo(QString hash) const; public slots: void addedTorrent(QTorrentHandle& h); diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index 2b6ff86e5..24162505c 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -102,7 +102,7 @@ void HttpConnection::write() } QString HttpConnection::translateDocument(QString data) { - std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg"}; + std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg", "TrackerList"}; int i=0; bool found = false; do { @@ -117,7 +117,7 @@ QString HttpConnection::translateDocument(QString data) { do { translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().data(), 0, QCoreApplication::UnicodeUTF8, 1); ++context_index; - }while(translation == word && context_index < 7); + }while(translation == word && context_index < 8); //qDebug("Translation is %s", translation.toUtf8().data()); data = data.replace(i, regex.matchedLength(), translation); i += translation.length(); @@ -162,6 +162,12 @@ void HttpConnection::respond() respondGenPropertiesJson(hash); return; } + if(list[1] == "propertiesTrackers") { + qDebug("Web UI asked for trackers"); + QString hash = list[2]; + respondTrackersPropertiesJson(hash); + return; + } } } if (list[0] == "command") @@ -226,6 +232,16 @@ void HttpConnection::respondGenPropertiesJson(QString hash) { write(); } +void HttpConnection::respondTrackersPropertiesJson(QString hash) { + EventManager* manager = parent->eventManager(); + QString string = json::toJson(manager->getPropTrackersInfo(hash)); + generator.setStatusLine(200, "OK"); + generator.setContentTypeByExt("js"); + generator.setMessage(string); + write(); +} + + void HttpConnection::respondCommand(QString command) { if(command == "download") diff --git a/src/httpconnection.h b/src/httpconnection.h index cc373328a..9b194e258 100644 --- a/src/httpconnection.h +++ b/src/httpconnection.h @@ -57,6 +57,7 @@ class HttpConnection : public QObject virtual void respond(); void respondJson(); void respondGenPropertiesJson(QString hash); + void respondTrackersPropertiesJson(QString hash); void respondCommand(QString command); void respondNotFound(); void processDownloadedFile(QString, QString); diff --git a/src/trackerlist.h b/src/trackerlist.h index 4d97ea7c4..618d99024 100644 --- a/src/trackerlist.h +++ b/src/trackerlist.h @@ -174,7 +174,7 @@ public slots: std::vector::iterator it; for(it = trackers.begin(); it != trackers.end(); it++) { QStringList item_list; - QString tracker_url = misc::toQString((*it).url); + QString tracker_url = misc::toQString(it->url); QTreeWidgetItem *item = tracker_items.value(tracker_url, 0); if(!item) { item = new QTreeWidgetItem(); @@ -187,13 +187,13 @@ public slots: TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); QString error_message = data.last_message.trimmed(); #ifdef LIBTORRENT_0_15 - if((*it).verified) { + if(it->verified) { item->setText(COL_STATUS, tr("Working")); } else { - if((*it).updating && (*it).fails == 0) { + if(it->updating && it->fails == 0) { item->setText(COL_STATUS, tr("Updating...")); } else { - if((*it).fails > 0) { + if(it->fails > 0) { item->setText(COL_STATUS, tr("Not working")); } else { item->setText(COL_STATUS, tr("Not contacted yet")); diff --git a/src/webui/css/dynamicTable.css b/src/webui/css/dynamicTable.css index 39b5c6bb1..83fd6d602 100644 --- a/src/webui/css/dynamicTable.css +++ b/src/webui/css/dynamicTable.css @@ -7,35 +7,42 @@ **************************************************************/ +#properties #trackers table, #transferList table { border: 1px solid #ccc; width: 100%; } +#properties #trackers th, #transferList th { background-color: #eee; padding: 4px; } +#properties #trackers tr, #transferList tr { background-color: #fff; padding: 4px; } +#properties #trackers tr.alt, #transferList tr.alt { background-color: #eee; padding: 4px; } +#properties #trackers td, #transferList td { padding: 0 2px; } +#properties #trackers tr.selected, #transferList tr.selected { background-color: #354158; color: #fff; } +#properties #trackers tr.over, #transferList tr.over { background-color: #ee6600; color: #fff; diff --git a/src/webui/prop-general.html b/src/webui/prop-general.html index 6dcc88b9f..082ca4153 100644 --- a/src/webui/prop-general.html +++ b/src/webui/prop-general.html @@ -51,10 +51,14 @@ dynamic information: total_downloaded, total_uploaded, total_wasted, up_limit, d } var loadData = function() { + if(!$defined($('torrent_hash'))) { + // Tab changed + return; + } var current_hash = myTable.getCurrentTorrentHash(); if(current_hash == "") { clearData(); - loadData.delay(2000); + loadData.delay(1500); return; } // Display hash @@ -89,7 +93,7 @@ dynamic information: total_downloaded, total_uploaded, total_wasted, up_limit, d clearData(); } waiting=false; - loadData.delay(2000); + loadData.delay(1500); } }).send(); } diff --git a/src/webui/prop-trackers.html b/src/webui/prop-trackers.html index 33840068c..9c2a75044 100644 --- a/src/webui/prop-trackers.html +++ b/src/webui/prop-trackers.html @@ -1 +1,127 @@ -CONTENT \ No newline at end of file + + + + + + + + + + + + +
_(URL)_(Status)_(Peers)_(Message)
+
+ + diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index da6f8502b..a2e7995e9 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -38,12 +38,11 @@ var dynamicTable = new Class ({ setup: function(table, progressIndex){ this.table = $(table); - this.rows = new Object(); + this.rows = new Hash(); this.cur = new Array(); this.priority_hidden = false; this.progressIndex = progressIndex; this.filter = 'all'; - this.current_hash = ''; }, getCurrentTorrentHash: function() { @@ -127,12 +126,11 @@ var dynamicTable = new Class ({ }, insertRow: function(id, row, status){ - var tr = this.rows[id]; - if($defined(tr)) - return; - //this.removeRow(id); + if(this.rows.has(id)) { + return; + } var tr = new Element('tr'); - this.rows[id] = tr; + this.rows.set(id, tr); for(var i=0; i