This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
web/js/stat.js
2023-05-01 21:04:19 +01:00

30 lines
1.3 KiB
JavaScript

init()
async function init() { // The page init function
versionDisplay()
display(await get())
}
async function get() { // Fetch data from API
var url = `${window.location.origin}/api/v1/stats`
var resp = await fetch(url)
return await resp.json()
}
async function display(data) { // Parses and displays data from API
document.getElementById('server_host').textContent = data.host
document.getElementById('server_mode').textContent = data.mode || 'Unknown'
document.getElementById('ver-bkend').textContent = data.verBkend || 'Unknown'
let dat = data.dat[0]
let ver = data.ver[0]
document.getElementById('time').textContent = await convertUnixLocal(dat.since)
document.getElementById('ldbws').textContent = dat.ldbws || '0'
document.getElementById('ldbsvws').textContent = dat.ldbsvws || '0'
document.getElementById('apicorpus').textContent = dat.corpus_api || '0'
document.getElementById('corpus').textContent = dat.corpus || '0'
document.getElementById('stations').textContent = dat.stations || '0'
document.getElementById('users').textContent = dat.user || '0'
document.getElementById('meta').textContent = dat.meta || '0'
document.getElementById('pis').textContent = dat.pis
document.getElementById('ver-dbman').textContent = ver.dbmanager || 'Unknown'
}