mirror of
https://github.com/gmemstr/sliproad.git
synced 2024-09-20 00:21:15 +01:00
88e0d6c7b1
Update README.md Add disk usage statistics to index & API.
52 lines
1.8 KiB
HTML
52 lines
1.8 KiB
HTML
<html>
|
|
<head>
|
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta content="utf-8" http-equiv="encoding">
|
|
<title>Home | GoNAS</title>
|
|
<link rel="stylesheet" href="/assets/styles.css">
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div>
|
|
<h1 style="display: inline-block">GoNAS</h1>
|
|
<p>Hot Storage Usage (<span id="hotUsagePercent"></span>%)</p>
|
|
<progress max="100" id="hotUsage"></progress>
|
|
<p>Cold Storage Usage (<span id="coldUsagePercent"></span>%)</p>
|
|
<progress max="100" id="coldUsage"></progress>
|
|
</div>
|
|
<div class="content index">
|
|
<a href="/files/">
|
|
<img src="/assets/svgs/hotfiles.svg" alt="">Hot Files</a><br>
|
|
<a href="/archive/">
|
|
<img src="/assets/svgs/coldfiles.svg" alt="">Cold Files</a>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
const $ = selector => document.querySelector(selector);
|
|
|
|
const init = event => {
|
|
getUsages();
|
|
}
|
|
|
|
const getUsages = () => {
|
|
fetch('/api/diskusage')
|
|
.then(function (response) {
|
|
return response.json();
|
|
})
|
|
.then(function (jsonResult) {
|
|
console.log(jsonResult);
|
|
let hot = (jsonResult.HotStorage.Free) / (jsonResult.HotStorage.Total) * 100;
|
|
let cold = (jsonResult.ColdStorage.Free) / (jsonResult.ColdStorage.Total) * 100;
|
|
// Flip values to reflect % used rather than % free.
|
|
$("#hotUsage").value = 100 - hot;
|
|
$("#hotUsagePercent").innerText = Math.floor(100 - hot);
|
|
$("#coldUsage").value = 100 - cold;
|
|
$("#coldUsagePercent").innerText = Math.floor(100 - cold);
|
|
});
|
|
}
|
|
|
|
window.addEventListener('load', init);
|
|
</script>
|
|
</body>
|
|
</html> |