Change color depending of torrent seeders and piece size.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
b8392c4c50
commit
b59def4718
2 changed files with 25 additions and 2 deletions
|
@ -5,6 +5,8 @@ setInterval(function () {
|
|||
fetchData();
|
||||
}, 2000)
|
||||
|
||||
const MB = 1048576;
|
||||
|
||||
function fetchData() {
|
||||
fetch('/api/routes')
|
||||
.then(function (response) {
|
||||
|
@ -22,7 +24,7 @@ function fetchData() {
|
|||
var upload = torrentStat.uploadedBytes / torrentStat.timePassed;
|
||||
var seeders = torrentStat.seeders;
|
||||
var peers = torrentStat.peers;
|
||||
var pieceSize = torrentStat.pieceSice;
|
||||
var pieceSize = torrentStat.pieceSize;
|
||||
|
||||
document.getElementById("up-down-speed-text-" + torrentStat.hash).innerText =
|
||||
Humanize.ibytes(download, 1024) + "/s down, " + Humanize.ibytes(upload, 1024) + "/s up";
|
||||
|
@ -30,6 +32,27 @@ function fetchData() {
|
|||
peers + " peers, " + seeders + " seeders."
|
||||
document.getElementById("piece-size-" + torrentStat.hash).innerText = "Piece size: " + Humanize.bytes(pieceSize, 1024)
|
||||
|
||||
var className = "";
|
||||
|
||||
if (seeders < 2) {
|
||||
className = "text-danger";
|
||||
} else if (seeders >= 2 && seeders < 4) {
|
||||
className = "text-warning";
|
||||
} else {
|
||||
className = "text-success";
|
||||
}
|
||||
|
||||
document.getElementById("peers-seeders-" + torrentStat.hash).className = className;
|
||||
|
||||
if (pieceSize <= MB) {
|
||||
className = "text-success";
|
||||
} else if (pieceSize > MB && pieceSize < (MB * 4)) {
|
||||
className = "text-warning";
|
||||
} else {
|
||||
className = "text-danger";
|
||||
}
|
||||
|
||||
document.getElementById("piece-size-" + torrentStat.hash).className = className;
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
@ -35,7 +35,7 @@ type TorrentStats struct {
|
|||
TimePassed float64 `json:"timePassed"`
|
||||
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
||||
TotalPieces int `json:"totalPieces"`
|
||||
PieceSize int64 `json:"pieceSice"`
|
||||
PieceSize int64 `json:"pieceSize"`
|
||||
}
|
||||
|
||||
type GlobalTorrentStats struct {
|
||||
|
|
Loading…
Reference in a new issue