Merge branch 'orbtk-localization' into master

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-10-02 12:04:22 +02:00
27 changed files with 643 additions and 855 deletions

View File

@@ -1,7 +1,16 @@
###
# .env
# will overwrite standard environment viariables
###
# set the language variable used in test-runs # set the language variable used in test-runs
#test lang=it #test LANG=es-ES
TEST_LANG=de #test LANG=it-IT
#test LANG=C
# set the language variable (overwriting standard Enviroment)
#TEST_LANG=de_DE
#TEST_LANG=C
#RUST_LOG=advotracker=trace #RUST_LOG=advotracker=trace
RUST_LOG=trace RUST_LOG=trace
#RUST_LOG=none
USERNAME=hiedemann USERNAME=hiedemann
DB_DRIVER=sqlite DB_DRIVER=sqlite

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "advotracker" name = "advotracker"
version = "0.1.3" version = "0.1.4"
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"] authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice." description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
readme = "README.md" readme = "README.md"
@@ -32,7 +32,7 @@ orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
serde = { version = "~1.0", features = ["derive"] } serde = { version = "~1.0", features = ["derive"] }
#tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] } #tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] }
tracing = { version = "~0.1" } tracing = { version = "~0.1" }
tracing-subscriber = { version = "0.2.0-alpha", features = ["tracing-log"] } tracing-subscriber = { version = "~0.2.0", features = ["tracing-log"] }
viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] } viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] }
[features] [features]

View File

@@ -2,13 +2,7 @@
name = "advotracker" name = "advotracker"
width = 580 width = 580
height = 280 height = 280
assets = "resources/advotracker"
[[apps.fonts]] [[apps.fonts]]
font_family = "Material Icons" font_family = "MaterialIcons-Regular"
src = "resources/fonts/MaterialIcons.ttf" src = "resources/fonts/MaterialIcons.ttf"
[[apps.fonts]]
font_family = "Roboto Regular"
src = "resources/fonts/Roboto-Regular.ttf"
[[apps.fonts]]
font_family = "Roboto Medium"
src = "resources/fonts/Roboto-Medium.ttf"

View File

@@ -1,128 +0,0 @@
{
"err.lang.not_found": {
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
"de": "Konnte Sprachkode nicht auslesen",
"en": "Couldn't read LANG"
},
"err.user.not_found": {
"fr": "Utilisateur introuvable: $email, $id",
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
"de": "Anwender nicht gefunden: $email, $id",
"en": "User not found: $email, $id"
},
"main.started": {
"de_DE.UTF-8": "Programmlogik starten",
"de": "Programmlogik starten",
"en": "Program logic started"
},
"main.finished": {
"de_DE.UTF-8": "Programmlogik beendet",
"de": "Programmlogik beendet",
"en": "Program logic finished"
},
"parse.arguments": {
"de_DE.UTF-8": "Programmargumente prüfen",
"de": "Programmargumente prüfen",
"en": "Parsing arguments"
},
"parse.environment": {
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
"de": "Umgebungsvariablen prüfen",
"en": "Parsing environment"
},
"parse.results": {
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
"de": "Ergebnisse der Konfigurationsparameterprüfung",
"en": "Config parsing results"
},
"config.name": {
"de_DE.UTF-8": "Konfigurationswert für",
"de": "Konfigurationswert für",
"en": "Config Value for"
},
"config.name.lang": {
"de_DE.UTF-8": "Sprach-Code",
"de": "Sprach-Code",
"en": "Language code"
},
"config.name.verbositylevel": {
"de_DE.UTF-8": "Ausgabe-Ebene",
"de": "Ausgabe-Ebene",
"en": "verbosity level"
},
"config.name.environment": {
"de_DE.UTF-8": "Umgebungsvariablen",
"de": "Umgebungsvariablen",
"en": "environment"
},
"config.name.configfile": {
"de_DE.UTF-8": "Konfigurations-Datei",
"de": "Konfigurations-Datei",
"en": "config file"
},
"config.name.dbdriver": {
"de_DE.UTF-8": "Datenbank-Treiber",
"de": "Datenbank-Treiber",
"en": "database driver"
},
"config.name.redis": {
"de_DE.UTF-8": "Redis Datenbank",
"de": "Redis Datenbank",
"en": "Redis database"
},
"csv.export.started": {
"de_DE.UTF-8": "Export in eine CSV Datei starten",
"de": "Export in eine CSV Datei starten",
"en": "Export to csv file started"
},
"csv.export.finished": {
"de_DE.UTF-8": "Export in eine CSV Datei beendet",
"de": "Export in eine CSV Datei beendet",
"en": "Export to csv file finished"
},
"csv.import.started": {
"de_DE.UTF-8": "Import von einer CSV Datei starten",
"de": "Import von einer CSV Datei starten",
"en": "Import from a csv file started"
},
"csv.import.finished": {
"de_DE.UTF-8": "Import von einer CSV Datei beendet",
"de": "Import von einer CSV Datei beendet",
"en": "Import from a csv file finished"
},
"redis.connection.error": {
"de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden",
"de": "Es konnte keine Redis Verbindung aufgebaut werden",
"en": "Could not establish a redis connection"
},
"policy.validation.failed": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig",
"de": "Die Versicherungsscheinnummber ist ungültig",
"en": "The given policy number is invalid"
},
"policy.validation.success": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig",
"de": "Die Versicherungsscheinnummber ist gültig",
"en": "The given policy number is valid"
},
"policy.validation.started": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"en": "Validation of the policy number started"
},
"policy.validation.finished": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"en": "Validation of the policy number finished"
},
"state.started": {
"de_DE.UTF-8": "gestartet",
"de": "gestartet",
"en": "started"
},
"state.finished": {
"de_DE.UTF-8": "beendet",
"de": "beended",
"en": "finished"
}
}

View File

@@ -0,0 +1,35 @@
// *
// * advotracker - Hotline tackingtool for Advocats
// *
// * Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
// * SPDX-License-Identifier: (0BSD or MIT)
// */
// the language class
Dictionary (
// the map of active identifiers
// like a struct, but keys are also values instead of just beenig identifiers
words: {
// policycheck_view
"Validation policy number": "Prüfung Versicherungsnummer",
"Policy number": "Versicherungsnummer",
"Policy code": "ID der Vers.-Nummer",
"Checklist elements: ": "Prüflistenelemente: ",
"Check result": "Prüfungsergebnis",
"Importing data": "Importiere Datensätze",
"Processing time": "Bearbeitungszeit",
"Error:": "Fehler:",
"Reason": "Grund",
"Policy number is to long": "Die Nummer ist zu lang",
"Policy number is to short": "Die Nummer ist zu kurz",
"The given policy number is invalid": "Die Versicherungsnummer ist ungültig",
"The given policy number is valid": "Die Versicherungsnummer ist gültig",
"Only numbers are valid": "Nur Nummern sind zulässig",
// localization
"Hello": "Hallo",
"User": "Anwender",
"Localization dialog": "Lokalisierungs-Dialog",
"German": "Deutsch",
"English": "Englisch"
}
)

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,32 +0,0 @@
.header {
background: #444e55;
}
.content {
background: #3b434a;
}
text_box {
background: transparent;
border-width: 0;
color: #9dafbf;
font-size: 16;
}
#input {
font-size: 16;
}
text-block {
font-size: 42;
color: #dfebf5;
}
#input {
background: transparent;
}
button {
border-radius: 1;
font-size: 20;
}

View File

@@ -1,15 +0,0 @@
.header {
background: #ffffff;
}
.content {
background: #fafafa;
}
text_box {
color: #4d4c4c;
}
text-block {
color: #4d4c4c;
}

Binary file not shown.

View File

@@ -1,25 +0,0 @@
* {
font-size: 24;
}
lynch {
background: #647b91;
}
bluebayoux {
background: #516475;
}
linkwater {
background: #dfebf5;
color: #3b434a;
}
light-text {
color: #dfebf5;
}
goldendream {
background: #efd035;
color: #3b434a;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

View File

@@ -1,25 +0,0 @@
* {
font-size: 24;
}
lynch {
background: #647b91;
}
bluebayoux {
background: #516475;
}
linkwater {
background: #dfebf5;
color: #3b434a;
}
light-text {
color: #dfebf5;
}
goldendream {
background: #efd035;
color: #3b434a;
}

View File

@@ -1,113 +1,122 @@
Theme ( Theme (
styles: { styles: {
"button_menu": ( "button_menu": (
base: "menu", base: "menu",
properties: { properties: {
"background": "transparent", "background": "transparent",
//"background": "$GOLDEN_DREAM", //"background": "$GOLDEN_DREAM",
//"background": "$LINK_WATER", //"background": "$LINK_WATER",
//"border_brush": "$LINK_WATER", //"border_brush": "$LINK_WATER",
//"border_brush": "$GOLDEN_DREAM", //"border_brush": "$GOLDEN_DREAM",
"border_radius": 0, "border_radius": 0,
"border_width": 0, "border_width": 0,
//"foreground": "$BRIGHT_GRAY", //"foreground": "$BRIGHT_GRAY",
//"icon_brush": "$BRIGHT_GRAY", //"icon_brush": "$BRIGHT_GRAY",
"font_size": "$ICON_SIZE_16", "font_size": "$ICON_SIZE_16",
"h_align": "left", "h_align": "left",
//"height": 14, //"height": 14,
"margin": (0, 4, 0, 0), "margin": (0, 4, 0, 0),
//"padding": (8, 0, 8, 0), //"padding": (8, 0, 8, 0),
}, },
), ),
"container_menu": ( "container_menu": (
properties: { properties: {
"border_radius": 0, "border_radius": 0,
"border_width": 1, "border_width": 1,
"background": "$BRIGHT_GRAY", "background": "$BRIGHT_GRAY",
"border_brush": "$LINK_WATER", "border_brush": "$LINK_WATER",
//"border_brush": "$GOLDEN_DREAM", //"border_brush": "$GOLDEN_DREAM",
"padding": 4, "padding": 4,
}, },
), ),
"container_progress": ( "container_progress": (
properties: { properties: {
"border_radius": 3, "border_radius": 3,
"border_width": 1, "border_width": 1,
"background": "$BRIGHT_GRAY", "background": "$BRIGHT_GRAY",
"border_brush": "$LINK_WATER", "border_brush": "$LINK_WATER",
//"border_brush": "$GOLDEN_DREAM", //"border_brush": "$GOLDEN_DREAM",
"padding": 14, "padding": 14,
"h_align": "end" "h_align": "end"
}, },
), ),
"container_form": ( "container_form": (
base: "container", base: "container",
properties: { properties: {
"background": "$BRIGHT_GRAY", "background": "$BRIGHT_GRAY",
"border_brush": "$LINK_WATER", "border_brush": "$LINK_WATER",
"border_radius": 3, "border_radius": 3,
"border_width": 1, "border_width": 1,
"padding": 14, "padding": 14,
"v_align": "top", "v_align": "top",
}, },
), ),
"header_bar": ( "header_bar": (
base: "header", base: "header",
properties: { properties: {
"foreground": "$LINK_WATER", "foreground": "$LINK_WATER",
}, },
), ),
"menu": ( "hint": (
//base: "base", base: "body",
properties: { properties: {
"font_size": 16, "font_size": 11,
"font_family": "$MEDIUM_FONT", "font_family": "$MEDIUM_FONT",
"background": "$BLACK", "width": "250",
"opacity": 1, "min_width": "250"
}, },
states: { ),
"pressed": { "menu": (
"background": "$WHITE", //base: "base",
}, properties: {
}, "font_size": 16,
), "font_family": "$MEDIUM_FONT",
"popup_progress": ( "background": "$BLACK",
base: "popup", "opacity": 1,
properties: { },
//"h_align": "center", states: {
"width": 300, "pressed": {
"heigth": 120, "background": "$WHITE",
}, },
), },
"stack_menu": ( ),
properties: { "popup_progress": (
//"background": "transparent", base: "popup",
"spacing": 2, properties: {
"orientation": "vertical", //"h_align": "center",
"h_align": "left", "width": 300,
}, "heigth": 120,
), },
"stack_progress": ( ),
properties: { "stack_menu": (
//"background": "transparent", properties: {
"spacing": 8, //"background": "transparent",
"margin": (16, 16, 16, 16), "spacing": 2,
}, "orientation": "vertical",
), "h_align": "left",
"textblock": ( },
//base: "base", ),
properties: { "stack_progress": (
"font_size": "$ICON_SIZE_12", properties: {
}, //"background": "transparent",
), "spacing": 8,
"textblock_progress": ( "margin": (16, 16, 16, 16),
base: "textblock", },
properties: { ),
//"background": "transparent", "textblock": (
//"font_size": 12, //base: "base",
"h_align": "center", properties: {
"v_align": "center", "font_size": "$ICON_SIZE_12",
}, },
), ),
"textblock_progress": (
base: "textblock",
properties: {
//"background": "transparent",
//"font_size": 12,
"h_align": "center",
"v_align": "center",
},
),
} }
) )

View File

@@ -5,7 +5,10 @@
* SPDX-License-Identifier: (0BSD or MIT) * SPDX-License-Identifier: (0BSD or MIT)
*/ */
use dotenv::dotenv;
use serde::Deserialize; use serde::Deserialize;
use std::env;
use tracing::{info, trace};
use orbtk::prelude::*; use orbtk::prelude::*;
@@ -23,33 +26,36 @@ struct Environment {
rust_log: String, rust_log: String,
} }
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`). /// Provides generic methods to handle states of datatypes.
pub trait GlobalState { pub trait GlobalState {
/// Navigates to the given entity. /// Get the active language environment.
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) { fn get_lang() -> String {
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget { // get system environment
let mut old_focused_element = ctx.get_widget(old_focused_element); let mut lang = env::var("LANG").unwrap_or("C".to_string());
old_focused_element.set("focused", false);
//old_focused_element.update_theme_by_state(false); // 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) }
} }
ctx.window().get_mut::<Global>("global").focused_widget = None; trace!(target: "advotracker", lang = ?lang);
ctx.widget().set("visibility", Visibility::Collapsed); lang
ctx.get_widget(to).set("visibility", Visibility::Visible);
} }
/// Get the text of a widget. // /// Navigates to the given entity.
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> { // fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
let mut widget = ctx.get_widget(entity); // if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
// let mut old_focused_element = ctx.get_widget(old_focused_element);
let entry = widget.get_mut::<String>("text"); // old_focused_element.set("focused", false);
if entry.is_empty() { // //old_focused_element.update_theme_by_state(false);
return None; // }
} // ctx.window().get_mut::<Global>("global").focused_widget = None;
// ctx.widget().set("visibility", Visibility::Collapsed);
let copy = entry.to_string(); // ctx.get_widget(to).set("visibility", Visibility::Visible);
entry.clear(); // }
Some(copy)
}
/// Save the our data structure and convert it to `ron` file format. /// Save the our data structure and convert it to `ron` file format.
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory. /// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
@@ -67,3 +73,9 @@ pub trait GlobalState {
.unwrap(); .unwrap();
} }
} }
// #[cfg(test)]
// mod tests {
// #[test]
// assert_eq!(2 + 2, 4);
// }

View File

@@ -1,5 +1,3 @@
//use chrono::{Local, DateTime, Duration};
use dotenv::dotenv;
use locales::t; use locales::t;
use orbtk::{ use orbtk::{
prelude::*, prelude::*,
@@ -15,10 +13,10 @@ use orbtk::theme::DARK_THEME_RON;
use orbtk::theme::LIGHT_THEME_RON; use orbtk::theme::LIGHT_THEME_RON;
use serde::Deserialize; use serde::Deserialize;
use std::{env, process}; use std::process;
use std::collections::HashMap; use std::collections::HashMap;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use tracing::{debug, error, info, trace}; use tracing::{error, info, trace};
use crate::{ use crate::{
callbacks::global_state::GlobalState, callbacks::global_state::GlobalState,
@@ -64,7 +62,7 @@ pub struct PolicyCheckState {
duration: Duration, duration: Duration,
label_result: Entity, label_result: Entity,
lang: String, lang: String,
last_focused: Option<Entity>, //last_focused: Option<Entity>,
button_menu: Entity, button_menu: Entity,
menu: Entity, menu: Entity,
policy_data_count: u64, policy_data_count: u64,
@@ -94,8 +92,7 @@ impl PolicyCheckState {
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"); trace!(target: "advotracker", create_hashmap = "started");
let res = t!("policy.string.label_policy_list", self.lang); let policy_list = PolicyList::new("policy list");
let policy_list = PolicyList::new(res);
trace!(target: "advotracker", policy_list = ?policy_list); trace!(target: "advotracker", policy_list = ?policy_list);
// create vector to hold imported data // create vector to hold imported data
@@ -136,28 +133,12 @@ impl PolicyCheckState {
TextBox::text_set(&mut ctx.widget(), String::from("")); TextBox::text_set(&mut ctx.widget(), String::from(""));
} }
/// Get the active language environment.
pub fn get_lang() -> String {
// get system environment
let mut lang = env::var("LANG").unwrap_or("en".to_string());
// 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) }
}
lang
}
/// Import policy numbers into hashmap /// Import policy numbers into hashmap
fn import_data(&mut self, ctx: &mut Context<'_>) fn import_data(&mut self, ctx: &mut Context<'_>)
-> Result<(), Box<dyn std::error::Error>> { -> Result<(), Box<dyn std::error::Error>> {
// WIP: for now, only import once per session // WIP: for now, only import once per session
if self.policy_data_count == 0 { if self.policy_data_count == 0 {
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true); TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
if self.policy_numbers.len() == 0 { if self.policy_numbers.len() == 0 {
// initialize popup widget // initialize popup widget
@@ -216,25 +197,21 @@ impl PolicyCheckState {
ctx: &mut Context<'_>) { ctx: &mut Context<'_>) {
trace!(target: "advotracker", parse_entry = "started"); trace!(target: "advotracker", parse_entry = "started");
//let policy_number_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number)); let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
let policy_number_length = policy_number_string.len(); let policy_number_length = policy_number_string.len();
// // WIP: redundant lang selection (already in main!) if self.policy_data_count == 0 {
// let mut lang = env::var("lang").unwrap_or("en".to_string()); // Load data into hashmap
// // testing environment: read from .env file match self.import_data(ctx) {
// dotenv().ok(); Ok(()) => {
// match envy::from_env::<Environment>() { trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
// Ok(environment) => { Stack::visibility_set(&mut ctx.child(ID_POLICY_DATA_STACK), Visibility::Visible);
// if environment.test_lang != lang { lang = environment.test_lang; } 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));
// Err(e) => { debug!(target: "advotracker", "{}", e); } },
// }
// Load data into hashmap Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
match self.import_data(ctx) { }
Ok(()) => trace!(target: "advotracker", policycheck_state = "init", import_data = "success"),
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
} }
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_number_string); trace!(target: "advotracker", state = "parsing", policy_number = ?policy_number_string);
@@ -242,15 +219,20 @@ impl PolicyCheckState {
// Parse policy code: "AS-123456789" // Parse policy code: "AS-123456789"
// DION VERS POLLFNR // DION VERS POLLFNR
// 1 AS 1515735810 // 1 AS 1515735810
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed); //Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible); //Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent")); //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), 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);
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
//Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
if policy_number_length == 10 { if policy_number_length == 10 {
// cast policy_number_sting to <u64> // cast policy_number_sting to <u64>
match policy_number_string.parse::<u64>() { match policy_number_string.parse::<u64>() {
Ok(p) => { Ok(p) => {
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from("")); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
// match hashmap's key // match hashmap's key
match self.policy_numbers.get(&p) { match self.policy_numbers.get(&p) {
@@ -258,62 +240,92 @@ impl PolicyCheckState {
// matching key, get associated value // matching key, get associated value
trace!(target: "advotracker", state = "success", trace!(target: "advotracker", state = "success",
policy_number = ?p, policy_code = ?policy_code); policy_number = ?p, policy_code = ?policy_code);
let string_result = format!("1-{:?}-{}", let string_result = format!("1-{:?}-{}",
policy_code, p); policy_code, p);
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(string_result)); TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
let res = t!("policy.validation.button_success", self.lang); Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res)); Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CHECK);
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#008000")); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#008000")); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent"));
} }
_ => { _ => {
// no matching key // no matching key
let res = t!("policy.validation.failed", self.lang); let res = t!("policy.validation.failed", self.lang);
trace!(target: "advotracker", state = ?res, policy_number = ?p); trace!(target: "advotracker", state = ?res, policy_number = ?p);
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
let res = t!("policy.validation.button_failed", self.lang); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("The given policy number is invalid"));
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res));
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible); Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR); Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000")); Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000")); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
let res = t!("policy.validation.not_found", self.lang);
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res)); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
} }
} }
}, },
Err(e) => { Err(e) => {
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e); trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible); TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR);
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000")); //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000")); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
let res = t!("policy.validation.invalid_input", self.lang); //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true); 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);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
} }
} }
} }
if policy_number_length < 10 { if policy_number_length < 10 {
let res = t!("policy.validation.to_short", self.lang); let res = t!("policy.validation.failed", self.lang);
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res)); trace!(target: "advotracker", state = ?res, reason = "number to short");
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); 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_HINT), Visibility::Visible);
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);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
} }
if policy_number_length > 10 { if policy_number_length > 10 {
let res = t!("policy.validation.to_long", self.lang); let res = t!("policy.validation.failed", self.lang);
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res)); trace!(target: "advotracker", state = ?res, reason = "number to long");
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); 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_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);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
} }
trace!(target: "advotracker", parse_entry = "finished"); trace!(target: "advotracker", parse_entry = "finished");
@@ -342,11 +354,11 @@ impl PolicyCheckState {
/// Change status of given text box to edit mode. /// Change status of given text box to edit mode.
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) { fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
if ctx.get_widget(text_box).get::<String16>("text").is_empty() { if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Collapsed); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
} else { } else {
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
} }
} }
@@ -359,13 +371,6 @@ impl PolicyCheckState {
self.menu = create_menu(current_entity, build_context); self.menu = create_menu(current_entity, build_context);
let _menu = build_context.append_child_to_overlay(self.menu) let _menu = build_context.append_child_to_overlay(self.menu)
.expect("PolicyCheckState: Can't create overlay as child of entity"); .expect("PolicyCheckState: Can't create overlay as child of entity");
let label_account = t!("policy.menu.label_account", self.lang);
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT), String::from(label_account));
let label_quit = t!("policy.menu.label_quit", self.lang);
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_QUIT), String::from(label_quit));
let label_toggle_theme = t!("policy.menu.label_toggle_theme", self.lang);
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME), String::from(label_toggle_theme));
} }
/// Set a progress popup that updates the import status in a progress bar /// Set a progress popup that updates the import status in a progress bar
@@ -377,8 +382,7 @@ impl PolicyCheckState {
let current_entity = ctx.entity; let current_entity = ctx.entity;
let build_context = &mut ctx.build_context(); let build_context = &mut ctx.build_context();
let res = t!("policy.string.progress_text", self.lang); self.progress_popup = create_popup_progress(current_entity, build_context);
self.progress_popup = create_popup_progress(current_entity, &res, build_context);
// create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER" // create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
build_context.append_child(stack, self.progress_popup); build_context.append_child(stack, self.progress_popup);
@@ -460,30 +464,15 @@ impl State for PolicyCheckState {
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT) .entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
.expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'."); .expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
// WIP: redundant lang selection (already in main!) //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
let mut lang = env::var("lang").unwrap_or("en".to_string()); //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
// testing environment: read from .env file //Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_0), Visibility::Collapsed);
dotenv().ok(); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
match envy::from_env::<Environment>() { Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
Ok(environment) => {
if environment.test_lang != lang { lang = environment.test_lang; }
},
Err(e) => { debug!(target: "advotracker", "{}", e); }
}
self.lang = lang;
// Constants // Preset localization with given environment lang
let res = t!("policy.string.header", self.lang); self.lang = PolicyCheckState::get_lang();
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HEADER), String::from(res)); ctx.set_language(&self.lang);
let res = t!("policy.string.label_policy_number", self.lang);
let string_label_policy_number = format!("{}:", res);
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_POLICY_NUMBER), String::from(string_label_policy_number));
let res = t!("policy.string.label_result", self.lang);
let string_label_result = format!("{}:", res);
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), String::from(string_label_result));
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
// // Load the saved data from a file in 'ron' format into our data structure. // // Load the saved data from a file in 'ron' format into our data structure.
// // The cargo package identifier (default: 'nwx.advotracker') is used as the // // The cargo package identifier (default: 'nwx.advotracker') is used as the
@@ -505,15 +494,15 @@ impl State for PolicyCheckState {
/// Update the widget state. /// Update the widget state.
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) { fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
// clear focus on focus moved // // clear focus on focus moved
if self.last_focused != ctx.window().get::<Global>("global").focused_widget { // if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
if let Some(last_focused) = self.last_focused { // if let Some(last_focused) = self.last_focused {
ctx.get_widget(last_focused).set("focused", false); // ctx.get_widget(last_focused).set("focused", false);
// widget is unvisible, but takes space to be considered // // widget is unvisible, but takes space to be considered
ctx.get_widget(last_focused) // ctx.get_widget(last_focused)
.set("visibility", Visibility::Collapsed); // .set("visibility", Visibility::Collapsed);
} // }
} //}
if let Some(action) = self.action { if let Some(action) = self.action {
match action { match action {
@@ -605,23 +594,10 @@ impl State for PolicyCheckState {
self.action = None; self.action = None;
} }
/// Update the view after the layout is rendered. // /// Update the view after the layout is rendered.
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) { // fn update_post_layout(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
// WIP: redundant lang selection (already in main!) // }
let mut lang = env::var("lang").unwrap_or("en".to_string());
// 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) => { debug!(target: "advotracker", "{}", e); }
}
let res = t!("policy.string.data_count", lang);
let string_data_count = format!("{}: {:?}", res, self.policy_numbers.len());
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT_BLOCK), String::from(string_data_count));
}
} }
/// Create a menu popup /// Create a menu popup
@@ -708,7 +684,7 @@ fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
} }
/// Create a progress popup with update status of an onging data import /// Create a progress popup with update status of an onging data import
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity { fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new() Popup::new()
.id(ID_POLICY_CHECK_POPUP_PROGRESS) .id(ID_POLICY_CHECK_POPUP_PROGRESS)
.target(target) .target(target)
@@ -725,14 +701,15 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
.child( .child(
Container::new() Container::new()
.style("container_progress") .style("container_progress")
.child( Stack::new() .child(
Stack::new()
.style("stack_progress") .style("stack_progress")
.child( .child(
TextBlock::new() TextBlock::new()
.id(ID_POLICY_CHECK_PROGRESS_TEXT) .id(ID_POLICY_CHECK_PROGRESS_TEXT)
//.style("textblock_progress") //.style("textblock_progress")
.font_size(12) .font_size(12)
.text(text) .text("Importing data")
.build(ctx) .build(ctx)
) )
.child( .child(
@@ -748,6 +725,7 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
//.style("textblock_progress") //.style("textblock_progress")
.h_align("end") .h_align("end")
.font_size(12) .font_size(12)
.text("Processing time")
.build(ctx) .build(ctx)
) )
.build(ctx) .build(ctx)

View File

@@ -16,11 +16,16 @@ pub static STYLE_STACK_MENU: &'static str = "stack_menu";
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state) // Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
pub static ID_POLICY_CHECK_FORM: &'static str = "policy_check_form"; pub static ID_POLICY_CHECK_FORM: &'static str = "policy_check_form";
pub static ID_POLICY_CHECK_FORM_ROW_0: &'static str = "policy_check_form_row_0";
pub static ID_POLICY_CHECK_FORM_ROW_1: &'static str = "policy_check_form_row_1";
pub static ID_POLICY_CHECK_FORM_ROW_2: &'static str = "policy_check_form_row_2";
pub static ID_POLICY_CHECK_HEADER: &'static str = "policy_check_header"; pub static ID_POLICY_CHECK_HEADER: &'static str = "policy_check_header";
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &'static str = "policy_check_items_widget"; pub static ID_POLICY_CHECK_ITEMS_WIDGET: &'static str = "policy_check_items_widget";
pub static ID_POLICY_CHECK_BUTTON_RESULT: &'static str = "policy_check_button_result"; pub static ID_POLICY_CHECK_BUTTON_RESULT: &'static str = "policy_check_button_result";
pub static ID_POLICY_CHECK_BUTTON_MENU: &'static str = "policy_check_button_menu"; pub static ID_POLICY_CHECK_BUTTON_MENU: &'static str = "policy_check_button_menu";
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &'static str = "policy_check_data_count_block"; pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &'static str = "policy_check_data_count_block";
pub static ID_POLICY_CHECK_HINT: &'static str = "policy_check_hint";
pub static ID_POLICY_CHECK_LABEL_HINT: &'static str = "policy_check_label_hint";
pub static ID_POLICY_CHECK_LABEL_MENU: &'static str = "policy_check_label_menu"; pub static ID_POLICY_CHECK_LABEL_MENU: &'static str = "policy_check_label_menu";
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &'static str = "policy_check_label_policy_number"; pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &'static str = "policy_check_label_policy_number";
pub static ID_POLICY_CHECK_LABEL_RESULT: &'static str = "policy_check_label_result"; pub static ID_POLICY_CHECK_LABEL_RESULT: &'static str = "policy_check_label_result";
@@ -39,12 +44,14 @@ pub static ID_POLICY_CHECK_RESULT: &'static str = "policy_check_result";
pub static ID_POLICY_CHECK_WIDGET: &'static str = "policy_check_widget"; pub static ID_POLICY_CHECK_WIDGET: &'static str = "policy_check_widget";
pub static ID_POLICY_DATA_ADD_BUTTON: &'static str = "policy_data_add_button"; pub static ID_POLICY_DATA_ADD_BUTTON: &'static str = "policy_data_add_button";
pub static ID_POLICY_DATA_COUNT_BLOCK: &'static str = "policy_data_count_block"; pub static ID_POLICY_DATA_COUNT: &'static str = "policy_data_count";
pub static ID_POLICY_DATA_LABEL: &'static str = "policy_data_label";
pub static ID_POLICY_DATA_ITEMS_WIDGET: &'static str = "policy_data_items_widget"; pub static ID_POLICY_DATA_ITEMS_WIDGET: &'static str = "policy_data_items_widget";
pub static ID_POLICY_DATA_DATE_INSERTED: &'static str = "policy_data_date_inserted"; pub static ID_POLICY_DATA_DATE_INSERTED: &'static str = "policy_data_date_inserted";
pub static ID_POLICY_DATA_DION: &'static str = "policy_data_dion"; pub static ID_POLICY_DATA_DION: &'static str = "policy_data_dion";
pub static ID_POLICY_DATA_POLICY_CODE: &'static str = "policy_data_policy_code"; pub static ID_POLICY_DATA_POLICY_CODE: &'static str = "policy_data_policy_code";
pub static ID_POLICY_DATA_POLICY_NUMBER: &'static str = "policy_data_policy_number"; pub static ID_POLICY_DATA_POLICY_NUMBER: &'static str = "policy_data_policy_number";
pub static ID_POLICY_DATA_STACK: &'static str = "policy_data_stack";
pub static ID_POLICY_DATA_STATUS: &'static str = "policy_data_status"; pub static ID_POLICY_DATA_STATUS: &'static str = "policy_data_status";
pub static ID_POLICY_DATA_LIST_NAME: &'static str = "policy_data_list_name"; pub static ID_POLICY_DATA_LIST_NAME: &'static str = "policy_data_list_name";

View File

@@ -1,238 +1,238 @@
{ {
"err.lang.not_found": { "err.lang.not_found": {
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen", "de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
"de": "Konnte Sprachkode nicht auslesen", "de_DE": "Konnte Sprachkode nicht auslesen",
"en": "Couldn't read LANG" "C": "Couldn't read LANG"
}, },
"err.user.not_found": { "err.user.not_found": {
"fr": "Utilisateur introuvable: $email, $id", "fr": "Utilisateur introuvable: $email, $id",
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id", "de_DE.UTF-8": "Anwender nicht gefunden: $email, $id",
"de": "Anwender nicht gefunden: $email, $id", "de_DE": "Anwender nicht gefunden: $email, $id",
"en": "User not found: $email, $id" "C": "User not found: $email, $id"
}, },
"main.started": { "main.started": {
"de_DE.UTF-8": "Programmlogik starten", "de_DE.UTF-8": "Programmlogik starten",
"de": "Programmlogik starten", "de_DE": "Programmlogik starten",
"en": "Program logic started" "C": "Program logic started"
}, },
"main.finished": { "main.finished": {
"de_DE.UTF-8": "Programmlogik beendet", "de_DE.UTF-8": "Programmlogik beendet",
"de": "Programmlogik beendet", "de_DE": "Programmlogik beendet",
"en": "Program logic finished" "C": "Program logic finished"
}, },
"parse.arguments": { "parse.arguments": {
"de_DE.UTF-8": "Programmargumente prüfen", "de_DE.UTF-8": "Programmargumente prüfen",
"de": "Programmargumente prüfen", "de_DE": "Programmargumente prüfen",
"en": "Parsing arguments" "C": "Parsing arguments"
}, },
"parse.environment": { "parse.environment": {
"de_DE.UTF-8": "Umgebungsvariablen prüfen", "de_DE.UTF-8": "Umgebungsvariablen prüfen",
"de": "Umgebungsvariablen prüfen", "de_DE": "Umgebungsvariablen prüfen",
"en": "Parsing environment" "C": "Parsing environment"
}, },
"parse.results": { "parse.results": {
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung", "de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
"de": "Ergebnisse der Konfigurationsparameterprüfung", "de_DE": "Ergebnisse der Konfigurationsparameterprüfung",
"en": "Config parsing results" "C": "Config parsing results"
}, },
"config.name": { "config.name": {
"de_DE.UTF-8": "Konfigurationswert für", "de_DE.UTF-8": "Konfigurationswert für",
"de": "Konfigurationswert für", "de_DE": "Konfigurationswert für",
"en": "Config Value for" "C": "Config Value for"
}, },
"config.name.lang": { "config.name.lang": {
"de_DE.UTF-8": "Sprach-Code", "de_DE.UTF-8": "Sprach-Code_DE",
"de": "Sprach-Code", "de_DE": "Sprach-Code_DE",
"en": "Language code" "C": "Language code_DE"
}, },
"config.name.verbositylevel": { "config.name.verbositylevel": {
"de_DE.UTF-8": "Ausgabe-Ebene", "de_DE.UTF-8": "Ausgabe-Ebene",
"de": "Ausgabe-Ebene", "de_DE": "Ausgabe-Ebene",
"en": "verbosity level" "C": "verbosity level"
}, },
"config.name.environment": { "config.name.environment": {
"de_DE.UTF-8": "Umgebungsvariablen", "de_DE.UTF-8": "Umgebungsvariablen",
"de": "Umgebungsvariablen", "de_DE": "Umgebungsvariablen",
"en": "environment" "C": "environment"
}, },
"config.name.configfile": { "config.name.configfile": {
"de_DE.UTF-8": "Konfigurations-Datei", "de_DE.UTF-8": "Konfigurations-Datei",
"de": "Konfigurations-Datei", "de_DE": "Konfigurations-Datei",
"en": "config file" "C": "config file"
}, },
"config.name.dbdriver": { "config.name.dbdriver": {
"de_DE.UTF-8": "Datenbank-Treiber", "de_DE.UTF-8": "Datenbank-Treiber",
"de": "Datenbank-Treiber", "de_DE": "Datenbank-Treiber",
"en": "database driver" "C": "database driver"
}, },
"config.name.redis": { "config.name.redis": {
"de_DE.UTF-8": "Redis Datenbank", "de_DE.UTF-8": "Redis Datenbank",
"de": "Redis Datenbank", "de_DE": "Redis Datenbank",
"en": "Redis database" "C": "Redis database"
}, },
"csv.export.started": { "csv.export.started": {
"de_DE.UTF-8": "Export in eine CSV Datei starten", "de_DE.UTF-8": "Export in eine CSV Datei starten",
"de": "Export in eine CSV Datei starten", "de_DE": "Export in eine CSV Datei starten",
"en": "Export to csv file started" "C": "Export to csv file started"
}, },
"csv.export.finished": { "csv.export.finished": {
"de_DE.UTF-8": "Export in eine CSV Datei beendet", "de_DE.UTF-8": "Export in eine CSV Datei beendet",
"de": "Export in eine CSV Datei beendet", "de_DE": "Export in eine CSV Datei beendet",
"en": "Export to csv file finished" "C": "Export to csv file finished"
}, },
"csv.import.started": { "csv.import.started": {
"de_DE.UTF-8": "Import aus einer CSV Datei", "de_DE.UTF-8": "Import aus einer CSV Datei",
"de": "Import aus einer CSV Datei", "de_DE": "Import aus einer CSV Datei",
"en": "Import from a csv file" "C": "Import from a csv file"
}, },
"csv.import.finished": { "csv.import.finished": {
"de_DE.UTF-8": "Import aus einer CSV Datei beendet", "de_DE.UTF-8": "Import aus einer CSV Datei beendet",
"de": "Import aus einer CSV Datei beendet", "de_DE": "Import aus einer CSV Datei beendet",
"en": "Import from a csv file finished" "C": "Import from a csv file finished"
}, },
"redis.connection.error": { "redis.connection.error": {
"de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden", "de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden",
"de": "Es konnte keine Redis Verbindung aufgebaut werden", "de_DE": "Es konnte keine Redis Verbindung aufgebaut werden",
"en": "Could not establish a redis connection" "C": "Could not establish a redis connection"
}, },
"policy.hashmap.success": { "policy.hashmap.success": {
"de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt", "de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt",
"de": "Hashmap wurde erfolgreich erstellt", "de_DE": "Hashmap wurde erfolgreich erstellt",
"en": "Hashmap creation was successfull" "C": "Hashmap creation was successfull"
}, },
"policy.hashmap.failed": { "policy.hashmap.failed": {
"de_DE.UTF-8": "Hashmap konnte nicht erstellt werden", "de_DE.UTF-8": "Hashmap konnte nicht erstellt werden",
"de": "Hashmap konnte nicht erstellt werden", "de_DE": "Hashmap konnte nicht erstellt werden",
"en": "Hashmap creation failed" "C": "Hashmap creation failed"
}, },
"policy.menu.label": { "policy.menu.label": {
"de_DE.UTF-8": "Menü", "de_DE.UTF-8": "Menü",
"de": "Menü", "de_DE": "Menü",
"en": "Menu" "C": "Menu"
}, },
"policy.menu.label_account": { "policy.menu.label_account": {
"de_DE.UTF-8": "Aktueller Benutzer", "de_DE.UTF-8": "Aktueller Benutzer",
"de": "Aktueller Benutzer", "de_DE": "Aktueller Benutzer",
"en": "Active user" "C": "Active user"
}, },
"policy.menu.label_quit": { "policy.menu.label_quit": {
"de_DE.UTF-8": "Beenden", "de_DE.UTF-8": "Beenden",
"de": "Beenden", "de_DE": "Beenden",
"en": "Quit" "C": "Quit"
}, },
"policy.menu.label_toggle_theme": { "policy.menu.label_toggle_theme": {
"de_DE.UTF-8": "Thema wechseln", "de_DE.UTF-8": "Thema wechseln",
"de": "Thema wechseln", "de_DE": "Thema wechseln",
"en": "Toggle theme" "C": "Toggle theme"
}, },
"policy.string.header": { "policy.string.header": {
"de_DE.UTF-8": "Validierung Versicherungsnummer", "de_DE.UTF-8": "Validierung Versicherungsnummer",
"de": "Validierung Versicherungsnummer", "de_DE": "Validierung Versicherungsnummer",
"en": "Policy number validation" "C": "Policy number validation"
}, },
"policy.string.label_policy_data": { "policy.string.label_policy_data": {
"de_DE.UTF-8": "Importierte Daten", "de_DE.UTF-8": "Importierte Daten",
"de": "Importierte Daten", "de_DE": "Importierte Daten",
"en": "imported data" "C": "imported data"
}, },
"policy.string.label_policy_list": { "policy.string.label_policy_list": {
"de_DE.UTF-8": "Versicherungsnummern-Liste", "de_DE.UTF-8": "Versicherungsnummern-Liste",
"de": "Versicherungsnummern-Liste", "de_DE": "Versicherungsnummern-Liste",
"en": "policy list" "C": "policy list"
}, },
"policy.string.label_policy_number": { "policy.string.label_policy_number": {
"de_DE.UTF-8": "Versicherungsnummer", "de_DE.UTF-8": "Versicherungsnummer",
"de": "Versicherungsnummer", "de_DE": "Versicherungsnummer",
"en": "policy number" "C": "policy number"
}, },
"policy.string.label_result": { "policy.string.label_result": {
"de_DE.UTF-8": "Prüfungsergebnis", "de_DE.UTF-8": "Prüfungsergebnis",
"de": "Prüfungsergebnis", "de_DE": "Prüfungsergebnis",
"en": "check result" "C": "check result"
}, },
"policy.string.data_count": { "policy.string.data_count": {
"de_DE.UTF-8": "Anzahl Prüflistenelemente", "de_DE.UTF-8": "Anzahl Prüflistenelemente",
"de": "Anzahl Prüflistenelemente", "de_DE": "Anzahl Prüflistenelemente",
"en": "Number of checklist elements" "C": "Number of checklist elements"
}, },
"policy.string.import_data": { "policy.string.import_data": {
"de_DE.UTF-8": "Importieren der Prüflisten-Elemente", "de_DE.UTF-8": "Importieren der Prüflisten-Elemente",
"de": "Importieren der Prüflisten-Elemente", "de_DE": "Importieren der Prüflisten-Elemente",
"en": "Import checklist elements" "C": "Import checklist elements"
}, },
"policy.string.progress_time": { "policy.string.progress_time": {
"de_DE.UTF-8": "Bearbeitungszeit", "de_DE.UTF-8": "Bearbeitungszeit",
"de": "Bearbeitungszeit", "de_DE": "Bearbeitungszeit",
"en": "processing time" "C": "processing time"
}, },
"policy.string.progress_text": { "policy.string.progress_text": {
"de_DE.UTF-8": "Importiere Daten", "de_DE.UTF-8": "Importiere Daten",
"de": "Importiere Daten", "de_DE": "Importiere Daten",
"en": "Importing data" "C": "Importing data"
}, },
"policy.validation.button_failed": { "policy.validation.button_failed": {
"de_DE.UTF-8": "ungültig", "de_DE.UTF-8": "ungültig",
"de": "ungültig", "de_DE": "ungültig",
"en": "invalid" "C": "invalid"
}, },
"policy.validation.button_success": { "policy.validation.button_success": {
"de_DE.UTF-8": "gültig", "de_DE.UTF-8": "gültig",
"de": "gültig", "de_DE": "gültig",
"en": "valid" "C": "valid"
}, },
"policy.validation.failed": { "policy.validation.failed": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig", "de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig",
"de": "Die Versicherungsscheinnummber ist ungültig", "de_DE": "Die Versicherungsscheinnummber ist ungültig",
"en": "The given policy number is invalid" "C": "The given policy number is invalid"
}, },
"policy.validation.new": { "policy.validation.new": {
"de_DE.UTF-8": "Neue Prüfung", "de_DE.UTF-8": "Neue Prüfung",
"de": "Neue Prüfung", "de_DE": "Neue Prüfung",
"en": "New validation" "C": "New validation"
}, },
"policy.validation.success": { "policy.validation.success": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig", "de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig",
"de": "Die Versicherungsscheinnummber ist gültig", "de_DE": "Die Versicherungsscheinnummber ist gültig",
"en": "The given policy number is valid" "C": "The given policy number is valid"
}, },
"policy.validation.started": { "policy.validation.started": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet", "de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde gestartet", "de_DE": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"en": "Validation of the policy number started" "C": "Validation of the policy number started"
}, },
"policy.validation.finished": { "policy.validation.finished": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet", "de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde beendet", "de_DE": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"en": "Validation of the policy number finished" "C": "Validation of the policy number finished"
}, },
"policy.validation.invalid_input": { "policy.validation.invalid_input": {
"de_DE.UTF-8": "Nur Nummer sind zulässig", "de_DE.UTF-8": "Nur Nummer sind zulässig",
"de": "Nur Nummer sind zulässig", "de_DE": "Nur Nummer sind zulässig",
"en": "only numbers are valid" "C": "Only numbers are valid"
}, },
"policy.validation.not_found": { "policy.validation.not_found": {
"de_DE.UTF-8": "Nummer ist nicht aktiviert", "de_DE.UTF-8": "Nummer ist nicht aktiviert",
"de": "Nummer ist nicht aktiviert", "de_DE": "Nummer ist nicht aktiviert",
"en": "number isn't marked active" "C": "number isn't marked active"
}, },
"policy.validation.to_long": { "policy.validation.to_long": {
"de_DE.UTF-8": "Die Nummer ist zu lang", "de_DE.UTF-8": "Die Nummer ist zu lang",
"de": "Die Nummer ist zu lang", "de_DE": "Die Nummer ist zu lang",
"en": "Policy number is to long" "C": "Policy number is to long"
}, },
"policy.validation.to_short": { "policy.validation.to_short": {
"de_DE.UTF-8": "Die Nummer ist zu kurz", "de_DE.UTF-8": "Die Nummer ist zu kurz",
"de": "Die Nummer ist zu kurz", "de_DE": "Die Nummer ist zu kurz",
"en": "Policy number is to short" "C": "Policy number is to short"
}, },
"state.started": { "state.started": {
"de_DE.UTF-8": "gestartet", "de_DE.UTF-8": "gestartet",
"de": "gestartet", "de_DE": "gestartet",
"en": "started" "C": "started"
}, },
"state.finished": { "state.finished": {
"de_DE.UTF-8": "beendet", "de_DE.UTF-8": "beendet",
"de": "beended", "de_DE": "beended",
"en": "finished" "C": "finished"
} }
} }

View File

@@ -1,208 +0,0 @@
{
"err.lang.not_found": {
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
"de": "Konnte Sprachkode nicht auslesen",
"en": "Couldn't read LANG"
},
"err.user.not_found": {
"fr": "Utilisateur introuvable: $email, $id",
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
"de": "Anwender nicht gefunden: $email, $id",
"en": "User not found: $email, $id"
},
"main.started": {
"de_DE.UTF-8": "Programmlogik starten",
"de": "Programmlogik starten",
"en": "Program logic started"
},
"main.finished": {
"de_DE.UTF-8": "Programmlogik beendet",
"de": "Programmlogik beendet",
"en": "Program logic finished"
},
"parse.arguments": {
"de_DE.UTF-8": "Programmargumente prüfen",
"de": "Programmargumente prüfen",
"en": "Parsing arguments"
},
"parse.environment": {
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
"de": "Umgebungsvariablen prüfen",
"en": "Parsing environment"
},
"parse.results": {
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
"de": "Ergebnisse der Konfigurationsparameterprüfung",
"en": "Config parsing results"
},
"config.name": {
"de_DE.UTF-8": "Konfigurationswert für",
"de": "Konfigurationswert für",
"en": "Config Value for"
},
"config.name.lang": {
"de_DE.UTF-8": "Sprach-Code",
"de": "Sprach-Code",
"en": "Language code"
},
"config.name.verbositylevel": {
"de_DE.UTF-8": "Ausgabe-Ebene",
"de": "Ausgabe-Ebene",
"en": "verbosity level"
},
"config.name.environment": {
"de_DE.UTF-8": "Umgebungsvariablen",
"de": "Umgebungsvariablen",
"en": "environment"
},
"config.name.configfile": {
"de_DE.UTF-8": "Konfigurations-Datei",
"de": "Konfigurations-Datei",
"en": "config file"
},
"config.name.dbdriver": {
"de_DE.UTF-8": "Datenbank-Treiber",
"de": "Datenbank-Treiber",
"en": "database driver"
},
"config.name.redis": {
"de_DE.UTF-8": "Redis Datenbank",
"de": "Redis Datenbank",
"en": "Redis database"
},
"csv.export.started": {
"de_DE.UTF-8": "Export in eine CSV Datei starten",
"de": "Export in eine CSV Datei starten",
"en": "Export to csv file started"
},
"csv.export.finished": {
"de_DE.UTF-8": "Export in eine CSV Datei beendet",
"de": "Export in eine CSV Datei beendet",
"en": "Export to csv file finished"
},
"csv.import.started": {
"de_DE.UTF-8": "Import aus einer CSV Datei",
"de": "Import aus einer CSV Datei",
"en": "Import from a csv file"
},
"csv.import.finished": {
"de_DE.UTF-8": "Import aus einer CSV Datei beendet",
"de": "Import aus einer CSV Datei beendet",
"en": "Import from a csv file finished"
},
"redis.connection.error": {
"de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden",
"de": "Es konnte keine Redis Verbindung aufgebaut werden",
"en": "Could not establish a redis connection"
},
"policy.hashmap.success": {
"de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt",
"de": "Hashmap wurde erfolgreich erstellt",
"en": "Hashmap creation was successfull"
},
"policy.hashmap.failed": {
"de_DE.UTF-8": "Hashmap konnte nicht erstellt werden",
"de": "Hashmap konnte nicht erstellt werden",
"en": "Hashmap creation failed"
},
"policy.string.header": {
"de_DE.UTF-8": "Validierung Versicherungsnummer",
"de": "Validierung Versicherungsnummer",
"en": "Policy number validation"
},
"policy.string.label_policy_number": {
"de_DE.UTF-8": "Versicherungsnummer",
"de": "Versicherungsnummer",
"en": "policy number"
},
"policy.string.label_result": {
"de_DE.UTF-8": "Prüfungsergebnis",
"de": "Prüfungsergebnis",
"en": "check result"
},
"policy.string.data_count": {
"de_DE.UTF-8": "Anzahl Prüflistenelemente",
"de": "Anzahl Prüflistenelemente",
"en": "Number of checklist elements"
},
"policy.string.import_data": {
"de_DE.UTF-8": "Importieren der Prüflisten-Elemente",
"de": "Importieren der Prüflisten-Elemente",
"en": "Import checklist elements"
},
"policy.string.progress_time": {
"de_DE.UTF-8": "Bearbeitungszeit",
"de": "Bearbeitungszeit",
"en": "processing time"
},
"policy.string.progress_text": {
"de_DE.UTF-8": "Importiere Daten",
"de": "Importiere Daten",
"en": "Importing data"
},
"policy.validation.button_failed": {
"de_DE.UTF-8": "ungültig",
"de": "ungültig",
"en": "invalid"
},
"policy.validation.button_success": {
"de_DE.UTF-8": "gültig",
"de": "gültig",
"en": "valid"
},
"policy.validation.failed": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig",
"de": "Die Versicherungsscheinnummber ist ungültig",
"en": "The given policy number is invalid"
},
"policy.validation.new": {
"de_DE.UTF-8": "Neue Prüfung",
"de": "Neue Prüfung",
"en": "New validation"
},
"policy.validation.success": {
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig",
"de": "Die Versicherungsscheinnummber ist gültig",
"en": "The given policy number is valid"
},
"policy.validation.started": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
"en": "Validation of the policy number started"
},
"policy.validation.finished": {
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"de": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
"en": "Validation of the policy number finished"
},
"policy.validation.invalid_input": {
"de_DE.UTF-8": "Nur Nummer sind zulässig",
"de": "Nur Nummer sind zulässig",
"en": "only numbers are valid"
},
"policy.validation.not_found": {
"de_DE.UTF-8": "Nummer ist nicht aktiviert",
"de": "Nummer ist nicht aktiviert",
"en": "number isn't marked active"
},
"policy.validation.to_long": {
"de_DE.UTF-8": "Die Nummer ist zu lang",
"de": "Die Nummer ist zu lang",
"en": "Policy number is to long"
},
"policy.validation.to_short": {
"de_DE.UTF-8": "Die Nummer ist zu kurz",
"de": "Die Nummer ist zu kurz",
"en": "Policy number is to short"
},
"state.started": {
"de_DE.UTF-8": "gestartet",
"de": "gestartet",
"en": "started"
},
"state.finished": {
"de_DE.UTF-8": "beendet",
"de": "beended",
"en": "finished"
}
}

View File

@@ -12,18 +12,19 @@
//extern crate lazy_static; //extern crate lazy_static;
//use chrono::{Local, DateTime}; //use chrono::{Local, DateTime};
use dotenv::dotenv;
use locales::t; use locales::t;
use serde::Deserialize; use serde::Deserialize;
//use std::env; use std::env;
//use std::process; //use std::process;
use tracing::{trace, Level}; use tracing::{info, trace, Level};
use orbtk::prelude::*; use orbtk::prelude::*;
// The Main view // The Main view
use advotracker::{ use advotracker::{
widgets::main_view,
callbacks::policycheck_state::PolicyCheckState, callbacks::policycheck_state::PolicyCheckState,
widgets::main_view,
}; };
mod parse_args; mod parse_args;
@@ -33,10 +34,31 @@ mod parse_args;
/// this is primarily used in testing scenarios (eg. debugging) /// this is primarily used in testing scenarios (eg. debugging)
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct Environment { struct Environment {
lang: String,
test_lang: String, test_lang: String,
rust_log: String, rust_log: String,
} }
// German localization file.
static ADVOTRACKER_DE_DE: &str = include_str!("../resources/advotracker/advotracker_de_DE.ron");
/// Get the active language environment.
fn get_lang() -> String {
// get system environment
let mut lang = env::var("LANG").unwrap_or("C".to_string());
// 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) }
}
trace!(target: "advotracker", lang = ?lang);
lang
}
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
use parse_args::parse_args; use parse_args::parse_args;
use tracing_subscriber::fmt; use tracing_subscriber::fmt;
@@ -66,7 +88,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing::subscriber::with_default(subscriber, || { tracing::subscriber::with_default(subscriber, || {
// get system environment // get system environment
let lang = PolicyCheckState::get_lang(); let lang = get_lang();
let mut state = t!("state.started", lang); let mut state = t!("state.started", lang);
let mut res = t!("parse.environment", lang); let mut res = t!("parse.environment", lang);
@@ -74,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
trace!(target: "advotracker", environment = "system", lang = ?lang); trace!(target: "advotracker", environment = "system", lang = ?lang);
trace!(target: "advotracker", machine = ?&machine_kind); trace!(target: "advotracker", machine = ?&machine_kind);
// how to handle unumplemented lang resources?? // how to handle unimplemented lang resources??
res = t!("parse.environment", lang); res = t!("parse.environment", lang);
trace!(target: "advotracker", environment = "envy", lang = ?lang); trace!(target: "advotracker", environment = "envy", lang = ?lang);
state = t!("state.finished", lang); state = t!("state.finished", lang);
@@ -100,8 +122,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// use this only if you want to run it as web application. // use this only if you want to run it as web application.
orbtk::initialize(); orbtk::initialize();
// if no dictionary is set for the default language e.g. english the content of the text property will drawn.
let localization = RonLocalization::create()
.language("en_US")
.dictionary("de_DE", ADVOTRACKER_DE_DE)
.build();
Application::from_name("nwx.advotracker") Application::from_name("nwx.advotracker")
.theme(PolicyCheckState::theme()) .theme(PolicyCheckState::theme())
.localization(localization)
.window(|ctx| { .window(|ctx| {
Window::new() Window::new()
.title("AdvoTracker - DirectCall") .title("AdvoTracker - DirectCall")

View File

@@ -24,7 +24,7 @@ pub fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
let mut res = t!("csv.export.started", lang); let mut res = t!("csv.export.started", lang);
let mut state = t!("state.started", lang); let mut state = t!("state.started", lang);
trace!(target: "advotrackerd", process = ?res, state = ?state); trace!(target: "csv-export", process = ?res, state = ?state);
// Note: slash syntax also works on Windows! // Note: slash syntax also works on Windows!
let path = Path::new(p); let path = Path::new(p);

View File

@@ -34,13 +34,13 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
let time_start = SystemTime::now(); let time_start = SystemTime::now();
let datetime: DateTime<Local> = time_start.into(); let datetime: DateTime<Local> = time_start.into();
trace!(target: "advotrackerd", process = ?res, state = ?state, date_start = ?datetime.to_string()); trace!(target: "csv-import", process = ?res, state = ?state, date_start = ?datetime.to_string());
// Note: slash syntax also works on Windows! // Note: slash syntax also works on Windows!
let path = Path::new(p); let path = Path::new(p);
// must be a readable file // must be a readable file
trace!(target: "advotrackerd", path = ?path); trace!(target: "csv-import", path = ?path);
assert_eq!(path.is_file(), true); assert_eq!(path.is_file(), true);
// only accept files with '.txt' extensions // only accept files with '.txt' extensions
@@ -49,7 +49,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
// open the file // open the file
let file = File::open(path)?; let file = File::open(path)?;
trace!(target: "advotrackerd", extension = ?extension, file = ?file); trace!(target: "csv-import", extension = ?extension, file = ?file);
// Build the CSV reader // Build the CSV reader
let mut csv_reader = csv::ReaderBuilder::new() let mut csv_reader = csv::ReaderBuilder::new()
@@ -61,7 +61,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
{ {
// We nest this call in its own scope because of lifetimes. // We nest this call in its own scope because of lifetimes.
let headers = csv_reader.headers()?; let headers = csv_reader.headers()?;
trace!(target: "advotrackerd", header = ?headers); trace!(target: "csv-import", header = ?headers);
} }
// Iterate over each record, deserialize und write to our structures // Iterate over each record, deserialize und write to our structures
@@ -88,12 +88,12 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
let time_end = SystemTime::now(); 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"); .expect("Clock may have gone backwards");
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration); trace!(target: "csv-import", record_count = ?count, duration = ?duration);
state = t!("state.finished", lang); state = t!("state.finished", lang);
res = t!("csv.import.finished", lang); res = t!("csv.import.finished", lang);
let datetime: DateTime<Local> = time_end.into(); let datetime: DateTime<Local> = time_end.into();
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?datetime.to_string()); trace!(target: "csv-import", process = ?res, state = ?state, date_stop = ?datetime.to_string());
Ok((count, duration)) Ok((count, duration))
} }

View File

@@ -8,5 +8,5 @@
/// advotracker import modules /// advotracker import modules
pub mod imports; pub mod imports;
/// advotracker import modules /// advotracker export modules
pub mod exports; pub mod exports;

View File

@@ -12,20 +12,23 @@ use crate::{
widgets::policycheck_view::PolicyCheckView, widgets::policycheck_view::PolicyCheckView,
}; };
type List = Vec<String>;
// [START] views
widget!(MainView { widget!(MainView {
// policy_list: PolicyList, // policy_list: PolicyList,
// policy_data_list: PolicyDataList, // policy_data_list: PolicyDataList,
// policylist_view: u32, // policylist_view: u32,
// policydata_view: u32, // policydata_view: u32,
//policycheck_view: u32
policycheck_view: PolicyCheck policycheck_view: PolicyCheck
}); });
impl Template for MainView { impl Template for MainView {
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self { fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let policycheck_view = PolicyCheckView::new() let policycheck_view = PolicyCheckView::new()
//.policy_number_count(0) //.policy_number_count(0)
//.policylist_view(id) //.policylist_view(id)
.build(ctx); .build(ctx);
// let policylist_view = PolicyListView::new() // let policylist_view = PolicyListView::new()
@@ -49,6 +52,83 @@ impl Template for MainView {
// .policylist_view(policylist_view.0) // .policylist_view(policylist_view.0)
// .child(policydata_view) // .child(policydata_view)
// .child(policylist_view) // .child(policylist_view)
.child(policycheck_view) .child(
TabWidget::new()
.tab("Policynumber check", policycheck_view)
.tab("Localization", LocalizationView::new().build(ctx))
.build(ctx),
)
//.child(policycheck_view)
} }
} }
widget!(LocalizationView<LocalizationState> { languages: List, selected_index: i32 });
impl Template for LocalizationView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let languages = vec!["English".to_string(), "German".to_string()];
let count = languages.len();
self.languages(languages).selected_index(1).child(
Stack::new()
.width(120)
.margin(16)
.spacing(8)
.child(TextBlock::new().text("Hello").build(ctx))
.child(TextBlock::new().text("User").build(ctx))
.child(TextBlock::new().text("Localization dialog").build(ctx))
.child(
ComboBox::new()
.count(count)
.items_builder(move |bc, index| {
let text = bc.get_widget(id)
.get::<Vec<String>>("languages")[index]
.clone();
TextBlock::new().v_align("center").text(text).build(bc)
})
.on_changed("selected_index", move |states, _| {
states.get_mut::<LocalizationState>(id).change_language();
})
.selected_index(id)
.build(ctx),
)
.build(ctx),
)
}
}
// [END] views
// [START] states
#[derive(AsAny, Debug, Default)]
struct LocalizationState {
change_language: bool,
}
impl LocalizationState {
fn change_language(&mut self) {
self.change_language = true;
}
}
impl State for LocalizationState {
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
if !self.change_language {
return;
}
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
match selected_language.as_str() {
"English" => ctx.set_language("en_US"),
"German" => ctx.set_language("de_DE"),
_ => {}
}
self.change_language = false;
}
}
// [END] states

View File

@@ -43,7 +43,7 @@ impl Template for PolicyCheckView {
.v_align("center") .v_align("center")
.child( .child(
ImageWidget::new() ImageWidget::new()
.image("resources/images/hiedemann_logo.png") .image("resources/advotracker/hiedemann_logo.png")
.v_align("center") .v_align("center")
.build(ctx), .build(ctx),
) )
@@ -58,7 +58,7 @@ impl Template for PolicyCheckView {
.v_align("end") .v_align("end")
.child( .child(
TextBlock::new() TextBlock::new()
.margin((0, 9, 16, 0)) .margin((0, 9, 48, 0))
.text("©Networkx GmbH") .text("©Networkx GmbH")
.build(ctx) .build(ctx)
) )
@@ -111,7 +111,7 @@ impl Template for PolicyCheckView {
.id(ID_POLICY_CHECK_HEADER) .id(ID_POLICY_CHECK_HEADER)
.v_align("center") .v_align("center")
.h_align("left") .h_align("left")
.text("Validierung Versicherungsnummer") .text("Validation policy number")
.build(ctx), .build(ctx),
) )
.build(ctx), .build(ctx),
@@ -120,11 +120,14 @@ impl Template for PolicyCheckView {
.build(ctx); .build(ctx);
let policy_check_form_row_0 = Stack::new() let policy_check_form_row_0 = Stack::new()
// 1st row
.id(ID_POLICY_CHECK_FORM_ROW_0)
.attach(Grid::row(0)) .attach(Grid::row(0))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::column_span(5)) .attach(Grid::column_span(5))
.orientation("horizontal") .orientation("horizontal")
.v_align("center") .v_align("center")
//.h_align("center")
.child( .child(
TextBlock::new() TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER) .id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
@@ -134,7 +137,9 @@ impl Template for PolicyCheckView {
.margin((0, 0, 16, 0)) .margin((0, 0, 16, 0))
.h_align("end") .h_align("end")
.v_align("center") .v_align("center")
.text("Versicherungsnummer:") .width(300)
.min_width(300)
.text("Policy number")
.build(ctx), .build(ctx),
) )
.child( .child(
@@ -144,6 +149,7 @@ impl Template for PolicyCheckView {
.id(ID_POLICY_CHECK_POLICY_NUMBER) .id(ID_POLICY_CHECK_POLICY_NUMBER)
.h_align("start") .h_align("start")
.lost_focus_on_activation(false) .lost_focus_on_activation(false)
//WIP: localization for water_mark
.water_mark("10-stellig") .water_mark("10-stellig")
.on_activate(move |ctx, entity| { .on_activate(move |ctx, entity| {
// Entity is entered/activated via Mouse/Keyboard // Entity is entered/activated via Mouse/Keyboard
@@ -181,11 +187,13 @@ impl Template for PolicyCheckView {
let policy_check_form_row_1 = Stack::new() let policy_check_form_row_1 = Stack::new()
// 2nd row // 2nd row
.id(ID_POLICY_CHECK_FORM_ROW_1)
.attach(Grid::row(1)) .attach(Grid::row(1))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::column_span(5)) .attach(Grid::column_span(5))
.orientation("horizontal") .orientation("horizontal")
.v_align("center") .v_align("center")
//.h_align("center")
.child( .child(
TextBlock::new() TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_RESULT) .id(ID_POLICY_CHECK_LABEL_RESULT)
@@ -195,9 +203,9 @@ impl Template for PolicyCheckView {
.margin((0, 0, 16, 0)) .margin((0, 0, 16, 0))
.h_align("end") .h_align("end")
.v_align("center") .v_align("center")
.width(250) .width(300)
.min_width(250) .min_width(300)
.visibility(Visibility::Visible) .text("Policy code")
.build(ctx), .build(ctx),
) )
.child( .child(
@@ -212,35 +220,78 @@ impl Template for PolicyCheckView {
) )
.build(ctx); .build(ctx);
let policy_check_form_row_2 = Stack::new()
// 3nd row
.id(ID_POLICY_CHECK_FORM_ROW_2)
.attach(Grid::row(2))
.attach(Grid::column(0))
.attach(Grid::column_span(5))
.orientation("horizontal")
.v_align("center")
.h_align("center")
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_HINT)
//.style("hint")
.attach(Grid::row(2))
.attach(Grid::column(0))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.width(300)
.min_width(300)
.font_size(11.)
.text("Error:")
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_HINT)
//.style("hint")
.attach(Grid::row(2))
.attach(Grid::column(2))
.h_align("start")
.v_align("center")
.font_size(11)
.build(ctx)
)
.build(ctx);
let policy_check_form = Container::new() let policy_check_form = Container::new()
.id(ID_POLICY_CHECK_FORM)
.min_width(420)
.attach(Grid::row(2)) .attach(Grid::row(2))
.attach(Grid::column(1)) .attach(Grid::column(1))
.style("container_form") .style("container_form")
.child( .child(
Grid::new() Grid::new()
.id(ID_POLICY_CHECK_FORM) .id(ID_POLICY_CHECK_FORM)
.width(450)
.min_width(400)
.columns( .columns(
Columns::create() Columns::create()
// Labels // Label
.push("250") .push("300")
// Seperator // Seperator
.push("16") .push("16")
// Values // Values
.push("100") .push("auto")
// Seperator // Seperator
.push("16") .push("16")
// Result-Button // Result-Button
.push("32") .push("32")
.build(), //.build(),
) )
.rows( .rows(
Rows::create() Rows::create()
.push("auto") .push("auto")
.push("auto") .push("auto")
.build(), .push("*")
//.build(),
) )
.child(policy_check_form_row_0) .child(policy_check_form_row_0)
.child(policy_check_form_row_1) .child(policy_check_form_row_1)
.child(policy_check_form_row_2)
.build(ctx), .build(ctx),
) )
.build(ctx); .build(ctx);
@@ -267,14 +318,31 @@ impl Template for PolicyCheckView {
//}) //})
.build(ctx); .build(ctx);
let policy_data_count_block = TextBlock::new() let policy_data_stack = Stack::new()
.id(ID_POLICY_DATA_COUNT_BLOCK) .id(ID_POLICY_DATA_STACK)
.attach(Grid::row(3)) .attach(Grid::row(3))
.attach(Grid::column(1)) .attach(Grid::column(1))
.margin((0, 4, 0, 0))
.h_align("end") .h_align("end")
.v_align("top") .v_align("top")
.enabled(true) .orientation("horizontal")
.visibility(Visibility::Collapsed)
//.spacing("4")
.child(
TextBlock::new()
.id(ID_POLICY_DATA_LABEL)
.margin((0, 4, 0, 0))
.enabled(true)
.text("Checklist elements: ")
.build(ctx)
)
.child(
TextBlock::new()
.id(ID_POLICY_DATA_COUNT)
.margin((0, 4, 0, 0))
.enabled(true)
.text("0")
.build(ctx)
)
.build(ctx); .build(ctx);
// Starter page: check policy numbers // Starter page: check policy numbers
@@ -289,7 +357,7 @@ impl Template for PolicyCheckView {
.push(50) .push(50)
.push("*") .push("*")
.push(50) .push(50)
.build(), //.build(),
) )
.rows( .rows(
Rows::create() Rows::create()
@@ -298,7 +366,7 @@ impl Template for PolicyCheckView {
.push("*") .push("*")
.push("auto") .push("auto")
.push("auto") .push("auto")
.build(), //.build(),
) )
// row 0: Policy Check Header // row 0: Policy Check Header
@@ -310,7 +378,7 @@ impl Template for PolicyCheckView {
.child(policy_check_form) .child(policy_check_form)
// row 3: Sum HashMap elements // row 3: Sum HashMap elements
.child(policy_data_count_block) .child(policy_data_stack)
// row 4: Policy Check Bottom // row 4: Policy Check Bottom
.child(policy_check_bottom_bar) .child(policy_check_bottom_bar)