From b7a7d1d9512357bb2309fff50afaebd4082f9dd8 Mon Sep 17 00:00:00 2001 From: Benedict Börger Date: Sat, 22 Jun 2019 23:56:25 +0200 Subject: [web_frontend][chart] link chart to transactions when a category in the pie chart is selected load the corresponding transaction site with the right filter set. --- src/web_frontend/chart.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/web_frontend') diff --git a/src/web_frontend/chart.rs b/src/web_frontend/chart.rs index 43ec3eb..0992e99 100644 --- a/src/web_frontend/chart.rs +++ b/src/web_frontend/chart.rs @@ -12,10 +12,16 @@ use regex::Regex; use chrono::{NaiveDate, Utc}; use chrono::Datelike; +#[derive(Serialize)] +struct GroupValues { + amount : f32, + filter : String +} + #[derive(Serialize)] struct ChartContext { account_name : String, - groups : HashMap, + groups : HashMap, total_sum : f32, total_chart : f32, date_start : String, @@ -71,9 +77,14 @@ pub fn chart_handler(account : &RawStr, start : Option<&RawStr>, end : Option<&R println!("total sum: {}", total_sum); let mut total_chart = 0.0; for (section_name, entries) in ini_file.sections { + let mut filter_string = String::from(""); let mut complete = 0.0; for (key, values) in entries { for val in values { + filter_string.push_str(&key); + filter_string.push_str("-"); + filter_string.push_str(&val); + filter_string.push_str("."); let mut t_filtered_cloned = t_filtered.clone(); if val.is_empty() || val.is_empty() { continue @@ -85,7 +96,7 @@ pub fn chart_handler(account : &RawStr, start : Option<&RawStr>, end : Option<&R complete = complete + tmp.abs(); } } - groups.insert(section_name, complete); + groups.insert(section_name, GroupValues{ amount: complete, filter : filter_string } ); total_chart = total_chart + complete; // ALSO INSERT OTHER, AKA THE REST } -- cgit v1.2.3-70-g09d2