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);
|
cacheChart.update(stats.cacheFilled, stats.cacheCapacity - stats.cacheFilled);
|
||||||
document.getElementById("down-speed-text").innerText =
|
document.getElementById("down-speed-text").innerText =
|
||||||
Humanize.bytes(download, 1024) + "/s";
|
Humanize.ibytes(download, 1024) + "/s";
|
||||||
|
|
||||||
document.getElementById("up-speed-text").innerText =
|
document.getElementById("up-speed-text").innerText =
|
||||||
Humanize.bytes(upload, 1024) + " /s";
|
Humanize.ibytes(upload, 1024) + " /s";
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log('Error getting status info: ' + error.message);
|
console.log('Error getting status info: ' + error.message);
|
||||||
|
|
|
@ -27,16 +27,18 @@ var GeneralChart = {
|
||||||
{
|
{
|
||||||
label: 'Download Speed',
|
label: 'Download Speed',
|
||||||
fill: false,
|
fill: false,
|
||||||
backgroundColor: 'rgb(255, 99, 132)',
|
backgroundColor: '#859900',
|
||||||
borderColor: 'rgb(255, 99, 132)',
|
borderColor: '#859900',
|
||||||
borderWidth: 1,
|
borderWidth: 2,
|
||||||
data: this._downloadData,
|
data: this._downloadData,
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Upload Speed',
|
label: 'Upload Speed',
|
||||||
fill: false,
|
fill: false,
|
||||||
borderWidth: 1,
|
backgroundColor: '#839496',
|
||||||
|
borderColor: '#839496',
|
||||||
|
borderWidth: 2,
|
||||||
data: this._uploadData,
|
data: this._uploadData,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -66,7 +68,7 @@ var GeneralChart = {
|
||||||
type: 'linear',
|
type: 'linear',
|
||||||
ticks: {
|
ticks: {
|
||||||
userCallback: function (tick) {
|
userCallback: function (tick) {
|
||||||
return Humanize.bytes(tick, 1024) + "/s";
|
return Humanize.ibytes(tick, 1024) + "/s";
|
||||||
},
|
},
|
||||||
beginAtZero: true
|
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) {
|
function logn(n, b) {
|
||||||
return Math.log(n) / Math.log(b);
|
return Math.log(n) / Math.log(b);
|
||||||
|
@ -19,6 +20,22 @@ var Humanize = {
|
||||||
f = val.toFixed(1);
|
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;
|
return f + suffix;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,12 +20,15 @@ function fetchData() {
|
||||||
|
|
||||||
var download = torrentStat.downloadedBytes / torrentStat.timePassed;
|
var download = torrentStat.downloadedBytes / torrentStat.timePassed;
|
||||||
var upload = torrentStat.uploadedBytes / torrentStat.timePassed;
|
var upload = torrentStat.uploadedBytes / torrentStat.timePassed;
|
||||||
var seeders = torrentStat.seeders
|
var seeders = torrentStat.seeders;
|
||||||
var peers = torrentStat.peers
|
var peers = torrentStat.peers;
|
||||||
|
var pieceSize = torrentStat.pieceSice;
|
||||||
|
|
||||||
document.getElementById("up-down-speed-text-" + torrentStat.hash).innerText =
|
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 =
|
document.getElementById("peers-seeders-" + torrentStat.hash).innerText =
|
||||||
peers + " peers, " + seeders + " seeders."
|
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: {
|
data: {
|
||||||
labels:[name],
|
labels:[name],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
backgroundColor: "gray",
|
backgroundColor: "#839496",
|
||||||
label: "used",
|
label: "used",
|
||||||
data: this._used,
|
data: this._used,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
backgroundColor: "green",
|
backgroundColor: "#859900",
|
||||||
label: "free",
|
label: "free",
|
||||||
data: this._free,
|
data: this._free,
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -35,6 +35,7 @@ type TorrentStats struct {
|
||||||
TimePassed float64 `json:"timePassed"`
|
TimePassed float64 `json:"timePassed"`
|
||||||
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
||||||
TotalPieces int `json:"totalPieces"`
|
TotalPieces int `json:"totalPieces"`
|
||||||
|
PieceSize int64 `json:"pieceSice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GlobalTorrentStats struct {
|
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.Hash = t.InfoHash().String()
|
||||||
ts.Name = t.Name()
|
ts.Name = t.Name()
|
||||||
ts.TotalPieces = totalPieces
|
ts.TotalPieces = totalPieces
|
||||||
|
|
||||||
|
if t.Info() != nil {
|
||||||
|
ts.PieceSize = t.Info().PieceLength
|
||||||
|
}
|
||||||
|
|
||||||
return ts
|
return ts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p id="up-down-speed-text-{{.Hash}}">...</p>
|
<p id="up-down-speed-text-{{.Hash}}">...</p>
|
||||||
<p id="peers-seeders-{{.Hash}}">...</p>
|
<p id="peers-seeders-{{.Hash}}">...</p>
|
||||||
|
<p id="piece-size-{{.Hash}}">...</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div id="file-chunks-{{.Hash}}" class="progress">
|
<div id="file-chunks-{{.Hash}}" class="progress">
|
||||||
|
|
Loading…
Reference in a new issue