@@ -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))]
|
||||
|
||||
Reference in New Issue
Block a user