2020-05-18 17:42:23 +00:00
|
|
|
GeneralChart.init();
|
|
|
|
var cacheChart = new SingleBarChart("chart-cache", "Cache disk");
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
setInterval(function () {
|
|
|
|
fetchData();
|
|
|
|
}, 2000)
|
|
|
|
|
|
|
|
function fetchData() {
|
|
|
|
fetch('/api/status')
|
|
|
|
.then(function (response) {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json();
|
|
|
|
} else {
|
2020-11-08 17:19:25 +00:00
|
|
|
toastError('Error getting data from server. Response: ' + response.status)
|
2020-05-18 17:42:23 +00:00
|
|
|
}
|
|
|
|
}).then(function (stats) {
|
|
|
|
var download = stats.torrentStats.downloadedBytes / stats.torrentStats.timePassed;
|
|
|
|
var upload = stats.torrentStats.uploadedBytes / stats.torrentStats.timePassed;
|
|
|
|
|
|
|
|
GeneralChart.update(download, upload);
|
|
|
|
|
|
|
|
cacheChart.update(stats.cacheFilled, stats.cacheCapacity - stats.cacheFilled);
|
|
|
|
document.getElementById("down-speed-text").innerText =
|
2020-06-09 10:06:12 +00:00
|
|
|
Humanize.ibytes(download, 1024) + "/s";
|
2020-05-18 17:42:23 +00:00
|
|
|
|
|
|
|
document.getElementById("up-speed-text").innerText =
|
2020-06-09 10:06:12 +00:00
|
|
|
Humanize.ibytes(upload, 1024) + " /s";
|
2020-05-18 17:42:23 +00:00
|
|
|
})
|
|
|
|
.catch(function (error) {
|
2020-11-08 17:19:25 +00:00
|
|
|
toastError('Error getting status info: ' + error.message)
|
2020-05-18 17:42:23 +00:00
|
|
|
});
|
|
|
|
}
|