Add piece size to web interface.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
59ce273e25
commit
401a79379f
7 changed files with 43 additions and 15 deletions
|
@ -22,10 +22,10 @@ function fetchData() {
|
|||
|
||||
cacheChart.update(stats.cacheFilled, stats.cacheCapacity - stats.cacheFilled);
|
||||
document.getElementById("down-speed-text").innerText =
|
||||
Humanize.bytes(download, 1024) + "/s";
|
||||
Humanize.ibytes(download, 1024) + "/s";
|
||||
|
||||
document.getElementById("up-speed-text").innerText =
|
||||
Humanize.bytes(upload, 1024) + " /s";
|
||||
Humanize.ibytes(upload, 1024) + " /s";
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Error getting status info: ' + error.message);
|
||||
|
|
|
@ -27,16 +27,18 @@ var GeneralChart = {
|
|||
{
|
||||
label: 'Download Speed',
|
||||
fill: false,
|
||||
backgroundColor: 'rgb(255, 99, 132)',
|
||||
borderColor: 'rgb(255, 99, 132)',
|
||||
borderWidth: 1,
|
||||
backgroundColor: '#859900',
|
||||
borderColor: '#859900',
|
||||
borderWidth: 2,
|
||||
data: this._downloadData,
|
||||
|
||||
},
|
||||
{
|
||||
label: 'Upload Speed',
|
||||
fill: false,
|
||||
borderWidth: 1,
|
||||
backgroundColor: '#839496',
|
||||
borderColor: '#839496',
|
||||
borderWidth: 2,
|
||||
data: this._uploadData,
|
||||
|
||||
},
|
||||
|
@ -66,7 +68,7 @@ var GeneralChart = {
|
|||
type: 'linear',
|
||||
ticks: {
|
||||
userCallback: function (tick) {
|
||||
return Humanize.bytes(tick, 1024) + "/s";
|
||||
return Humanize.ibytes(tick, 1024) + "/s";
|
||||
},
|
||||
beginAtZero: true
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var sizes = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"];
|
||||
var isizes = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"];
|
||||
var sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB"];
|
||||
|
||||
function logn(n, b) {
|
||||
return Math.log(n) / Math.log(b);
|
||||
|
@ -19,6 +20,22 @@ var Humanize = {
|
|||
f = val.toFixed(1);
|
||||
}
|
||||
|
||||
return f + suffix;
|
||||
},
|
||||
ibytes: function (s, base) {
|
||||
if (s < 10) {
|
||||
return s.toFixed(0) + " B";
|
||||
}
|
||||
var e = Math.floor(logn(s, base));
|
||||
var suffix = isizes[e];
|
||||
var val = Math.floor(s / Math.pow(base, e) * 10 + 0.5) / 10;
|
||||
|
||||
var f = val.toFixed(0);
|
||||
|
||||
if (val < 10) {
|
||||
f = val.toFixed(1);
|
||||
}
|
||||
|
||||
return f + suffix;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,12 +20,15 @@ function fetchData() {
|
|||
|
||||
var download = torrentStat.downloadedBytes / torrentStat.timePassed;
|
||||
var upload = torrentStat.uploadedBytes / torrentStat.timePassed;
|
||||
var seeders = torrentStat.seeders
|
||||
var peers = torrentStat.peers
|
||||
var seeders = torrentStat.seeders;
|
||||
var peers = torrentStat.peers;
|
||||
var pieceSize = torrentStat.pieceSice;
|
||||
|
||||
document.getElementById("up-down-speed-text-" + torrentStat.hash).innerText =
|
||||
Humanize.bytes(download, 1024) + "/s down, " + Humanize.bytes(upload, 1024) + "/s up";
|
||||
Humanize.ibytes(download, 1024) + "/s down, " + Humanize.ibytes(upload, 1024) + "/s up";
|
||||
document.getElementById("peers-seeders-" + torrentStat.hash).innerText =
|
||||
peers + " peers, " + seeders + " seeders."
|
||||
document.getElementById("piece-size-" + torrentStat.hash).innerText = "Piece size: " + Humanize.bytes(pieceSize, 1024)
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,12 +7,12 @@ function SingleBarChart(id, name) {
|
|||
data: {
|
||||
labels:[name],
|
||||
datasets: [{
|
||||
backgroundColor: "gray",
|
||||
backgroundColor: "#839496",
|
||||
label: "used",
|
||||
data: this._used,
|
||||
},
|
||||
{
|
||||
backgroundColor: "green",
|
||||
backgroundColor: "#859900",
|
||||
label: "free",
|
||||
data: this._free,
|
||||
}],
|
||||
|
|
|
@ -35,6 +35,7 @@ type TorrentStats struct {
|
|||
TimePassed float64 `json:"timePassed"`
|
||||
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
||||
TotalPieces int `json:"totalPieces"`
|
||||
PieceSize int64 `json:"pieceSice"`
|
||||
}
|
||||
|
||||
type GlobalTorrentStats struct {
|
||||
|
@ -196,6 +197,11 @@ func (s *Torrent) stats(now time.Time, t *torrent.Torrent, chunks bool) *Torrent
|
|||
ts.Hash = t.InfoHash().String()
|
||||
ts.Name = t.Name()
|
||||
ts.TotalPieces = totalPieces
|
||||
|
||||
if t.Info() != nil {
|
||||
ts.PieceSize = t.Info().PieceLength
|
||||
}
|
||||
|
||||
return ts
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<div class="col">
|
||||
<p id="up-down-speed-text-{{.Hash}}">...</p>
|
||||
<p id="peers-seeders-{{.Hash}}">...</p>
|
||||
|
||||
<p id="piece-size-{{.Hash}}">...</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div id="file-chunks-{{.Hash}}" class="progress">
|
||||
|
|
Loading…
Reference in a new issue