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
Raw Normal View History

init()
2023-02-09 20:29:07 +00:00
async function init() { // The page init function
versionDisplay()
2023-05-23 12:03:48 +01:00
await display(await get())
hideLoading()
2023-02-09 20:29:07 +00:00
}
async function get() { // Fetch data from API
var url = `${window.location.origin}/api/v1/stats`
var resp = await fetch(url)
return await resp.json()
2023-02-09 20:29:07 +00:00
}
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'
2023-05-23 12:03:48 +01:00
document.getElementById('corpus_api').textContent = dat.corpus_api || '0'
document.getElementById('corpus').textContent = dat.corpus || '0'
document.getElementById('stations').textContent = dat.stations || '0'
2023-05-23 23:52:55 +01:00
document.getElementById('users').textContent = dat.users || '0'
document.getElementById('meta').textContent = dat.meta || '0'
2023-05-24 09:33:37 +01:00
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'
2023-02-09 20:29:07 +00:00
}