@@ -7,11 +7,10 @@
|
||||
|
||||
// use orbtk::prelude::*;
|
||||
|
||||
// /*
|
||||
// * WidgetContainer = entity
|
||||
// */
|
||||
// // methods get, get_mut, try_get, try_get_mut and clone
|
||||
// // ctx.widget returns a WidgetContainer that wraps the current widget of the state
|
||||
// /* * WidgetContainer = entity */
|
||||
// associated functions: get, get_mut, try_get, try_get_mut and clone
|
||||
// ctx.widget() returns a WidgetContainer object, that wraps
|
||||
// the current state of that widget (i.e properties)
|
||||
// let mut widget_container: WidgetContainer = ctx.widget();
|
||||
|
||||
// // property handling (componets)
|
||||
@@ -23,7 +22,6 @@
|
||||
// // .set<PropertyType>("property_name", property_value);
|
||||
// widget_container.set::<String16>("text", "my_text");
|
||||
|
||||
|
||||
// /*
|
||||
// * Child WidgetContainer = child entity
|
||||
// */
|
||||
@@ -48,11 +46,9 @@
|
||||
// // set child field attributes
|
||||
// text_box.set_text("My new text");
|
||||
|
||||
|
||||
// /*
|
||||
// * Registry handling
|
||||
// */
|
||||
|
||||
// // register service
|
||||
// fn update(registry: &mut Registry, _: &mut Context) {
|
||||
// registry.register("my_db_serve", MyDBServie::new());
|
||||
@@ -62,8 +58,6 @@
|
||||
// let mut my_db_service: MyDBSerivce = registry.get_mut("my_db_service");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// API Update: access properties of widgets in states
|
||||
|
||||
// Old style (associated functions)
|
||||
@@ -85,5 +79,4 @@
|
||||
// or
|
||||
// ctx.get_widget(self.text_block).set("offset", offset);
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
||||
@@ -8,25 +8,25 @@
|
||||
// suppress creation of a new console window on window
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use locales::t;
|
||||
use orbtk::{
|
||||
prelude::*,
|
||||
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
|
||||
theming::config::ThemeConfig,
|
||||
};
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use std::time::SystemTime;
|
||||
use tracing::{Level, info, trace};
|
||||
use tracing::{info, trace, Level};
|
||||
|
||||
use advotracker::{
|
||||
data::{constants::*, structures::Email},
|
||||
widgets::global_state::GlobalState,
|
||||
widgets::main_view,
|
||||
//services::exports::send_ticketdata::sendticketdata,
|
||||
widgets::policycheck::*,
|
||||
widgets::policycheck_state::*,
|
||||
widgets::main_view,
|
||||
widgets::ticketdata::*,
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_F
|
||||
pub enum TicketdataAction {
|
||||
ClearForm(),
|
||||
SendForm(),
|
||||
UpdatePolicyCode(String)
|
||||
UpdatePolicyCode(String),
|
||||
}
|
||||
|
||||
// German localization file.
|
||||
@@ -46,7 +46,7 @@ static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
lang = lang.substring(0, 5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
|
||||
// return the active language
|
||||
@@ -92,7 +92,6 @@ cfg_if! {
|
||||
|
||||
// Main
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// initialize the tracing subsystem
|
||||
// a drop in replacement for classical logging
|
||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
||||
@@ -167,18 +166,13 @@ widget!(MainView {
|
||||
policycheck_view: PolicyCheck
|
||||
});
|
||||
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let ticketdata_view = TicketdataView::new()
|
||||
.build(ctx);
|
||||
let ticketdata_view = TicketdataView::new().build(ctx);
|
||||
|
||||
let policycheck_view = PolicycheckView::new()
|
||||
.target(ticketdata_view.0)
|
||||
.build(ctx);
|
||||
let policycheck_view = PolicycheckView::new().target(ticketdata_view.0).build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.child(
|
||||
self.name("MainView").child(
|
||||
TabWidget::new()
|
||||
.tab(ID_POLICY_CHECK_VIEW, policycheck_view)
|
||||
.tab(ID_TICKET_DATA_VIEW, ticketdata_view)
|
||||
@@ -232,7 +226,7 @@ impl Template for TicketdataView {
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -263,7 +257,7 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(32) // Delimiter (2x margin)
|
||||
.push(32), // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -280,7 +274,7 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 12
|
||||
.push(14) // Seperator
|
||||
.push(14), // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -470,10 +464,7 @@ impl Template for TicketdataView {
|
||||
let items_mail_to_count = items_mail_to.len();
|
||||
|
||||
// vector with valid carbon copy recipients addresses (mail_to)
|
||||
let items_mail_cc = vec![
|
||||
PROP_MAIL_CC_1,
|
||||
PROP_MAIL_CC_2,
|
||||
];
|
||||
let items_mail_cc = vec![PROP_MAIL_CC_1, PROP_MAIL_CC_2];
|
||||
let items_mail_cc_count = items_mail_cc.len();
|
||||
|
||||
let ticket_data_form_mail = Container::new()
|
||||
@@ -490,14 +481,14 @@ impl Template for TicketdataView {
|
||||
.push("stretch") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("auto") // MailAddress
|
||||
.push("32") // Delimiter (2x margin)
|
||||
.push("32"), // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(2) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(2) // Seperator
|
||||
.push(2), // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -517,7 +508,9 @@ impl Template for TicketdataView {
|
||||
.style(STYLE_MAIL_TO)
|
||||
.count(items_mail_to_count)
|
||||
.items_builder(move |ibc, index| {
|
||||
let text_mail_to = TicketdataView::items_mail_to_ref(&ibc.get_widget(id))[index].clone();
|
||||
let text_mail_to =
|
||||
TicketdataView::items_mail_to_ref(&ibc.get_widget(id))[index]
|
||||
.clone();
|
||||
TextBox::new()
|
||||
.text(text_mail_to)
|
||||
.v_align("center")
|
||||
@@ -543,7 +536,9 @@ impl Template for TicketdataView {
|
||||
.style(STYLE_MAIL_CC)
|
||||
.count(items_mail_cc_count)
|
||||
.items_builder(move |ibc, index| {
|
||||
let text_mail_cc = TicketdataView::items_mail_cc_ref(&ibc.get_widget(id))[index].clone();
|
||||
let text_mail_cc =
|
||||
TicketdataView::items_mail_cc_ref(&ibc.get_widget(id))[index]
|
||||
.clone();
|
||||
TextBox::new()
|
||||
.text(text_mail_cc)
|
||||
.v_align("center")
|
||||
@@ -584,7 +579,7 @@ impl Template for TicketdataView {
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
.push(50), // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -592,9 +587,8 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Mail_Form
|
||||
.push("*") // Input_Form
|
||||
.push("auto") // Action
|
||||
.push("auto") // Bottom_Bar
|
||||
.push("auto"), // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(ticket_data_header_bar) // row 0
|
||||
.child(ticket_data_form_mail) // row 1
|
||||
.child(ticket_data_form) // row 2
|
||||
@@ -613,14 +607,26 @@ impl TicketdataState {
|
||||
/// Clear the text property of all children of the given form entity
|
||||
pub fn clear_form(entity: Entity, ctx: &mut Context<'_>) {
|
||||
if let Some(count) = ctx.get_widget(entity).children_count() {
|
||||
info!("Widget name: {:?}", ctx.get_widget(entity).get::<String>("name"));
|
||||
info!("Widget id: {:?}", ctx.get_widget(entity).get::<String>("id"));
|
||||
info!(
|
||||
"Widget name: {:?}",
|
||||
ctx.get_widget(entity).get::<String>("name")
|
||||
);
|
||||
info!(
|
||||
"Widget id: {:?}",
|
||||
ctx.get_widget(entity).get::<String>("id")
|
||||
);
|
||||
}
|
||||
|
||||
// identify the form by its id
|
||||
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
||||
info!("Form id: {:?}", ctx.get_widget(form_entity).get::<String>("id"));
|
||||
info!("Form node name: {:?}", ctx.get_widget(form_entity).get::<String>("name"));
|
||||
info!(
|
||||
"Form id: {:?}",
|
||||
ctx.get_widget(form_entity).get::<String>("id")
|
||||
);
|
||||
info!(
|
||||
"Form node name: {:?}",
|
||||
ctx.get_widget(form_entity).get::<String>("name")
|
||||
);
|
||||
|
||||
// Loop through children
|
||||
if let Some(count) = ctx.get_widget(form_entity).children_count() {
|
||||
@@ -633,7 +639,6 @@ impl TicketdataState {
|
||||
}
|
||||
|
||||
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
||||
|
||||
// type conversion (String -> u64)
|
||||
//let policy_code = ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").unwrap().parse::<u64>().unwrap();
|
||||
|
||||
@@ -647,20 +652,40 @@ impl TicketdataState {
|
||||
//mail_to: ctx.child(ID_TICKET_DATA_MAIL_TO).get::<String>("text").to_string(),
|
||||
// WIP: mail_cc -> selected index auslesen
|
||||
//mail_cc: ctx.child(ID_TICKET_DATA_MAIL_CC).get::<String>("text").to_string(),
|
||||
|
||||
mail_to: PROP_MAIL_TO_1.to_string(),
|
||||
mail_cc: PROP_MAIL_CC_1.to_string(),
|
||||
mail_bcc: PROP_MAIL_BCC_1.to_string(),
|
||||
mail_from: PROP_MAIL_FROM.to_string(),
|
||||
mail_reply: PROP_MAIL_REPLY.to_string(),
|
||||
subject: PROP_MAIL_SUBJECT.to_string(),
|
||||
policy_code: ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").to_string(),
|
||||
policy_holder: ctx.child(ID_TICKET_DATA_POLICY_HOLDER).get::<String>("text").to_string(),
|
||||
deductible: ctx.child(ID_TICKET_DATA_DEDUCTIBLE).get::<String>("text").to_string(),
|
||||
callback_number: ctx.child(ID_TICKET_DATA_CALLBACK_NUMBER).get::<String>("text").to_string(),
|
||||
callback_date: ctx.child(ID_TICKET_DATA_CALLBACK_DATE).get::<String>("text").to_string(),
|
||||
harm_type: ctx.child(ID_TICKET_DATA_HARM_TYPE).get::<String>("text").to_string(),
|
||||
ivr_comment: ctx.child(ID_TICKET_DATA_IVR_COMMENT).get::<String>("text").to_string(),
|
||||
policy_code: ctx
|
||||
.child(ID_TICKET_DATA_POLICY_CODE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
policy_holder: ctx
|
||||
.child(ID_TICKET_DATA_POLICY_HOLDER)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
deductible: ctx
|
||||
.child(ID_TICKET_DATA_DEDUCTIBLE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
callback_number: ctx
|
||||
.child(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
callback_date: ctx
|
||||
.child(ID_TICKET_DATA_CALLBACK_DATE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
harm_type: ctx
|
||||
.child(ID_TICKET_DATA_HARM_TYPE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
ivr_comment: ctx
|
||||
.child(ID_TICKET_DATA_IVR_COMMENT)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
info!("WIP: Sending form to construct eMail to {:?}", email);
|
||||
@@ -673,7 +698,7 @@ impl TicketdataState {
|
||||
impl State for TicketdataState {
|
||||
/// Initialize the state of widgets inside `TicketState`
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let time_start= SystemTime::now();
|
||||
let time_start = SystemTime::now();
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||
|
||||
@@ -682,8 +707,11 @@ impl State for TicketdataState {
|
||||
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
||||
self.target = Entity::from(
|
||||
ctx.widget()
|
||||
.try_clone::<u32>("target")
|
||||
.expect("TicketState.init: Can't find resource entity 'target'."),
|
||||
);
|
||||
|
||||
// Get language from environment
|
||||
self.lang = TicketdataState::get_lang();
|
||||
@@ -710,7 +738,9 @@ impl State for TicketdataState {
|
||||
info!("message: {:?} recieved", message);
|
||||
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
_ => {
|
||||
println!("messages: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
@@ -719,7 +749,9 @@ impl State for TicketdataState {
|
||||
info!("Message received: 'PolicycheckAction::UpdatePolicyCode'");
|
||||
TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_CODE), policy_code);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
_ => {
|
||||
println!("messages: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,13 +769,14 @@ impl State for TicketdataState {
|
||||
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||
info!("update: send_message {:?}", action);
|
||||
}
|
||||
_ => { println!("TicketdataAction: action not implemented!"); }
|
||||
_ => {
|
||||
println!("TicketdataAction: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// send ticket data via eMail
|
||||
pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
let mut res = t!("sendticketdata.export.started", lang);
|
||||
@@ -751,13 +784,27 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
let ascii_body = String::new()
|
||||
+ &"Vers.-Schein/Schadennummer".to_string() + &(email.policy_code) + &"\n"
|
||||
+ &"Versicherungsnehmer: ".to_string() + &(email.policy_holder) + &"\n"
|
||||
+ &"Selbstbehalt: ".to_string() + &(email.deductible) + &"\n"
|
||||
+ &"Rückrufnummer: ".to_string()+ &(email.callback_number) + &"\n"
|
||||
+ &"Erreichbarkeit: ".to_string() + &(email.callback_date) + &"\n"
|
||||
+ &"Rechtsproblem: ".to_string() + &(email.harm_type) + &"\n"
|
||||
+ &"Rechtsrat: ".to_string() + &(email.ivr_comment) + &"\n";
|
||||
+ &"Vers.-Schein/Schadennummer".to_string()
|
||||
+ &(email.policy_code)
|
||||
+ &"\n"
|
||||
+ &"Versicherungsnehmer: ".to_string()
|
||||
+ &(email.policy_holder)
|
||||
+ &"\n"
|
||||
+ &"Selbstbehalt: ".to_string()
|
||||
+ &(email.deductible)
|
||||
+ &"\n"
|
||||
+ &"Rückrufnummer: ".to_string()
|
||||
+ &(email.callback_number)
|
||||
+ &"\n"
|
||||
+ &"Erreichbarkeit: ".to_string()
|
||||
+ &(email.callback_date)
|
||||
+ &"\n"
|
||||
+ &"Rechtsproblem: ".to_string()
|
||||
+ &(email.harm_type)
|
||||
+ &"\n"
|
||||
+ &"Rechtsrat: ".to_string()
|
||||
+ &(email.ivr_comment)
|
||||
+ &"\n";
|
||||
|
||||
info!("email body: {:?}", ascii_body);
|
||||
|
||||
@@ -770,11 +817,12 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
//.cc((email.mail_cc).parse().unwrap())
|
||||
//.bcc((email.mail_bcc).parse().unwrap())
|
||||
.from((email.mail_from).parse().unwrap())
|
||||
.subject(String::new()
|
||||
.subject(
|
||||
String::new()
|
||||
+ &email.subject.to_string()
|
||||
+ &" (".to_string()
|
||||
+ &email.policy_code.to_string()
|
||||
+ &")".to_string()
|
||||
+ &")".to_string(),
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::alternative() // This is composed of two parts.
|
||||
@@ -784,11 +832,10 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
"text/plain; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(String::from(ascii_body)),
|
||||
)
|
||||
),
|
||||
)
|
||||
.expect("failed to build email");
|
||||
|
||||
|
||||
info!("message: {:?}", message);
|
||||
|
||||
trace!(target: "sendticketdata", email = ?email);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use chrono::{Local, DateTime};
|
||||
use chrono::{DateTime, Local};
|
||||
use locales::t;
|
||||
//use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
@@ -17,7 +17,7 @@ use std::{
|
||||
};
|
||||
use tracing::{debug, trace, Level};
|
||||
|
||||
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
|
||||
use advotracker::data::structures::{PolicyCode, PolicyData, PolicyDataList, PolicyList};
|
||||
|
||||
// include modules
|
||||
mod parse_args;
|
||||
@@ -77,12 +77,15 @@ fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
|
||||
/// import from csv format
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>, lang: &String)
|
||||
-> Result<u64, Box<dyn Error>> {
|
||||
fn import(
|
||||
p: &mut String,
|
||||
data_list: &mut PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||
lang: &String,
|
||||
) -> Result<u64, Box<dyn Error>> {
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
let mut res = t!("csv.import.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
@@ -142,7 +145,7 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
// push record as new vector elements
|
||||
data_list.push(record);
|
||||
|
||||
count +=1;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
let dt_end: DateTime<Local> = Local::now();
|
||||
@@ -163,10 +166,12 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
#[allow(dead_code)]
|
||||
/// validate a given policy number
|
||||
/// result will return true or false
|
||||
fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>, lang: &String)
|
||||
-> Result<bool, Box<dyn std::error::Error>> {
|
||||
|
||||
fn is_valid(
|
||||
policy_number: &u64,
|
||||
policy_list: &PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||
lang: &String,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let mut res = t!("policy.validation.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
let dt_start: DateTime<Local> = Local::now();
|
||||
@@ -186,7 +191,6 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
||||
// println!("policy_list: {:?} (with {:?} elements)",
|
||||
// policy_list.name, policy_list.policy_data.len());
|
||||
|
||||
|
||||
// policy_list.into_iter()
|
||||
// .filter(|num| matches(w, w1))
|
||||
// .clone
|
||||
@@ -230,14 +234,13 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
||||
match policy_numbers.get(&policy_number) {
|
||||
Some(&policy_code) => {
|
||||
let res = t!("policy.validation.success", lang);
|
||||
println!("policy_number: {} ({:?})",
|
||||
policy_number, policy_code);
|
||||
println!("policy_number: {} ({:?})", policy_number, policy_code);
|
||||
result = true;
|
||||
trace!(target: "csv-test",
|
||||
policy_number = ?policy_number,
|
||||
validation = ?res,
|
||||
policy_code = ?policy_code);
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
let res = t!("policy.validation.failed", lang);
|
||||
//println!("Noop! Number isn't valid!");
|
||||
@@ -245,9 +248,8 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
||||
trace!(target: "csv-test",
|
||||
policy_number = ?policy_number,
|
||||
validation = ?res);
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let dt_end: DateTime<Local> = Local::now();
|
||||
let duration = dt_end.signed_duration_since(dt_start);
|
||||
@@ -296,9 +298,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenv().ok();
|
||||
match envy::from_env::<Environment>() {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { debug!(target: "csv-test", "{}", e); }
|
||||
if environment.test_lang != lang {
|
||||
lang = environment.test_lang;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
debug!(target: "csv-test", "{}", e);
|
||||
}
|
||||
}
|
||||
// how to handle unumplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
@@ -331,11 +337,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||
println!("Policy Data List {:?} ", policy_data.name);
|
||||
|
||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||
|
||||
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang) {
|
||||
match import(
|
||||
&mut csv_import_path,
|
||||
&mut policy_data,
|
||||
&mut policy_numbers,
|
||||
&lang,
|
||||
) {
|
||||
Ok(count) => {
|
||||
println!("Imported {:?} records", count);
|
||||
}
|
||||
@@ -347,7 +357,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// test if policy_number is_valid
|
||||
// type conversion (viperus String -> u64)
|
||||
let test_policy_number = v.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
||||
let test_policy_number = v
|
||||
.get::<String>("test_policy_number")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
||||
// Ok(true) => {
|
||||
@@ -356,14 +370,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Some(&policy_code) => {
|
||||
let res = t!("policy.validation.success", lang);
|
||||
println!("{:?}", res);
|
||||
println!("policy_number: {} ({:?})",
|
||||
test_policy_number, policy_code);
|
||||
println!("policy_number: {} ({:?})", test_policy_number, policy_code);
|
||||
}
|
||||
_ => {
|
||||
let res = t!("policy.validation.failed", lang);
|
||||
println!("{:?}", res);
|
||||
//println!("Nuup! Number isn't valid!");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// export policy code elements to csv-file
|
||||
@@ -389,21 +402,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[test]
|
||||
fn test_policy_number() {
|
||||
// Takes a reference and returns Option<&V>
|
||||
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
|
||||
let my_policy_numbers: [u64; 2] = [1511111111, 9999999993];
|
||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||
|
||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||
|
||||
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let lang = "en".to_string();
|
||||
|
||||
println!("import with Path: {:?} PolicyData: {:?} PolicyNumbers: {:?}, Lang: {:?}",
|
||||
csv_import_path, policy_data, policy_numbers, lang);
|
||||
let count = import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang);
|
||||
println!(
|
||||
"import with Path: {:?} PolicyData: {:?} PolicyNumbers: {:?}, Lang: {:?}",
|
||||
csv_import_path, policy_data, policy_numbers, lang
|
||||
);
|
||||
let count = import(
|
||||
&mut csv_import_path,
|
||||
&mut policy_data,
|
||||
&mut policy_numbers,
|
||||
&lang,
|
||||
);
|
||||
|
||||
assert_eq!(count.unwrap(), 15498);
|
||||
|
||||
}
|
||||
|
||||
@@ -26,24 +26,31 @@ pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
|
||||
v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
v.add_default("export_file", String::from(""));
|
||||
v.add_default("test_policy_number", String::from("9999999992"));
|
||||
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||
v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
||||
v.add_default(
|
||||
"to_email_address_file",
|
||||
String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"),
|
||||
);
|
||||
v.add_default(
|
||||
"from_email_address_file",
|
||||
String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"),
|
||||
);
|
||||
//v.add_default("username", String::from("nctalkbot"));
|
||||
//v.add_default("password", String::from("botpassword"));
|
||||
v.add_default("verbose", 0);
|
||||
|
||||
|
||||
// CLI arguments are defined inline
|
||||
let matches = App::new("csv-test")
|
||||
.name(crate_name!())
|
||||
.version(crate_version!())
|
||||
.author(crate_authors!())
|
||||
.about(crate_description!())
|
||||
.after_help("
|
||||
.after_help(
|
||||
"
|
||||
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
||||
Direct-Call via IVR-System (Interactive Voice Response)
|
||||
SMR Deckungssummen-Prüfung: 089 92529 60211
|
||||
SMR Unerledigt: 089 92529 60222")
|
||||
SMR Unerledigt: 089 92529 60222",
|
||||
)
|
||||
.template(
|
||||
"\
|
||||
{bin} v{version}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
// SPDX-License-Identifier: (0BSD or MIT)
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use lettre::{
|
||||
transport::smtp::authentication::Credentials,
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
use lettre::{transport::smtp::authentication::Credentials, Message, SmtpTransport, Transport};
|
||||
|
||||
fn main() {
|
||||
let email = Message::builder()
|
||||
@@ -21,7 +18,10 @@ fn main() {
|
||||
|
||||
// Create credential for remote authentication (username, password)
|
||||
//let creds = Credentials::new("ralf.zerres@networkx.de".to_string(), "dekifjgh".to_string());
|
||||
let creds = Credentials::new("ralf.zerres.de@gmail.com".to_string(), "20jacara03".to_string());
|
||||
let creds = Credentials::new(
|
||||
"ralf.zerres.de@gmail.com".to_string(),
|
||||
"20jacara03".to_string(),
|
||||
);
|
||||
|
||||
// Open a remote connection to relay server
|
||||
//let mailer = SmtpTransport::relay("nwxex.networkx.de")
|
||||
|
||||
@@ -8,7 +8,7 @@ static ID_CHECK_POLICY_NUMBER: &'static str = "ID_CHECK_POLICY_NUMBER";
|
||||
static ID_PROGRESS_BAR: &'static str = "ID_PROGRESS_BAR";
|
||||
|
||||
enum Action {
|
||||
ParsePolicyNumber
|
||||
ParsePolicyNumber,
|
||||
}
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
@@ -16,15 +16,18 @@ struct MainViewState {
|
||||
action: Option<Action>,
|
||||
progress_bar: Entity,
|
||||
text_box: Entity,
|
||||
progress_counter: f64
|
||||
//records: HashMap::<String, String>,
|
||||
progress_counter: f64, //records: HashMap::<String, String>,
|
||||
//record_counter: u64
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
self.text_box = ctx.entity_of_child(ID_CHECK_POLICY_NUMBER).expect("Cannot get TextBox!");
|
||||
self.progress_bar = ctx.entity_of_child(ID_PROGRESS_BAR).expect("Cannot get progress bar !");
|
||||
self.text_box = ctx
|
||||
.entity_of_child(ID_CHECK_POLICY_NUMBER)
|
||||
.expect("Cannot get TextBox!");
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child(ID_PROGRESS_BAR)
|
||||
.expect("Cannot get progress bar !");
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
@@ -32,7 +35,10 @@ impl State for MainViewState {
|
||||
if let Some(action) = &self.action {
|
||||
match action {
|
||||
Action::ParsePolicyNumber => {
|
||||
let value_to_parse = ctx.get_widget(self.text_box).get::<String16>("text").clone();
|
||||
let value_to_parse = ctx
|
||||
.get_widget(self.text_box)
|
||||
.get::<String16>("text")
|
||||
.clone();
|
||||
self.parse_policy_number(value_to_parse, ctx);
|
||||
}
|
||||
}
|
||||
@@ -81,9 +87,7 @@ widget!(MainView<MainViewState>);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self
|
||||
.margin(32.0)
|
||||
.child(
|
||||
self.margin(32.0).child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.h_align("center")
|
||||
@@ -95,16 +99,14 @@ impl Template for MainView {
|
||||
.water_mark("Mut value and type <Return>")
|
||||
.on_activate(move |states, _entity| {
|
||||
// you have to fire a new event to be able to get in the update() with access to Context
|
||||
states.get_mut::<MainViewState>(id).action(Action::ParsePolicyNumber);
|
||||
states
|
||||
.get_mut::<MainViewState>(id)
|
||||
.action(Action::ParsePolicyNumber);
|
||||
})
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id(ID_PROGRESS_BAR)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
.child(ProgressBar::new().id(ID_PROGRESS_BAR).build(ctx))
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
receiver::receiver_view::ReceiverView,
|
||||
sender::sender_view::SenderView,
|
||||
};
|
||||
use crate::{receiver::receiver_view::ReceiverView, sender::sender_view::SenderView};
|
||||
|
||||
// constants
|
||||
pub static ID_SENDER_VIEW: &str = "sender_view";
|
||||
@@ -23,20 +20,18 @@ widget!(MainView {
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let receiver_view = ReceiverView::new()
|
||||
.build(ctx);
|
||||
let receiver_view = ReceiverView::new().build(ctx);
|
||||
|
||||
let sender_view = SenderView::new()
|
||||
.target(receiver_view.0) // entity of the target
|
||||
.build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.child(
|
||||
self.name("MainView").child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.child(sender_view)
|
||||
.child(receiver_view)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
// .child(
|
||||
// TabWidget::new()
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::sender::sender_state::{SenderAction, SenderState};
|
||||
/// state changes for the `SenderView` widget.
|
||||
pub enum TestMessageAction {
|
||||
// Toggle visibility of a message TextBox.
|
||||
ToggleMessageBox
|
||||
ToggleMessageBox,
|
||||
}
|
||||
|
||||
/// Valid `structure members` of the `ReceiverState` used to react on
|
||||
@@ -21,7 +21,7 @@ pub enum TestMessageAction {
|
||||
#[derive(Default, AsAny)]
|
||||
pub struct ReceiverState {
|
||||
message_box: Option<Entity>,
|
||||
progress_bar: Entity
|
||||
progress_bar: Entity,
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `ReceiverState`.
|
||||
@@ -38,7 +38,8 @@ impl ReceiverState {
|
||||
impl State for ReceiverState {
|
||||
// initialize the view entities
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
self.progress_bar = ctx.entity_of_child("progress_bar")
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child("progress_bar")
|
||||
.expect("Cannot find ProgressBar!");
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ impl State for ReceiverState {
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context
|
||||
ctx: &mut Context,
|
||||
) {
|
||||
for message in messages.read::<SenderAction>() {
|
||||
match message {
|
||||
|
||||
@@ -7,31 +7,26 @@
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::receiver::receiver_state::{TestMessageAction, ReceiverState};
|
||||
use crate::receiver::receiver_state::{ReceiverState, TestMessageAction};
|
||||
|
||||
widget!(ReceiverView<ReceiverState>);
|
||||
|
||||
impl Template for ReceiverView {
|
||||
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("ReceiverView")
|
||||
.child(
|
||||
self.name("ReceiverView").child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.spacing(16)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id("progress_bar")
|
||||
.build(bc)
|
||||
)
|
||||
.child(ProgressBar::new().id("progress_bar").build(bc))
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id("message_box")
|
||||
.h_align("center")
|
||||
.text("message received. Box toggled!")
|
||||
.visibility("hidden")
|
||||
.build(bc)
|
||||
.build(bc),
|
||||
)
|
||||
.build(bc)
|
||||
.build(bc),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct SenderState {
|
||||
// actions
|
||||
actions: Vec<SenderAction>,
|
||||
// entity that will receive the message
|
||||
target: Entity
|
||||
target: Entity,
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `SenderState`.
|
||||
@@ -38,8 +38,11 @@ impl State for SenderState {
|
||||
// initialize the view entities
|
||||
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||
// create the target entity, that receives the Sender messages
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("ERROR: SenderState::init(): target entity not found!"));
|
||||
self.target = Entity::from(
|
||||
ctx.widget()
|
||||
.try_clone::<u32>("target")
|
||||
.expect("ERROR: SenderState::init(): target entity not found!"),
|
||||
);
|
||||
}
|
||||
|
||||
// update entities, before we render the view
|
||||
|
||||
@@ -16,8 +16,7 @@ widget!(SenderView<SenderState> {
|
||||
|
||||
impl Template for SenderView {
|
||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("SenderView")
|
||||
.child(
|
||||
self.name("SenderView").child(
|
||||
Button::new()
|
||||
.text("Click me to send a message!")
|
||||
.v_align("center")
|
||||
@@ -28,7 +27,7 @@ impl Template for SenderView {
|
||||
//ctx.send_message(TestMessageAction::ToggleMessageBox, id);
|
||||
false
|
||||
})
|
||||
.build(bc)
|
||||
.build(bc),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ widget!(SenderWidget<SenderState> {
|
||||
|
||||
impl Template for SenderWidget {
|
||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("SenderWidget")
|
||||
.child(
|
||||
self.name("SenderWidget").child(
|
||||
Button::new()
|
||||
.text("Click me to send a message!")
|
||||
.v_align("center")
|
||||
@@ -23,7 +22,7 @@ impl Template for SenderWidget {
|
||||
states.get_mut::<SenderState>(id).send_message();
|
||||
false
|
||||
})
|
||||
.build(bc)
|
||||
.build(bc),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -31,13 +30,13 @@ impl Template for SenderWidget {
|
||||
// States
|
||||
|
||||
enum Action {
|
||||
UpdateProgress(f64)
|
||||
UpdateProgress(f64),
|
||||
}
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
struct SenderState {
|
||||
actions: Vec<Action>,
|
||||
target: Entity
|
||||
target: Entity,
|
||||
}
|
||||
|
||||
impl SenderState {
|
||||
@@ -48,8 +47,11 @@ impl SenderState {
|
||||
|
||||
impl State for SenderState {
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("ERROR: SenderState::init(): target entity not found!"));
|
||||
self.target = Entity::from(
|
||||
ctx.widget()
|
||||
.try_clone::<u32>("target")
|
||||
.expect("ERROR: SenderState::init(): target entity not found!"),
|
||||
);
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
@@ -77,11 +79,7 @@ widget!(ReceiverWidget<ReceiverState>);
|
||||
impl Template for ReceiverWidget {
|
||||
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("ReceiverWidget")
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id("progress_bar")
|
||||
.build(bc)
|
||||
)
|
||||
.child(ProgressBar::new().id("progress_bar").build(bc))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,15 +87,22 @@ impl Template for ReceiverWidget {
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
struct ReceiverState {
|
||||
progress_bar: Entity
|
||||
progress_bar: Entity,
|
||||
}
|
||||
|
||||
impl State for ReceiverState {
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
self.progress_bar = ctx.entity_of_child("progress_bar").expect("Cannot find ProgressBar!");
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child("progress_bar")
|
||||
.expect("Cannot find ProgressBar!");
|
||||
}
|
||||
|
||||
fn messages(&mut self, mut messages: MessageReader, _registry: &mut Registry, ctx: &mut Context) {
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context,
|
||||
) {
|
||||
for action in messages.read::<Action>() {
|
||||
match action {
|
||||
Action::UpdateProgress(amount) => {
|
||||
@@ -135,7 +140,7 @@ pub fn main() {
|
||||
.orientation("vertical")
|
||||
.child(sender)
|
||||
.child(receiver)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
})
|
||||
|
||||
@@ -10,7 +10,6 @@ struct Config {
|
||||
nested: Nested,
|
||||
var: Variant,
|
||||
array: Vec<()>,
|
||||
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
||||
@@ -21,11 +21,9 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
widget!(
|
||||
MainView {
|
||||
widget!(MainView {
|
||||
policy_number: String16
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
@@ -51,9 +49,7 @@ impl Template for MainView {
|
||||
//.child(ticket_data_button_menu)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_form_row_0 = Stack::new()
|
||||
.name("Row 0")
|
||||
.build(ctx);
|
||||
let ticket_data_form_row_0 = Stack::new().name("Row 0").build(ctx);
|
||||
|
||||
let ticket_data_form = Container::new()
|
||||
//.id(ID_TICKET_DATA_FORM)
|
||||
@@ -72,7 +68,7 @@ impl Template for MainView {
|
||||
.push("auto") // Label
|
||||
.push(14) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(4) // Delimiter
|
||||
.push(4), // Delimiter
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -88,14 +84,12 @@ impl Template for MainView {
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 12
|
||||
.push("auto"), // Row 12
|
||||
)
|
||||
|
||||
//.child(ticket_data_form_row_0)
|
||||
//.child(ticket_data_form_row_1)
|
||||
//.child(ticket_data_form_row_2)
|
||||
//.build(ctx),
|
||||
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(0))
|
||||
@@ -237,7 +231,6 @@ impl Template for MainView {
|
||||
.orientation("horizontal")
|
||||
.visibility(Visibility::Collapsed)
|
||||
//.spacing("4")
|
||||
|
||||
.child(
|
||||
Button::new()
|
||||
.margin(14)
|
||||
@@ -255,25 +248,18 @@ impl Template for MainView {
|
||||
.build(ctx);
|
||||
|
||||
// Starter page: Ticket Data Widget
|
||||
self.name("TicketdataView")
|
||||
.child(
|
||||
self.name("TicketdataView").child(
|
||||
Grid::new()
|
||||
//.id(ID_TICKET_DATA_WIDGET)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50)
|
||||
.push("*")
|
||||
.push(50)
|
||||
)
|
||||
.columns(Columns::create().push(50).push("*").push(50))
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // ActionSend
|
||||
.push("auto"), // ActionSend
|
||||
//.push("auto") // Bottom )
|
||||
)
|
||||
|
||||
.child(ticket_data_header_bar) // row 0
|
||||
.child(ticket_data_form) // row 2
|
||||
.child(ticket_data_action) // row 3
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#[cfg(windows)] extern crate winapi;
|
||||
#[cfg(windows)]
|
||||
extern crate winapi;
|
||||
use std::io::Error;
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -7,13 +8,14 @@ fn print_message(msg: &str) -> Result<i32, Error> {
|
||||
use std::iter::once;
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
use std::ptr::null_mut;
|
||||
use winapi::um::winuser::{MB_OK, MessageBoxW};
|
||||
use winapi::um::winuser::{MessageBoxW, MB_OK};
|
||||
let wide: Vec<u16> = OsStr::new(msg).encode_wide().chain(once(0)).collect();
|
||||
let ret = unsafe {
|
||||
MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK)
|
||||
};
|
||||
if ret == 0 { Err(Error::last_os_error()) }
|
||||
else { Ok(ret) }
|
||||
let ret = unsafe { MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK) };
|
||||
if ret == 0 {
|
||||
Err(Error::last_os_error())
|
||||
} else {
|
||||
Ok(ret)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
||||
@@ -10,7 +10,7 @@ use orbtk::prelude::*;
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity)
|
||||
EntryChanged(Entity),
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
@@ -66,10 +66,7 @@ impl State for MainViewState {
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
.style("header")
|
||||
.build(ctx)
|
||||
TextBlock::new().text(text).style("header").build(ctx)
|
||||
}
|
||||
|
||||
widget!(
|
||||
@@ -85,19 +82,8 @@ impl Template for MainView {
|
||||
self.name("MainView").child(
|
||||
Grid::new()
|
||||
.background("#fafafa")
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(150.0)
|
||||
.push("*")
|
||||
.push(150.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("*")
|
||||
.push("*")
|
||||
.build(),
|
||||
)
|
||||
.columns(Columns::create().push(150.0).push("*").push(150.0).build())
|
||||
.rows(Rows::create().push("*").push("*").build())
|
||||
.child(
|
||||
Grid::new()
|
||||
//.element("policyholder_check")
|
||||
@@ -146,7 +132,7 @@ impl Template for MainView {
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
|
||||
@@ -34,7 +34,9 @@ pub static PROP_MAIL_TO_4: &str = "sekretariat@m2-mediation.de";
|
||||
/// Mail header 5th List-Entry 'Recpt-To': recipient name
|
||||
pub static PROP_MAIL_TO_5: &str = "kooperation@rightmart.de";
|
||||
/// Mail header 6th List-Entry 'Recpt-To': recipient name
|
||||
pub static PROP_MAIL_TO_6: &str = "ralf.zerres@networkx.de";
|
||||
pub static PROP_MAIL_TO_6: &str = "allianz@legalhero.de";
|
||||
/// Mail header 7th List-Entry 'Recpt-To': recipient name
|
||||
pub static PROP_MAIL_TO_7: &str = "ralf.zerres@networkx.de";
|
||||
|
||||
/// Property: policy_check
|
||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
|
||||
/// provides orbtk widgets constants
|
||||
pub mod constants;
|
||||
|
||||
|
||||
@@ -15,11 +15,13 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Serialize)]
|
||||
pub enum PolicyCode {
|
||||
/// Allianz Sachversicherung
|
||||
AS
|
||||
AS,
|
||||
}
|
||||
|
||||
impl Default for PolicyCode {
|
||||
fn default() -> Self { PolicyCode::AS }
|
||||
fn default() -> Self {
|
||||
PolicyCode::AS
|
||||
}
|
||||
}
|
||||
|
||||
/// Classifier of the Allinaz DirectCall communication type.
|
||||
@@ -59,11 +61,13 @@ pub enum CommunicationType {
|
||||
/// Zeugins
|
||||
ZE,
|
||||
/// Typ is unspecified
|
||||
XX
|
||||
XX,
|
||||
}
|
||||
|
||||
impl Default for CommunicationType {
|
||||
fn default() -> Self { CommunicationType::XX }
|
||||
fn default() -> Self {
|
||||
CommunicationType::XX
|
||||
}
|
||||
}
|
||||
|
||||
/// Status of a given policy data element.
|
||||
@@ -72,11 +76,13 @@ pub enum Status {
|
||||
/// Active -> the policy is active an supported
|
||||
Active,
|
||||
/// Inactive -> the policy is inactive or resigned
|
||||
Inactive
|
||||
Inactive,
|
||||
}
|
||||
|
||||
impl Default for Status {
|
||||
fn default() -> Self { Status::Active }
|
||||
fn default() -> Self {
|
||||
Status::Active
|
||||
}
|
||||
}
|
||||
|
||||
/// A communication type describes possible classifications of customer calls.
|
||||
@@ -86,7 +92,7 @@ pub struct CommunicationData {
|
||||
/// pub communication_type: CommunicationType,
|
||||
pub communication_type: String,
|
||||
/// A literal name describing the selected communication type
|
||||
pub communication_name: String
|
||||
pub communication_name: String,
|
||||
}
|
||||
|
||||
/// CSV Export
|
||||
@@ -139,7 +145,7 @@ pub struct Email {
|
||||
/// Body type harm type
|
||||
pub harm_type: String,
|
||||
/// Body type ivr comment
|
||||
pub ivr_comment: String
|
||||
pub ivr_comment: String,
|
||||
}
|
||||
|
||||
impl Email {}
|
||||
@@ -151,7 +157,7 @@ pub struct HarmData {
|
||||
pub harm_data: Vec<HarmType>,
|
||||
/// Status der Schadenliste
|
||||
//pub name: String,
|
||||
pub selected: bool
|
||||
pub selected: bool,
|
||||
}
|
||||
|
||||
/// Harm types are destincted by a type code.
|
||||
@@ -186,7 +192,7 @@ pub struct PolicyCheck {
|
||||
/// Referenz zur Versicherungsschein-Nummer
|
||||
pub policy_number: u64,
|
||||
/// Validitätsergebnis
|
||||
pub policy_number_status: Status
|
||||
pub policy_number_status: Status,
|
||||
}
|
||||
|
||||
impl PolicyCheck {}
|
||||
@@ -256,7 +262,7 @@ pub struct PolicyDataList {
|
||||
/// Name der Versicherungsliste
|
||||
pub name: String,
|
||||
/// Status der Versicherungsliste
|
||||
pub selected: bool
|
||||
pub selected: bool,
|
||||
}
|
||||
|
||||
/// implements the helper methods, to manage policy data collections.
|
||||
@@ -335,7 +341,7 @@ pub struct PolicyData {
|
||||
#[serde(rename = "POLLFNR")]
|
||||
pub policy_number: u64,
|
||||
/// Status des Versicherungsscheins
|
||||
pub status: Option<Status>
|
||||
pub status: Option<Status>,
|
||||
}
|
||||
|
||||
/// Policy Number Set
|
||||
@@ -350,7 +356,7 @@ pub struct AllianzPolicyNumber {
|
||||
pub policy_code: String,
|
||||
/// 10-stellige Versicherungsscheinnummer (numerisch)
|
||||
#[serde(rename = "POLLFNR")]
|
||||
pub policy_number: usize
|
||||
pub policy_number: usize,
|
||||
}
|
||||
|
||||
// /// List of Allianz Policy Number records
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#![crate_name = "advotracker_client"]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
|
||||
|
||||
//! advotracker
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
//use chrono::{Local, DateTime};
|
||||
use dotenv::dotenv;
|
||||
use cfg_if::cfg_if;
|
||||
use dotenv::dotenv;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
//use std::process;
|
||||
@@ -42,11 +42,13 @@ struct Environment {
|
||||
}
|
||||
|
||||
// Style extension
|
||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||
//static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||
//static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||
} else {
|
||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +63,8 @@ fn get_lang() -> String {
|
||||
|
||||
// prepare lang_id to represent twine language prefix
|
||||
// env: "de_DE.UTF-8" -> "De"
|
||||
lang_id = lang_id.substring(0,2).to_string();
|
||||
lang_id.replace_range(..1, &lang_id.substring(0,1).to_string().to_uppercase() );
|
||||
lang_id = lang_id.substring(0, 2).to_string();
|
||||
lang_id.replace_range(..1, &lang_id.substring(0, 1).to_string().to_uppercase());
|
||||
|
||||
// handle testing environment variables (.env file) with precedence
|
||||
dotenv().ok();
|
||||
@@ -71,11 +73,13 @@ fn get_lang() -> String {
|
||||
if environment.test_lang != lang_id {
|
||||
info!("GUI-Language: preset from .env to {:?}", lang_id);
|
||||
lang_id = environment.test_lang;
|
||||
lang_id = lang_id.substring(0,2).to_string();
|
||||
lang_id.replace_range(..1, &lang_id.substring(0,1).to_string().to_uppercase() );
|
||||
lang_id = lang_id.substring(0, 2).to_string();
|
||||
lang_id.replace_range(..1, &lang_id.substring(0, 1).to_string().to_uppercase());
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
info!(target: "advotracker", "{}", e)
|
||||
}
|
||||
},
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
|
||||
let lang = format!("Lang::{}(\"{}\")", lang_id, lang_variant);
|
||||
@@ -96,19 +100,22 @@ cfg_if! {
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
fn theme_fluent() -> Theme {
|
||||
orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
||||
ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_FLUENT))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
))
|
||||
// orbtk::widgets::themes::theme_orbtk::register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// fn theme_fluent_dark() -> Theme {
|
||||
// orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
}
|
||||
// ))
|
||||
// }
|
||||
// fn theme_fluent_light() -> Theme {
|
||||
// orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_LIGHT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
// ))
|
||||
// }
|
||||
} else {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
@@ -181,7 +188,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// type conversion (viperus String -> u64)
|
||||
let test_policy_number = viperus.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
||||
let test_policy_number = viperus
|
||||
.get::<String>("test_policy_number")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
trace!(target: "advotracker", test_policy_number = ?test_policy_number);
|
||||
|
||||
// main tasks
|
||||
@@ -201,9 +212,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
Application::from_name("nwx.advotracker")
|
||||
.localization(localization)
|
||||
.theme(theme())
|
||||
//.theme(theme_fluent_light())
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
@@ -216,6 +230,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
} else{
|
||||
Application::from_name("nwx.advotracker")
|
||||
.localization(localization)
|
||||
.theme(theme())
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(800.0, 620.0)
|
||||
//.min_width(460.0)
|
||||
//.min_height(380.0)
|
||||
.resizeable(true)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
state = t!(state_finished => lang);
|
||||
res = t!(main_finished => lang);
|
||||
|
||||
@@ -45,8 +45,14 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
|
||||
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
viperus.add_default("export_file", String::from(""));
|
||||
viperus.add_default("test_policy_number", String::from("9999999992"));
|
||||
viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||
viperus.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
||||
viperus.add_default(
|
||||
"to_email_address_file",
|
||||
String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"),
|
||||
);
|
||||
viperus.add_default(
|
||||
"from_email_address_file",
|
||||
String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"),
|
||||
);
|
||||
//viperus.add_default("username", String::from("nctalkbot"));
|
||||
//viperus.add_default("password", String::from("botpassword"));
|
||||
viperus.add_default("verbose", 0);
|
||||
@@ -57,11 +63,13 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
|
||||
.version(crate_version!())
|
||||
.author(crate_authors!())
|
||||
.about(crate_description!())
|
||||
.after_help("
|
||||
.after_help(
|
||||
"
|
||||
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
||||
Direct-Call via IVR-System (Interactive Voice Response)
|
||||
SMR Deckungssummen-Prüfung: 089 92529 60211
|
||||
SMR Unerledigt: 089 92529 60222")
|
||||
SMR Unerledigt: 089 92529 60222",
|
||||
)
|
||||
.template(
|
||||
"\
|
||||
{bin} v{version}
|
||||
|
||||
@@ -7,18 +7,15 @@
|
||||
|
||||
use lettre::{
|
||||
message::{header, MultiPart, SinglePart},
|
||||
Message, SmtpTransport, Transport,
|
||||
transport::smtp::authentication::Credentials,
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
use maud::html;
|
||||
use std::error::Error;
|
||||
//use std::process;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use crate::{
|
||||
data::structures::Email,
|
||||
Lang,
|
||||
};
|
||||
use crate::{data::structures::Email, Lang};
|
||||
|
||||
/// send ticket data via eMail
|
||||
pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>> {
|
||||
@@ -49,13 +46,27 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
||||
};
|
||||
|
||||
let ascii_body = String::new()
|
||||
+ &"Vers.-Schein/Schadennummer".to_string() + &(email.policy_code) + &"\n"
|
||||
+ &"Versicherungsnehmer: ".to_string() + &(email.policy_holder) + &"\n"
|
||||
+ &"Selbstbehalt: ".to_string() + &(email.deductible) + &"\n"
|
||||
+ &"Rückrufnummer: ".to_string()+ &(email.callback_number) + &"\n"
|
||||
+ &"Erreichbarkeit: ".to_string() + &(email.callback_date) + &"\n"
|
||||
+ &"Rechtsproblem: ".to_string() + &(email.harm_type) + &"\n"
|
||||
+ &"Rechtsrat: ".to_string() + &(email.ivr_comment) + &"\n";
|
||||
+ &"Vers.-Schein/Schadennummer".to_string()
|
||||
+ &(email.policy_code)
|
||||
+ &"\n"
|
||||
+ &"Versicherungsnehmer: ".to_string()
|
||||
+ &(email.policy_holder)
|
||||
+ &"\n"
|
||||
+ &"Selbstbehalt: ".to_string()
|
||||
+ &(email.deductible)
|
||||
+ &"\n"
|
||||
+ &"Rückrufnummer: ".to_string()
|
||||
+ &(email.callback_number)
|
||||
+ &"\n"
|
||||
+ &"Erreichbarkeit: ".to_string()
|
||||
+ &(email.callback_date)
|
||||
+ &"\n"
|
||||
+ &"Rechtsproblem: ".to_string()
|
||||
+ &(email.harm_type)
|
||||
+ &"\n"
|
||||
+ &"Rechtsrat: ".to_string()
|
||||
+ &(email.ivr_comment)
|
||||
+ &"\n";
|
||||
|
||||
info!("email body: {:?}", ascii_body);
|
||||
|
||||
@@ -66,11 +77,12 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
||||
.cc((email.mail_cc).parse().unwrap())
|
||||
// we do not use bcc yet
|
||||
//.bcc((email.mail_bcc).parse().unwrap())
|
||||
.subject(String::new()
|
||||
.subject(
|
||||
String::new()
|
||||
+ &email.subject.to_string()
|
||||
+ &" (".to_string()
|
||||
+ &email.policy_code.to_string()
|
||||
+ &")".to_string()
|
||||
+ &")".to_string(),
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::alternative() // This is composed of two parts.
|
||||
@@ -87,12 +99,14 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
||||
)
|
||||
.expect("failed to build email");
|
||||
|
||||
|
||||
info!("message: {:?}", message);
|
||||
|
||||
// Create credential for remote authentication (username, password)
|
||||
// WIP: get credentials from config file / cli
|
||||
let credentials = Credentials::new("service@hiedemann.de".to_string(), "88service99$".to_string());
|
||||
let credentials = Credentials::new(
|
||||
"service@hiedemann.de".to_string(),
|
||||
"88service99$".to_string(),
|
||||
);
|
||||
|
||||
// standard smtp client connection
|
||||
//let mailer = SmtpTransport::starttls_relay("hiedemannsbs.kanzlei.hiedemann.de")
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use chrono::{Local, DateTime};
|
||||
use std::error::Error;
|
||||
use chrono::{DateTime, Local};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tracing::trace;
|
||||
|
||||
//use crate::db::redis;
|
||||
use crate::{
|
||||
data::structures::{PolicyCode, PolicyDataList, PolicyData},
|
||||
data::structures::{PolicyCode, PolicyData, PolicyDataList},
|
||||
Lang,
|
||||
};
|
||||
|
||||
@@ -21,13 +21,15 @@ use crate::{
|
||||
/// save records to redis backend
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
||||
pub fn import(
|
||||
path: &mut String,
|
||||
data_list: &mut PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||
policy_data_count: &mut u64)
|
||||
-> Result<(u64, Duration), Box<dyn Error>> {
|
||||
policy_data_count: &mut u64,
|
||||
) -> Result<(u64, Duration), Box<dyn Error>> {
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
let lang = Lang::De("");
|
||||
let mut res = t!(csv_import_started => lang);
|
||||
@@ -66,7 +68,7 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
||||
}
|
||||
|
||||
// Iterate over each record, deserialize und write to our structures
|
||||
let mut count : u64 = 0;
|
||||
let mut count: u64 = 0;
|
||||
for result in csv_reader.deserialize() {
|
||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||
// error here.
|
||||
@@ -82,12 +84,13 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
||||
// push record as new vector elements
|
||||
data_list.push(record);
|
||||
|
||||
count +=1;
|
||||
count += 1;
|
||||
*policy_data_count = count;
|
||||
};
|
||||
}
|
||||
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start)
|
||||
let duration = time_end
|
||||
.duration_since(time_start)
|
||||
.expect("Clock may have gone backwards");
|
||||
trace!(target: "csv-import", record_count = ?count, duration = ?duration);
|
||||
|
||||
@@ -102,18 +105,22 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
||||
#[test]
|
||||
fn test_import() {
|
||||
// Takes a reference and returns Option<&V>
|
||||
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
|
||||
let my_policy_numbers: [u64; 2] = [1511111111, 9999999993];
|
||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||
|
||||
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_data_count: u64 = 0;
|
||||
let lang = "en".to_string();
|
||||
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &mut policy_data_count,
|
||||
&lang) {
|
||||
match import(
|
||||
&mut csv_import_path,
|
||||
&mut policy_data,
|
||||
&mut policy_numbers,
|
||||
&mut policy_data_count,
|
||||
&lang,
|
||||
) {
|
||||
Ok((count, duration)) => {
|
||||
println!("import {:?} records. Duration: {:?}", count, duration);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@ pub enum ConfigurationAction {
|
||||
/// Define valid configuration data.
|
||||
/// This structure is serialized and saved inside the OS dependent settings file.
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
struct ConfigurationData(
|
||||
pub String,
|
||||
pub String
|
||||
);
|
||||
struct ConfigurationData(pub String, pub String);
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Configuration` widget.
|
||||
#[derive(Debug, Default, AsAny)]
|
||||
@@ -45,20 +42,17 @@ impl State for ConfigurationState {
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
.load_async::<ConfigurationData>(
|
||||
"configuration_data".to_string(), ctx.entity()
|
||||
"configuration_data".to_string(),
|
||||
ctx.entity(),
|
||||
);
|
||||
}
|
||||
ConfigurationAction::SaveConfiguration => {
|
||||
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
|
||||
let configuration_file: String =
|
||||
ConfigurationView::configuration_file_clone(&ctx.widget());
|
||||
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
.save_async(
|
||||
registry.get::<Settings>("settings").save_async(
|
||||
"configuration_data".to_string(),
|
||||
ConfigurationData(
|
||||
configuration_file,
|
||||
language_id
|
||||
),
|
||||
ConfigurationData(configuration_file, language_id),
|
||||
ctx.entity(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,13 +31,9 @@ impl Template for ConfigurationView {
|
||||
Grid::new()
|
||||
.id(ID_CONFIGURATION_FORM)
|
||||
.style("configuration_form")
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
.push(12)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.columns(Columns::create().push(120).push(12).push("auto"))
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push(4) // Seperator
|
||||
.push("auto") // Configuartion_File
|
||||
@@ -101,15 +97,8 @@ impl Template for ConfigurationView {
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column_span(3))
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto")
|
||||
.push(8)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto")
|
||||
)
|
||||
.columns(Columns::create().push("auto").push(8).push("auto"))
|
||||
.rows(Rows::create().push("auto"))
|
||||
.child(
|
||||
Button::new()
|
||||
.style("button_single_content")
|
||||
|
||||
@@ -13,10 +13,7 @@ use tracing::{info, trace};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
data::structures::PolicyList
|
||||
};
|
||||
use crate::{data::constants::*, data::structures::PolicyList};
|
||||
|
||||
/// define valid environment variables provided via .env files
|
||||
/// located in the current call directory
|
||||
@@ -33,16 +30,20 @@ pub trait GlobalState {
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
lang = lang.substring(0, 5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
match envy::from_env::<Environment>() {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
if environment.test_lang != lang {
|
||||
lang = environment.test_lang;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
info!(target: "advotracker", "{}", e)
|
||||
}
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
widgets::localization::localization_state::LocalizationState,
|
||||
};
|
||||
use crate::{data::constants::*, widgets::localization::localization_state::LocalizationState};
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
@@ -31,19 +28,13 @@ impl Template for LocalizationView {
|
||||
let languages = vec!["English".to_string(), "German".to_string()];
|
||||
let count = languages.len();
|
||||
|
||||
self.languages(languages)
|
||||
.selected_index(1)
|
||||
.child(
|
||||
self.languages(languages).selected_index(1).child(
|
||||
Grid::new()
|
||||
.id(ID_LOCALIZATION_FORM)
|
||||
.margin(4)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
.push(12)
|
||||
.push(150)
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.columns(Columns::create().push(120).push(12).push(150))
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
@@ -80,9 +71,8 @@ impl Template for LocalizationView {
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id)
|
||||
.get::<Vec<String>>("languages")[index]
|
||||
.clone();
|
||||
let text =
|
||||
bc.get_widget(id).get::<Vec<String>>("languages")[index].clone();
|
||||
TextBlock::new()
|
||||
.id(ID_LOCALIZATION_LANGUAGE_NAME)
|
||||
.v_align("center")
|
||||
|
||||
@@ -8,13 +8,10 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::{
|
||||
constants::*,
|
||||
structures::PolicyCheck,
|
||||
},
|
||||
data::{constants::*, structures::PolicyCheck},
|
||||
widgets::configuration::configuration_view::ConfigurationView,
|
||||
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
widgets::localization::localization_view::LocalizationView,
|
||||
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
//widgets::menu::menu_view::MenuView,
|
||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||
};
|
||||
@@ -29,14 +26,13 @@ widget!(
|
||||
// policylist_view: u32,
|
||||
// policydata_view: u32,
|
||||
/// The policycheck view
|
||||
policycheck_view: PolicyCheck
|
||||
//ticketdata_view: TicketData
|
||||
});
|
||||
policycheck_view: PolicyCheck //ticketdata_view: TicketData
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let ticketdata_view = TicketdataView::new()
|
||||
.build(ctx);
|
||||
let ticketdata_view = TicketdataView::new().build(ctx);
|
||||
|
||||
let policycheck_view = PolicycheckView::new()
|
||||
.target(ticketdata_view.0)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use orbtk::{prelude::*, shell::*, widgets::themes::* };
|
||||
use orbtk::{prelude::*, shell::*, widgets::themes::*};
|
||||
use tracing::{info, trace};
|
||||
|
||||
use std::process;
|
||||
@@ -31,7 +31,7 @@ pub enum MenuAction {
|
||||
/// Set the active theme
|
||||
SetTheme,
|
||||
/// Update the relative position inside the menu
|
||||
UpdateMenuRelativePosition
|
||||
UpdateMenuRelativePosition,
|
||||
}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Menu` widget.
|
||||
@@ -43,7 +43,7 @@ pub struct MenuState {
|
||||
menu: Option<Entity>,
|
||||
//menu_toggle_theme: Option<Entity>
|
||||
/// Entity-id of the toggled theme
|
||||
menu_toggle_theme: Entity
|
||||
menu_toggle_theme: Entity,
|
||||
}
|
||||
|
||||
/// Method definitions, that react on any given state change inside the `Menu` widget.
|
||||
@@ -116,7 +116,9 @@ impl State for MenuState {
|
||||
// append the child to target (overlay stays on top of the main tree)
|
||||
ctx.build_context()
|
||||
.append_child_to_overlay(menu_popup)
|
||||
.expect("Failed create an overlay that consumes popup `menu` as its child.");
|
||||
.expect(
|
||||
"Failed create an overlay that consumes popup `menu` as its child.",
|
||||
);
|
||||
self.menu = Some(menu_popup);
|
||||
|
||||
trace!(menu = ?self.menu);
|
||||
@@ -124,7 +126,10 @@ impl State for MenuState {
|
||||
// open: is the default
|
||||
//ctx.get_widget(menu).set("open", true);
|
||||
|
||||
info!("CreateMenu: parent {:?}, target: {:?}, popup: {:?}", parent, target, self.menu);
|
||||
info!(
|
||||
"CreateMenu: parent {:?}, target: {:?}, popup: {:?}",
|
||||
parent, target, self.menu
|
||||
);
|
||||
}
|
||||
|
||||
MenuAction::SetTheme => {
|
||||
@@ -160,21 +165,26 @@ impl State for MenuState {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
MenuAction::CreateMenuToggleTheme => {
|
||||
let menu_target = ctx
|
||||
.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME)
|
||||
.expect("MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.");
|
||||
let menu_target = ctx.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME).expect(
|
||||
"MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.",
|
||||
);
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create a new menu popup
|
||||
self.menu_toggle_theme = create_menu_toggle_theme_popup(current_entity, build_context);
|
||||
self.menu_toggle_theme =
|
||||
create_menu_toggle_theme_popup(current_entity, build_context);
|
||||
|
||||
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
|
||||
build_context.append_child(menu_target, self.menu_toggle_theme);
|
||||
|
||||
ctx.get_widget(self.menu_toggle_theme).clone::<Visibility>("visibility");
|
||||
ctx.get_widget(self.menu_toggle_theme)
|
||||
.clone::<Visibility>("visibility");
|
||||
|
||||
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
|
||||
println!(
|
||||
"Popup Menu Toggle Theme created: {:?}",
|
||||
self.menu_toggle_theme
|
||||
);
|
||||
}
|
||||
MenuAction::RemoveMenu => {
|
||||
self.remove_menu(ctx);
|
||||
@@ -226,23 +236,22 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
//.style("popup_menu")
|
||||
.width(300.0)
|
||||
.height(100.0)
|
||||
|
||||
.on_key_down(move | ctx, key_event | {
|
||||
.on_key_down(move |ctx, key_event| {
|
||||
match key_event.key {
|
||||
Key::Q(..) => {
|
||||
//if is_ctrl_home_down(ctx)
|
||||
println!("KeyHandler: got Ctrl+Q");
|
||||
process::exit(0);
|
||||
//}
|
||||
},
|
||||
}
|
||||
Key::Escape => {
|
||||
println!("KeyHandler: got Escape");
|
||||
ctx.get_mut::<MenuState>(target)
|
||||
.set_action(MenuAction::RemoveMenu);
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
println!("KeyHandler: got {:?}", key_event.key);
|
||||
},
|
||||
}
|
||||
};
|
||||
true
|
||||
})
|
||||
@@ -266,14 +275,9 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Columns::create()
|
||||
.push("180") // Menu Button
|
||||
.push("1") // Seperator
|
||||
.push("auto") // Keyboard Shortcut
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("auto"), // Keyboard Shortcut
|
||||
)
|
||||
.rows(Rows::create().push("auto").push("auto").push("auto"))
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_MENU_LABEL_ACCOUNT)
|
||||
@@ -339,7 +343,6 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
|
||||
fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id("test_popup")
|
||||
@@ -368,8 +371,6 @@ fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Enti
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Create a new popup submenu to toogle the active theme
|
||||
fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
cfg_if! {
|
||||
@@ -400,16 +401,16 @@ fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Ent
|
||||
.style("container_menu")
|
||||
.width(280)
|
||||
.height(140)
|
||||
.on_key_down(move | _ctx, key_event | {
|
||||
.on_key_down(move |_ctx, key_event| {
|
||||
match key_event.key {
|
||||
Key::Escape => {
|
||||
println!("KeyHandler: got Escape");
|
||||
//ctx.get_mut::<MenuState>(id)
|
||||
// .set_action(MenuAction::RemoveMenuToggleTheme);
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
println!("KeyHandler: got {:?}", key_event.key);
|
||||
},
|
||||
}
|
||||
};
|
||||
true
|
||||
})
|
||||
@@ -420,9 +421,11 @@ fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Ent
|
||||
.count(themes_count)
|
||||
.style("combo_box_form")
|
||||
.items_builder(move |ctx, index| {
|
||||
let theme_name =
|
||||
MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
||||
TextBlock::new().v_align("center").text(theme_name).build(ctx)
|
||||
let theme_name = MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
||||
TextBlock::new()
|
||||
.v_align("center")
|
||||
.text(theme_name)
|
||||
.build(ctx)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _entity| {
|
||||
states.send_message(MenuAction::SetTheme, id);
|
||||
|
||||
@@ -38,7 +38,8 @@ impl Template for MenuView {
|
||||
.v_align("end")
|
||||
.child(
|
||||
Container::new()
|
||||
.child( Container::new()
|
||||
.child(
|
||||
Container::new()
|
||||
.margin((0, 16, 16, 0))
|
||||
.v_align("center")
|
||||
.child(
|
||||
@@ -60,7 +61,7 @@ impl Template for MenuView {
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -104,24 +105,22 @@ impl Template for MenuView {
|
||||
.build(ctx);
|
||||
|
||||
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
|
||||
self.name("MenuView")
|
||||
.child(
|
||||
self.name("MenuView").child(
|
||||
Grid::new()
|
||||
.id(ID_MENU_VIEW)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
.push(50), // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // Bottom_Bar
|
||||
.push("auto"), // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(menu_header_bar) // Row 0
|
||||
.child(menu_bottom_bar) // Row 3
|
||||
.build(ctx),
|
||||
|
||||
@@ -5,26 +5,26 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use orbtk::{prelude::*, widgets::themes::* };
|
||||
use orbtk::{prelude::*, widgets::themes::*};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::process;
|
||||
use std::collections::HashMap;
|
||||
use std::process;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tracing::{error, info, trace};
|
||||
|
||||
use crate::{
|
||||
data::{
|
||||
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||
constants::*,
|
||||
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||
},
|
||||
Lang,
|
||||
//services::imports::allianzdirectcall::import,
|
||||
services::imports::allianzdirectcall,
|
||||
widgets::global_state::GlobalState,
|
||||
//widgets::menu::menu_view::MenuView,
|
||||
//widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
//widgets::ticketdata::ticketdata_state::TicketdataAction,
|
||||
Lang,
|
||||
};
|
||||
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
@@ -68,7 +68,7 @@ pub enum PolicycheckAction {
|
||||
/// Update the given policy code
|
||||
UpdatePolicyCode,
|
||||
/// Update the process status to given value
|
||||
UpdateProgress(f64)
|
||||
UpdateProgress(f64),
|
||||
}
|
||||
|
||||
/// Define valid environment variables provided via .env files
|
||||
@@ -96,7 +96,7 @@ pub struct PolicycheckState {
|
||||
progress_popup: Entity,
|
||||
// target that recieves messages
|
||||
target: Entity,
|
||||
ticketdata_view: Entity
|
||||
ticketdata_view: Entity,
|
||||
}
|
||||
|
||||
impl GlobalState for PolicycheckState {}
|
||||
@@ -104,8 +104,10 @@ impl GlobalState for PolicycheckState {}
|
||||
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
||||
impl PolicycheckState {
|
||||
/// Create a hashmap (key: policy number, value: policy type).
|
||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>)
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn create_hashmap(
|
||||
&mut self,
|
||||
_ctx: &mut Context<'_>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "advotracker", create_hashmap = "started");
|
||||
|
||||
let policy_list = PolicyList::new("policy list");
|
||||
@@ -116,13 +118,17 @@ impl PolicycheckState {
|
||||
let mut policy_data = PolicyDataList::new(res);
|
||||
trace!(target: "advotracker", policy_data = ?policy_data);
|
||||
|
||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||
|
||||
// Wip: use cli parameter stored in viperus ...
|
||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
||||
match allianzdirectcall::import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &mut self.policy_data_count) {
|
||||
match allianzdirectcall::import(
|
||||
&mut csv_import_path,
|
||||
&mut policy_data,
|
||||
&mut policy_numbers,
|
||||
&mut self.policy_data_count,
|
||||
) {
|
||||
Ok((count, duration)) => {
|
||||
self.policy_data_count = count;
|
||||
self.duration = duration;
|
||||
@@ -145,15 +151,26 @@ impl PolicycheckState {
|
||||
|
||||
/// Clear text in text box.
|
||||
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) {
|
||||
TextBox::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from(""));
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||
TextBox::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from(""),
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
}
|
||||
|
||||
/// Import policy numbers into hashmap
|
||||
fn import_data(&mut self, ctx: &mut Context<'_>)
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
fn import_data(&mut self, ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
// WIP: for now, only import once per session
|
||||
if self.policy_data_count == 0 {
|
||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), true);
|
||||
@@ -167,7 +184,10 @@ impl PolicycheckState {
|
||||
for _ in 1..4 {
|
||||
self.progress_count += 0.33;
|
||||
self.update_progress_bar(ctx);
|
||||
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup);
|
||||
ctx.send_message(
|
||||
PolicycheckAction::UpdateProgress(self.progress_count),
|
||||
self.progress_popup,
|
||||
);
|
||||
}
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
@@ -181,7 +201,6 @@ impl PolicycheckState {
|
||||
|
||||
self.progress_count = 1.;
|
||||
self.update_progress_bar(ctx);
|
||||
|
||||
}
|
||||
_ => {
|
||||
let res = t!(policy_hashmap_failed => self.lang);
|
||||
@@ -208,8 +227,7 @@ impl PolicycheckState {
|
||||
}
|
||||
|
||||
/// Parse validity of the given policy number.
|
||||
pub fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
ctx: &mut Context<'_>) {
|
||||
pub fn parse_entry(&mut self, policy_check_policy_number: Entity, ctx: &mut Context<'_>) {
|
||||
trace!(target: "advotracker", parse_entry = "started");
|
||||
|
||||
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number));
|
||||
@@ -220,12 +238,20 @@ impl PolicycheckState {
|
||||
match self.import_data(ctx) {
|
||||
Ok(()) => {
|
||||
trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_DATA_STACK), Visibility::Visible);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_DATA_STACK),
|
||||
Visibility::Visible,
|
||||
);
|
||||
let policy_data_count_string = format!("{:?}", &self.policy_data_count);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT), String::from(&policy_data_count_string));
|
||||
},
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_DATA_COUNT),
|
||||
String::from(&policy_data_count_string),
|
||||
);
|
||||
}
|
||||
|
||||
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
||||
Err(e) => {
|
||||
trace!(target: "advotracker", policycheck_state = "init", import_data = ?e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,14 +260,23 @@ impl PolicycheckState {
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
Button::background_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("transparent"),
|
||||
);
|
||||
|
||||
if policy_number_length == 10 {
|
||||
// cast policy_number_sting to <u64>
|
||||
match policy_number_string.parse::<u64>() {
|
||||
Ok(p) => {
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), String::from(""));
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
String::from(""),
|
||||
);
|
||||
|
||||
// match hashmap's key
|
||||
match self.policy_numbers.get(&p) {
|
||||
@@ -250,62 +285,157 @@ impl PolicycheckState {
|
||||
trace!(target: "advotracker", state = "success",
|
||||
policy_number = ?p, policy_code = ?policy_code);
|
||||
|
||||
let string_result = format!("1-{:?}-{}",
|
||||
policy_code, p);
|
||||
let string_result = format!("1-{:?}-{}", policy_code, p);
|
||||
|
||||
// adapt the view properties
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), string_result);
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
string_result,
|
||||
);
|
||||
TextBox::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from("#008000"),
|
||||
);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#008000"),
|
||||
);
|
||||
Button::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#008000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
material_icons_font::MD_CHECK,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Visible);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR), Visibility::Visible);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||
Visibility::Visible,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
// no matching key
|
||||
let res = t!(policy_validation_failed => self.lang);
|
||||
trace!(target: "advotracker", state = ?res, policy_number = ?p);
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("The given policy number is invalid"));
|
||||
TextBox::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
String::from("The given policy number is invalid"),
|
||||
);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
material_icons_font::MD_CLEAR,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
TextBox::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
String::from("Only numbers are valid"),
|
||||
);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
material_icons_font::MD_CLEAR,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,41 +443,101 @@ impl PolicycheckState {
|
||||
let res = t!(policy_validation_failed => self.lang);
|
||||
trace!(target: "advotracker", state = ?res, reason = "number to short");
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
TextBox::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to short"));
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
String::from("Policy number is to short"),
|
||||
);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
material_icons_font::MD_CLEAR,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
let res = t!(policy_validation_failed => self.lang);
|
||||
trace!(target: "advotracker", state = ?res, reason = "number to long");
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
TextBox::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to long"));
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||
String::from("Policy number is to long"),
|
||||
);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::foreground_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
material_icons_font::MD_CLEAR,
|
||||
);
|
||||
Button::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
|
||||
trace!(target: "advotracker", parse_entry = "finished");
|
||||
@@ -355,7 +545,8 @@ impl PolicycheckState {
|
||||
|
||||
/// parse message 'ParseEntry'
|
||||
pub fn parse_policy_number(&mut self, entity: Entity) {
|
||||
self.actions.push(PolicycheckAction::ParsePolicyNumber(entity));
|
||||
self.actions
|
||||
.push(PolicycheckAction::ParsePolicyNumber(entity));
|
||||
}
|
||||
|
||||
/// Remove the popup box
|
||||
@@ -389,51 +580,84 @@ impl PolicycheckState {
|
||||
/// Change status of given text box to edit mode.
|
||||
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
} else {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Set a progress popup that updates the import status in a progress bar
|
||||
fn set_popup_progress(&mut self, ctx: &mut Context<'_>) {
|
||||
// create a stack as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
|
||||
let stack = ctx.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER).expect(
|
||||
"PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.",
|
||||
);
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create the progress_popup widget
|
||||
self.progress_popup = create_popup_progress(current_entity, build_context);
|
||||
info!("set_popup_progress: New entity 'popup_progress' {:?} created", self.progress_popup);
|
||||
info!(
|
||||
"set_popup_progress: New entity 'popup_progress' {:?} created",
|
||||
self.progress_popup
|
||||
);
|
||||
|
||||
// append the stack inside the progress_popup
|
||||
build_context.append_child(stack, self.progress_popup);
|
||||
|
||||
// make sure we have a progress bar
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
||||
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar);
|
||||
self.progress_bar = ctx.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR).expect(
|
||||
"PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.",
|
||||
);
|
||||
info!(
|
||||
"set_popup_progress: New entity 'progress_bar' created: {:?}",
|
||||
self.progress_bar
|
||||
);
|
||||
}
|
||||
|
||||
/// Change visibility of the result label.
|
||||
fn _set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
} else {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||
Visibility::Visible,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Update count of elements in the policy data list.
|
||||
fn _update_data_count(&self, ctx: &mut Context<'_>) {
|
||||
let data_list_count = ctx.widget().get::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();
|
||||
let data_list_count = ctx
|
||||
.widget()
|
||||
.get::<PolicyDataList>(PROP_POLICY_DATA_LIST)
|
||||
.len();
|
||||
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
|
||||
}
|
||||
|
||||
@@ -441,7 +665,10 @@ impl PolicycheckState {
|
||||
let res = t!(policy_string_progress_time => self.lang);
|
||||
let string_duration = format!("{}: {:?}", res, self.duration);
|
||||
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), string_duration);
|
||||
TextBlock::text_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME),
|
||||
string_duration,
|
||||
);
|
||||
|
||||
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
||||
progress_bar.set::<f64>("val", self.progress_count);
|
||||
@@ -453,14 +680,13 @@ impl PolicycheckState {
|
||||
//let policy_code = ctx.widget().get::<PolicycheckState>(ID_POLICY_CHECK_POLICY_CODE);
|
||||
//ctx.widget().set(PROP_POLICY_DATA_COUNT, policy_code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Supported methods handled inside the `PolicycheckState`
|
||||
impl State for PolicycheckState {
|
||||
/// Initialize the state of widgets inside `PolicycheckState`
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let time_start= SystemTime::now();
|
||||
let time_start = SystemTime::now();
|
||||
|
||||
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
||||
|
||||
@@ -469,27 +695,41 @@ impl State for PolicycheckState {
|
||||
self.lang = Lang::De("");
|
||||
|
||||
// Initialize required entities
|
||||
self.button_menu = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
|
||||
self.button_menu = ctx.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU).expect(
|
||||
"PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.",
|
||||
);
|
||||
|
||||
self.label_result = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
||||
self.label_result = ctx.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT).expect(
|
||||
"PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.",
|
||||
);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
|
||||
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
// .expect("PolicycheckState::init(): Can't find resource entity 'ID_POLICY_CHECK_POLICY_NUMBER'."));
|
||||
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("PolicycheckState::init(): Can't find resource entity 'target'."));
|
||||
self.target = Entity::from(
|
||||
ctx.widget()
|
||||
.try_clone::<u32>("target")
|
||||
.expect("PolicycheckState::init(): Can't find resource entity 'target'."),
|
||||
);
|
||||
|
||||
//self.ticketdata_view = (*ctx.widget().get::<u32>("ticketdata_view")).into();
|
||||
//self.ticketdata = Entity::from(ctx.widget().try_clone::<u32>(ID_TICKET_DATA_VIEW)
|
||||
@@ -532,18 +772,24 @@ impl State for PolicycheckState {
|
||||
self.update_policy_code(ctx);
|
||||
}
|
||||
PolicycheckAction::UpdateProgress(increment) => {
|
||||
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
let old_width =
|
||||
ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
|
||||
let new_width = old_width + increment;
|
||||
// Set the ProgressBar's val property to the calculated percentage
|
||||
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
||||
if new_width <= 1. {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
||||
ProgressBar::val_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR),
|
||||
new_width,
|
||||
);
|
||||
} else {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||
}
|
||||
}
|
||||
_ => { println!("PolicycheckAction: action not implemented!"); }
|
||||
_ => {
|
||||
println!("PolicycheckAction: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,10 +816,12 @@ impl State for PolicycheckState {
|
||||
self.clear_policy_number(ctx);
|
||||
}
|
||||
PolicycheckAction::InputTextChanged(entity) => {
|
||||
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
||||
println!(
|
||||
"entry changed: {}",
|
||||
TextBox::text_clone(&ctx.get_widget(entity))
|
||||
);
|
||||
}
|
||||
PolicycheckAction::ImportData => {
|
||||
match self.import_data(ctx) {
|
||||
PolicycheckAction::ImportData => match self.import_data(ctx) {
|
||||
Ok(()) => {
|
||||
trace!(target: "advotracker", import_data = "success");
|
||||
}
|
||||
@@ -581,8 +829,7 @@ impl State for PolicycheckState {
|
||||
error!("Importing data failed!");
|
||||
trace!(target: "advotracker", import_data = "failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
PolicycheckAction::NewTicket => {
|
||||
self.new_ticket(ctx);
|
||||
}
|
||||
@@ -590,7 +837,8 @@ impl State for PolicycheckState {
|
||||
self.parse_entry(text_box, ctx);
|
||||
}
|
||||
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
ctx.get_widget(policy_check_policy_number)
|
||||
.set("enabled", false);
|
||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||
}
|
||||
PolicycheckAction::RemovePopup(entity) => {
|
||||
@@ -608,12 +856,16 @@ impl State for PolicycheckState {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
||||
} else {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
||||
} }
|
||||
}
|
||||
}
|
||||
PolicycheckAction::SetProgressPopup(_entity) => {
|
||||
self.set_popup_progress(ctx);
|
||||
}
|
||||
PolicycheckAction::SetVisibility(_entity) => {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(
|
||||
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
}
|
||||
PolicycheckAction::TextChanged(entity, _index) => {
|
||||
self.set_entry(entity, ctx);
|
||||
@@ -677,7 +929,7 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
||||
.style("textblock_progress")
|
||||
.text("Importing data")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
@@ -685,7 +937,7 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.style("progress_bar")
|
||||
.val(0)
|
||||
//.width(250)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -693,11 +945,11 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.style("textblock_progress")
|
||||
.h_align("end")
|
||||
.text("Processing time")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use orbtk::{prelude::*, shell::*, widgets::themes::* };
|
||||
use orbtk::{prelude::*, shell::*, widgets::themes::*};
|
||||
|
||||
use crate::{
|
||||
data::{
|
||||
constants::*,
|
||||
structures::PolicyCheck,
|
||||
},
|
||||
data::{constants::*, structures::PolicyCheck},
|
||||
//widgets::menu::menu_state::{MenuAction, MenuState},
|
||||
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
|
||||
};
|
||||
@@ -69,7 +66,7 @@ impl Template for PolicycheckView {
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -181,7 +178,7 @@ impl Template for PolicycheckView {
|
||||
.push("200") // Data
|
||||
.push("16") // Delimiter
|
||||
.push("32") // Result-Button
|
||||
.push("4") // Delimeter
|
||||
.push("4"), // Delimeter
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -189,9 +186,8 @@ impl Template for PolicycheckView {
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 3
|
||||
.push("auto"), // Row 3
|
||||
)
|
||||
|
||||
//.child(policy_check_form_row_0)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -215,7 +211,9 @@ impl Template for PolicycheckView {
|
||||
.water_mark("10-stellig")
|
||||
.on_activate(move |states, entity| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
states.get_mut::<PolicycheckState>(id).parse_policy_number(entity);
|
||||
states
|
||||
.get_mut::<PolicycheckState>(id)
|
||||
.parse_policy_number(entity);
|
||||
})
|
||||
.on_key_down(move |_, key_event| {
|
||||
if key_event.key == Key::A(true) {
|
||||
@@ -225,10 +223,9 @@ impl Template for PolicycheckView {
|
||||
// .set_action(Action::ImportData);
|
||||
true
|
||||
})
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_button_result)
|
||||
|
||||
//.child(policy_check_form_row_2)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -242,7 +239,6 @@ impl Template for PolicycheckView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_policy_code)
|
||||
|
||||
//.child(policy_check_form_row_2)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -268,7 +264,6 @@ impl Template for PolicycheckView {
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
|
||||
// row3: only shown, if we read in `policy numbers` in
|
||||
// a hashmap as values
|
||||
let policy_data_stack = Stack::new()
|
||||
@@ -285,7 +280,7 @@ impl Template for PolicycheckView {
|
||||
.margin((0, 4, 0, 0))
|
||||
.enabled(true)
|
||||
.text("Checklist elements: ")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -293,7 +288,7 @@ impl Template for PolicycheckView {
|
||||
.margin((0, 4, 0, 0))
|
||||
.enabled(true)
|
||||
.text("0")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
@@ -308,7 +303,7 @@ impl Template for PolicycheckView {
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
.push(50), // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -316,9 +311,8 @@ impl Template for PolicycheckView {
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // Data_Result
|
||||
.push("auto") // Bottom_Bar
|
||||
.push("auto"), // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(policy_check_header_bar) // row 0
|
||||
.child(policy_check_form) // row 2
|
||||
.child(policy_data_stack) // row 3
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use orbtk::{prelude::*, widgets::themes::* };
|
||||
use orbtk::{prelude::*, widgets::themes::*};
|
||||
|
||||
use serde::Deserialize;
|
||||
//use std::process;
|
||||
@@ -15,8 +15,8 @@ use tracing::{error, info, trace};
|
||||
|
||||
use crate::{
|
||||
data::{constants::*, structures::Email},
|
||||
widgets::global_state::GlobalState,
|
||||
services::exports::send_ticketdata::sendticketdata,
|
||||
widgets::global_state::GlobalState,
|
||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||
//widgets::policycheck::policycheck_state::PolicycheckAction,
|
||||
Lang,
|
||||
@@ -32,8 +32,7 @@ pub enum TicketdataAction {
|
||||
/// Send Email with form data
|
||||
SendForm(),
|
||||
/// Update the policycode
|
||||
UpdatePolicyCode(String)
|
||||
|
||||
UpdatePolicyCode(String),
|
||||
}
|
||||
|
||||
/// Define valid environment variables provided via .env files
|
||||
@@ -45,13 +44,13 @@ struct Environment {
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Ticket` widget.
|
||||
/// Valid `structures` that are handled inside the state of the `Ticketdata` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct TicketdataState {
|
||||
actions: Vec<TicketdataAction>,
|
||||
button_menu: Entity,
|
||||
lang: Lang,
|
||||
target: Entity
|
||||
target: Entity,
|
||||
}
|
||||
|
||||
impl GlobalState for TicketdataState {}
|
||||
@@ -78,11 +77,9 @@ impl TicketdataState {
|
||||
for i in 0..count {
|
||||
if let Some(child) = &mut ctx.try_child_from_index(i) {
|
||||
let child_name: &str = child.get::<String>("name");
|
||||
info!("child({:?}) name: {:?}",
|
||||
i, child_name);
|
||||
info!("child({:?}) name: {:?}", i, child_name);
|
||||
let child_id: &str = child.get::<String>("id");
|
||||
info!("child({:?}) name: {:?}",
|
||||
i, child_id);
|
||||
info!("child({:?}) name: {:?}", i, child_id);
|
||||
|
||||
// TODO: check the orbtk type
|
||||
// if let child_type: bool = child.get::<String>("id") = std::any::type_name::<TextBox>().to_string() {
|
||||
@@ -102,7 +99,6 @@ impl TicketdataState {
|
||||
// "ticket_data_policy_callback_ivr_comment" => TextBox::text_set(child, ""),
|
||||
// _ => info!("don't act on child_id '{:?}", child_id),
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,9 +106,18 @@ impl TicketdataState {
|
||||
// switch back to parent entity
|
||||
ctx.change_into(entity);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Collapsed);
|
||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#008000"));
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_SEND);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
Button::background_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
String::from("#008000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
material_icons_font::MD_SEND,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,13 +137,34 @@ impl TicketdataState {
|
||||
mail_from: PROP_MAIL_FROM.to_string(),
|
||||
mail_reply: PROP_MAIL_REPLY.to_string(),
|
||||
subject: PROP_MAIL_SUBJECT.to_string(),
|
||||
policy_code: ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").to_string(),
|
||||
policy_holder: ctx.child(ID_TICKET_DATA_POLICY_HOLDER).get::<String>("text").to_string(),
|
||||
deductible: ctx.child(ID_TICKET_DATA_DEDUCTIBLE).get::<String>("text").to_string(),
|
||||
callback_number: ctx.child(ID_TICKET_DATA_CALLBACK_NUMBER).get::<String>("text").to_string(),
|
||||
callback_date: ctx.child(ID_TICKET_DATA_CALLBACK_DATE).get::<String>("text").to_string(),
|
||||
harm_type: ctx.child(ID_TICKET_DATA_HARM_TYPE).get::<String>("text").to_string(),
|
||||
ivr_comment: ctx.child(ID_TICKET_DATA_IVR_COMMENT).get::<String>("text").to_string(),
|
||||
policy_code: ctx
|
||||
.child(ID_TICKET_DATA_POLICY_CODE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
policy_holder: ctx
|
||||
.child(ID_TICKET_DATA_POLICY_HOLDER)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
deductible: ctx
|
||||
.child(ID_TICKET_DATA_DEDUCTIBLE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
callback_number: ctx
|
||||
.child(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
callback_date: ctx
|
||||
.child(ID_TICKET_DATA_CALLBACK_DATE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
harm_type: ctx
|
||||
.child(ID_TICKET_DATA_HARM_TYPE)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
ivr_comment: ctx
|
||||
.child(ID_TICKET_DATA_IVR_COMMENT)
|
||||
.get::<String>("text")
|
||||
.to_string(),
|
||||
};
|
||||
trace!("eMail fields: {:?}", email);
|
||||
|
||||
@@ -146,22 +172,43 @@ impl TicketdataState {
|
||||
let lang = Lang::De("");
|
||||
if let Err(err) = sendticketdata(&email, &lang) {
|
||||
error!("sendticketdata error: {:?}", err);
|
||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#008000"));
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
String::from("#008000"),
|
||||
);
|
||||
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#CC000000"));
|
||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#CC000000"));
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_THUMB_DOWN);
|
||||
Button::background_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
String::from("#CC000000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
material_icons_font::MD_THUMB_DOWN,
|
||||
);
|
||||
//Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_ERROR);
|
||||
} else {
|
||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||
Button::icon_brush_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_THUMB_UP);
|
||||
Button::background_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
String::from("#FF0000"),
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
material_icons_font::MD_THUMB_UP,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/// Update the policy code
|
||||
pub fn update_policy_code(_entity: Entity, _id: &str, ctx: &mut Context<'_>) {
|
||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Visible);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||
Visibility::Visible,
|
||||
);
|
||||
//self.actions.push(TicketdataAction::UpdatePolicyCode(entity));
|
||||
}
|
||||
}
|
||||
@@ -170,7 +217,7 @@ impl TicketdataState {
|
||||
impl State for TicketdataState {
|
||||
/// Initialize the state of widgets inside `TicketState`
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let time_start= SystemTime::now();
|
||||
let time_start = SystemTime::now();
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||
|
||||
@@ -180,16 +227,28 @@ impl State for TicketdataState {
|
||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||
|
||||
// initialize the entity object, that will receive messages
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
||||
self.target = Entity::from(
|
||||
ctx.widget()
|
||||
.try_clone::<u32>("target")
|
||||
.expect("TicketState.init: Can't find resource entity 'target'."),
|
||||
);
|
||||
|
||||
// Get language from environment
|
||||
//self.lang = TicketdataState::get_lang();
|
||||
//let self.lang = Lang::De("");
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Collapsed);
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_CLEAR), material_icons_font::MD_CLEAR);
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_SEND);
|
||||
Stack::visibility_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||
Visibility::Collapsed,
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_CLEAR),
|
||||
material_icons_font::MD_CLEAR,
|
||||
);
|
||||
Button::icon_set(
|
||||
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||
material_icons_font::MD_SEND,
|
||||
);
|
||||
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start);
|
||||
@@ -215,7 +274,9 @@ impl State for TicketdataState {
|
||||
TicketdataAction::UpdatePolicyCode(id) => {
|
||||
TicketdataState::update_policy_code(ctx.entity(), &id, ctx);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
_ => {
|
||||
println!("messages: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,7 +293,9 @@ impl State for TicketdataState {
|
||||
// //ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||
// info!("update: got send_message {:?}", action);
|
||||
// }
|
||||
_ => { println!("TicketdataAction: action not implemented!"); }
|
||||
_ => {
|
||||
println!("TicketdataAction: action not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
use orbtk::{prelude::*, widgets::themes::* };
|
||||
use orbtk::{prelude::*, widgets::themes::*};
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
@@ -46,14 +46,12 @@ impl Template for TicketdataView {
|
||||
PROP_MAIL_TO_4.to_string(),
|
||||
PROP_MAIL_TO_5.to_string(),
|
||||
PROP_MAIL_TO_6.to_string(),
|
||||
PROP_MAIL_TO_7.to_string(),
|
||||
];
|
||||
let count_mail_to = mail_to.len();
|
||||
|
||||
// vector with valid carbon copy recipients addresses (mail_to)
|
||||
let mail_cc = vec![
|
||||
PROP_MAIL_CC_1.to_string(),
|
||||
PROP_MAIL_CC_2.to_string(),
|
||||
];
|
||||
let mail_cc = vec![PROP_MAIL_CC_1.to_string(), PROP_MAIL_CC_2.to_string()];
|
||||
let _count_mail_cc = mail_cc.len();
|
||||
|
||||
let tenent_logo = Container::new()
|
||||
@@ -84,7 +82,7 @@ impl Template for TicketdataView {
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -121,7 +119,7 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(32) // Delimiter (2x margin)
|
||||
.push(32), // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -138,7 +136,7 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 12
|
||||
.push(14) // Seperator
|
||||
.push(14), // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -159,7 +157,12 @@ impl Template for TicketdataView {
|
||||
.v_align("center")
|
||||
.water_mark("ID, bzw. Nummer")
|
||||
.on_activate(move |states, _entity| {
|
||||
states.send_message(TicketdataAction::UpdatePolicyCode(ID_TICKET_DATA_POLICY_CODE.to_string()), id);
|
||||
states.send_message(
|
||||
TicketdataAction::UpdatePolicyCode(
|
||||
ID_TICKET_DATA_POLICY_CODE.to_string(),
|
||||
),
|
||||
id,
|
||||
);
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -302,7 +305,12 @@ impl Template for TicketdataView {
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Clear")
|
||||
.on_click(move |states, _entity| {
|
||||
states.send_message(TicketdataAction::ClearForm(ID_TICKET_DATA_FORM_GRID.to_string()), id);
|
||||
states.send_message(
|
||||
TicketdataAction::ClearForm(
|
||||
ID_TICKET_DATA_FORM_GRID.to_string(),
|
||||
),
|
||||
id,
|
||||
);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
@@ -324,13 +332,11 @@ impl Template for TicketdataView {
|
||||
|
||||
let ticket_data_form_mail = Container::new()
|
||||
.id(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
|
||||
.name(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_CONTAINER_MAIL)
|
||||
.child(
|
||||
|
||||
Grid::new()
|
||||
.columns(
|
||||
Columns::create()
|
||||
@@ -338,14 +344,14 @@ impl Template for TicketdataView {
|
||||
.push("stretch") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("auto") // MailAddress
|
||||
.push("32") // Delimiter (2x margin)
|
||||
.push("32"), // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(2) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(2) // Seperator
|
||||
.push(2), // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -366,7 +372,8 @@ impl Template for TicketdataView {
|
||||
// create the items builder context (ibc) for the `mail_to` vector-items
|
||||
.selected_index(id)
|
||||
.items_builder(move |ibc, index| {
|
||||
let text = TicketdataView::mail_to_ref(&ibc.get_widget(id))[index].clone();
|
||||
let text =
|
||||
TicketdataView::mail_to_ref(&ibc.get_widget(id))[index].clone();
|
||||
TextBlock::new()
|
||||
.name(ID_TICKET_DATA_MAIL_TO)
|
||||
.v_align("center")
|
||||
@@ -376,7 +383,7 @@ impl Template for TicketdataView {
|
||||
//.on_changed("selected_index", move |states, _entity| {
|
||||
// states.send_message(TicketdataAction::UpdateSelectedIndex(ID_TICKET_DATA_COMBO_BOX_MAIL_TO.to_string()), id);
|
||||
//})
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -395,7 +402,7 @@ impl Template for TicketdataView {
|
||||
.name(ID_TICKET_DATA_MAIL_CC)
|
||||
.margin((12, 0, 0, 0))
|
||||
.text("service@hiedemann.de")
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
// .child(
|
||||
// ComboBox::new()
|
||||
@@ -422,7 +429,7 @@ impl Template for TicketdataView {
|
||||
// })
|
||||
// .build(ctx)
|
||||
// )
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
@@ -459,7 +466,7 @@ impl Template for TicketdataView {
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
.push(50), // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -467,9 +474,8 @@ impl Template for TicketdataView {
|
||||
.push("auto") // Mail_Form
|
||||
.push("*") // Input_Form
|
||||
.push("auto") // Action
|
||||
.push("auto") // Bottom_Bar
|
||||
.push("auto"), // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(ticket_data_header_bar) // row 0
|
||||
.child(ticket_data_form_mail) // row 1
|
||||
.child(ticket_data_form) // row 2
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
//!
|
||||
//!
|
||||
|
||||
|
||||
// eperimental features
|
||||
//#![feature(extern_doc)]
|
||||
//#[doc(include="../README.md")]
|
||||
|
||||
Reference in New Issue
Block a user