feat(dashboard): #191 add development of treasurechests
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 12m24s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 2m53s

This commit was merged in pull request #207.
This commit is contained in:
2025-06-30 00:39:14 +02:00
parent f37b50515b
commit 6e1d24eef7
8 changed files with 230 additions and 19 deletions

View File

@@ -7,6 +7,9 @@ async function initMainChart() {
}
var myChart = echarts.init(element);
window.addEventListener('resize', function() {
myChart.resize();
});
try {
const response = await fetch("/dashboard/main-chart");
@@ -22,10 +25,7 @@ async function initMainChart() {
'Sum of Savings: <span class="font-bold">' + params[1].data[1] + '</span> €'
};
const chart = myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
});
myChart.setOption(option);
console.log("initialized main-chart");
} catch (error) {
@@ -40,6 +40,9 @@ async function initTreasureChests() {
}
var myChart = echarts.init(element);
window.addEventListener('resize', function() {
myChart.resize();
});
try {
const response = await fetch("/dashboard/treasure-chests");
@@ -48,11 +51,7 @@ async function initTreasureChests() {
}
const option = await response.json();
const chart = myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
});
myChart.setOption(option);
console.log("initialized treasure-chests");
} catch (error) {
@@ -60,5 +59,42 @@ async function initTreasureChests() {
}
}
async function initTreasureChest() {
const element = document.getElementById('treasure-chest')
if (element === null) {
return;
}
var myChart = echarts.init(element);
window.addEventListener('resize', function() {
myChart.resize();
});
const treasureChestSelect = document.getElementById('treasure-chest-id')
treasureChestSelect.addEventListener("change", async (e) => {
try {
const response = await fetch("/dashboard/treasure-chest?id="+e.target.value);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const option = await response.json();
option.tooltip.formatter = function (params) {
return new Date(params[0].data[0]).toLocaleString([], { day: 'numeric', month: 'short', year: 'numeric' }) +
'<br />' +
'Sum of Accounts: <span class="font-bold">' + params[0].data[1] + '</span> €'
};
myChart.setOption(option);
} catch (error) {
console.error(error.message);
}
});
console.log("initialized treasure-chest");
}
initMainChart();
initTreasureChests();
initTreasureChest();