From ce2c163abe03c01b924d0766111c956418695310 Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Tue, 29 Oct 2024 15:23:15 +0200 Subject: [PATCH] monthly budget analysis page --- app/static/budget_monthly_analysis.js | 32 +++++++++++++++++ app/templates/budget_monthly_analysis.html | 40 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 app/static/budget_monthly_analysis.js create mode 100644 app/templates/budget_monthly_analysis.html diff --git a/app/static/budget_monthly_analysis.js b/app/static/budget_monthly_analysis.js new file mode 100644 index 0000000..50c4848 --- /dev/null +++ b/app/static/budget_monthly_analysis.js @@ -0,0 +1,32 @@ +const monthSelector = document.getElementById('month-selector'); +const tableBody = document.getElementById('table-body'); + + + +async function displayMonthLineItems(dateString){ + const [month, year] = dateString.split(' '); + var result = await fetch(`/get_budget_details_for_month/${month}/${year}`, {method:'POST'}); + var data = await result.json(); + tableBody.innerHTML = '' + data.forEach(budget_category => { + const row = ` + + ${budget_category.id} + ${budget_category.name} + ${budget_category.month_cost} + + `; + + // Insert the row into the table body + tableBody.insertAdjacentHTML('beforeend', row); + + }); + addListenersToReassignButtons(); +} + +document.addEventListener("DOMContentLoaded", (event) => { + displayMonthLineItems(monthSelector.value); + monthSelector.addEventListener('change', (e) => { + displayMonthLineItems(e.target.value); + }) + }); \ No newline at end of file diff --git a/app/templates/budget_monthly_analysis.html b/app/templates/budget_monthly_analysis.html new file mode 100644 index 0000000..28bf9e9 --- /dev/null +++ b/app/templates/budget_monthly_analysis.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} +{% block title %}Budget Monthly Analysis{% endblock title %} + +{% block content %} +
+
+
+
+ Budget Categories +
+ + + +
+
+ +
+ + + + + + + + + + + +
IDNameTotal Month Cost
Loading...
+
+
+
+
+
+ +{% endblock content %} \ No newline at end of file