WebUI: make API locale independet

Sizes are now given in bytes.
Dates are Unix timestamps and converted to ISO 8601 in the web UI.
Numbers are not converted to strings.
-1 is returned for undefined values.

Some keys have been splitted:

Torrent list (json/torrents)
 * num_seeds: Torrent seeds connected to
 * num_complete: Torrent seeds in the swarm
 * num_leechs: Torrent leechers connected to
 * num_incomplete: Torrent leechers in the swarm

Torrent generic properties (propertiesGeneral/hash)
 * total_uploaded: Total data uploaded
 * total_uploaded_session: Total data uploaded this session
 * total_downloaded: Total data dowloaded
 * total_downloaded_session: Total data downloaded this session
 * time_elapsed: Torrent elapsed time
 * seeding_time: Torrent elapsed time while complete
 * nb_connections: Torrent connection count
 * nb_connections_limit: Torrent connection count limit

Global transfer info (json/transferInfo)
 * dl_info_speed: Global downalod rate
 * dl_info_data: Data downloaded this session
 * up_info_speed: Global upload rate
 * up_info_data: Data uploaded this session

Closes #1524.
This commit is contained in:
Gabriele 2014-11-08 16:13:00 +01:00
parent 6d64f2430c
commit aedf579d77
9 changed files with 192 additions and 64 deletions

View file

@ -108,8 +108,10 @@ window.addEvent('load', function(){
},
onSuccess: function(info) {
if(info) {
$("DlInfos").set('html', info.dl_info);
$("UpInfos").set('html', info.up_info);
$("DlInfos").set('html', "_(D: %1 - T: %2)".replace("%1", friendlyUnit(info.dl_info_speed, true))
.replace("%2", friendlyUnit(info.dl_info_data, false)));
$("UpInfos").set('html', "_(U: %1 - T: %2)".replace("%1", friendlyUnit(info.up_info_speed, true))
.replace("%2", friendlyUnit(info.up_info_data, false)));
waitingTrInfo=false;
loadTransferInfo.delay(3000);
}
@ -146,18 +148,25 @@ window.addEvent('load', function(){
row.length = 10;
row[0] = stateToImg(event.state);
row[1] = event.name;
row[2] = event.priority
row[3] = event.size;
row[2] = event.priority > -1 ? event.priority : null;
row[3] = friendlyUnit(event.size, false);
row[4] = (event.progress*100).round(1);
if(row[4] == 100.0 && event.progress != 1.0)
row[4] = 99.9;
row[5] = event.num_seeds;
row[6] = event.num_leechs;
row[7] = event.dlspeed;
row[8] = event.upspeed;
row[9] = event.eta;
row[10] = event.ratio;
if(row[2] != "*")
row[5] = event.num_seeds;
if (event.num_complete != -1)
row[5] += " (" + event.num_complete + ")";
row[6] = event.num_leechs;
if (event.num_incomplete != -1)
row[6] += " (" + event.num_incomplete + ")";
row[7] = friendlyUnit(event.dlspeed, true);
row[8] = friendlyUnit(event.upspeed, true);
row[9] = friendlyDuration(event.eta);
if(event.ratio == -1)
row[10] = "∞";
else
row[10] = (Math.floor(100 * event.ratio) / 100).toFixed(2); //Don't round up
if(row[2] != null)
queueing_enabled = true;
if(!torrent_hashes.contains(event.hash)) {
// New unfinished torrent