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/stats.js

37 lines
1.8 KiB
JavaScript

init()
async function init() { // The page init function
versionDisplay()
await display(await get())
hideLoading()
}
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('corpus_api').textContent = dat.corpus_api || '0'
document.getElementById('corpus').textContent = dat.corpus || '0'
document.getElementById('stations').textContent = dat.stations || '0'
document.getElementById('users').textContent = dat.users || '0'
document.getElementById('meta').textContent = dat.meta || '0'
document.getElementById('pis').textContent = dat.pis || '0'
document.getElementById('timetable_count').textContent = data.count.timetable || '0'
document.getElementById('ver-dbman').textContent = ver.dbmanager || 'Unknown'
document.getElementById('user_count').textContent = data.count.users || 'Unknown'
document.getElementById('reg_count').textContent = data.count.reg || '0'
document.getElementById('pis_count').textContent = data.count.pis || 'Unknown'
document.getElementById('corpus_count').textContent = data.count.corpus || 'Unknown'
document.getElementById('stations_count').textContent = data.count.stations || 'Unknown'
}