Browse Source

FEATURE: Global transfer information are displayed in the new Web UI status bar

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
f6bfacda2c
  1. 1
      Changelog
  2. 17
      src/httpconnection.cpp
  3. 1
      src/httpconnection.h
  4. 1
      src/httpserver.h
  5. 7
      src/webui/index.html
  6. 26
      src/webui/scripts/client.js

1
Changelog

@ -10,6 +10,7 @@
- FEATURE: Torrents can be automatically rechecked on completion - FEATURE: Torrents can be automatically rechecked on completion
- FEATURE: If 2 torrents have the same hash, add new trackers/URL seeds to the existing torrent - FEATURE: If 2 torrents have the same hash, add new trackers/URL seeds to the existing torrent
- FEATURE: Trackers can be added from Web UI - FEATURE: Trackers can be added from Web UI
- FEATURE: Global transfer information are displayed in the new Web UI status bar
- COSMETIC: Improved style management - COSMETIC: Improved style management
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0

17
src/httpconnection.cpp

@ -35,6 +35,7 @@
#include "preferences.h" #include "preferences.h"
#include "json.h" #include "json.h"
#include "bittorrent.h" #include "bittorrent.h"
#include "misc.h"
#include <QTcpSocket> #include <QTcpSocket>
#include <QDateTime> #include <QDateTime>
#include <QStringList> #include <QStringList>
@ -203,6 +204,10 @@ void HttpConnection::respond() {
} else { } else {
if(list[1] == "preferences") { if(list[1] == "preferences") {
respondPreferencesJson(); respondPreferencesJson();
} else {
if(list[1] == "transferInfo") {
respondGlobalTransferInfoJson();
}
} }
} }
} }
@ -298,6 +303,18 @@ void HttpConnection::respondPreferencesJson() {
write(); write();
} }
void HttpConnection::respondGlobalTransferInfoJson() {
QVariantMap info;
session_status sessionStatus = parent->getBTSession()->getSessionStatus();
info["DlInfos"] = tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download));
info["UpInfos"] = tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload));
QString string = json::toJson(info);
generator.setStatusLine(200, "OK");
generator.setContentTypeByExt("js");
generator.setMessage(string);
write();
}
void HttpConnection::respondCommand(QString command) void HttpConnection::respondCommand(QString command)
{ {
if(command == "download") if(command == "download")

1
src/httpconnection.h

@ -60,6 +60,7 @@ class HttpConnection : public QObject
void respondTrackersPropertiesJson(QString hash); void respondTrackersPropertiesJson(QString hash);
void respondFilesPropertiesJson(QString hash); void respondFilesPropertiesJson(QString hash);
void respondPreferencesJson(); void respondPreferencesJson();
void respondGlobalTransferInfoJson();
void respondCommand(QString command); void respondCommand(QString command);
void respondNotFound(); void respondNotFound();
void processDownloadedFile(QString, QString); void processDownloadedFile(QString, QString);

1
src/httpserver.h

@ -60,6 +60,7 @@ class HttpServer : public QTcpServer {
EventManager *eventManager() const; EventManager *eventManager() const;
QString generateNonce() const; QString generateNonce() const;
QHash<QString, int> client_failed_attempts; QHash<QString, int> client_failed_attempts;
Bittorrent *getBTSession() const { return BTSession; }
private slots: private slots:
void newHttpConnection(); void newHttpConnection();

7
src/webui/index.html

@ -97,5 +97,12 @@
<li><a href="#UploadLimit" class="uploadLimit">_(Limit upload rate)</a></li> <li><a href="#UploadLimit" class="uploadLimit">_(Limit upload rate)</a></li>
<li class="separator"><a href="#ForceRecheck" class="recheck">_(Force recheck)</a></li> <li class="separator"><a href="#ForceRecheck" class="recheck">_(Force recheck)</a></li>
</ul> </ul>
<div id="desktopFooterWrapper">
<div id="desktopFooter">
<table style="position: absolute; right: 5px;">
<tr><td id="DlInfos"></td><td style="width: 2px;margin:0;"><img src="images/skin/toolbox-divider.gif" style="height: 18px; padding-left: 10px; padding-right: 10px; margin-bottom: -2px;"/></td><td id="UpInfos"></td></tr>
</table>
</div>
</div>
</body> </body>
</html> </html>

26
src/webui/scripts/client.js

@ -106,9 +106,34 @@ window.addEvent('load', function(){
initializeWindows(); initializeWindows();
var r=0; var r=0;
var waiting=false; var waiting=false;
var waitingTrInfo = false;
var stateToImg = function(state){ var stateToImg = function(state){
return 'images/skin/'+state+'.png'; return 'images/skin/'+state+'.png';
};
var loadTransferInfo = function() {
var url = 'json/transferInfo';
if(!waitingTrInfo) {
waitingTrInfo = true;
var request = new Request.JSON({
url: url,
noCache: true,
method: 'get',
onFailure: function() {
$('error_div').set('html', 'qBittorrent client is not reachable');
waitingTrInfo=false;
loadTransferInfo.delay(4000);
},
onSuccess: function(info) {
if(info) {
$("DlInfos").set('html', info.DlInfos);
$("UpInfos").set('html', info.UpInfos);
waitingTrInfo=false;
loadTransferInfo.delay(3000);
}
}
}).send();
}
}; };
var ajaxfn = function(){ var ajaxfn = function(){
var queueing_enabled = false; var queueing_enabled = false;
@ -178,6 +203,7 @@ window.addEvent('load', function(){
} }
}; };
ajaxfn(); ajaxfn();
loadTransferInfo();
// ajaxfn.periodical(5000); // ajaxfn.periodical(5000);
setFilter = function(f) { setFilter = function(f) {

Loading…
Cancel
Save