Add peers and seeders on routes page.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
ecd524ed3c
commit
9f6d1d713a
3 changed files with 14 additions and 1 deletions
|
@ -20,8 +20,12 @@ 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 peers = torrentStat.peers
|
||||||
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.bytes(download, 1024) + "/s down, " + Humanize.bytes(upload, 1024) + "/s up";
|
||||||
|
document.getElementById("peers-seeders-" + torrentStat.hash).innerText =
|
||||||
|
peers + " peers, " + seeders + " seeders."
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,8 @@ type TorrentStats struct {
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
DownloadedBytes int64 `json:"downloadedBytes"`
|
DownloadedBytes int64 `json:"downloadedBytes"`
|
||||||
UploadedBytes int64 `json:"uploadedBytes"`
|
UploadedBytes int64 `json:"uploadedBytes"`
|
||||||
|
Peers int `json:"peers"`
|
||||||
|
Seeders int `json:"seeders"`
|
||||||
TimePassed float64 `json:"timePassed"`
|
TimePassed float64 `json:"timePassed"`
|
||||||
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
PieceChunks []*PieceChunk `json:"pieceChunks"`
|
||||||
TotalPieces int `json:"totalPieces"`
|
TotalPieces int `json:"totalPieces"`
|
||||||
|
@ -51,6 +53,8 @@ type stats struct {
|
||||||
downloadBytes int64
|
downloadBytes int64
|
||||||
totalUploadBytes int64
|
totalUploadBytes int64
|
||||||
uploadBytes int64
|
uploadBytes int64
|
||||||
|
peers int
|
||||||
|
seeders int
|
||||||
time time.Time
|
time time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +145,6 @@ func (s *Torrent) stats(now time.Time, t *torrent.Torrent, chunks bool) *Torrent
|
||||||
log.Println("Using previous stats")
|
log.Println("Using previous stats")
|
||||||
} else {
|
} else {
|
||||||
st := t.Stats()
|
st := t.Stats()
|
||||||
|
|
||||||
rd := st.BytesReadData.Int64()
|
rd := st.BytesReadData.Int64()
|
||||||
wd := st.BytesWrittenData.Int64()
|
wd := st.BytesWrittenData.Int64()
|
||||||
ist := &stats{
|
ist := &stats{
|
||||||
|
@ -150,10 +153,14 @@ func (s *Torrent) stats(now time.Time, t *torrent.Torrent, chunks bool) *Torrent
|
||||||
totalDownloadBytes: rd,
|
totalDownloadBytes: rd,
|
||||||
totalUploadBytes: wd,
|
totalUploadBytes: wd,
|
||||||
time: now,
|
time: now,
|
||||||
|
peers: st.TotalPeers,
|
||||||
|
seeders: st.ConnectedSeeders,
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.DownloadedBytes = ist.downloadBytes
|
ts.DownloadedBytes = ist.downloadBytes
|
||||||
ts.UploadedBytes = ist.uploadBytes
|
ts.UploadedBytes = ist.uploadBytes
|
||||||
|
ts.Peers = ist.peers
|
||||||
|
ts.Seeders = ist.seeders
|
||||||
|
|
||||||
s.previousStats[t.InfoHash().String()] = ist
|
s.previousStats[t.InfoHash().String()] = ist
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
</div>
|
</div>
|
||||||
<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>
|
||||||
|
|
||||||
</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