Fix stats reporting. Add Vite compatibility
This commit is contained in:
@@ -14,7 +14,7 @@ let {
|
||||
|
||||
let loading = $state(true)
|
||||
let downloads = $state(0)
|
||||
let transfer_used = $state(0)
|
||||
let egress_used = $state(0)
|
||||
let socket = null
|
||||
let error_msg = $state("")
|
||||
|
||||
@@ -48,6 +48,9 @@ const update_base = async () => {
|
||||
} else if (connected_to === nav.base.path) {
|
||||
return // If we're already connected to the same path, don't reconnect
|
||||
}
|
||||
|
||||
console.debug("Websocket connection path changed from", connected_to, "to", nav.base.path)
|
||||
|
||||
connected_to = nav.base.path
|
||||
|
||||
// If the socket is already active we need to close it
|
||||
@@ -68,7 +71,7 @@ const update_base = async () => {
|
||||
error_msg = ""
|
||||
loading = false
|
||||
downloads = j.downloads
|
||||
transfer_used = j.transfer_free + j.transfer_paid
|
||||
egress_used = j.egress
|
||||
}
|
||||
socket.onerror = err => {
|
||||
console.error("WS error", err)
|
||||
@@ -133,7 +136,7 @@ const toggle_expand_keyboard = (e: KeyboardEvent) => {
|
||||
<div class="group">
|
||||
<div class="label">Egress</div>
|
||||
<div class="stat">
|
||||
{loading ? "Loading..." : formatDataVolume(transfer_used, 3)}
|
||||
{loading ? "Loading..." : formatDataVolume(egress_used, 3)}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user