reminder-bot/web/static/js/admin.js

82 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-06-21 14:09:24 +00:00
document.addEventListener("DOMContentLoaded", () => {
fetch("/admin/data")
.then((resp) => resp.json())
.then((data) => {
document.querySelector("#backlog").textContent = data.backlog;
document.querySelector("#reminders").textContent = data.count.reminders;
document.querySelector("#intervals").textContent = data.count.intervals;
2023-06-21 14:09:24 +00:00
new Chart(document.getElementById("schedule"), {
type: "bar",
data: {
2023-06-21 14:24:43 +00:00
labels: [
...data.scheduleShort.once,
...data.scheduleShort.interval,
].map((row) => luxon.DateTime.fromISO(row.time_key)),
2023-06-21 14:09:24 +00:00
datasets: [
{
label: "Reminders",
2023-06-21 14:24:43 +00:00
data: data.scheduleShort.once.map((row) => row.count),
},
{
label: "Intervals",
data: data.scheduleShort.interval.map((row) => row.count),
2023-06-21 14:09:24 +00:00
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
2023-06-21 14:24:43 +00:00
stacked: true,
2023-06-21 14:09:24 +00:00
type: "time",
time: {
unit: "minute",
},
},
2023-06-21 14:24:43 +00:00
y: {
stacked: true,
},
2023-06-21 14:09:24 +00:00
},
},
});
new Chart(document.getElementById("scheduleLong"), {
type: "bar",
data: {
2023-06-21 14:24:43 +00:00
labels: [
...data.scheduleLong.once,
...data.scheduleLong.interval,
].map((row) => luxon.DateTime.fromISO(row.time_key)),
2023-06-21 14:09:24 +00:00
datasets: [
{
label: "Reminders",
2023-06-21 14:24:43 +00:00
data: data.scheduleLong.once.map((row) => row.count),
},
{
label: "Intervals",
data: data.scheduleLong.interval.map((row) => row.count),
2023-06-21 14:09:24 +00:00
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
2023-06-21 14:24:43 +00:00
stacked: true,
2023-06-21 14:09:24 +00:00
type: "time",
time: {
unit: "day",
},
},
2023-06-21 14:24:43 +00:00
y: {
stacked: true,
},
2023-06-21 14:09:24 +00:00
},
},
});
});
});