advotracker: restructure project using crate tree
* advotracker: the framework crate * crate/advotrackerdb: crate implementing the database backend * crate/advotrackerd: the backend daemon * crate/adovtracker: the application (CLI and GUI) Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
6
crates/.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "advotrackerdb"]
|
||||
path = advotrackerdb
|
||||
url = https://gitea.networkx.de:50443/rzerres/advotrackerdb
|
||||
[submodule "advotrackerd"]
|
||||
path = advotrackerd
|
||||
url = https://gitea.networkx.de:50443/rzerres/advotrackerd
|
||||
17
crates/advotracker/.env
Normal file
@@ -0,0 +1,17 @@
|
||||
###
|
||||
# .env
|
||||
# will overwrite standard environment viariables
|
||||
###
|
||||
# set the language variable used in test-runs
|
||||
#test LANG=de-DE
|
||||
#test LANG=es-ES
|
||||
#test LANG=C
|
||||
# set the language variable (overwriting standard Enviroment)
|
||||
#TEST_LANG=de_DE
|
||||
#TEST_LANG=C
|
||||
#RUST_LOG=advotracker=trace
|
||||
#LANG=de_DE
|
||||
RUST_LOG=trace
|
||||
#RUST_LOG=none
|
||||
USERNAME=hiedemann
|
||||
DB_DRIVER=sqlite
|
||||
16
crates/advotracker/.env-bak
Normal file
@@ -0,0 +1,16 @@
|
||||
###
|
||||
# .env
|
||||
# will overwrite standard environment viariables
|
||||
###
|
||||
# set the language variable used in test-runs
|
||||
#test LANG=es-ES
|
||||
#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=trace
|
||||
#RUST_LOG=none
|
||||
USERNAME=hiedemann
|
||||
DB_DRIVER=sqlite
|
||||
68
crates/advotracker/Cargo.toml
Normal file
@@ -0,0 +1,68 @@
|
||||
[package]
|
||||
name = "advotracker"
|
||||
version = "0.1.5"
|
||||
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
||||
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
||||
readme = "README.md"
|
||||
license = "(0BSD OR MIT)"
|
||||
edition = "2018"
|
||||
default-run = "advotracker"
|
||||
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
|
||||
ar = "/usr/x86_64-w64-mingw32i/bin/ar"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winuser"] }
|
||||
#diesel = { version = "1.4", features = [ "postgres", "sqlite" ] }
|
||||
|
||||
[dependencies]
|
||||
async-stream = "~0.2"
|
||||
chrono = { version = "~0.4.0", features = ["serde"] }
|
||||
cfg-if = { version = "~1.0" }
|
||||
clap = { version = "~2.33", features = ["suggestions", "color"] }
|
||||
csv = { version = "~1.1" }
|
||||
dotenv = { version = "~0.15.0" }
|
||||
envy = { version = "~0.4" }
|
||||
lettre = "0.10.0-beta.1"
|
||||
lazy_static = { version = "~1.4.0" }
|
||||
log = { version = "~0.4.8" }
|
||||
locales = { version = "~0.1" }
|
||||
maud = { version = "~0.22.1" }
|
||||
#orbtk = { version = "~0.3.1-alpha4" }
|
||||
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
||||
orbtk = { path = "../../orbtk" }
|
||||
serde = { version = "~1.0", features = ["derive"] }
|
||||
substring = { version = "~1" }
|
||||
#tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] }
|
||||
tracing = { version = "~0.1" }
|
||||
tracing-subscriber = { version = "~0.2.0", features = ["tracing-log"] }
|
||||
viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
debug = ["orbtk/debug"]
|
||||
light = []
|
||||
|
||||
[package.metadata.bundle]
|
||||
name = "advotracker"
|
||||
identifier = "nwx.advotracker"
|
||||
short_description = "Online legal advice helper."
|
||||
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
incremental = true
|
||||
|
||||
[profile.release]
|
||||
incremental = true
|
||||
|
||||
#[[bin]]
|
||||
#//name = "policycheck"
|
||||
#path = "src/bin/policycheck.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "advotracker"
|
||||
path = "src/main.rs"
|
||||
8
crates/advotracker/Node.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[[apps]]
|
||||
name = "advotracker"
|
||||
width = 580
|
||||
height = 280
|
||||
assets = "resources/advotracker"
|
||||
[[apps.fonts]]
|
||||
font_family = "MaterialIcons-Regular"
|
||||
src = "resources/fonts/MaterialIcons.ttf"
|
||||
1
crates/advotracker/POLLFNR_WOECHENTLICH.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
POLLFNR_WOECHENTLICH_test.txt
|
||||
1
crates/advotracker/POLLFNR_WOECHENTLICH_full.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
data/POLLFNR_WOECHENTLICH.txt
|
||||
1
crates/advotracker/POLLFNR_WOECHENTLICH_test.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
data/POLLFNR_TEST.txt
|
||||
1
crates/advotracker/RA-Hiedemann_DirectCall.txt
Normal file
@@ -0,0 +1 @@
|
||||
Allianz DirectCall Protokoll!
|
||||
5
crates/advotracker/advotracker.conf
Normal file
@@ -0,0 +1,5 @@
|
||||
[advotracker.conf]
|
||||
|
||||
mode = interative
|
||||
|
||||
|
||||
59
crates/advotracker/assets/advotracker/advotracker_de_DE.ron
Normal file
@@ -0,0 +1,59 @@
|
||||
// *
|
||||
// * 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": "Vers.-Schein/Schadennummer",
|
||||
"Policy holder": "Versicherungsnehmer",
|
||||
"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",
|
||||
"Account": "Benutzer",
|
||||
"Toggle theme": "Thema wechseln",
|
||||
"Quit": "Beenden",
|
||||
|
||||
// ticketdata_view
|
||||
"Callback number": "Rückrufnummer",
|
||||
"Callback date": "Erreichbarkeit",
|
||||
"Clear": "Zurücksetzen",
|
||||
"Deductible": "Selbstbehalt",
|
||||
"Harm type": "Rechtsproblem",
|
||||
"IVR comment": "Rechtsrat",
|
||||
"Policy holder": "Versicherungsnehmer",
|
||||
"Recipient (To)": "Empfänger (To)",
|
||||
"Copie (CC)": "Kopie (CC)",
|
||||
"Send": "Senden",
|
||||
|
||||
// localization view
|
||||
"Language ID": "Sprache ID",
|
||||
"Localization dialog": "Lokalisierungs-Dialog",
|
||||
"German": "Deutsch",
|
||||
"English": "Englisch",
|
||||
|
||||
// configuration view
|
||||
"Configuration settings": "Konfigurationseinstellungen",
|
||||
"Configuration file": "Konfigurationsdatei",
|
||||
"Language Id": "Sprach-Id",
|
||||
"Default theme": "Standard-Thema",
|
||||
"Load": "Laden",
|
||||
"Save": "Speichern",
|
||||
}
|
||||
)
|
||||
179
crates/advotracker/assets/advotracker/default_dark.ron
Normal file
@@ -0,0 +1,179 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"button_action": (
|
||||
base: "button",
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"border_radius": 3,
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"button_menu": (
|
||||
base: "button_single_content",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
//"icon": "material_icons_font::MD_MENU",
|
||||
},
|
||||
),
|
||||
"combo_box_form": (
|
||||
base: "combo_box",
|
||||
properties: {
|
||||
"width": 200,
|
||||
//"height": 28,
|
||||
},
|
||||
),
|
||||
"combo_box_popup": (
|
||||
base: "popup_box_popup",
|
||||
properties: {
|
||||
"height": 80,
|
||||
"min_height": 80,
|
||||
"width": 160,
|
||||
"min_width": 80,
|
||||
},
|
||||
),
|
||||
"mail_label": (
|
||||
base: "base",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"mail_to": (
|
||||
base: "combo_box_form",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
},
|
||||
),
|
||||
"mail_cc": (
|
||||
base: "combo_box_form",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
},
|
||||
),
|
||||
"configuration_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"margin": 4,
|
||||
},
|
||||
),
|
||||
"container_action": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"border_width": 1,
|
||||
"padding": {
|
||||
"left": 14,
|
||||
"top": 0,
|
||||
"right": 14,
|
||||
"bottom": 0,
|
||||
},
|
||||
"h_align": "center",
|
||||
},
|
||||
),
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"padding": 14,
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"min_height": 330,
|
||||
},
|
||||
),
|
||||
"container_mail": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"border_width": 0,
|
||||
"padding": {
|
||||
"left": 14,
|
||||
"top": 0,
|
||||
"right": 14,
|
||||
"bottom": 14,
|
||||
}
|
||||
},
|
||||
),
|
||||
"container_progress": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
"h_align": "center",
|
||||
"padding": 14,
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"header_bar": (
|
||||
base: "header",
|
||||
properties: {
|
||||
//"h_align": "center",
|
||||
//"v_align": "center",
|
||||
"min_height": 32,
|
||||
//"padding": 14,
|
||||
}
|
||||
),
|
||||
"header_text": (
|
||||
base: "header",
|
||||
properties: {
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
}
|
||||
),
|
||||
"popup_menu": (
|
||||
//base: "popup",
|
||||
properties: {
|
||||
"width": 300,
|
||||
"hight": 200,
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"h_align": "center",
|
||||
},
|
||||
),
|
||||
"popup_progress": (
|
||||
base: "popup",
|
||||
properties: {
|
||||
"padding": 4,
|
||||
},
|
||||
),
|
||||
"stack_action": (
|
||||
//base: "stack",
|
||||
properties: {
|
||||
//"min_height": 50,
|
||||
"orientation": "Horizontal",
|
||||
"spacing": 50,
|
||||
},
|
||||
),
|
||||
"stack_progress": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"spacing": 10,
|
||||
},
|
||||
),
|
||||
"ticket_data_form_label": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"padding": 1,
|
||||
"h_align": "end",
|
||||
"v_align": "center",
|
||||
"margin": {
|
||||
"left": 0,
|
||||
"top": 0,
|
||||
"right": 0,
|
||||
"bottom": 0,
|
||||
},
|
||||
"min_size": 300,
|
||||
"max_size": 400,
|
||||
},
|
||||
),
|
||||
"ticket_data_form_input": (
|
||||
base: "ticket_data_form_label",
|
||||
properties: {
|
||||
"h_align": "start",
|
||||
},
|
||||
),
|
||||
"text_block_progress": (
|
||||
base: "small_text",
|
||||
properties: {
|
||||
"background": "$PROGRESS_BAR_BACKGROUND",
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
10
crates/advotracker/assets/advotracker/fluent_dark.ron
Normal file
@@ -0,0 +1,10 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"border": 1,
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
BIN
crates/advotracker/assets/advotracker/hiedemann_logo.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
crates/advotracker/assets/advotracker/networkx_logo.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
crates/advotracker/assets/fonts/CynthoPro-Regular.otf
Normal file
BIN
crates/advotracker/assets/icons/advotracker/20x20/back.png
Executable file
|
After Width: | Height: | Size: 220 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20/drawer.png
Executable file
|
After Width: | Height: | Size: 123 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20/menu.png
Executable file
|
After Width: | Height: | Size: 123 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@2/back.png
Executable file
|
After Width: | Height: | Size: 289 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@2/drawer.png
Executable file
|
After Width: | Height: | Size: 126 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@2/menu.png
Executable file
|
After Width: | Height: | Size: 158 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@3/back.png
Executable file
|
After Width: | Height: | Size: 351 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@3/drawer.png
Executable file
|
After Width: | Height: | Size: 130 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@3/menu.png
Executable file
|
After Width: | Height: | Size: 193 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@4/back.png
Executable file
|
After Width: | Height: | Size: 452 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@4/drawer.png
Executable file
|
After Width: | Height: | Size: 131 B |
BIN
crates/advotracker/assets/icons/advotracker/20x20@4/menu.png
Executable file
|
After Width: | Height: | Size: 223 B |
152
crates/advotracker/assets/icons/advotracker/Hiedemann_Logo.svg
Normal file
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="105mm"
|
||||
height="74mm"
|
||||
viewBox="0 0 105 74"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||
sodipodi:docname="Hiedemann_Logo.svg">
|
||||
<title
|
||||
id="title850">Hiedemann Rechtsanwälte</title>
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
units="mm"
|
||||
inkscape:snap-global="true"
|
||||
inkscape:snap-grids="true"
|
||||
inkscape:snap-nodes="true"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-height="1088"
|
||||
inkscape:window-width="2048"
|
||||
showgrid="false"
|
||||
inkscape:document-rotation="0"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:cy="285.11146"
|
||||
inkscape:cx="343.98278"
|
||||
inkscape:zoom="1.4564683"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
borderopacity="1.0"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff"
|
||||
id="base" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title>Hiedemann Rechtsanwälte</dc:title>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Hiedemann Rechtsanwälte</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:publisher>
|
||||
<cc:Agent>
|
||||
<dc:title>Networkx GmbH</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:publisher>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:title>Hiedemann Rechtsanwälte</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
style="display:inline"
|
||||
inkscape:label="Rahmen"
|
||||
id="layer2"
|
||||
inkscape:groupmode="layer" />
|
||||
<g
|
||||
style="display:inline"
|
||||
id="layer1"
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="Logo">
|
||||
<g
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-filename="/data/development/advotracker/advotracker/resources/images/hiedemann_logo.png"
|
||||
transform="matrix(0.5,0,0,0.5,26.483775,16.188821)"
|
||||
id="g1005">
|
||||
<g
|
||||
id="g910"
|
||||
style="display:inline"
|
||||
transform="translate(-1.958558,18.772823)"
|
||||
inkscape:export-filename="/data/development/advotracker/advotracker/resources/images/hiedemann_logo.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<rect
|
||||
ry="6.2927017"
|
||||
rx="0.08973857"
|
||||
y="1.2013354"
|
||||
x="4.9724188"
|
||||
height="24.806967"
|
||||
width="99.907379"
|
||||
id="rect852"
|
||||
style="vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.0926207;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
id="g1098"
|
||||
transform="matrix(1.3250965,0,0,1.3250965,-38.983201,-118.19402)"
|
||||
inkscape:export-filename="/data/development/advotracker/advotracker/resources/images/hiedemann_logo.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<text
|
||||
transform="scale(0.95388348,1.0483461)"
|
||||
id="text835"
|
||||
y="108.37959"
|
||||
x="36.210163"
|
||||
style="font-size:8.71712px;line-height:125%;font-family:FreeSans;-inkscape-font-specification:'FreeSans, Normal';letter-spacing:2.60261px;word-spacing:0px;writing-mode:lr-tb;fill:#c46069;fill-opacity:1;stroke:#000000;stroke-width:0.363212px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.71712px;font-family:'Cyntho Pro';-inkscape-font-specification:'Cyntho Pro, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#c46069;fill-opacity:1;stroke:none;stroke-width:0.363212px"
|
||||
y="108.37959"
|
||||
x="36.210163"
|
||||
id="tspan833"
|
||||
sodipodi:role="line">HIEDE<tspan
|
||||
id="tspan889"
|
||||
style="letter-spacing:1.31762px">M</tspan><tspan
|
||||
id="tspan883"
|
||||
style="letter-spacing:1.31762px;stroke-width:0.363212px">A</tspan>NN</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.58611px;line-height:125%;font-family:FreeSans;-inkscape-font-specification:'FreeSans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;letter-spacing:3.43958px;word-spacing:0px;writing-mode:lr-tb;fill:#9d9b9b;fill-opacity:1;stroke:none;stroke-width:0.444725px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="40.402027"
|
||||
y="104.09837"
|
||||
id="text853"
|
||||
transform="scale(0.86606999,1.1546411)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan851"
|
||||
x="40.402027"
|
||||
y="104.09837"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333px;font-family:'Cyntho Pro';-inkscape-font-specification:'Cyntho Pro';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#9d9b9b;fill-opacity:1;stroke:none;stroke-width:0.444725px"><tspan
|
||||
id="tspan925"
|
||||
style="letter-spacing:3.70417px">REC</tspan><tspan
|
||||
style="letter-spacing:3.33375px"
|
||||
id="tspan1083">HT</tspan><tspan
|
||||
style="letter-spacing:2.92894px"
|
||||
id="tspan1075">S</tspan><tspan
|
||||
style="letter-spacing:3.23585px"
|
||||
id="tspan1069">AN</tspan><tspan
|
||||
id="tspan921"
|
||||
style="letter-spacing:2.94746px">WÄLTE</tspan></tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
24
crates/advotracker/assets/icons/advotracker/index.theme
Executable file
@@ -0,0 +1,24 @@
|
||||
[Icon Theme]
|
||||
Name=AdvoTracker
|
||||
Comment=AdvoTracker Icon Theme
|
||||
|
||||
Directories=20x20,20x20@2,20x20@3,20x20@4
|
||||
|
||||
[20x20]
|
||||
Size=20
|
||||
Type=Fixed
|
||||
|
||||
[20x20@2]
|
||||
Size=20
|
||||
Scale=2
|
||||
Type=Fixed
|
||||
|
||||
[20x20@3]
|
||||
Size=20
|
||||
Scale=3
|
||||
Type=Fixed
|
||||
|
||||
[20x20@4]
|
||||
Size=20
|
||||
Scale=4
|
||||
Type=Fixed
|
||||
BIN
crates/advotracker/assets/images/advotracker.jpg
Executable file
|
After Width: | Height: | Size: 53 KiB |
BIN
crates/advotracker/assets/images/arrow.png
Executable file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
crates/advotracker/assets/images/arrow@2x.png
Executable file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
crates/advotracker/assets/images/arrow@3x.png
Executable file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
crates/advotracker/assets/images/arrow@4x.png
Executable file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
crates/advotracker/assets/images/arrows.png
Executable file
|
After Width: | Height: | Size: 768 B |
BIN
crates/advotracker/assets/images/arrows@2x.png
Executable file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
crates/advotracker/assets/images/arrows@3x.png
Executable file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
crates/advotracker/assets/images/arrows@4x.png
Executable file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
crates/advotracker/assets/images/background.jpg
Executable file
|
After Width: | Height: | Size: 455 KiB |
BIN
crates/advotracker/assets/images/customer_background.jpg
Executable file
|
After Width: | Height: | Size: 53 KiB |
BIN
crates/advotracker/assets/images/customer_logo.jpg
Executable file
|
After Width: | Height: | Size: 53 KiB |
1
crates/advotracker/assets/images/customer_logo.png
Symbolic link
@@ -0,0 +1 @@
|
||||
hiedemann_logo.png
|
||||
BIN
crates/advotracker/assets/images/hiedemann_logo.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
crates/advotracker/assets/images/networkx_logo.jpg
Executable file
|
After Width: | Height: | Size: 71 KiB |
BIN
crates/advotracker/assets/images/networkx_logo.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
crates/advotracker/assets/images/nobody.png
Executable file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
crates/advotracker/assets/images/orbtk-space.png
Normal file
|
After Width: | Height: | Size: 237 KiB |
BIN
crates/advotracker/assets/images/orbtk_logo.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
crates/advotracker/assets/images/rust_logo.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
15498
crates/advotracker/data/POLLFNR_TEST.txt
Normal file
2498330
crates/advotracker/data/POLLFNR_WOECHENTLICH.txt
Normal file
49
crates/advotracker/data/bench.txt
Normal file
@@ -0,0 +1,49 @@
|
||||
Target: debug
|
||||
[ralf@jacara-x1 frontend]$ time ../target/debug/examples/csv-import --importFile /home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt -v
|
||||
Jun 27 02:43:48.886 TRACE csv-import: "Umgebungsvariablen prüfen" state="gestartet"
|
||||
Jun 27 02:43:48.886 TRACE csv-import: environment="system" lang="de_DE.UTF-8"
|
||||
Jun 27 02:43:48.887 DEBUG csv-import: missing value for field test_lang
|
||||
Jun 27 02:43:48.887 TRACE csv-import: environment="envy" lang="de_DE.UTF-8"
|
||||
Jun 27 02:43:48.887 TRACE csv-import: "Umgebungsvariablen prüfen" state="beendet"
|
||||
Jun 27 02:43:48.887 TRACE csv-import: process="Programmargumente prüfen" state="gestartet"
|
||||
RUST_LOG=None
|
||||
Jun 27 02:43:48.887 TRACE csv_import::parse_args: verbose 1
|
||||
config_file: "csv_import.ron"
|
||||
import_file: "/home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt"
|
||||
verbosity level: 1
|
||||
Jun 27 02:43:48.887 TRACE csv-import: process="Programmargumente prüfen" state="beendet"
|
||||
Jun 27 02:43:48.887 TRACE csv-import: process="Programmlogik starten" state="gestartet"
|
||||
Jun 27 02:43:48.887 TRACE csv-import: extension=Some("txt") file=File { fd: 3, path: "/home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt", read: true, write: false }
|
||||
Jun 27 02:43:48.888 TRACE csv-import: header=StringRecord(["DION", "VERS", "POLLFNR"])
|
||||
Jun 27 02:43:57.513 TRACE csv-import: record_count=2498330
|
||||
Imported 2498330 records
|
||||
Jun 27 02:43:57.513 TRACE csv-import: process="Programmlogik beendet" state="beendet"
|
||||
|
||||
real 0m8,700s
|
||||
user 0m8,675s
|
||||
sys 0m0,017s
|
||||
|
||||
Target: release
|
||||
[ralf@jacara-x1 frontend]$ time ../target/release/examples/csv-import --importFile /home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt -v
|
||||
Jun 27 02:48:13.753 TRACE csv-import: "Umgebungsvariablen prüfen" state="gestartet"
|
||||
Jun 27 02:48:13.753 TRACE csv-import: environment="system" lang="de_DE.UTF-8"
|
||||
Jun 27 02:48:13.753 DEBUG csv-import: missing value for field test_lang
|
||||
Jun 27 02:48:13.753 TRACE csv-import: environment="envy" lang="de_DE.UTF-8"
|
||||
Jun 27 02:48:13.753 TRACE csv-import: "Umgebungsvariablen prüfen" state="beendet"
|
||||
Jun 27 02:48:13.753 TRACE csv-import: process="Programmargumente prüfen" state="gestartet"
|
||||
RUST_LOG=None
|
||||
Jun 27 02:48:13.753 TRACE csv_import::parse_args: verbose 1
|
||||
config_file: "csv_import.ron"
|
||||
import_file: "/home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt"
|
||||
verbosity level: 1
|
||||
Jun 27 02:48:13.753 TRACE csv-import: process="Programmargumente prüfen" state="beendet"
|
||||
Jun 27 02:48:13.753 TRACE csv-import: process="Programmlogik starten" state="gestartet"
|
||||
Jun 27 02:48:13.754 TRACE csv-import: extension=Some("txt") file=File { fd: 3, path: "/home/ralf/projekte/Hiedemann/Allianz_Vorgaben_Policycheck/ERG.txt", read: true, write: false }
|
||||
Jun 27 02:48:13.754 TRACE csv-import: header=StringRecord(["DION", "VERS", "POLLFNR"])
|
||||
Jun 27 02:48:14.098 TRACE csv-import: record_count=2498330
|
||||
Imported 2498330 records
|
||||
Jun 27 02:48:14.098 TRACE csv-import: process="Programmlogik beendet" state="beendet"
|
||||
|
||||
real 0m0,355s
|
||||
user 0m0,338s
|
||||
sys 0m0,017s
|
||||
7
crates/advotracker/examples/.env
Normal file
@@ -0,0 +1,7 @@
|
||||
# set the language variable used in test-runs
|
||||
#test lang=it
|
||||
TEST_LANG=en
|
||||
#RUST_LOG=csv-import=trace
|
||||
LOG=debug
|
||||
USERNAME=ralf
|
||||
DB_DRIVER=sqlite
|
||||
502
crates/advotracker/examples/advowidgets.rs
Normal file
@@ -0,0 +1,502 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
AddItem,
|
||||
ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity),
|
||||
ValueChanged(Entity),
|
||||
IncrementCounter,
|
||||
RemoveItem,
|
||||
ToggleTheme(Entity),
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
pub struct MainViewState {
|
||||
action: Option<Action>,
|
||||
}
|
||||
|
||||
impl Default for MainViewState {
|
||||
fn default() -> Self {
|
||||
MainViewState { action: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: impl Into<Option<Action>>) {
|
||||
self.action = action.into();
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
Action::AddItem => {
|
||||
let len = main_view(ctx.widget()).list().len();
|
||||
|
||||
if len < 5 {
|
||||
main_view(ctx.widget())
|
||||
.list_mut()
|
||||
.push(format!("Item {}", len + 1));
|
||||
ctx.child("items").clone_or_default::<usize>("Item");
|
||||
items_widget(ctx.child("items")).set_count(len + 1);
|
||||
button(ctx.child("remove-item-button")).set_enabled(true);
|
||||
button(ctx.child("remove-item-button")).set_visibility(Visibility::Visible);
|
||||
|
||||
if len == 4 {
|
||||
button(ctx.child("add-item-button")).set_enabled(false);
|
||||
button(ctx.child("add-item-button"))
|
||||
.set_visibility(Visibility::Collapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::RemoveItem => {
|
||||
let len = main_view(ctx.widget()).list().len();
|
||||
if len > 0 {
|
||||
main_view(ctx.widget()).list_mut().remove(len - 1);
|
||||
items_widget(ctx.child("items")).set_count(len - 1);
|
||||
button(ctx.child("add-item-button")).set_enabled(true);
|
||||
button(ctx.child("add-item-button")).set_visibility(Visibility::Visible);
|
||||
|
||||
if len == 1 {
|
||||
button(ctx.child("remove-item-button")).set_enabled(false);
|
||||
button(ctx.child("remove-item-button"))
|
||||
.set_visibility(Visibility::Collapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::IncrementCounter => {
|
||||
*main_view(ctx.widget()).counter_mut() += 1;
|
||||
|
||||
let counter = *main_view(ctx.widget()).counter();
|
||||
|
||||
main_view(ctx.widget())
|
||||
.set_result(String16::from(format!("Button count: {}", counter)));
|
||||
}
|
||||
Action::ClearText => {
|
||||
main_view(ctx.widget()).set_text_one(String16::default());
|
||||
main_view(ctx.widget()).set_text_two(String16::default());
|
||||
}
|
||||
Action::EntryActivated(entity) => {
|
||||
let mut text_box = text_box(ctx.get_widget(entity));
|
||||
let text = text_box.text_mut();
|
||||
println!("submitting {}", text);
|
||||
text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
println!("entry changed: {}", text_box(ctx.get_widget(entity)).text());
|
||||
}
|
||||
Action::ValueChanged(_entity) => {
|
||||
//println!("Slider value changed");
|
||||
}
|
||||
Action::ToggleTheme(entity) => {
|
||||
let light = *ctx.get_widget(entity).get::<bool>("selected");
|
||||
|
||||
let theme = if light { light_theme() } else { dark_theme() };
|
||||
ctx.switch_theme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
let mut selection_string = "Selected:".to_string();
|
||||
|
||||
for index in &main_view(ctx.widget()).selected_indices().0 {
|
||||
selection_string = format!("{} {}", selection_string, index);
|
||||
}
|
||||
|
||||
text_block(ctx.child("selection")).set_text(selection_string);
|
||||
}
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new().text(text).style("header").build(ctx)
|
||||
}
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
widget!(
|
||||
MainView<MainViewState> {
|
||||
selected_indices: SelectedIndices,
|
||||
counter: usize,
|
||||
list_count: usize,
|
||||
combo_box_list_count: usize,
|
||||
list: List,
|
||||
selection_list: List,
|
||||
combo_box_list: List,
|
||||
selection_list_count: usize,
|
||||
text_one: String16,
|
||||
text_two: String16,
|
||||
result: String16
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
let slider = Slider::new()
|
||||
.min(0.0)
|
||||
.max(1.0)
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::ValueChanged(entity));
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.result("Button count: 0")
|
||||
.counter(0)
|
||||
.selected_indices(HashSet::new())
|
||||
.list(vec![
|
||||
"Item 1".to_string(),
|
||||
"Item 2".to_string(),
|
||||
"Item 3".to_string(),
|
||||
])
|
||||
.list_count(3)
|
||||
.selection_list(vec![
|
||||
"Select Item 1".to_string(),
|
||||
"Select Item 2".to_string(),
|
||||
"Select Item 3".to_string(),
|
||||
"Select Item 4".to_string(),
|
||||
"Select Item 5".to_string(),
|
||||
"Select Item 6".to_string(),
|
||||
"Select Item 7".to_string(),
|
||||
"Select Item 8".to_string(),
|
||||
"Select Item 9".to_string(),
|
||||
"Select Item 10".to_string(),
|
||||
])
|
||||
.combo_box_list(vec![
|
||||
"CB 1".to_string(),
|
||||
"CB 2".to_string(),
|
||||
"CB 3".to_string(),
|
||||
"CB 4".to_string(),
|
||||
"CB 5".to_string(),
|
||||
"CB 6".to_string(),
|
||||
"CB 7".to_string(),
|
||||
"CB 8".to_string(),
|
||||
"CB 9".to_string(),
|
||||
"CB 10".to_string(),
|
||||
])
|
||||
.selection_list_count(10)
|
||||
.combo_box_list_count(10)
|
||||
.child(
|
||||
Grid::new()
|
||||
.margin(8)
|
||||
.columns(Columns::new().add(132).add(16).add(132).add(16).add(132))
|
||||
.rows(Rows::new().add("*").add(32))
|
||||
.child(
|
||||
// Row 0
|
||||
Stack::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
// Column 0
|
||||
.child(create_header(ctx, "Buttons"))
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Button")
|
||||
.margin((0, 8, 0, 0))
|
||||
.icon(material_icons_font::MD_CHECK)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::IncrementCounter);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Primary")
|
||||
.style("button_primary")
|
||||
.margin((0, 8, 0, 0))
|
||||
.icon(material_icons_font::MD_360)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ToggleButton::new()
|
||||
.style("button_single_content")
|
||||
.text("ToggleButton")
|
||||
.margin((0, 8, 2, 0))
|
||||
.icon(material_icons_font::MD_ALARM_ON)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(3))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
CheckBox::new()
|
||||
.text("CheckBox")
|
||||
.margin((0, 8, 0, 0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Switch::new()
|
||||
.margin((0, 8, 0, 0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(5))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(slider)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.val(slider)
|
||||
.margin((0, 8, 0, 0))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Stack::new()
|
||||
// Column 2
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(0))
|
||||
.child(create_header(ctx, "Text"))
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.style("body")
|
||||
.text(("result", id))
|
||||
.margin((0, 8, 0, 0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_one", id))
|
||||
.margin((0, 8, 0, 0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_two", id))
|
||||
.margin((0, 8, 0, 0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.margin((0, 8, 0, 0))
|
||||
.style("button_single_content")
|
||||
.text("clear text")
|
||||
.icon(material_icons_font::MD_CLEAR)
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::ClearText);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
NumericBox::new()
|
||||
.margin((0, 8, 0, 0))
|
||||
.max(123)
|
||||
.step(0.123)
|
||||
.val(0.123)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
// Column 4
|
||||
Grid::new()
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("auto")
|
||||
.add(32)
|
||||
.add(16)
|
||||
.add(204)
|
||||
.add("auto")
|
||||
.add(192)
|
||||
.add("auto"),
|
||||
)
|
||||
.columns(Columns::new().add("*").add(4).add("*"))
|
||||
.attach(Grid::column(4))
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.text("Items")
|
||||
.style("header")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(0))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("combo_box_list")[index]
|
||||
.clone();
|
||||
TextBlock::new()
|
||||
.style("small_text")
|
||||
.margin((0, 0, 0, 2))
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.selected_index(0)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(1))
|
||||
.margin((0, 8, 0, 0))
|
||||
.count(("combo_box_list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ItemsWidget::new()
|
||||
.id("items")
|
||||
.padding((4, 4, 4, 2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(3))
|
||||
.margin((0, 0, 0, 8))
|
||||
// bc = build-context
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id).get::<Vec<String>>("list")
|
||||
[index]
|
||||
.clone();
|
||||
|
||||
Button::new().margin((0, 0, 0, 2)).text(text).build(bc)
|
||||
})
|
||||
.count(("list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.style("button_single_content")
|
||||
.id("remove-item-button")
|
||||
.icon(material_icons_font::MD_REMOVE_CIRCLE)
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::RemoveItem);
|
||||
true
|
||||
})
|
||||
.min_width(0)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.style("button_single_content")
|
||||
.id("add-item-button")
|
||||
.icon(material_icons_font::MD_ADD_CIRCLE)
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::AddItem);
|
||||
true
|
||||
})
|
||||
.min_width(0)
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ListView::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(5))
|
||||
.selected_indices(id)
|
||||
.margin((0, 16, 0, 8))
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("selection_list")[index]
|
||||
.clone();
|
||||
TextBlock::new()
|
||||
.margin((0, 0, 0, 2))
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.on_selection_changed(|_, _, _| println!("Selection changed"))
|
||||
.count(("selection_list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
// todo: wrong text width????
|
||||
TextBlock::new()
|
||||
.style("body")
|
||||
.id("selection")
|
||||
.max_width(120)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(6))
|
||||
.text("Selected:")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
// Row 1
|
||||
Stack::new()
|
||||
.orientation("horizontal")
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(0))
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.style("body")
|
||||
.text("Toggle theme: ")
|
||||
.v_align("center")
|
||||
.margin((0, 0, 4, 0))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Switch::new()
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::ToggleTheme(entity));
|
||||
})
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("OrbTk - widgets example")
|
||||
.position((100, 100))
|
||||
.size(468, 730)
|
||||
.resizeable(true)
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
// helper to request MainViewState
|
||||
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
|
||||
states.get_mut(id)
|
||||
}
|
||||
89
crates/advotracker/examples/cheet_sheet.rs
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* OrbTk - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (MIT)
|
||||
*/
|
||||
|
||||
// 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
|
||||
// let mut widget_container: WidgetContainer = ctx.widget();
|
||||
|
||||
// // property handling (componets)
|
||||
// // Gets a reference for the property
|
||||
// // .get<PropertyType>("property_name");
|
||||
// widget_container.get::<String16>("text");
|
||||
|
||||
// // Sets the value of a property
|
||||
// // .set<PropertyType>("property_name", property_value);
|
||||
// widget_container.set::<String16>("text", "my_text");
|
||||
|
||||
|
||||
// /*
|
||||
// * Child WidgetContainer = child entity
|
||||
// */
|
||||
// // child of a state's widget, that is referenced by an entity id.
|
||||
// // e.g: .child(TextBox::new().id(child_entity_id).build(ctx)
|
||||
// let mut child: WidgetContainer = ctx.get_widget(child_entity_id);
|
||||
|
||||
// // child of a state's widget that is referenced by an string id
|
||||
// // e.g: .child(TextBox::new().id("text_box_id").build(ctx)
|
||||
// let child: WidgetContainer = ctx.child("text_box_id");
|
||||
|
||||
// // property handling (components)
|
||||
// // Gets an TextBoxCtx wrapper for the text box child.
|
||||
// let mut text_box: TextBoxCtx = text_box(ctx.child("text_box_id"));
|
||||
|
||||
// // or as an alternative:
|
||||
// let text_box: TextBoxCtx = TextBox::get(ctx.child("text_box_id"));
|
||||
|
||||
// // get child field attributes
|
||||
// let text_len = text_box.text().len();
|
||||
|
||||
// // 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());
|
||||
// }
|
||||
// // access service
|
||||
// fn update(registry: &mut Registry, _: &mut Context) {
|
||||
// let mut my_db_service: MyDBSerivce = registry.get_mut("my_db_service");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// API Update: access properties of widgets in states
|
||||
|
||||
// Old style
|
||||
// let text = *button(&mut ctx.widget()).text();
|
||||
// let text = Button::get(&mut ctx.widget()).text();
|
||||
// let text = *button(&mut ctx.widget()).clone_text();
|
||||
// let text = Button::get(&mut ctx.widget()).clone_text();
|
||||
// button(&mut ctx.widget()).text_mut().push_str("test");
|
||||
// Button::get(&mut ctx.widget()).text_mut().push_str("test");
|
||||
// button(&mut ctx.widget()).set_text(String16::from("test"));
|
||||
// Button::get(&mut ctx.widget()).set_text(String16::from("test"));
|
||||
|
||||
// Current style
|
||||
// let text = Button::text_clone(&ctx.widget());
|
||||
// Button::text_mut(&mut ctx.widget()).push_str("test");
|
||||
// Button::text_set(&mut ctx.widget(), String16::from("test"));
|
||||
//
|
||||
// TextBehaviour::offset_set(&mut ctx.widget(self.text_block), offset);
|
||||
// or
|
||||
// ctx.get_widget(self.text_block).set("offset", offset);
|
||||
|
||||
|
||||
fn main() {}
|
||||
800
crates/advotracker/examples/combobox-test.rs
Normal file
@@ -0,0 +1,800 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// suppress creation of a new console window on window
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
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 advotracker::{
|
||||
data::{constants::*, structures::Email},
|
||||
widgets::global_state::GlobalState,
|
||||
//services::exports::send_ticketdata::sendticketdata,
|
||||
widgets::policycheck::*,
|
||||
widgets::policycheck_state::*,
|
||||
widgets::main_view,
|
||||
widgets::ticketdata::*,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS};
|
||||
|
||||
pub enum TicketdataAction {
|
||||
ClearForm(),
|
||||
SendForm(),
|
||||
UpdatePolicyCode(String)
|
||||
}
|
||||
|
||||
// German localization file.
|
||||
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/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_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
|
||||
// return the active language
|
||||
lang
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
fn theme_fluent() -> Theme {
|
||||
register_fluent_fonts(Theme::from_config(
|
||||
ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_FLUENT))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
))
|
||||
// register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
}
|
||||
} else {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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/
|
||||
let span = tracing::span!(Level::TRACE, "advotracker");
|
||||
let _enter = span.enter();
|
||||
let subscriber = fmt::Subscriber::builder()
|
||||
.with_env_filter(trace)
|
||||
//.with_max_level(tracing::Level::DEBUG)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
// get system environment
|
||||
let lang = get_lang();
|
||||
|
||||
let mut state = t!("state.started", lang);
|
||||
let mut res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", machine = ?&machine_kind);
|
||||
|
||||
// how to handle unimplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// main tasks
|
||||
res = t!("main.started", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
// Preset localization and language from given environment.
|
||||
// if no dictionary is set for the chosen default language
|
||||
// the content of the text property will be drawn.
|
||||
//let language = lang.substring(0,5); // "de_DE.UTF-8" -> "de_DE"
|
||||
//info!("GUI-Language: preset to {:?}", language);
|
||||
let localization = RonLocalization::create()
|
||||
.language(&lang)
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
Application::from_name("nwx.advotracker")
|
||||
.localization(localization)
|
||||
.theme(theme())
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(800.0, 600.0)
|
||||
//.min_width(460.0)
|
||||
//.min_height(380.0)
|
||||
.resizeable(true)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("main.finished", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// View
|
||||
|
||||
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 policycheck_view = PolicycheckView::new()
|
||||
.target(ticketdata_view.0)
|
||||
.build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.child(
|
||||
TabWidget::new()
|
||||
.tab(ID_POLICY_CHECK_VIEW, policycheck_view)
|
||||
.tab(ID_TICKET_DATA_VIEW, ticketdata_view)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Macro that initializes the widget structures/variables for the policy check view
|
||||
widget!(
|
||||
/// Form to enter data of a ticket record
|
||||
TicketdataView<TicketdataState> {
|
||||
// language used inside the widget
|
||||
lang: String,
|
||||
// title used in the header
|
||||
ticket_data_title: String,
|
||||
// entity id that will receive the messages
|
||||
target: u32
|
||||
}
|
||||
);
|
||||
|
||||
/// The template implementation of the ticket view
|
||||
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
||||
impl Template for TicketdataView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let tenent_logo = Container::new()
|
||||
.margin((16, 16, 0, 0))
|
||||
.attach(Grid::column(0))
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("assets/advotracker/hiedemann_logo.png")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_bottom_bar = Container::new()
|
||||
.id(ID_TICKET_DATA_BOTTOM_BAR)
|
||||
.style(STYLE_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column_span(2))
|
||||
.v_align("end")
|
||||
.child(
|
||||
Container::new()
|
||||
.attach(Grid::column(1))
|
||||
.h_align("end")
|
||||
.v_align("end")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_button_menu = Button::new()
|
||||
.id(ID_TICKET_DATA_BUTTON_MENU)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.h_align("end")
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
//.style("button_single_content")
|
||||
.style(STYLE_BUTTON_MENU)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_form = Container::new()
|
||||
.id(ID_TICKET_DATA_FORM)
|
||||
.name(ID_TICKET_DATA_FORM)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style("container_form")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_TICKET_DATA_GRID)
|
||||
.name(ID_TICKET_DATA_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(32) // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 4
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 6
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 8
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 12
|
||||
.push(14) // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_POLICY_CODE)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.text("Policy code")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_POLICY_CODE)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_POLICY_HOLDER)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.text("Policy holder")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_POLICY_HOLDER)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Name des Versicherungsnehmers")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_DEDUCTIBLE)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.text("Deductible")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_DEDUCTIBLE)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("im Beratungsgespräch erfragen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_CALLBACK_NUMBER)
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(0))
|
||||
.text("Callback number")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("wie zu erreichen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_CALLBACK_DATE)
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(0))
|
||||
.text("Callback date")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_CALLBACK_DATE)
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Rückruf gewünscht um")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_HARM_TYPE)
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(0))
|
||||
.text("Harm type")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_HARM_TYPE)
|
||||
.name(ID_TICKET_DATA_HARM_TYPE)
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Schadenstyp")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_IVR_COMMENT)
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(0))
|
||||
.text("IVR comment")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_IVR_COMMENT)
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Kommentar zur Haftung, bzw. zur Deckung")
|
||||
//.height(48.0)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_form_action = Container::new()
|
||||
.id(ID_TICKET_DATA_ACTION_GRID)
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column(1))
|
||||
//.style(STYLE_CONTAINER_ACTION)
|
||||
.padding(14)
|
||||
.h_align("center")
|
||||
.child(
|
||||
Stack::new()
|
||||
//.style(STYLE_STACK_ACTION)
|
||||
.orientation("horizontal")
|
||||
.spacing(50)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_TICKET_DATA_ACTION_BUTTON_CLEAR)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Clear")
|
||||
.on_click(move |states, _| {
|
||||
states.send_message(TicketdataAction::ClearForm(), id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_TICKET_DATA_ACTION_BUTTON_SEND)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Send")
|
||||
//.visibility(Visibility::Collapsed)
|
||||
.on_click(move |states, _entity| {
|
||||
states.send_message(TicketdataAction::SendForm(), id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
// vector with valid mail recipients addresses (mail_to)
|
||||
let items_mail_to = vec![
|
||||
PROP_MAIL_TO_1,
|
||||
PROP_MAIL_TO_2,
|
||||
PROP_MAIL_TO_3,
|
||||
PROP_MAIL_TO_4,
|
||||
];
|
||||
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_count = items_mail_cc.len();
|
||||
|
||||
let ticket_data_form_mail = Container::new()
|
||||
.id(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
.name(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_CONTAINER_MAIL)
|
||||
.child(
|
||||
Grid::new()
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(16) // Delimiter
|
||||
.push("stretch") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("auto") // MailAddress
|
||||
.push("32") // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(2) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(2) // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_MAIL_TO)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_MAIL_LABEL)
|
||||
.text("Recipient (To)")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
/// WIP: get selected item
|
||||
ComboBox::new()
|
||||
.id(ID_TICKET_DATA_MAIL_TO)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(3))
|
||||
.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();
|
||||
TextBox::new()
|
||||
.text(text_mail_to)
|
||||
.v_align("center")
|
||||
.build(ibc)
|
||||
})
|
||||
.selected_index(0)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_MAIL_CC)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_MAIL_LABEL)
|
||||
.text("Copie (CC)")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.id(ID_TICKET_DATA_MAIL_CC)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(3))
|
||||
.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();
|
||||
TextBox::new()
|
||||
.text(text_mail_cc)
|
||||
.v_align("center")
|
||||
.build(ibc)
|
||||
})
|
||||
.selected_index(0)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_header_text = TextBlock::new()
|
||||
.id(ID_TICKET_DATA_HEADER)
|
||||
.attach(Grid::column(0))
|
||||
.style(STYLE_HEADER_TEXT)
|
||||
.text("Ticket Data")
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_header_bar = Container::new()
|
||||
.id(ID_TICKET_DATA_HEADER_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.style(STYLE_HEADER_BAR)
|
||||
.child(tenent_logo)
|
||||
.child(ticket_data_header_text)
|
||||
.child(ticket_data_button_menu)
|
||||
.build(ctx);
|
||||
|
||||
// Widget: Ticket data view
|
||||
self.id(ID_TICKET_DATA_VIEW)
|
||||
.name(ID_TICKET_DATA_VIEW)
|
||||
.min_height(410.0)
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_TICKET_DATA_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push("auto") // Mail_Form
|
||||
.push("*") // Input_Form
|
||||
.push("auto") // Action
|
||||
.push("auto") // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(ticket_data_header_bar) // row 0
|
||||
.child(ticket_data_form_mail) // row 1
|
||||
.child(ticket_data_form) // row 2
|
||||
.child(ticket_data_form_action) // row 3
|
||||
.child(ticket_data_bottom_bar) // row 4
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// State
|
||||
impl GlobalState for TicketdataState {}
|
||||
|
||||
/// Method definitions, that react on any given state change inside the `Ticketdata` widget.
|
||||
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"));
|
||||
}
|
||||
|
||||
// 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"));
|
||||
|
||||
// Loop through children
|
||||
if let Some(count) = ctx.get_widget(form_entity).children_count() {
|
||||
for c in 1..=count {
|
||||
info!("WIP clear entry of child {:?}", c);
|
||||
//info!("WIP clear entry of child {:?}: {:?}", c, ctx.get_child(form_entity).get::<String>("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// WIP: get selected items ComboBox'es
|
||||
//let mail_cc_index = *TicketdataView::selected_index_ref(&ctx.widget()) as usize;
|
||||
//let mail_cc_selected = TicketdataView::mail_cc_ref(&ctx.widget())[mail_cc_index].clone();
|
||||
|
||||
// create Email structures
|
||||
let email = Email {
|
||||
// WIP: mail_to -> selected index auslesen
|
||||
//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(),
|
||||
};
|
||||
|
||||
info!("WIP: Sending form to construct eMail to {:?}", email);
|
||||
// send email via service
|
||||
let _ = sendticketdata(&email, &lang);
|
||||
}
|
||||
}
|
||||
|
||||
/// Supported methods handled inside the `TicketState`
|
||||
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();
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||
|
||||
// Initialize required entities
|
||||
self.button_menu = ctx
|
||||
.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'."));
|
||||
|
||||
// Get language from environment
|
||||
self.lang = TicketdataState::get_lang();
|
||||
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start);
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "finished", duration = ?duration);
|
||||
}
|
||||
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<TicketdataAction>() {
|
||||
match message {
|
||||
TicketdataAction::ClearForm() => {
|
||||
info!("message: {:?} recieved", message);
|
||||
TicketdataState::clear_form(ctx.entity(), ctx);
|
||||
}
|
||||
TicketdataAction::SendForm() => {
|
||||
info!("message: {:?} recieved", message);
|
||||
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
match message {
|
||||
PolicycheckAction::UpdatePolicyCode => {
|
||||
info!("Message received: 'PolicycheckAction::UpdatePolicyCode'");
|
||||
TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_CODE), policy_code);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let actions: Vec<TicketdataAction> = self.actions.drain(..).collect();
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
TicketdataAction::ClearForm() => {
|
||||
info!("update: send_message {:?}", action);
|
||||
ctx.send_message(TicketdataAction::ClearForm(), self.target);
|
||||
}
|
||||
TicketdataAction::SendForm() => {
|
||||
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||
info!("update: send_message {:?}", action);
|
||||
}
|
||||
_ => { 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);
|
||||
let mut state = t!("state.started", lang);
|
||||
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";
|
||||
|
||||
info!("email body: {:?}", ascii_body);
|
||||
|
||||
let message = Message::builder()
|
||||
//.reply_to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.cc(" <ralf.zerres@networkx.de>".parse().unwrap())
|
||||
.reply_to((email.mail_reply).parse().unwrap())
|
||||
//.to((email.mail_to).parse().unwrap())
|
||||
//.cc((email.mail_cc).parse().unwrap())
|
||||
//.bcc((email.mail_bcc).parse().unwrap())
|
||||
.from((email.mail_from).parse().unwrap())
|
||||
.subject(String::new()
|
||||
+ &email.subject.to_string()
|
||||
+ &" (".to_string()
|
||||
+ &email.policy_code.to_string()
|
||||
+ &")".to_string()
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::alternative() // This is composed of two parts.
|
||||
.singlepart(
|
||||
SinglePart::builder()
|
||||
.header(header::ContentType(
|
||||
"text/plain; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(String::from(ascii_body)),
|
||||
)
|
||||
)
|
||||
.expect("failed to build email");
|
||||
|
||||
|
||||
info!("message: {:?}", message);
|
||||
|
||||
trace!(target: "sendticketdata", email = ?email);
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("sendticketdata.export.finished", lang);
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
7
crates/advotracker/examples/csv-test/.env
Normal file
@@ -0,0 +1,7 @@
|
||||
# set the language variable used in test-runs
|
||||
#test lang=de
|
||||
TEST_LANG=en
|
||||
#RUST_LOG=csv-test=trace
|
||||
RUST_LOG=trace
|
||||
USERNAME=ralf
|
||||
DB_DRIVER=sqlite
|
||||
23
crates/advotracker/examples/csv-test/data/POLLFNR_MINI.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
DION VERS POLLFNR
|
||||
1 AS 1
|
||||
1 AS 11
|
||||
1 AS 123456789
|
||||
9 AS 99
|
||||
9 AS 999
|
||||
1 AS 1511111111
|
||||
1 AS 1511111119
|
||||
1 AS 9000000001
|
||||
1 AS 9000000002
|
||||
1 AS 9999999991
|
||||
1 AS 9999999992
|
||||
1 AS 9999999999
|
||||
3 AS 1515735920
|
||||
3 AS 9999999991
|
||||
3 AS 9999999992
|
||||
3 AS 9999999999
|
||||
9 AS 9927764110
|
||||
9 AS 9927764251
|
||||
9 AS 9927764426
|
||||
9 AS 9999999991
|
||||
9 AS 9999999992
|
||||
9 AS 9999999999
|
||||
15498
crates/advotracker/examples/csv-test/data/POLLFNR_TEST.txt
Normal file
@@ -0,0 +1 @@
|
||||
../../../data/POLLFNR_WOECHENTLICH.txt
|
||||
409
crates/advotracker/examples/csv-test/main.rs
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
//use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
{error::Error, process},
|
||||
//path::{Path, PathBuf},
|
||||
};
|
||||
use tracing::{debug, trace, Level};
|
||||
|
||||
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
|
||||
|
||||
// include modules
|
||||
mod parse_args;
|
||||
|
||||
/// respect environment variables set in .env files
|
||||
/// located in the current call directory
|
||||
/// this is primarily used in testing scenarios (eg. debugging)
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
test_lang: String,
|
||||
log: String,
|
||||
}
|
||||
|
||||
/// export as csv format
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
//use std::ffi::OsStr;
|
||||
use std::io::prelude::*;
|
||||
|
||||
let mut res = t!("csv.export.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
let dt_start: DateTime<Local> = Local::now();
|
||||
|
||||
trace!(target: "csv-test",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
date_start = ?dt_start.to_string());
|
||||
|
||||
// Note: slash syntax also works on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
// open the file descriptor
|
||||
let mut file = File::create(path)?;
|
||||
trace!(target: "csv-export", extension = ?path.extension(), file = ?file);
|
||||
|
||||
// Build the CSV writer and push selected records.
|
||||
//for result in csv_reader.records() {
|
||||
let mut count = 0;
|
||||
file.write_all(b"Allianz DirectCall Protokoll!")?;
|
||||
count += 1;
|
||||
|
||||
let dt_end: DateTime<Local> = Local::now();
|
||||
let duration = dt_end.signed_duration_since(dt_start);
|
||||
println!("Duration: {:#?}", duration);
|
||||
|
||||
trace!(target: "csv-test", record_count = ?count, duration = ?duration);
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.import.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
/// 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>> {
|
||||
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);
|
||||
let dt_start: DateTime<Local> = Local::now();
|
||||
|
||||
trace!(target: "csv-test",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
date_start = ?dt_start.to_string());
|
||||
|
||||
// Note: slash syntax also workd on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
// must be a readable file
|
||||
trace!(target: "csv-test", path = ?path);
|
||||
assert_eq!(path.is_file(), true);
|
||||
|
||||
// only accept files with '.txt' extensions
|
||||
let extension = path.extension();
|
||||
assert_eq!(extension, Some(OsStr::new("txt")));
|
||||
|
||||
// open the file
|
||||
let file = File::open(path)?;
|
||||
|
||||
trace!(target: "csv-test",
|
||||
extension = ?extension,
|
||||
file = ?file,
|
||||
data_list = ?data_list.name);
|
||||
|
||||
// Build the CSV reader and iterate over each record.
|
||||
let mut csv_reader = csv::ReaderBuilder::new()
|
||||
.has_headers(true)
|
||||
.delimiter(b' ')
|
||||
.flexible(true)
|
||||
//.comment(Some(b'#'))
|
||||
//.from_reader(io::stdin());
|
||||
//.from_path(path);
|
||||
.from_reader(file);
|
||||
{
|
||||
// We nest this call in its own scope because of lifetimes.
|
||||
let headers = csv_reader.headers()?;
|
||||
trace!(target: "csv-test", header = ?headers);
|
||||
}
|
||||
|
||||
// Deserialize the input data and push result to target vector
|
||||
let mut count = 0;
|
||||
for result in csv_reader.deserialize() {
|
||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||
// error here.
|
||||
let record: PolicyData = result?;
|
||||
//println!("{:?}", record);
|
||||
|
||||
// WIP: write to redis backend
|
||||
// append the policy_number to the HashMap
|
||||
policy_numbers.insert(record.policy_number, record.policy_code);
|
||||
|
||||
// push record as new vector elements
|
||||
data_list.push(record);
|
||||
|
||||
count +=1;
|
||||
}
|
||||
|
||||
let dt_end: DateTime<Local> = Local::now();
|
||||
let duration = dt_end.signed_duration_since(dt_start);
|
||||
|
||||
trace!(target: "csv-test", record_count = ?count, duration = ?duration);
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.import.finished", lang);
|
||||
trace!(target: "csv-test",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
date_stop = ?dt_end.to_string());
|
||||
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
#[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>> {
|
||||
|
||||
let mut res = t!("policy.validation.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
let dt_start: DateTime<Local> = Local::now();
|
||||
|
||||
trace!(target: "csv-test",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
policy_number = ?policy_number,
|
||||
policy_list = ?policy_list.name,
|
||||
elements = ?policy_list.policy_data.len(),
|
||||
date_start = ?dt_start.to_string());
|
||||
//println!("Policy_number list: {:?}", policy_list.policy_data);
|
||||
|
||||
// WIP: testcode to collect policy_number via iterator
|
||||
//println!("policy_number: {:?}", policy_list.policy_data[1].policy_number);
|
||||
//println!("Policy_number list: {:?}", policy_list.policy_data);
|
||||
// println!("policy_list: {:?} (with {:?} elements)",
|
||||
// policy_list.name, policy_list.policy_data.len());
|
||||
|
||||
|
||||
// policy_list.into_iter()
|
||||
// .filter(|num| matches(w, w1))
|
||||
// .clone
|
||||
// .collect::<Vec<policy_number>>()
|
||||
// let my_num = policy_list.policy_data.iter()
|
||||
// .map(|policy_number| {
|
||||
// policy_number
|
||||
// })
|
||||
// .collect::<Vec<_>>();
|
||||
|
||||
//println!("My policy_numbers: {:?}", my_num);
|
||||
|
||||
// let mut my_policy_list = [
|
||||
// [ ("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19), ],
|
||||
// [ ("Bill", 17), ("Brenda", 16), ("Brad", 18), ("Barbara", 17), ]
|
||||
// ];
|
||||
|
||||
// let teams_in_score_order = teams
|
||||
// .iter_mut()
|
||||
// .map(|team| {
|
||||
// team.sort_by(|&a, &b| a.1.cmp(&b.1).reverse());
|
||||
// team
|
||||
// })
|
||||
// .collect::<Vec<_>>();
|
||||
|
||||
//println!("Teams: {:?}", teams_in_score_order);
|
||||
|
||||
// if policy_list.policy_data.iter().any(|v| v == policy_number) {
|
||||
// println!("{:?} contains {}", policy_list.name, policy_number);
|
||||
// } else {
|
||||
// println!("{:?} doesn't contain {}", policy_list, policy_number);
|
||||
//}
|
||||
|
||||
// let test: Vec<_> = vec!["one", "two", "three"];
|
||||
// let index: usize = test.iter().enumerate().find(|&r| r.1.to_string() == "two".to_string()).unwrap().0;
|
||||
// println!("index: {:?} -> {:?}", index, test[index]);
|
||||
|
||||
//let index: usize = test.iter().enumerate().find(|&r| r.policy_number == "two".to_string()).unwrap().0;
|
||||
|
||||
let mut result = false;
|
||||
match policy_numbers.get(&policy_number) {
|
||||
Some(&policy_code) => {
|
||||
let res = t!("policy.validation.success", lang);
|
||||
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!");
|
||||
println!("{:?}", res);
|
||||
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);
|
||||
|
||||
res = t!("policy.validation.finished", lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
date_stop = ?dt_end.to_string(),
|
||||
duration = ?duration);
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
use dotenv::dotenv;
|
||||
use parse_args::parse_args;
|
||||
//use std::process;
|
||||
//use std::sync::Arc;
|
||||
use tracing_subscriber::fmt;
|
||||
use viperus::Viperus;
|
||||
|
||||
//static DEFAULT_FILTER: &str = concat!(module_path!(), "=", "trace");
|
||||
|
||||
// initialize the tracing subsystem
|
||||
// a drop in replacement for classical logging
|
||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
||||
let span = tracing::span!(Level::TRACE, "csv-test");
|
||||
let _enter = span.enter();
|
||||
let subscriber = fmt::Subscriber::builder()
|
||||
.with_env_filter("trace")
|
||||
//.with_max_level(tracing::Level::DEBUG)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or("en".to_string());
|
||||
let mut res = t!("parse.environment", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||
//debug!(message = ?res, state = ?state);
|
||||
trace!(target: "csv-test", environment = "system", lang = ?lang);
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
match envy::from_env::<Environment>() {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { debug!(target: "csv-test", "{}", e); }
|
||||
}
|
||||
// how to handle unumplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "csv-test", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut v = Viperus::new();
|
||||
|
||||
// parse commandline arguments
|
||||
res = t!("parse.arguments", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
let _ = parse_args(&mut v);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
//trace!(target: "Viperus", "Config results: {:?}", v);
|
||||
|
||||
// main tasks
|
||||
res = t!("main.started", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
// create policy structures
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-Liste");
|
||||
println!("Policy List {:?} ", policy_list.name);
|
||||
|
||||
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 csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang) {
|
||||
Ok(count) => {
|
||||
println!("Imported {:?} records", count);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running Csv-Test: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
||||
// Ok(true) => {
|
||||
// use Hashmap method 'get' to check if we have the given key
|
||||
match policy_numbers.get(&test_policy_number) {
|
||||
Some(&policy_code) => {
|
||||
let res = t!("policy.validation.success", lang);
|
||||
println!("{:?}", res);
|
||||
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
|
||||
let mut csv_export_path = v.get::<String>("export_file").unwrap();
|
||||
match export(&mut csv_export_path, &lang) {
|
||||
Ok(count) => {
|
||||
println!("Exported {:?} records", count);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running CSV-Export: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("main.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_policy_number() {
|
||||
// Takes a reference and returns Option<&V>
|
||||
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 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);
|
||||
|
||||
assert_eq!(count.unwrap(), 15498);
|
||||
|
||||
}
|
||||
216
crates/advotracker/examples/csv-test/parse_args.rs
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// parse CLI commandline arguments with clap
|
||||
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
|
||||
|
||||
//use log::{debug, info, trace, warn};
|
||||
use std::env;
|
||||
use tracing::trace;
|
||||
use viperus::Viperus;
|
||||
|
||||
/// Parse the commandline arguments and preset default values
|
||||
/// Precedence: defaults -> config-file -> environment -> commandline
|
||||
pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if cfg!(feature = "fmt-clap") {
|
||||
trace!(target: "Viperus", "Viperus feature 'fmt-clap' enabled.");
|
||||
println!("Using feature fmt-clap");
|
||||
}
|
||||
|
||||
// preset default key/value pairs (lowest priority)
|
||||
v.add_default("config_file", String::from("csv_import.ron"));
|
||||
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("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("
|
||||
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")
|
||||
.template(
|
||||
"\
|
||||
{bin} v{version}
|
||||
{about}
|
||||
|
||||
{all-args}
|
||||
|
||||
(C) 2020 {author}
|
||||
{after-help}",
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("configFile")
|
||||
.short("c")
|
||||
.long("configFile")
|
||||
.value_name("FILE")
|
||||
.help("Select a config file")
|
||||
.default_value("csv_import.ron")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("importFile")
|
||||
.short("i")
|
||||
.long("importFile")
|
||||
.help("Select source file for the csv-import")
|
||||
.default_value("POLLFNR_WOECHENTLICH.txt")
|
||||
//.default_value("POLLFNR_MINI.txt")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("exportFile")
|
||||
.short("e")
|
||||
.long("exportFile")
|
||||
.help("Select target file for the csv-export")
|
||||
.default_value("RA-Hiedemann_DirectCall.txt")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("fromEmailAddress")
|
||||
.short("f")
|
||||
.long("fromEmailAddress")
|
||||
.help("Select the sender email-address (From:)")
|
||||
.default_value("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("toEmailAddress")
|
||||
.short("t")
|
||||
.long("toEmailAddress")
|
||||
.help("Select the target email-address (To:)")
|
||||
.default_value("Allianz RA-Hotline <smr-rahotline@allianz.de>")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("testPolicyNumber")
|
||||
.short("p")
|
||||
.long("testPolicyNumber")
|
||||
.help("Test validity of given policy number")
|
||||
//.default_value("")
|
||||
.takes_value(true),
|
||||
)
|
||||
// .arg(
|
||||
// Arg::with_name("username")
|
||||
// .short("u")
|
||||
// .long("username")
|
||||
// .help("Sets username")
|
||||
// .takes_value(true),
|
||||
// )
|
||||
// .arg(
|
||||
// Arg::with_name("password")
|
||||
// .short("P")
|
||||
// .long("password")
|
||||
// .help("Sets password")
|
||||
// .takes_value(true),
|
||||
// )
|
||||
.arg(
|
||||
Arg::with_name("verbose")
|
||||
.short("v")
|
||||
.long("verbose")
|
||||
.help("Sets verbosity level")
|
||||
.multiple(true),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if matches.occurrences_of("verbose") > 0 {
|
||||
// clap is using i64, viperus i32
|
||||
let n = matches.occurrences_of("verbose") as i32;
|
||||
v.add("verbose", n);
|
||||
}
|
||||
|
||||
// preset the prefix for relevant environment variables ("ADVOTRACKER_")
|
||||
let mut env_prefix: String = crate_name!().to_uppercase();
|
||||
env_prefix.push_str("_");
|
||||
v.set_env_prefix(&env_prefix);
|
||||
|
||||
// respect dotenv environment (e.g for testing)
|
||||
// -> overwrites the preset default values
|
||||
println!(
|
||||
"RUST_LOG={}",
|
||||
dotenv::var("RUST_LOG").unwrap_or_else(|_| String::from("None"))
|
||||
);
|
||||
|
||||
// enable caching and automatic update of environment values
|
||||
v.cache(true);
|
||||
v.automatic_env(true);
|
||||
|
||||
// load user selected call arguments
|
||||
// -> overwrites values given via environment variables
|
||||
v.load_clap(matches)?;
|
||||
|
||||
// bond the clap names to camel_case rust variable names
|
||||
v.bond_clap("configFile", "config_file");
|
||||
v.bond_clap("importFile", "import_file");
|
||||
v.bond_clap("exportFile", "export_file");
|
||||
v.bond_clap("toEmailAddress", "to_email_address");
|
||||
v.bond_clap("fromEmailAddress", "from_email_address");
|
||||
v.bond_clap("testPolicyNumber", "test_policy_number");
|
||||
//v.bond_clap("username", "username");
|
||||
//v.bond_clap("password", "password");
|
||||
v.bond_clap("verbose", "verbose");
|
||||
|
||||
trace!("verbose {:?}", v.get::<i32>("verbose").unwrap());
|
||||
if v.get::<i32>("verbose").unwrap() > 0 {
|
||||
println!(
|
||||
"config_file: {:?}",
|
||||
v.get::<String>("config_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"import_file: {:?}",
|
||||
v.get::<String>("import_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"export_file: {:?}",
|
||||
v.get::<String>("export_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"to_email_address: {:?}",
|
||||
v.get::<String>("to_email_address").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"from_email_address: {:?}",
|
||||
v.get::<String>("from_email_address").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"test_policy_number: {:?}",
|
||||
v.get::<String>("test_policy_number").unwrap_or_default()
|
||||
);
|
||||
// println!(
|
||||
// "username: {:?}",
|
||||
// v.get::<String>("username").unwrap_or_default()
|
||||
// );
|
||||
// println!(
|
||||
// "password: {:?}",
|
||||
// v.get::<String>("password").unwrap_or_default()
|
||||
// ); // only for testing now
|
||||
|
||||
println!(
|
||||
"verbosity level: {:?}",
|
||||
v.get::<i32>("verbose").unwrap_or_default()
|
||||
);
|
||||
}
|
||||
|
||||
if v.get::<i32>("verbose").unwrap() > 1 {
|
||||
println!("\nEnvironment:");
|
||||
for (key, value) in env::vars() {
|
||||
println!("{}={}", key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
40
crates/advotracker/examples/email_test.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use lettre::{
|
||||
transport::smtp::authentication::Credentials,
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let email = Message::builder()
|
||||
.from("Info <info@networkx.de>".parse().unwrap())
|
||||
.reply_to("Support <support@networkx.de>".parse().unwrap())
|
||||
.to("Ralf Zerres <ralf.zerres@networkx.de>".parse().unwrap())
|
||||
.subject("Eine advotracker eMail")
|
||||
.body("Eine neue advotracker eMail!".to_string())
|
||||
.unwrap();
|
||||
|
||||
// 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());
|
||||
|
||||
// Open a remote connection to relay server
|
||||
//let mailer = SmtpTransport::relay("nwxex.networkx.de")
|
||||
let mailer = SmtpTransport::relay("smtp.gmail.com")
|
||||
.unwrap()
|
||||
.credentials(creds)
|
||||
.build();
|
||||
|
||||
// Open a remote connection to gmail using STARTTLS
|
||||
// let mailer = SmtpTransport::starttls_relay("nwxex.networkx.de")
|
||||
// .unwrap()
|
||||
// .credentials(creds)
|
||||
// .build();
|
||||
|
||||
// Open a local connection on port 25
|
||||
//let mailer = SmtpTransport::unencrypted_localhost();
|
||||
|
||||
// Send the email
|
||||
match mailer.send(&email) {
|
||||
Ok(_) => println!("Email sent successfully!"),
|
||||
Err(e) => panic!("Could not send email: {:?}", e),
|
||||
}
|
||||
}
|
||||
124
crates/advotracker/examples/increment_progress_bar.rs
Normal file
@@ -0,0 +1,124 @@
|
||||
use std::collections::HashMap;
|
||||
//use std::sync::mpsc;
|
||||
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::shell::WindowRequest;
|
||||
|
||||
static ID_CHECK_POLICY_NUMBER: &'static str = "ID_CHECK_POLICY_NUMBER";
|
||||
static ID_PROGRESS_BAR: &'static str = "ID_PROGRESS_BAR";
|
||||
|
||||
enum Action {
|
||||
ParsePolicyNumber
|
||||
}
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
struct MainViewState {
|
||||
action: Option<Action>,
|
||||
progress_bar: Entity,
|
||||
text_box: Entity,
|
||||
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 !");
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
// if there is an action, process it
|
||||
if let Some(action) = &self.action {
|
||||
match action {
|
||||
Action::ParsePolicyNumber => {
|
||||
let value_to_parse = ctx.get_widget(self.text_box).get::<String16>("text").clone();
|
||||
self.parse_policy_number(value_to_parse, ctx);
|
||||
}
|
||||
}
|
||||
// Reset action
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: Action) {
|
||||
self.action = Some(action);
|
||||
}
|
||||
|
||||
fn parse_policy_number(&mut self, _value: String16, ctx: &mut Context) {
|
||||
self.import_csv(ctx);
|
||||
}
|
||||
|
||||
fn import_csv(&mut self, ctx: &mut Context) {
|
||||
// code to import csv file into a hashmap
|
||||
// will read in number_of_records = 100%
|
||||
// progress_counter should be incremented, if
|
||||
// read_in_loop will reach next 10% -> self.progress_counter += 0.1
|
||||
// now fire an event to update the widget
|
||||
|
||||
// question: how to fire up the event inside import_csv function,
|
||||
// without the need to mute "ID_CHECK_POLICY_NUMBER" ?
|
||||
|
||||
// given code just increments, if you change "ID_CHECK_POLICY_NUMBER"
|
||||
self.progress_counter += 0.1;
|
||||
self.update_progress(ctx);
|
||||
}
|
||||
|
||||
fn update_progress(&self, ctx: &mut Context) {
|
||||
// create a mpsc::Sender<WindowRequest> object
|
||||
let sender = ctx.window_sender();
|
||||
let mut pgbar = ctx.get_widget(self.progress_bar);
|
||||
pgbar.set::<f64>("val", self.progress_counter);
|
||||
// redraw screen if sender has changed
|
||||
// only way to trigger a redraw: create an event
|
||||
sender.send(WindowRequest::Redraw).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
widget!(MainView<MainViewState>);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self
|
||||
.margin(32.0)
|
||||
.child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.h_align("center")
|
||||
.v_align("top")
|
||||
.spacing(8.0)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_CHECK_POLICY_NUMBER)
|
||||
.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);
|
||||
})
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id(ID_PROGRESS_BAR)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("incroment_progress_bar skeleton")
|
||||
.position((100.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
.resizeable(true)
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
23
crates/advotracker/examples/messages_test/data/constants.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// constants
|
||||
pub static ID_RECEIVER: &str = "Receiver_Widget";
|
||||
pub static ID_RECEIVER_CONTAINER: &str = "reciever_container";
|
||||
pub static ID_RECEIVER_PROGRESS_BAR: &str = "receiver_progress_bar";
|
||||
pub static ID_RECEIVER_TEXT_BLOCK: &str = "receiver_text_block";
|
||||
//pub static ID_RECEIVER_MESSAGE_BOX: &str = "receiver_message_box";
|
||||
pub static ID_RECEIVER_MESSAGE_BLOCK: &str = "receiver_message_block";
|
||||
//pub static ID_RECEIVER_MESSAGE: &str = "receiver_message";
|
||||
|
||||
pub static ID_SENDER: &str = "Sender_Widget";
|
||||
pub static ID_SENDER_CONTAINER: &str = "sender_container";
|
||||
pub static ID_SENDER_GRID: &str = "sender_grid";
|
||||
pub static ID_SENDER_BUTTON: &str = "sender_button";
|
||||
pub static ID_SENDER_TEXT_BOX: &str = "sender_text_box";
|
||||
|
||||
pub static COLOR_BOMBAY: &str = "#adb3B8";
|
||||
9
crates/advotracker/examples/messages_test/data/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// provides orbtk widgets constants
|
||||
pub mod constants;
|
||||
32
crates/advotracker/examples/messages_test/main.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
mod main_view;
|
||||
mod receiver;
|
||||
mod sender;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.name("Main")
|
||||
.title("OrbTK: example send/receive messages")
|
||||
.position((100.0, 100.0))
|
||||
.resizeable(true)
|
||||
.size(450.0, 500.0)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
48
crates/advotracker/examples/messages_test/main_view.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
receiver::receiver_view::ReceiverView,
|
||||
sender::sender_view::SenderView,
|
||||
};
|
||||
|
||||
// constants
|
||||
pub static ID_SENDER_VIEW: &str = "sender_view";
|
||||
pub static ID_RECEIVER_VIEW: &str = "receiver_view";
|
||||
|
||||
widget!(MainView {
|
||||
//sender_view: ,
|
||||
//receiver_view:
|
||||
});
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
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(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.child(sender_view)
|
||||
.child(receiver_view)
|
||||
.build(ctx)
|
||||
)
|
||||
// .child(
|
||||
// TabWidget::new()
|
||||
// .tab(ID_SENDER_VIEW, SenderView::new().build(ctx))
|
||||
// .tab(ID_RECEIVER_VIEW, ReceiverView::new().build(ctx))
|
||||
// .build(ctx),
|
||||
// )
|
||||
}
|
||||
}
|
||||
8
crates/advotracker/examples/messages_test/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
// The starting point (Main View).
|
||||
pub mod main_view;
|
||||
|
||||
/// Receiver widget
|
||||
pub mod receiver;
|
||||
|
||||
/// Sender widget.
|
||||
pub mod sender;
|
||||
@@ -0,0 +1,5 @@
|
||||
/// The reciever state
|
||||
pub mod receiver_state;
|
||||
|
||||
/// The receiver view
|
||||
pub mod receiver_view;
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::sender::sender_state::{SenderAction, SenderState};
|
||||
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `SenderView` widget.
|
||||
pub enum TestMessageAction {
|
||||
// Toggle visibility of a message TextBox.
|
||||
ToggleMessageBox
|
||||
}
|
||||
|
||||
/// Valid `structure members` of the `ReceiverState` used to react on
|
||||
/// state changes inside the `ReceiverView` widget.
|
||||
#[derive(Default, AsAny)]
|
||||
pub struct ReceiverState {
|
||||
message_box: Option<Entity>,
|
||||
progress_bar: Entity
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `ReceiverState`.
|
||||
impl ReceiverState {
|
||||
fn toggle_message_box(&self, ctx: &mut Context) {
|
||||
if let Some(message_box) = self.message_box {
|
||||
ctx.get_widget(message_box)
|
||||
.set("visibility", Visibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait methods provided for the `SenderState`
|
||||
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")
|
||||
.expect("Cannot find ProgressBar!");
|
||||
}
|
||||
|
||||
// handle messages targeting the view
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context
|
||||
) {
|
||||
for message in messages.read::<SenderAction>() {
|
||||
match message {
|
||||
SenderAction::UpdateProgress(amount) => {
|
||||
println!("Message received");
|
||||
let mut progress_bar = ctx.get_widget(self.progress_bar);
|
||||
let current_progress = progress_bar.clone::<f64>("val");
|
||||
progress_bar.set::<f64>("val", current_progress + amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
for action in messages.read::<TestMessageAction>() {
|
||||
match action {
|
||||
TestMessageAction::ToggleMessageBox => {
|
||||
self.toggle_message_box(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::receiver::receiver_state::{TestMessageAction, ReceiverState};
|
||||
|
||||
widget!(ReceiverView<ReceiverState>);
|
||||
|
||||
impl Template for ReceiverView {
|
||||
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("ReceiverView")
|
||||
.child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.spacing(16)
|
||||
.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)
|
||||
)
|
||||
}
|
||||
}
|
||||
5
crates/advotracker/examples/messages_test/sender/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
/// The sender state
|
||||
pub mod sender_state;
|
||||
|
||||
/// The sender view
|
||||
pub mod sender_view;
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `SenderView` widget.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum SenderAction {
|
||||
UpdateProgress(f64),
|
||||
}
|
||||
|
||||
/// Valid `structure members` of the `SenderState` used to react on
|
||||
/// state changes inside the `SenderView` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct SenderState {
|
||||
// actions
|
||||
actions: Vec<SenderAction>,
|
||||
// entity that will receive the message
|
||||
target: Entity
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `SenderState`.
|
||||
impl SenderState {
|
||||
/// Sending message 'UpdateProgress'
|
||||
pub fn send_message(&mut self) {
|
||||
println!("Sender: push 'UpdateProgress' action");
|
||||
self.actions.push(SenderAction::UpdateProgress(0.1));
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait methods provided for the `SenderState`
|
||||
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!"));
|
||||
}
|
||||
|
||||
// update entities, before we render the view
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
let actions: Vec<SenderAction> = self.actions.drain(..).collect();
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
SenderAction::UpdateProgress(amount) => {
|
||||
ctx.send_message(SenderAction::UpdateProgress(amount), self.target);
|
||||
println!("Sender: send message 'SenderAction::UpdateProgress'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::sender::sender_state::{SenderAction, SenderState};
|
||||
|
||||
widget!(SenderView<SenderState> {
|
||||
// the Entity of the widget that will receive the messages
|
||||
target: u32
|
||||
});
|
||||
|
||||
impl Template for SenderView {
|
||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("SenderView")
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Click me to send a message!")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.on_click(move |states, _entity| {
|
||||
states.get_mut::<SenderState>(id).send_message();
|
||||
//states.send_message(SenderAction::UpdateProgress, id);
|
||||
//ctx.send_message(TestMessageAction::ToggleMessageBox, id);
|
||||
false
|
||||
})
|
||||
.build(bc)
|
||||
)
|
||||
}
|
||||
}
|
||||
143
crates/advotracker/examples/my_progress_bar.rs
Normal file
@@ -0,0 +1,143 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
//|---------------------------------------------------------------------------|
|
||||
//|------------------------------SENDER---------------------------------------|
|
||||
//|---------------------------------------------------------------------------|
|
||||
|
||||
// View
|
||||
|
||||
widget!(SenderWidget<SenderState> {
|
||||
// the Entity of the widget that will receive the messages
|
||||
target: u32
|
||||
});
|
||||
|
||||
impl Template for SenderWidget {
|
||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||
self.name("SenderWidget")
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Click me to send a message!")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.on_click(move |states, _entity| {
|
||||
states.get_mut::<SenderState>(id).send_message();
|
||||
false
|
||||
})
|
||||
.build(bc)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// States
|
||||
|
||||
enum Action {
|
||||
UpdateProgress(f64)
|
||||
}
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
struct SenderState {
|
||||
actions: Vec<Action>,
|
||||
target: Entity
|
||||
}
|
||||
|
||||
impl SenderState {
|
||||
fn send_message(&mut self) {
|
||||
self.actions.push(Action::UpdateProgress(0.1));
|
||||
}
|
||||
}
|
||||
|
||||
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!"));
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
let actions: Vec<Action> = self.actions.drain(..).collect();
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
Action::UpdateProgress(amount) => {
|
||||
ctx.send_message(Action::UpdateProgress(amount), self.target);
|
||||
println!("Message sent!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//|---------------------------------------------------------------------------|
|
||||
//|------------------------------RECEIVER-------------------------------------|
|
||||
//|---------------------------------------------------------------------------|
|
||||
|
||||
// View
|
||||
|
||||
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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// States
|
||||
|
||||
#[derive(Default, AsAny)]
|
||||
struct ReceiverState {
|
||||
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!");
|
||||
}
|
||||
|
||||
fn messages(&mut self, mut messages: MessageReader, _registry: &mut Registry, ctx: &mut Context) {
|
||||
for action in messages.read::<Action>() {
|
||||
match action {
|
||||
Action::UpdateProgress(amount) => {
|
||||
println!("Message received");
|
||||
let mut progress_bar = ctx.get_widget(self.progress_bar);
|
||||
let current_progress = progress_bar.clone::<f64>("val");
|
||||
progress_bar.set::<f64>("val", current_progress + amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//|---------------------------------------------------------------------------|
|
||||
//|--------------------------------MAIN---------------------------------------|
|
||||
//|---------------------------------------------------------------------------|
|
||||
|
||||
pub fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
let receiver = ReceiverWidget::new().build(ctx);
|
||||
|
||||
let sender = SenderWidget::new()
|
||||
// the entity of the target (receiver)
|
||||
.target(receiver.0)
|
||||
.build(ctx);
|
||||
|
||||
Window::new()
|
||||
.title("Messages example")
|
||||
.position((100.0, 100.0))
|
||||
.resizeable(true)
|
||||
.size(450.0, 500.0)
|
||||
.child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.child(sender)
|
||||
.child(receiver)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
112
crates/advotracker/examples/pager_test.rs
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
fn main() {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("OrbTk - Pager test")
|
||||
.position((100, 100))
|
||||
.size(800, 600)
|
||||
.resizeable(true)
|
||||
.child(PagerTestView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
// Views
|
||||
|
||||
widget!(
|
||||
PagerTestView<PagerTestState> {}
|
||||
);
|
||||
|
||||
impl Template for PagerTestView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let pager = Pager::new()
|
||||
.attach(Grid::row(1))
|
||||
.child(TextBlock::new().text("Page 1").build(ctx))
|
||||
.child(TextBlock::new().text("Page 2").build(ctx))
|
||||
.child(TextBlock::new().text("Page 3").build(ctx))
|
||||
.build(ctx);
|
||||
|
||||
let next_button = Button::new()
|
||||
.style("button_single_content")
|
||||
.icon(material_icons_font::MD_KEYBOARD_ARROW_RIGHT)
|
||||
.h_align("end")
|
||||
.attach(Grid::row(2))
|
||||
.enabled(("next_enabled", pager))
|
||||
.text("next")
|
||||
.on_click(move |states, _| {
|
||||
states.send_message(PagerAction::Next, pager);
|
||||
true
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
let previous_button = Button::new()
|
||||
.style("button_single_content")
|
||||
.icon(material_icons_font::MD_KEYBOARD_ARROW_LEFT)
|
||||
.h_align("start")
|
||||
.attach(Grid::row(2))
|
||||
.enabled(("previous_enabled", pager))
|
||||
.text("previous")
|
||||
.on_click(move |states, _| {
|
||||
states.send_message(PagerAction::Previous, pager);
|
||||
true
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
self.child(
|
||||
Grid::new()
|
||||
.margin(16)
|
||||
.rows("32, *, 32")
|
||||
.child(TextBlock::new().text("Pager Widget").build(ctx))
|
||||
.child(pager)
|
||||
.child(previous_button)
|
||||
.child(next_button)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// States
|
||||
static ID_PAGER_TEST: &str = "id_pager_test";
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum PagerTestAction {}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `PagerTest` widget.
|
||||
#[derive(AsAny, Debug, Default)]
|
||||
pub struct PagerTestState {
|
||||
pager_test: Entity,
|
||||
}
|
||||
|
||||
/// Method definitions, that react on any given state change inside the `Menu` widget.
|
||||
impl PagerTestState {
|
||||
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||
self.pager_test = ctx.child(ID_PAGER_TEST).entity();
|
||||
}
|
||||
}
|
||||
|
||||
impl State for PagerTestState {
|
||||
/// Handle messages for the `PagerTestState`
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<PagerTestAction>() {
|
||||
ctx.send_message(message, self.pager_test);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
crates/advotracker/examples/pdf_check_rs.example
Normal file
@@ -0,0 +1,37 @@
|
||||
//extern crate pdf_extract;
|
||||
//extern crate lopdf;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::path;
|
||||
use std::io::BufWriter;
|
||||
use std::fs::File;
|
||||
use pdf_extract::*;
|
||||
use lopdf::*;
|
||||
|
||||
fn main() {
|
||||
//let output_kind = "html";
|
||||
//let output_kind = "txt";
|
||||
//let output_kind = "svg";
|
||||
let file = env::args().nth(1).unwrap();
|
||||
let output_kind = env::args().nth(2).unwrap_or_else(|| "txt".to_owned());
|
||||
println!("{}", file);
|
||||
let path = path::Path::new(&file);
|
||||
let filename = path.file_name().expect("expected a filename");
|
||||
let mut output_file = PathBuf::new();
|
||||
output_file.push(filename);
|
||||
output_file.set_extension(&output_kind);
|
||||
let mut output_file = BufWriter::new(File::create(output_file).expect("could not create output"));
|
||||
let doc = Document::load(path).unwrap();
|
||||
|
||||
print_metadata(&doc);
|
||||
|
||||
let mut output: Box<dyn OutputDev> = match output_kind.as_ref() {
|
||||
"txt" => Box::new(PlainTextOutput::new(&mut output_file as &mut dyn std::io::Write)),
|
||||
"html" => Box::new(HTMLOutput::new(&mut output_file)),
|
||||
"svg" => Box::new(SVGOutput::new(&mut output_file)),
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
output_doc(&doc, output.as_mut());
|
||||
}
|
||||
65
crates/advotracker/examples/ron_decode_test.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
use ron::de::from_str;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Config {
|
||||
boolean: bool,
|
||||
float: f32,
|
||||
map: HashMap<u8, char>,
|
||||
nested: Nested,
|
||||
option: Option<String>,
|
||||
tuple: (u32, u32),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Nested {
|
||||
a: String,
|
||||
b: char,
|
||||
}
|
||||
|
||||
const CONFIG: &str = "
|
||||
/*
|
||||
* RON now has multi-line (C-style) block comments!
|
||||
* They can be freely nested:
|
||||
* /* This is a nested comment */
|
||||
* If you just want a single-line comment,
|
||||
* do it like here:
|
||||
// Just put two slashes before the comment and the rest of the line
|
||||
// can be used freely!
|
||||
*/
|
||||
|
||||
// Note that block comments can not be started in a line comment
|
||||
// (Putting a /* here will have no effect)
|
||||
|
||||
(
|
||||
boolean: true,
|
||||
float: 8.2,
|
||||
map: {
|
||||
1: '1',
|
||||
2: '4',
|
||||
3: '9',
|
||||
4: '1',
|
||||
5: '2',
|
||||
6: '3',
|
||||
},
|
||||
nested: Nested(
|
||||
a: \"Decode me!\",
|
||||
b: 'z',
|
||||
),
|
||||
option: Some(\t \"Weird formatting!\" \n\n ),
|
||||
tuple: (3 /*(2 + 1)*/, 7 /*(2 * 5 - 3)*/),
|
||||
)";
|
||||
|
||||
fn main() {
|
||||
let config: Config = match from_str(CONFIG) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
println!("Failed to load config: {}", e);
|
||||
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
println!("Config: {:?}", &config);
|
||||
}
|
||||
50
crates/advotracker/examples/ron_encode_test.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use ron::ser::{to_string_pretty, PrettyConfig};
|
||||
use serde::Serialize;
|
||||
use std::{collections::HashMap, iter::FromIterator};
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Config {
|
||||
float: (f32, f64),
|
||||
tuple: TupleStruct,
|
||||
map: HashMap<u8, char>,
|
||||
nested: Nested,
|
||||
var: Variant,
|
||||
array: Vec<()>,
|
||||
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct TupleStruct((), bool);
|
||||
|
||||
#[derive(Serialize)]
|
||||
enum Variant {
|
||||
A(u8, &'static str),
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Nested {
|
||||
a: String,
|
||||
b: char,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let data = Config {
|
||||
float: (2.18, -1.1),
|
||||
tuple: TupleStruct((), false),
|
||||
map: HashMap::from_iter(vec![(0, '1'), (1, '2'), (3, '5'), (8, '1')]),
|
||||
nested: Nested {
|
||||
a: "Hello from \"RON\"".to_string(),
|
||||
b: 'b',
|
||||
},
|
||||
var: Variant::A(!0, ""),
|
||||
array: vec![(); 3],
|
||||
};
|
||||
|
||||
let pretty = PrettyConfig::new()
|
||||
.with_depth_limit(2)
|
||||
.with_separate_tuple_members(true)
|
||||
.with_enumerate_arrays(true);
|
||||
let s = to_string_pretty(&data, pretty).expect("Serialization failed");
|
||||
|
||||
println!("{}", s);
|
||||
}
|
||||
49
crates/advotracker/examples/ron_test.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use ron::ser::{to_string_pretty, PrettyConfig};
|
||||
use serde::Serialize;
|
||||
use std::{collections::HashMap, iter::FromIterator};
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Config {
|
||||
float: (f32, f64),
|
||||
tuple: TupleStruct,
|
||||
map: HashMap<u8, char>,
|
||||
nested: Nested,
|
||||
var: Variant,
|
||||
array: Vec<()>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct TupleStruct((), bool);
|
||||
|
||||
#[derive(Serialize)]
|
||||
enum Variant {
|
||||
A(u8, &'static str),
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Nested {
|
||||
a: String,
|
||||
b: char,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let data = Config {
|
||||
float: (2.18, -1.1),
|
||||
tuple: TupleStruct((), false),
|
||||
map: HashMap::from_iter(vec![(0, '1'), (1, '2'), (3, '5'), (8, '1')]),
|
||||
nested: Nested {
|
||||
a: "Hello from \"RON\"".to_string(),
|
||||
b: 'b',
|
||||
},
|
||||
var: Variant::A(!0, ""),
|
||||
array: vec![(); 3],
|
||||
};
|
||||
|
||||
let pretty = PrettyConfig::new()
|
||||
.with_depth_limit(2)
|
||||
.with_separate_tuple_members(true)
|
||||
.with_enumerate_arrays(true);
|
||||
let s = to_string_pretty(&data, pretty).expect("Serialization failed");
|
||||
|
||||
println!("{}", s);
|
||||
}
|
||||
283
crates/advotracker/examples/size_test.rs
Normal file
@@ -0,0 +1,283 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
fn main() {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("OrbTk - Test Size/Bounds")
|
||||
.position((100.0, 100.0))
|
||||
//.size(200.0, 150.0)
|
||||
.size(800.0, 600.0)
|
||||
//.min_size(160.0, 120.0)
|
||||
//.max_size(240.0, 180.0)
|
||||
.always_on_top(true)
|
||||
.resizeable(true)
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
widget!(
|
||||
MainView {
|
||||
policy_number: String16
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
let ticket_data_header_bar = Container::new()
|
||||
//.id(ID_TICKET_DATA_HEADER_CONTAINER)
|
||||
//.style(STYLE_HEADER_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column_span(2))
|
||||
.child(
|
||||
Grid::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.id(ID_TICKET_DATA_HEADER_GRID)
|
||||
.style("header")
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.text("Ticket Data")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
//.child(ticket_data_button_menu)
|
||||
.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)
|
||||
.name("TicketdataContainer")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
//.margin(16)
|
||||
.padding(14)
|
||||
.border_brush("#dfebf5")
|
||||
.border_radius(0)
|
||||
.border_width(1)
|
||||
.child(
|
||||
Grid::new()
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto") // Label
|
||||
.push(14) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(4) // Delimiter
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 4
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 6
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 8
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.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))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel1")
|
||||
.text("Policy number")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
//.foreground("#516475")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox1")
|
||||
.text("9999999990")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel2")
|
||||
.text("Policy holder")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox2")
|
||||
.text("Name des Versicherungsnehmers")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel3")
|
||||
.text("Deductible")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox3")
|
||||
.text("im Beratungsgespräch erfragen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel4")
|
||||
.text("Callback number")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox4")
|
||||
.water_mark("wie zu erreichen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel5")
|
||||
.text("Callback date")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox5")
|
||||
.water_mark("Rückruf gewünscht um")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel6")
|
||||
.water_mark("Harm type")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox6")
|
||||
.water_mark("Rechtsproblem/Schadenstyp")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(0))
|
||||
.name("TextLabel7")
|
||||
.text("IVR comment")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(2))
|
||||
.name("TextBox7")
|
||||
.water_mark("Rechtsrat / Kommentar zu Haftungs, bzw. Deckung")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_action = Stack::new()
|
||||
//.id(ID_TICKET_DATA_STACK)
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column(1))
|
||||
.h_align("end")
|
||||
.v_align("top")
|
||||
.orientation("horizontal")
|
||||
.visibility(Visibility::Collapsed)
|
||||
//.spacing("4")
|
||||
|
||||
.child(
|
||||
Button::new()
|
||||
.margin(14)
|
||||
.name("TicketdataContainer")
|
||||
.text("Senden")
|
||||
.icon(material_icons_font::MD_MAIL)
|
||||
.on_click(move |_ctx, _| {
|
||||
println!("WIP: send mail");
|
||||
// ctx.get_mut::<MenuState>(id)
|
||||
// .set_action(MenuAction::CreateMenu(ID_MENU_STACK));
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
// Starter page: Ticket Data Widget
|
||||
self.name("TicketdataView")
|
||||
.child(
|
||||
Grid::new()
|
||||
//.id(ID_TICKET_DATA_WIDGET)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50)
|
||||
.push("*")
|
||||
.push(50)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.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
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
206
crates/advotracker/src/bin/policycheck.rs
Normal file
@@ -0,0 +1,206 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
// fn get_theme() -> ThemeValue {
|
||||
// //ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
// ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
// .extension_css(WIDGET_EXT)
|
||||
// .build()
|
||||
// }
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity)
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
pub struct MainViewState {
|
||||
action: Option<Action>,
|
||||
}
|
||||
|
||||
impl Default for MainViewState {
|
||||
fn default() -> Self {
|
||||
MainViewState { action: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: impl Into<Option<Action>>) {
|
||||
self.action = action.into();
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
// Action::ClearText => {
|
||||
// ctx.widget().set("policynumber", String16::from(""));
|
||||
// }
|
||||
// Action::ValueOk => {
|
||||
// //let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
// //let text = text_box.text_mut();
|
||||
// //ctx.widget().set("policynumber", background("#4d4c4c"));
|
||||
// }
|
||||
// Action::ValueNone => {
|
||||
// //let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
// //let text = text_box.text_mut();
|
||||
// //ctx.widget().set("policynumber", background("#5b0f22"));
|
||||
//}
|
||||
Action::EntryActivated(entity) => {
|
||||
//let text = ctx.get_widget(entity).clone::<String>("text");
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String>("text");
|
||||
println!("got value policynumber: {}", text);
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String>("text");
|
||||
println!("entry changed: {}", text);
|
||||
}
|
||||
}
|
||||
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
.style("header")
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
widget!(
|
||||
MainView<MainViewState> {
|
||||
sum_policynumbers: usize,
|
||||
policynumber: String16,
|
||||
result: String16
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.name("MainView").child(
|
||||
Grid::new()
|
||||
.background("#fafafa")
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(150.0)
|
||||
.push("*")
|
||||
.push(150.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("*")
|
||||
.push("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.element("policyholder_check")
|
||||
.margin((4.0, 24.0, 24.0, 4.0))
|
||||
.min_width(180.0)
|
||||
.min_height(80.0)
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
Stack::new()
|
||||
.spacing(8.0)
|
||||
.orientation("vertical")
|
||||
.h_align("center")
|
||||
//.child(create_header(ctx, "Validation number policyholder"))
|
||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||
.child(
|
||||
TextBox::new()
|
||||
.foreground("#9dafbf")
|
||||
.background("#fafafa")
|
||||
.border_brush("#5b0f22")
|
||||
.border_width(5)
|
||||
.border_radius(15)
|
||||
//.name("policynumber")
|
||||
.focused(true)
|
||||
.water_mark("Versicherungs-Nr...")
|
||||
.text(("policynumber", id))
|
||||
.font_size(24.0)
|
||||
.h_align("stretch")
|
||||
.on_activate(move |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed("text", move |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.element("text-block")
|
||||
.id("result")
|
||||
.min_width(80.0)
|
||||
.max_width(180.0)
|
||||
//.text("Result:")
|
||||
.text("Ergebnis:")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.class("logo_customer")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("assets/images/customer_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.class("logo_vendor")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("assets/images/networkx_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
) // MainView
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker example")
|
||||
.name("MainWindow")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.position((-500.0, -100.0))
|
||||
.size(480.0, 260.0)
|
||||
.min_width(460.0)
|
||||
.min_height(180.0)
|
||||
.resizeable(true)
|
||||
//.theme(get_theme())
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
// helper to request MainViewState
|
||||
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
|
||||
states.get_mut(id)
|
||||
}
|
||||
1
crates/advotracker/src/bin/resources
Symbolic link
@@ -0,0 +1 @@
|
||||
../../resources
|
||||
167
crates/advotracker/src/data/constants.rs
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// Component Values (Properties)
|
||||
pub static PROP_ADVOTRACKER: &str = "advotracker";
|
||||
|
||||
pub static PROP_MAIL_CC_1: &str = "info@hiedemann.de";
|
||||
pub static PROP_MAIL_CC_2: &str = "service@hiedemann.de";
|
||||
pub static PROP_MAIL_BCC_1: &str = "Networkx Support <support@networkx.de>";
|
||||
pub static PROP_MAIL_BCC_2: &str = "knoche@hiedemann.de";
|
||||
pub static PROP_MAIL_FROM: &str = "Kanzlei Hiedemann <info@heidemann.de>";
|
||||
pub static PROP_MAIL_REPLY: &str = "Kanzlei Hiedemann <info@heidemann.de>";
|
||||
pub static PROP_MAIL_SUBJECT: &str = "ZMB Allianz - neues Mandat";
|
||||
pub static PROP_MAIL_TO_1: &str = "allianz@ponschab-partner.com";
|
||||
pub static PROP_MAIL_TO_2: &str = "kontakt@chevalier.law";
|
||||
pub static PROP_MAIL_TO_3: &str = "kontakt@metamedlaw.de";
|
||||
pub static PROP_MAIL_TO_4: &str = "sekretariat@m2-mediation.de";
|
||||
|
||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||
pub static PROP_POLICY_PROGRESS_COUNT: &str = "policy_progress_count";
|
||||
|
||||
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
|
||||
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
|
||||
|
||||
pub static PROP_POLICY_LIST: &str = "policy_list";
|
||||
pub static PROP_POLICY_LIST_COUNT: &str = "policy_list_count";
|
||||
|
||||
// Styles (RON based theme system)
|
||||
pub static STYLE_BOTTOM_BAR: &str = "bottom_bar";
|
||||
pub static STYLE_BUTTON_MENU: &str = "button_menu";
|
||||
pub static STYLE_BUTTON_ACTION: &str = "button_action";
|
||||
pub static STYLE_CONTAINER_ACTION: &str = "container_action";
|
||||
pub static STYLE_CONTAINER_MAIL: &str = "container_mail";
|
||||
pub static STYLE_HEADER_BAR: &str = "header_bar";
|
||||
pub static STYLE_HEADER_TEXT: &str = "header_text";
|
||||
pub static STYLE_SEPARATOR: &str = "separator";
|
||||
pub static STYLE_MAIL_LABEL: &str = "mail_label";
|
||||
pub static STYLE_MAIL_TO: &str = "mail_to";
|
||||
pub static STYLE_MAIL_CC: &str = "mail_cc";
|
||||
pub static STYLE_MENU: &str = "menu";
|
||||
pub static STYLE_STACK_ACTION: &str = "stack_action";
|
||||
pub static STYLE_STACK_MENU: &str = "stack_menu";
|
||||
|
||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||
pub static ID_CONFIGURATION_VIEW: &str = "Configuration";
|
||||
pub static ID_CONFIGURATION_FORM: &str = "configuration_form";
|
||||
pub static ID_CONFIGURATION_HEADER: &str = "configuration_header";
|
||||
pub static ID_CONFIGURATION_LABEL_CONFIG_FILE: &str = "configuration_label_config_file";
|
||||
pub static ID_CONFIGURATION_CONFIG_FILE: &str = "configuration_config_file";
|
||||
pub static ID_CONFIGURATION_LABEL_LANGUAGE_ID: &str = "configuration_label_language_id";
|
||||
pub static ID_CONFIGURATION_LANGUAGE_ID: &str = "configuration_language_id";
|
||||
|
||||
pub static ID_LOCALIZATION_VIEW: &str = "Localization";
|
||||
pub static ID_LOCALIZATION_FORM: &str = "localization_form";
|
||||
pub static ID_LOCALIZATION_HEADER: &str = "localization_header";
|
||||
pub static ID_LOCALIZATION_LANGUAGES: &str = "localization_languages";
|
||||
pub static ID_LOCALIZATION_LABEL_LANGUAGE_NAME: &str = "localization_label_language_name";
|
||||
pub static ID_LOCALIZATION_LANGUAGE_NAME: &str = "localization_language_name";
|
||||
|
||||
pub static ID_MAIN_GRID: &str = "main_grid";
|
||||
pub static ID_MAIN_TABWIDGET: &str = "main_tabwidget";
|
||||
pub static ID_MAIN_BUTTON_MENU: &str = "main_button_menu";
|
||||
|
||||
pub static ID_MENU_VIEW: &str = "menu_view";
|
||||
pub static ID_MENU_POPUP: &str = "menu_popup";
|
||||
pub static ID_MENU_STACK: &str = "menu_stack";
|
||||
pub static ID_MENU_BOTTOM_BAR: &str = "menu_bottom_bar";
|
||||
pub static ID_MENU_BUTTON: &str = "menu_button";
|
||||
pub static ID_MENU_BUTTON_MENU: &str = "menu_button_menu";
|
||||
pub static ID_MENU_GRID: &str = "menu_grid";
|
||||
pub static ID_MENU_HEADER: &str = "menu_header";
|
||||
pub static ID_MENU_HEADER_BAR: &str = "menu_header_bar";
|
||||
pub static ID_MENU_LABEL_ACCOUNT: &str = "menu_label_account";
|
||||
pub static ID_MENU_LABEL_QUIT: &str = "menu_label_quit";
|
||||
pub static ID_MENU_LABEL_TOGGLE_THEME: &str = "menu_label_toggle_theme";
|
||||
pub static ID_MENU_SHORTCUT_QUIT: &str = "menu_shortcut_quit";
|
||||
pub static ID_MENU_TOGGLE_THEME: &str = "menu_toggle_theme";
|
||||
|
||||
pub static ID_POLICY_CHECK_VIEW: &str = "policy_check_view";
|
||||
pub static ID_POLICY_CHECK_ACTION_BUTTON_CLEAR: &str = "policy_check_action_button_clear";
|
||||
pub static ID_POLICY_CHECK_ACTION_BUTTON_CREATE: &str = "policy_check_action_button_create";
|
||||
pub static ID_POLICY_CHECK_ACTION_GRID: &str = "policy_check_action_grid";
|
||||
pub static ID_POLICY_CHECK_ACTION_STACK: &str = "policy_check_action_stack";
|
||||
pub static ID_POLICY_CHECK_BOTTOM_BAR: &str = "policy_check_bottom_bar";
|
||||
pub static ID_POLICY_CHECK_BUTTON_RESULT: &str = "policy_check_button_result";
|
||||
pub static ID_POLICY_CHECK_BUTTON_MENU: &str = "policy_check_button_menu";
|
||||
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &str = "policy_check_data_count_block";
|
||||
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
||||
pub static ID_POLICY_CHECK_HEADER_BAR: &str = "policy_check_header_bar";
|
||||
pub static ID_POLICY_CHECK_HINT: &str = "policy_check_hint";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_LABEL_HINT: &str = "policy_check_label_hint";
|
||||
pub static ID_POLICY_CHECK_LABEL_MENU: &str = "policy_check_label_menu";
|
||||
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
|
||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
|
||||
pub static ID_POLICY_CHECK_POLICY_CODE: &str = "policy_check_policy_code";
|
||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_number";
|
||||
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &str = "policy_check_popup_progress";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_BAR: &str = "policy_check_progress_bar";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_TIME: &str = "policy_check_progress_time";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_TEXT: &str = "policy_check_progress_text";
|
||||
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
|
||||
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
|
||||
|
||||
pub static ID_POLICY_DATA_ADD_BUTTON: &str = "policy_data_add_button";
|
||||
pub static ID_POLICY_DATA_COUNT: &str = "policy_data_count";
|
||||
pub static ID_POLICY_DATA_LABEL: &str = "policy_data_label";
|
||||
pub static ID_POLICY_DATA_ITEMS_WIDGET: &str = "policy_data_items_widget";
|
||||
pub static ID_POLICY_DATA_DATE_INSERTED: &str = "policy_data_date_inserted";
|
||||
pub static ID_POLICY_DATA_DION: &str = "policy_data_dion";
|
||||
pub static ID_POLICY_DATA_POLICY_CODE: &str = "policy_data_policy_code";
|
||||
pub static ID_POLICY_DATA_POLICY_NUMBER: &str = "policy_data_policy_number";
|
||||
pub static ID_POLICY_DATA_STACK: &str = "policy_data_stack";
|
||||
pub static ID_POLICY_DATA_STATUS: &str = "policy_data_status";
|
||||
pub static ID_POLICY_DATA_LIST_NAME: &str = "policy_data_list_name";
|
||||
|
||||
pub static ID_POLICY_LIST_ADD_BUTTON: &str = "policy_list_add_button";
|
||||
pub static ID_POLICY_LIST_ITEMS_WIDGET: &str = "policy_list_items_widget";
|
||||
pub static ID_POLICY_LIST_TEXT_BOX: &str = "policy_list_text_box";
|
||||
|
||||
pub static ID_TICKET_DATA_ACTION_BUTTON_CLEAR: &str = "ticket_data_action_button_clear";
|
||||
pub static ID_TICKET_DATA_ACTION_BUTTON_SEND: &str = "ticket_data_action_button_send";
|
||||
pub static ID_TICKET_DATA_ACTION_GRID: &str = "ticket_data_action_grid";
|
||||
pub static ID_TICKET_DATA_BOTTOM_BAR: &str = "ticket_data_bottom_bar";
|
||||
pub static ID_TICKET_DATA_BUTTON_MENU: &str = "ticket_data_button_menu";
|
||||
pub static ID_TICKET_DATA_BUTTON_RESULT: &str = "ticket_data_button_result";
|
||||
pub static ID_TICKET_DATA_CALLBACK_DATE: &str = "ticket_data_label_callback_date";
|
||||
pub static ID_TICKET_DATA_CALLBACK_NUMBER: &str = "ticket_data_label_callback_number";
|
||||
pub static ID_TICKET_DATA_COMBO_BOX_MAIL_CC: &str = "ticket_data_combo_box_mail_cc";
|
||||
pub static ID_TICKET_DATA_COMBO_BOX_MAIL_TO: &str = "ticket_data_combo_box_mail_to";
|
||||
pub static ID_TICKET_DATA_CONTAINER_MAIL: &str = "ticket_data_container_mail";
|
||||
pub static ID_TICKET_DATA_COUNT_BLOCK: &str = "ticket_data_count_block";
|
||||
pub static ID_TICKET_DATA_DEDUCTIBLE: &str = "ticket_data_deductible";
|
||||
pub static ID_TICKET_DATA_FORM: &str = "ticket_data_form";
|
||||
pub static ID_TICKET_DATA_FORM_GRID: &str = "ticket_data_form_grid";
|
||||
pub static ID_TICKET_DATA_GRID: &str = "ticket_data_grid";
|
||||
pub static ID_TICKET_DATA_GRID_MAIL: &str = "ticket_data_grid_mail";
|
||||
pub static ID_TICKET_DATA_HARM_TYPE: &str = "ticket_data_harm_type";
|
||||
pub static ID_TICKET_DATA_HEADER_BAR: &str = "ticket_data_header_bar";
|
||||
pub static ID_TICKET_DATA_HEADER: &str = "ticket_data_header";
|
||||
pub static ID_TICKET_DATA_HINT: &str = "ticket_data_hint";
|
||||
pub static ID_TICKET_DATA_ITEMS_WIDGET: &str = "ticket_data_items_widget";
|
||||
pub static ID_TICKET_DATA_IVR_COMMENT: &str = "ticket_data_ivr_comment";
|
||||
pub static ID_TICKET_DATA_LABEL_CALLBACK_DATE: &str = "ticket_data_label_callback_data";
|
||||
pub static ID_TICKET_DATA_LABEL_CALLBACK_NUMBER: &str = "ticket_data_label_callback_number";
|
||||
pub static ID_TICKET_DATA_LABEL_DEDUCTIBLE: &str = "ticket_data_label_deductible";
|
||||
pub static ID_TICKET_DATA_LABEL_HARM_TYPE: &str = "ticket_data_label_harm_type";
|
||||
pub static ID_TICKET_DATA_LABEL_HINT: &str = "ticket_data_label_hint";
|
||||
pub static ID_TICKET_DATA_LABEL_IVR_COMMENT: &str = "ticket_data_label_ivr_comment";
|
||||
pub static ID_TICKET_DATA_LABEL_MAIL_CC: &str = "ticket_data_label_mail_cc";
|
||||
pub static ID_TICKET_DATA_LABEL_MAIL_TO: &str = "ticket_data_label_mail_to";
|
||||
pub static ID_TICKET_DATA_LABEL_MENU: &str = "ticket_data_label_menu";
|
||||
pub static ID_TICKET_DATA_LABEL_POLICY_CODE: &str = "ticket_data_label_policy_code";
|
||||
pub static ID_TICKET_DATA_LABEL_POLICY_HOLDER: &str = "ticket_data_label_policy_holder";
|
||||
pub static ID_TICKET_DATA_LOGO_BAR: &str = "ticket_data_logo_bar";
|
||||
pub static ID_TICKET_DATA_MAIL_CC: &str = "ticket_data_mail_cc";
|
||||
pub static ID_TICKET_DATA_MAIL_TO: &str = "ticket_data_mail_to";
|
||||
pub static ID_TICKET_DATA_POLICY_CODE: &str = "ticket_data_policy_code";
|
||||
pub static ID_TICKET_DATA_POLICY_HOLDER: &str = "ticket_data_policy_holder";
|
||||
pub static ID_TICKET_DATA_RESULT: &str = "ticket_data_result";
|
||||
pub static ID_TICKET_DATA_VIEW: &str = "ticket_data_view";
|
||||
pub static ID_TICKET_DATA_WIDGET: &str = "ticket_data_widget";
|
||||
13
crates/advotracker/src/data/mod.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
|
||||
/// provides orbtk widgets constants
|
||||
pub mod constants;
|
||||
|
||||
/// structures with implementations
|
||||
pub mod structures;
|
||||
364
crates/advotracker/src/data/structures.rs
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use orbtk::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An enumeration of valid policy codes.
|
||||
/// right now, only "AS" is used.
|
||||
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Serialize)]
|
||||
pub enum PolicyCode {
|
||||
/// Allianz Sachversicherung
|
||||
AS
|
||||
}
|
||||
|
||||
impl Default for PolicyCode {
|
||||
fn default() -> Self { PolicyCode::AS }
|
||||
}
|
||||
|
||||
/// Classifier of the Allinaz DirectCall communication type.
|
||||
pub enum CommunicationType {
|
||||
/// Anhörung
|
||||
A,
|
||||
/// Bußgeldbescheid
|
||||
BU,
|
||||
/// Gdb
|
||||
Gdb,
|
||||
/// Geburt
|
||||
GE,
|
||||
/// Hochzeit
|
||||
HO,
|
||||
/// Kündigung
|
||||
KD,
|
||||
/// Kaufvertrag
|
||||
KV,
|
||||
/// Lohn
|
||||
LO,
|
||||
/// Nachbar
|
||||
NA,
|
||||
/// Rente
|
||||
RE,
|
||||
/// Unfallflucht
|
||||
UF,
|
||||
/// Unterhalt
|
||||
UH,
|
||||
/// Unfall
|
||||
UN,
|
||||
/// Vodafone
|
||||
VF,
|
||||
/// Vermieter
|
||||
VM,
|
||||
/// Verwaltungsrecht
|
||||
VW,
|
||||
/// Zeugins
|
||||
ZE,
|
||||
/// Typ is unspecified
|
||||
XX
|
||||
}
|
||||
|
||||
impl Default for CommunicationType {
|
||||
fn default() -> Self { CommunicationType::XX }
|
||||
}
|
||||
|
||||
/// Status of a given policy data element.
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
|
||||
pub enum Status {
|
||||
/// Active -> the policy is active an supported
|
||||
Active,
|
||||
/// Inactive -> the policy is inactive or resigned
|
||||
Inactive
|
||||
}
|
||||
|
||||
impl Default for Status {
|
||||
fn default() -> Self { Status::Active }
|
||||
}
|
||||
|
||||
/// A communication type describes possible classifications of customer calls.
|
||||
/// If the type isn't selected, the default will be 'unclassified -> XX'.
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
pub struct CommunicationData {
|
||||
/// pub communication_type: CommunicationType,
|
||||
pub communication_type: String,
|
||||
/// A literal name describing the selected communication type
|
||||
pub communication_name: String
|
||||
}
|
||||
|
||||
/// CSV Export
|
||||
/// The structure elements are required for an export to a comma seperated text list.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct CsvExportRecord {
|
||||
/// Versicherungsschein Code
|
||||
pub policy_code: String,
|
||||
/// Versicherungsscheinnummer (10-stellig, numerisch)
|
||||
pub policy_number: u64,
|
||||
/// Anrufer: "Vorname, Nachname"
|
||||
pub policy_holder: String,
|
||||
/// Sachverhalt: "Kurzschilderung"
|
||||
pub facts: String,
|
||||
/// Schadensart: "harm_name (harm_id)"
|
||||
pub harm_type: String,
|
||||
/// communication_type => Kommunikationszeichen: "(communication_name)"
|
||||
pub communication_name: String,
|
||||
/// ra_hotline => RA_Hotline: Kanzlei Laqua, Kanzlei Buschbell, Kanzlei DAH, Kanzlei Hiedemann
|
||||
pub ra_hotline: String, // const "Kanzlei Hiedemann",
|
||||
/// ivr_comment => Haftungs-/Deckungskommentar; #IVR (ggf. ergänzt um das Beratungsergebnis)
|
||||
pub ivr_comment: String,
|
||||
}
|
||||
|
||||
/// Handel fields of an Email (header, body)
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Email {
|
||||
/// Recipient address
|
||||
pub mail_to: String,
|
||||
/// Carbon Copy recipient address
|
||||
pub mail_cc: String,
|
||||
/// Blind Carbon Copy recipient address
|
||||
pub mail_bcc: String,
|
||||
/// Sender address
|
||||
pub mail_from: String,
|
||||
/// Replay to given address
|
||||
pub mail_reply: String,
|
||||
/// Mail subject
|
||||
pub subject: String,
|
||||
/// Body policy code
|
||||
pub policy_code: String,
|
||||
/// Body type policy holder
|
||||
pub policy_holder: String,
|
||||
/// Body type deductible
|
||||
pub deductible: String,
|
||||
/// Body callback number
|
||||
pub callback_number: String,
|
||||
/// Body type callback date
|
||||
pub callback_date: String,
|
||||
/// Body type harm type
|
||||
pub harm_type: String,
|
||||
/// Body type ivr comment
|
||||
pub ivr_comment: String
|
||||
}
|
||||
|
||||
impl Email {}
|
||||
|
||||
/// Harm data are list/collections of harm types. You may toggle them to an unselected state.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct HarmData {
|
||||
/// Liste der Schadensdaten
|
||||
pub harm_data: Vec<HarmType>,
|
||||
/// Status der Schadenliste
|
||||
//pub name: String,
|
||||
pub selected: bool
|
||||
}
|
||||
|
||||
/// Harm types are destincted by a type code.
|
||||
/// The type code represents the unique harm identifier, bound with a literal name.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct HarmType {
|
||||
/// Kennzeichen des Schadenstyps
|
||||
// Schadenersatz-RS im Verkehrsbereich (RS112)
|
||||
// Ordnungswidrigkeits-RS im Verkehrsbereich (RS122)
|
||||
// Straf-RS im Verkehrsbereich (RS121)
|
||||
// Vertrags-RS im Verkehrsbereich (RS118)
|
||||
// Vertrags-RS im Privatbereich (RS218)
|
||||
// Arbeits-RS im Berufsbereich (RS315)
|
||||
// WuG-RS im Privatbereich (RS220)
|
||||
// Sozialgerichts-RS im Privatbereich (RS216)
|
||||
// Rechtsschutz im Familien- und Erbrecht (RS217)
|
||||
// Wagnis nicht versicherbar / versichert (RS999)
|
||||
pub harm_type: String,
|
||||
/// Beschreibung des Schadenstyps
|
||||
pub harm_name: String,
|
||||
}
|
||||
|
||||
/// Structure used to verify a policy data element.
|
||||
#[derive(Default, Debug, Clone, Deserialize, PartialEq, Serialize)]
|
||||
pub struct PolicyCheck {
|
||||
/// Versicherungsschein-Prüfnummer
|
||||
pub policy_check_number: String,
|
||||
/// Referenz zum Versicherungsschein-Typ
|
||||
pub dion: u8,
|
||||
/// Referenz zum Versicherungsschein-Typ
|
||||
pub policy_code: PolicyCode,
|
||||
/// Referenz zur Versicherungsschein-Nummer
|
||||
pub policy_number: u64,
|
||||
/// Validitätsergebnis
|
||||
pub policy_number_status: Status
|
||||
}
|
||||
|
||||
impl PolicyCheck {}
|
||||
|
||||
/// Structure collecting policy data elements
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct PolicyList {
|
||||
/// Bescheibung der Versicherungsdatenliste
|
||||
pub name: String,
|
||||
/// Listenelemente der Versicherungsdatendaten
|
||||
pub policy_list: Vec<PolicyDataList>,
|
||||
}
|
||||
|
||||
/// implements helper methods, that manage lists of policy data collections
|
||||
impl PolicyList {
|
||||
/// Index auf Versicherungsliste zurückgeben (unveränderbar)
|
||||
pub fn get(&self, index: usize) -> Option<&PolicyDataList> {
|
||||
self.policy_list.get(index)
|
||||
}
|
||||
|
||||
/// Index auf Versicherungsliste zurückgeben (veränderbar)
|
||||
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyDataList> {
|
||||
self.policy_list.get_mut(index)
|
||||
}
|
||||
|
||||
/// Neuer Eintrag am Anfang der Liste einfügen.
|
||||
pub fn insert_front(&mut self, policy_list: PolicyDataList) {
|
||||
self.policy_list.insert(0, policy_list);
|
||||
}
|
||||
|
||||
/// Prüfung ob Versicherungsliste keine Elemente enthält.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.policy_list.is_empty()
|
||||
}
|
||||
|
||||
/// Berechnet die Anzahl der Versicherungslisten Elemente.
|
||||
pub fn len(&self) -> usize {
|
||||
self.policy_list.len()
|
||||
}
|
||||
|
||||
/// Neuen Versicherungslisten-Namen erzeugen
|
||||
pub fn new(name: impl Into<String>) -> Self {
|
||||
PolicyList {
|
||||
name: name.into(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Element der Versicherungsliste anfügen
|
||||
pub fn push(&mut self, policy_list: PolicyDataList) {
|
||||
self.policy_list.push(policy_list);
|
||||
}
|
||||
|
||||
/// Element der Versicherungsliste löschen
|
||||
pub fn remove(&mut self, index: usize) -> PolicyDataList {
|
||||
self.policy_list.remove(index)
|
||||
}
|
||||
}
|
||||
|
||||
/// Structure collects policy data elements.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct PolicyDataList {
|
||||
/// Verfalldatum des Versicherungslisten Elements
|
||||
pub date_valid_until: Option<NaiveDateTime>,
|
||||
/// Elemente des Versicherungsobjektes
|
||||
pub policy_data: Vec<PolicyData>,
|
||||
/// Name der Versicherungsliste
|
||||
pub name: String,
|
||||
/// Status der Versicherungsliste
|
||||
pub selected: bool
|
||||
}
|
||||
|
||||
/// implements the helper methods, to manage policy data collections.
|
||||
impl PolicyDataList {
|
||||
/// Prüfung auf Versicherungselemente
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.policy_data.is_empty()
|
||||
}
|
||||
|
||||
/// Versicherungselement am Anfang anfügen
|
||||
pub fn insert_front(&mut self, policy_data: PolicyData) {
|
||||
self.policy_data.insert(0, policy_data);
|
||||
}
|
||||
|
||||
/// Index zum Versicherungselement zurückgeben (unveränderbar)
|
||||
pub fn get(&self, index: usize) -> Option<&PolicyData> {
|
||||
self.policy_data.get(index)
|
||||
}
|
||||
|
||||
/// Index zum Versicherungselement zurückgeben (veränderbar)
|
||||
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyData> {
|
||||
self.policy_data.get_mut(index)
|
||||
}
|
||||
|
||||
/// Berechnet die Anzahl der Versicherungselemente.
|
||||
pub fn len(&self) -> usize {
|
||||
self.policy_data.len()
|
||||
}
|
||||
|
||||
/// Neues Versicherungselement erstellen.
|
||||
pub fn new(name: impl Into<String>) -> Self {
|
||||
// the new inserted element will be active by default
|
||||
PolicyDataList {
|
||||
date_valid_until: None,
|
||||
name: name.into(),
|
||||
selected: true,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Versicherungselement anfügen
|
||||
pub fn push(&mut self, policy_data: PolicyData) {
|
||||
self.policy_data.push(policy_data);
|
||||
}
|
||||
|
||||
/// Versicherungselement löschen
|
||||
pub fn remove(&mut self, index: usize) -> PolicyData {
|
||||
self.policy_data.remove(index)
|
||||
}
|
||||
}
|
||||
|
||||
/// Structure representing a policy data element
|
||||
/// This structure groups a set of fields that describes a policy number.
|
||||
/// The data are regularily updated via a data import from a comma seperated
|
||||
/// text file (csv file).
|
||||
/// Since we parse the source record fields to rust types (serde deserialize)
|
||||
/// the field order in our struct must meet the data field order in the source!
|
||||
/// We do use field attribute to precisely rename the source fields (header names)
|
||||
/// to our target rust field names.
|
||||
/// Referenz: POLLFNR_WOECHENTLICH.txt ->
|
||||
/// Header 'DION VERS POLLFNR'
|
||||
/// Record '1 AS 1515735810'
|
||||
// DION: Allianz id => len = 1??
|
||||
// VERS: policy_code => enum(AS; ??)
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct PolicyData {
|
||||
/// Erstellungsdatum
|
||||
pub date_inserted: Option<NaiveDateTime>,
|
||||
/// Allianz Dion
|
||||
#[serde(rename = "DION")]
|
||||
pub dion: u8,
|
||||
/// Kennzeichen des Allianz Versicherungscodes
|
||||
#[serde(rename = "VERS")]
|
||||
pub policy_code: PolicyCode,
|
||||
/// Versicherungsscheinnummer (10stellig, numerisch)
|
||||
#[serde(rename = "POLLFNR")]
|
||||
pub policy_number: u64,
|
||||
/// Status des Versicherungsscheins
|
||||
pub status: Option<Status>
|
||||
}
|
||||
|
||||
/// Policy Number Set
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct AllianzPolicyNumber {
|
||||
/// Allianz Dion
|
||||
#[serde(rename = "DION")]
|
||||
pub dion: u8,
|
||||
/// Kennzeichen des Allianz Versicherungstyps
|
||||
#[serde(rename = "VERS")]
|
||||
pub policy_code: String,
|
||||
/// 10-stellige Versicherungsscheinnummer (numerisch)
|
||||
#[serde(rename = "POLLFNR")]
|
||||
pub policy_number: usize
|
||||
}
|
||||
|
||||
// /// List of Allianz Policy Number records
|
||||
// /// The structure elements are required for an export to a comma seperated text list.
|
||||
// #[derive(Default, Debug, Deserialize)]
|
||||
// pub struct AllianzPolicyNumberList {
|
||||
// records: Vec<AllianzPolicyNumber>
|
||||
// }
|
||||
|
||||
into_property_source!(PolicyCheck);
|
||||
into_property_source!(PolicyDataList);
|
||||
into_property_source!(PolicyList);
|
||||
43
crates/advotracker/src/lib.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: 0BSD, MIT
|
||||
*/
|
||||
|
||||
#![crate_name = "advotracker_client"]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
//#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
|
||||
#![warn(rust_2018_idioms, rust_2018_compatibility)]
|
||||
|
||||
//! advotracker
|
||||
//! Supports lawyers to capture relevant data encountered during an
|
||||
//! online legal advice.
|
||||
//! This is the frontend componet that communicates to the backend `advotrackerd`.
|
||||
//!
|
||||
//! The crate is called `advotracker` and you can depend on it via cargo:
|
||||
//!
|
||||
//! ```ini
|
||||
//! [dependencies]
|
||||
//! advotracker = { version = "~0.1" }
|
||||
//! ```
|
||||
//!
|
||||
//! WIP: provide a workflow image
|
||||
//!
|
||||
|
||||
// /// The client specific services
|
||||
// pub mod clients;
|
||||
|
||||
/// provides data definitions
|
||||
pub mod data;
|
||||
|
||||
/// provides orbtk widgets (handling views and states)
|
||||
pub mod widgets;
|
||||
|
||||
/// provides services
|
||||
pub mod services;
|
||||
|
||||
// /// Provide test data
|
||||
// #[cfg!Test]
|
||||
// pub mod data;
|
||||
248
crates/advotracker/src/locales/advotracker.json
Normal file
@@ -0,0 +1,248 @@
|
||||
{
|
||||
"err.lang.not_found": {
|
||||
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
|
||||
"de_DE": "Konnte Sprachkode nicht auslesen",
|
||||
"C": "Couldn't read LANG"
|
||||
},
|
||||
"err.user.not_found": {
|
||||
"fr": "Utilisateur introuvable: $email, $id",
|
||||
"de_DE.UTF-8": "Anwender nicht gefunden: $email, $id",
|
||||
"de_DE": "Anwender nicht gefunden: $email, $id",
|
||||
"C": "User not found: $email, $id"
|
||||
},
|
||||
"main.started": {
|
||||
"de_DE.UTF-8": "Programmlogik starten",
|
||||
"de_DE": "Programmlogik starten",
|
||||
"C": "Program logic started"
|
||||
},
|
||||
"main.finished": {
|
||||
"de_DE.UTF-8": "Programmlogik beendet",
|
||||
"de_DE": "Programmlogik beendet",
|
||||
"C": "Program logic finished"
|
||||
},
|
||||
"parse.arguments": {
|
||||
"de_DE.UTF-8": "Programmargumente prüfen",
|
||||
"de_DE": "Programmargumente prüfen",
|
||||
"C": "Parsing arguments"
|
||||
},
|
||||
"parse.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
|
||||
"de_DE": "Umgebungsvariablen prüfen",
|
||||
"C": "Parsing environment"
|
||||
},
|
||||
"parse.results": {
|
||||
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
|
||||
"de_DE": "Ergebnisse der Konfigurationsparameterprüfung",
|
||||
"C": "Config parsing results"
|
||||
},
|
||||
"config.name": {
|
||||
"de_DE.UTF-8": "Konfigurationswert für",
|
||||
"de_DE": "Konfigurationswert für",
|
||||
"C": "Config Value for"
|
||||
},
|
||||
"config.name.lang": {
|
||||
"de_DE.UTF-8": "Sprach-Code_DE",
|
||||
"de_DE": "Sprach-Code_DE",
|
||||
"C": "Language code_DE"
|
||||
},
|
||||
"config.name.verbositylevel": {
|
||||
"de_DE.UTF-8": "Ausgabe-Ebene",
|
||||
"de_DE": "Ausgabe-Ebene",
|
||||
"C": "verbosity level"
|
||||
},
|
||||
"config.name.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen",
|
||||
"de_DE": "Umgebungsvariablen",
|
||||
"C": "environment"
|
||||
},
|
||||
"config.name.configfile": {
|
||||
"de_DE.UTF-8": "Konfigurations-Datei",
|
||||
"de_DE": "Konfigurations-Datei",
|
||||
"C": "config file"
|
||||
},
|
||||
"config.name.dbdriver": {
|
||||
"de_DE.UTF-8": "Datenbank-Treiber",
|
||||
"de_DE": "Datenbank-Treiber",
|
||||
"C": "database driver"
|
||||
},
|
||||
"config.name.redis": {
|
||||
"de_DE.UTF-8": "Redis Datenbank",
|
||||
"de_DE": "Redis Datenbank",
|
||||
"C": "Redis database"
|
||||
},
|
||||
"csv.export.started": {
|
||||
"de_DE.UTF-8": "Export in eine CSV Datei starten",
|
||||
"de_DE": "Export in eine CSV Datei starten",
|
||||
"C": "Export to csv file started"
|
||||
},
|
||||
"csv.export.finished": {
|
||||
"de_DE.UTF-8": "Export in eine CSV Datei beendet",
|
||||
"de_DE": "Export in eine CSV Datei beendet",
|
||||
"C": "Export to csv file finished"
|
||||
},
|
||||
"csv.import.started": {
|
||||
"de_DE.UTF-8": "Import aus einer CSV Datei",
|
||||
"de_DE": "Import aus einer CSV Datei",
|
||||
"C": "Import from a csv file"
|
||||
},
|
||||
"csv.import.finished": {
|
||||
"de_DE.UTF-8": "Import aus einer CSV Datei beendet",
|
||||
"de_DE": "Import aus einer CSV Datei beendet",
|
||||
"C": "Import from a csv file finished"
|
||||
},
|
||||
"redis.connection.error": {
|
||||
"de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden",
|
||||
"de_DE": "Es konnte keine Redis Verbindung aufgebaut werden",
|
||||
"C": "Could not establish a redis connection"
|
||||
},
|
||||
"policy.hashmap.success": {
|
||||
"de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt",
|
||||
"de_DE": "Hashmap wurde erfolgreich erstellt",
|
||||
"C": "Hashmap creation was successfull"
|
||||
},
|
||||
"policy.hashmap.failed": {
|
||||
"de_DE.UTF-8": "Hashmap konnte nicht erstellt werden",
|
||||
"de_DE": "Hashmap konnte nicht erstellt werden",
|
||||
"C": "Hashmap creation failed"
|
||||
},
|
||||
"policy.menu.label": {
|
||||
"de_DE.UTF-8": "Menü",
|
||||
"de_DE": "Menü",
|
||||
"C": "Menu"
|
||||
},
|
||||
"policy.menu.label_account": {
|
||||
"de_DE.UTF-8": "Aktueller Benutzer",
|
||||
"de_DE": "Aktueller Benutzer",
|
||||
"C": "Active user"
|
||||
},
|
||||
"policy.menu.label_quit": {
|
||||
"de_DE.UTF-8": "Beenden",
|
||||
"de_DE": "Beenden",
|
||||
"C": "Quit"
|
||||
},
|
||||
"policy.menu.label_toggle_theme": {
|
||||
"de_DE.UTF-8": "Thema wechseln",
|
||||
"de_DE": "Thema wechseln",
|
||||
"C": "Toggle theme"
|
||||
},
|
||||
"policy.string.header": {
|
||||
"de_DE.UTF-8": "Validierung Versicherungsnummer",
|
||||
"de_DE": "Validierung Versicherungsnummer",
|
||||
"C": "Policy number validation"
|
||||
},
|
||||
"policy.string.label_policy_data": {
|
||||
"de_DE.UTF-8": "Importierte Daten",
|
||||
"de_DE": "Importierte Daten",
|
||||
"C": "imported data"
|
||||
},
|
||||
"policy.string.label_policy_list": {
|
||||
"de_DE.UTF-8": "Versicherungsnummern-Liste",
|
||||
"de_DE": "Versicherungsnummern-Liste",
|
||||
"C": "policy list"
|
||||
},
|
||||
"policy.string.label_policy_number": {
|
||||
"de_DE.UTF-8": "Versicherungsnummer",
|
||||
"de_DE": "Versicherungsnummer",
|
||||
"C": "policy number"
|
||||
},
|
||||
"policy.string.label_result": {
|
||||
"de_DE.UTF-8": "Prüfungsergebnis",
|
||||
"de_DE": "Prüfungsergebnis",
|
||||
"C": "check result"
|
||||
},
|
||||
"policy.string.data_count": {
|
||||
"de_DE.UTF-8": "Anzahl Prüflistenelemente",
|
||||
"de_DE": "Anzahl Prüflistenelemente",
|
||||
"C": "Number of checklist elements"
|
||||
},
|
||||
"policy.string.import_data": {
|
||||
"de_DE.UTF-8": "Importieren der Prüflisten-Elemente",
|
||||
"de_DE": "Importieren der Prüflisten-Elemente",
|
||||
"C": "Import checklist elements"
|
||||
},
|
||||
"policy.string.progress_time": {
|
||||
"de_DE.UTF-8": "Bearbeitungszeit",
|
||||
"de_DE": "Bearbeitungszeit",
|
||||
"C": "processing time"
|
||||
},
|
||||
"policy.string.progress_text": {
|
||||
"de_DE.UTF-8": "Importiere Daten",
|
||||
"de_DE": "Importiere Daten",
|
||||
"C": "Importing data"
|
||||
},
|
||||
"policy.validation.button_failed": {
|
||||
"de_DE.UTF-8": "ungültig",
|
||||
"de_DE": "ungültig",
|
||||
"C": "invalid"
|
||||
},
|
||||
"policy.validation.button_success": {
|
||||
"de_DE.UTF-8": "gültig",
|
||||
"de_DE": "gültig",
|
||||
"C": "valid"
|
||||
},
|
||||
"policy.validation.failed": {
|
||||
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig",
|
||||
"de_DE": "Die Versicherungsscheinnummber ist ungültig",
|
||||
"C": "The given policy number is invalid"
|
||||
},
|
||||
"policy.validation.new": {
|
||||
"de_DE.UTF-8": "Neue Prüfung",
|
||||
"de_DE": "Neue Prüfung",
|
||||
"C": "New validation"
|
||||
},
|
||||
"policy.validation.success": {
|
||||
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig",
|
||||
"de_DE": "Die Versicherungsscheinnummber ist gültig",
|
||||
"C": "The given policy number is valid"
|
||||
},
|
||||
"policy.validation.started": {
|
||||
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
|
||||
"de_DE": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
|
||||
"C": "Validation of the policy number started"
|
||||
},
|
||||
"policy.validation.finished": {
|
||||
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
|
||||
"de_DE": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
|
||||
"C": "Validation of the policy number finished"
|
||||
},
|
||||
"policy.validation.invalid_input": {
|
||||
"de_DE.UTF-8": "Nur Nummer sind zulässig",
|
||||
"de_DE": "Nur Nummer sind zulässig",
|
||||
"C": "Only numbers are valid"
|
||||
},
|
||||
"policy.validation.not_found": {
|
||||
"de_DE.UTF-8": "Nummer ist nicht aktiviert",
|
||||
"de_DE": "Nummer ist nicht aktiviert",
|
||||
"C": "number isn't marked active"
|
||||
},
|
||||
"policy.validation.to_long": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu lang",
|
||||
"de_DE": "Die Nummer ist zu lang",
|
||||
"C": "Policy number is to long"
|
||||
},
|
||||
"policy.validation.to_short": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu kurz",
|
||||
"de_DE": "Die Nummer ist zu kurz",
|
||||
"C": "Policy number is to short"
|
||||
},
|
||||
"sendticketdata.export.started":{
|
||||
"de_DE.UTF-8": "Versenden von ticket daten via eMail gestartet",
|
||||
"de_DE": "Versenden von ticket daten via eMail gestartet",
|
||||
"C": "Send ticket data via eMail started"
|
||||
},
|
||||
"sendticketdata.export.finished":{
|
||||
"de_DE.UTF-8": "Versenden von ticket daten via eMail beendet",
|
||||
"de_DE": "Versenden von ticket daten via eMail beendet",
|
||||
"C": "Send ticket data via eMail finished"
|
||||
},
|
||||
"state.started": {
|
||||
"de_DE.UTF-8": "gestartet",
|
||||
"de_DE": "gestartet",
|
||||
"C": "started"
|
||||
},
|
||||
"state.finished": {
|
||||
"de_DE.UTF-8": "beendet",
|
||||
"de_DE": "beended",
|
||||
"C": "finished"
|
||||
}
|
||||
}
|
||||
225
crates/advotracker/src/main.rs
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// suppress creation of a new console window on window
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
//#[macro_use]
|
||||
//extern crate lazy_static;
|
||||
|
||||
//use chrono::{Local, DateTime};
|
||||
use dotenv::dotenv;
|
||||
use locales::t;
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
//use std::process;
|
||||
use substring::Substring;
|
||||
use tracing::{info, trace, Level};
|
||||
|
||||
use orbtk::{
|
||||
prelude::*,
|
||||
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
|
||||
theming::config::ThemeConfig,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS};
|
||||
|
||||
// The Main view
|
||||
use advotracker::widgets::main_view;
|
||||
|
||||
mod parse_args;
|
||||
|
||||
/// define valid environment variables provided via .env files
|
||||
/// located in the current call directory
|
||||
/// this is primarily used in testing scenarios (eg. debugging)
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
lang: String,
|
||||
test_lang: String,
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
// Style extension
|
||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||
}
|
||||
}
|
||||
|
||||
// German localization file.
|
||||
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/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_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
match envy::from_env::<Environment>() {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
|
||||
// return the active language
|
||||
lang
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
fn theme_fluent() -> Theme {
|
||||
register_fluent_fonts(Theme::from_config(
|
||||
ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_FLUENT))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
))
|
||||
// register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
}
|
||||
} else {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
use parse_args::parse_args;
|
||||
use tracing_subscriber::fmt;
|
||||
use viperus::Viperus;
|
||||
|
||||
let machine_kind = if cfg!(unix) {
|
||||
"unix"
|
||||
} else if cfg!(windows) {
|
||||
"windows"
|
||||
} else {
|
||||
"unknown/unsupported"
|
||||
};
|
||||
|
||||
// respect dotenv environment (e.g for testing)
|
||||
// -> overwrites the preset default values
|
||||
let rust_log = dotenv::var("RUST_LOG").unwrap_or_else(|_| String::from("None"));
|
||||
|
||||
// initialize the tracing subsystem
|
||||
// a drop in replacement for classical logging
|
||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
||||
let span = tracing::span!(Level::TRACE, "advotracker");
|
||||
let _enter = span.enter();
|
||||
let subscriber = fmt::Subscriber::builder()
|
||||
.with_env_filter(&rust_log)
|
||||
//.with_max_level(tracing::Level::DEBUG)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
// get system environment
|
||||
let lang = get_lang();
|
||||
|
||||
let mut state = t!("state.started", lang);
|
||||
let mut res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", machine = ?&machine_kind);
|
||||
|
||||
// how to handle unimplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut viperus = Viperus::new();
|
||||
|
||||
// parse commandline arguments
|
||||
res = t!("parse.arguments", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
let _ = parse_args(&mut viperus);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// type conversion (viperus String -> u64)
|
||||
let test_policy_number = viperus.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
||||
trace!(target: "advotracker", test_policy_number = ?test_policy_number);
|
||||
|
||||
// main tasks
|
||||
res = t!("main.started", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
// Preset localization and language from given environment.
|
||||
// if no dictionary is set for the chosen default language
|
||||
// the content of the text property will be drawn.
|
||||
//let language = lang.substring(0,5); // "de_DE.UTF-8" -> "de_DE"
|
||||
//info!("GUI-Language: preset to {:?}", language);
|
||||
let localization = RonLocalization::create()
|
||||
.language(&lang)
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
Application::from_name("nwx.advotracker")
|
||||
.localization(localization)
|
||||
.theme(theme())
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(800.0, 600.0)
|
||||
//.min_width(460.0)
|
||||
//.min_height(380.0)
|
||||
.resizeable(true)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("main.finished", lang);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
213
crates/advotracker/src/parse_args.rs
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// parse CLI commandline arguments with clap
|
||||
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
|
||||
|
||||
//use log::{debug, info, trace, warn};
|
||||
use std::env;
|
||||
use tracing::trace;
|
||||
use viperus::Viperus;
|
||||
|
||||
/// Parse the commandline arguments and preset default values
|
||||
/// Precedence: defaults -> config-file -> environment -> commandline
|
||||
pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if cfg!(feature = "global") {
|
||||
trace!(target: "Viperus", "Viperus feature 'global' enabled.");
|
||||
println!("Lasy static: 'VIPERUS' is accessible globaly");
|
||||
}
|
||||
|
||||
if cfg!(feature = "fmt-clap") {
|
||||
trace!(target: "Viperus", "Viperus feature 'fmt-clap' enabled.");
|
||||
println!("Using feature fmt-clap");
|
||||
}
|
||||
|
||||
// preset default key/value pairs (lowest priority)
|
||||
viperus.add_default("config_file", String::from("csv_import.ron"));
|
||||
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
viperus.add_default("export_file", String::from(""));
|
||||
viperus.add_default("test_policy_number", String::from("9999999992"));
|
||||
viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||
viperus.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
||||
//viperus.add_default("username", String::from("nctalkbot"));
|
||||
//viperus.add_default("password", String::from("botpassword"));
|
||||
viperus.add_default("verbose", 0);
|
||||
|
||||
// CLI arguments are defined inline
|
||||
let matches = App::new("advotracker")
|
||||
.name(crate_name!())
|
||||
.version(crate_version!())
|
||||
.author(crate_authors!())
|
||||
.about(crate_description!())
|
||||
.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")
|
||||
.template(
|
||||
"\
|
||||
{bin} v{version}
|
||||
{about}
|
||||
|
||||
{all-args}
|
||||
|
||||
(C) 2020 {author}
|
||||
{after-help}",
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("configFile")
|
||||
.short("c")
|
||||
.long("configFile")
|
||||
.value_name("FILE")
|
||||
.help("Select a config file")
|
||||
.default_value("csv_import.ron")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("importFile")
|
||||
.short("i")
|
||||
.long("importFile")
|
||||
.help("Select source file for the csv-import")
|
||||
.default_value("POLLFNR_WOECHENTLICH.txt")
|
||||
//.default_value("POLLFNR_MINI.txt")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("exportFile")
|
||||
.short("e")
|
||||
.long("exportFile")
|
||||
.help("Select target file for the csv-export")
|
||||
.default_value("RA-Hiedemann_DirectCall.txt")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("fromEmailAddress")
|
||||
.short("f")
|
||||
.long("fromEmailAddress")
|
||||
.help("Select the sender email-address (From:)")
|
||||
.default_value("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("toEmailAddress")
|
||||
.short("t")
|
||||
.long("toEmailAddress")
|
||||
.help("Select the target email-address (To:)")
|
||||
.default_value("Allianz RA-Hotline <smr-rahotline@allianz.de>")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("testPolicyNumber")
|
||||
.short("p")
|
||||
.long("testPolicyNumber")
|
||||
.help("Test validity of given policy number")
|
||||
//.default_value("")
|
||||
.takes_value(true),
|
||||
)
|
||||
// .arg(
|
||||
// Arg::with_name("username")
|
||||
// .short("u")
|
||||
// .long("username")
|
||||
// .help("Sets username")
|
||||
// .takes_value(true),
|
||||
// )
|
||||
// .arg(
|
||||
// Arg::with_name("password")
|
||||
// .short("P")
|
||||
// .long("password")
|
||||
// .help("Sets password")
|
||||
// .takes_value(true),
|
||||
// )
|
||||
.arg(
|
||||
Arg::with_name("verbose")
|
||||
.short("v")
|
||||
.long("verbose")
|
||||
.help("Sets verbosity level")
|
||||
.multiple(true),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if matches.occurrences_of("verbose") > 0 {
|
||||
// clap is using i64, viperus i32
|
||||
let n = matches.occurrences_of("verbose") as i32;
|
||||
viperus.add("verbose", n);
|
||||
}
|
||||
|
||||
// preset the prefix for relevant environment variables ("ADVOTRACKER_")
|
||||
let mut env_prefix: String = crate_name!().to_uppercase();
|
||||
env_prefix.push('_');
|
||||
viperus.set_env_prefix(&env_prefix);
|
||||
|
||||
// enable caching and automatic update of environment values
|
||||
viperus.cache(true);
|
||||
viperus.automatic_env(true);
|
||||
|
||||
// load user selected call arguments
|
||||
// -> overwrites values given via environment variables
|
||||
viperus.load_clap(matches)?;
|
||||
|
||||
// bond the clap names to camel_case rust variable names
|
||||
viperus.bond_clap("configFile", "config_file");
|
||||
viperus.bond_clap("importFile", "import_file");
|
||||
viperus.bond_clap("exportFile", "export_file");
|
||||
viperus.bond_clap("toEmailAddress", "to_email_address");
|
||||
viperus.bond_clap("fromEmailAddress", "from_email_address");
|
||||
viperus.bond_clap("testPolicyNumber", "test_policy_number");
|
||||
//viperus.bond_clap("username", "username");
|
||||
//viperus.bond_clap("password", "password");
|
||||
viperus.bond_clap("verbose", "verbose");
|
||||
|
||||
trace!("verbose {:?}", viperus.get::<i32>("verbose").unwrap());
|
||||
if viperus.get::<i32>("verbose").unwrap() > 0 {
|
||||
println!(
|
||||
"config_file: {:?}",
|
||||
viperus.get::<String>("config_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"import_file: {:?}",
|
||||
viperus.get::<String>("import_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"export_file: {:?}",
|
||||
viperus.get::<String>("export_file").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"to_email_address: {:?}",
|
||||
viperus.get::<String>("to_email_address").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"from_email_address: {:?}",
|
||||
viperus.get::<String>("from_email_address").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"test_policy_number: {:?}",
|
||||
viperus.get::<i32>("test_policy_number").unwrap_or_default()
|
||||
);
|
||||
// println!(
|
||||
// "username: {:?}",
|
||||
// viperus.get::<String>("username").unwrap_or_default()
|
||||
// );
|
||||
// println!(
|
||||
// "password: {:?}",
|
||||
// viperus.get::<String>("password").unwrap_or_default()
|
||||
// ); // only for testing now
|
||||
|
||||
println!(
|
||||
"verbosity level: {:?}",
|
||||
viperus.get::<i32>("verbose").unwrap_or_default()
|
||||
);
|
||||
}
|
||||
|
||||
if viperus.get::<i32>("verbose").unwrap() > 1 {
|
||||
println!("\nEnvironment:");
|
||||
for (key, value) in env::vars() {
|
||||
println!("{}={}", key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
37
crates/advotracker/src/services/exports/allianzdirectcall.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
//use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
use std::error::Error;
|
||||
use tracing::trace;
|
||||
|
||||
/// export as csv format
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
pub fn export(p: &mut String, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
//use std::ffi::OsStr;
|
||||
|
||||
let mut res = t!("csv.export.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "csv-export", process = ?res, state = ?state);
|
||||
|
||||
// Note: slash syntax also works on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
// open the file
|
||||
let file = File::open(path)?;
|
||||
|
||||
trace!(target: "csv.export", extension = ?path.extension(), file = ?file);
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.export.finished", lang);
|
||||
trace!(target: "csv-export", process = ?res, state = ?state);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
12
crates/advotracker/src/services/exports/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// Send ticketdata via email
|
||||
pub mod send_ticketdata;
|
||||
|
||||
/// Exporting Allianz DirecCall data
|
||||
pub mod allianzdirectcall;
|
||||
122
crates/advotracker/src/services/exports/send_ticketdata.rs
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use lettre::{
|
||||
message::{header, MultiPart, SinglePart},
|
||||
Message, SmtpTransport, Transport,
|
||||
transport::smtp::authentication::Credentials,
|
||||
};
|
||||
use locales::t;
|
||||
use maud::html;
|
||||
use std::error::Error;
|
||||
//use std::process;
|
||||
use tracing::{info, error, trace};
|
||||
|
||||
use crate::data::structures::Email;
|
||||
|
||||
/// send ticket data via eMail
|
||||
pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
let mut res = t!("sendticketdata.export.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
// The html we want to send.
|
||||
// It uses https://crates.io/crates/maud
|
||||
let html = html! {
|
||||
head {
|
||||
title { (email.subject) " (" (email.policy_code) ")" }
|
||||
style type="text/css" {
|
||||
"h2, h4 { font-family: Arial, Helvetica, sans-serif; }"
|
||||
}
|
||||
}
|
||||
div style="display: flex; flex-direction: column; align-items: center;" {
|
||||
// compose with variables and strings
|
||||
h2 { (email.subject) " (" (email.policy_code) ")" }
|
||||
p { "Vers.-Schein/Schadennummer: " (email.policy_code) }
|
||||
p { "Versicherungsnehmer: " (email.policy_holder) }
|
||||
p { "Selbstbehalt: "(email.deductible) }
|
||||
p { "Rückrufnummer: " (email.callback_number) }
|
||||
p { "Erreichbarkeit: " (email.callback_date) }
|
||||
p { "Rechtsproblem: "(email.harm_type) }
|
||||
p { "Rechtsrat: "(email.ivr_comment) }
|
||||
}
|
||||
};
|
||||
|
||||
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";
|
||||
|
||||
info!("email body: {:?}", ascii_body);
|
||||
|
||||
let message = Message::builder()
|
||||
//.reply_to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.cc(" <ralf.zerres@networkx.de>".parse().unwrap())
|
||||
.reply_to((email.mail_reply).parse().unwrap())
|
||||
//.to((email.mail_to).parse().unwrap())
|
||||
//.cc((email.mail_cc).parse().unwrap())
|
||||
//.bcc((email.mail_bcc).parse().unwrap())
|
||||
.from((email.mail_from).parse().unwrap())
|
||||
.subject(String::new()
|
||||
+ &email.subject.to_string()
|
||||
+ &" (".to_string()
|
||||
+ &email.policy_code.to_string()
|
||||
+ &")".to_string()
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::alternative() // This is composed of two parts.
|
||||
.singlepart(
|
||||
SinglePart::builder()
|
||||
.header(header::ContentType(
|
||||
"text/plain; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(String::from(ascii_body)),
|
||||
)
|
||||
.singlepart(
|
||||
SinglePart::builder()
|
||||
.header(header::ContentType(
|
||||
"text/html; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(html.into_string()),
|
||||
),
|
||||
)
|
||||
.expect("failed to build email");
|
||||
|
||||
|
||||
info!("message: {:?}", message);
|
||||
|
||||
// Create credential for remote authentication (username, password)
|
||||
// WIP: get credentials from config file / cli
|
||||
let creds = Credentials::new("info@kanzlei.hiedemann.de".to_string(), "17info67$".to_string());
|
||||
|
||||
|
||||
|
||||
// Open a remote connection to relay server (port 2525)
|
||||
// WIP: get relay address from config file / cli
|
||||
let mailer = SmtpTransport::relay("hiedemannsbs.kanzlei.hiedemann.de")
|
||||
.unwrap()
|
||||
.credentials(creds)
|
||||
.build();
|
||||
|
||||
// Send the email
|
||||
match mailer.send(&message) {
|
||||
Ok(_) => info!("Email sent successfully!"),
|
||||
Err(e) => error!("Could not send email: {:?}", e),
|
||||
}
|
||||
|
||||
trace!(target: "sendticketdata", email = ?email);
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("sendticketdata.export.finished", lang);
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
133
crates/advotracker/src/services/imports/allianzdirectcall.rs
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
use std::error::Error;
|
||||
use std::collections::HashMap;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tracing::trace;
|
||||
|
||||
//use crate::db::redis;
|
||||
use crate::data::structures::{PolicyCode, PolicyDataList, PolicyData};
|
||||
//use crate::data::structures::PolicyDataList;
|
||||
|
||||
/// import AllianzDirectCall data from a csv delimeted file
|
||||
/// save records to redis backend
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||
policy_data_count: &mut u64,
|
||||
lang: &str)
|
||||
-> Result<(u64, Duration), Box<dyn Error>> {
|
||||
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);
|
||||
let time_start = SystemTime::now();
|
||||
let datetime: DateTime<Local> = time_start.into();
|
||||
|
||||
trace!(target: "csv-import", process = ?res, state = ?state, date_start = ?datetime.to_string());
|
||||
|
||||
// Note: slash syntax also works on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
// must be a readable file
|
||||
trace!(target: "csv-import", path = ?path);
|
||||
assert_eq!(path.is_file(), true);
|
||||
|
||||
// only accept files with '.txt' extensions
|
||||
let extension = path.extension();
|
||||
assert_eq!(extension, Some(OsStr::new("txt")));
|
||||
|
||||
// open the file
|
||||
let file = File::open(path)?;
|
||||
trace!(target: "csv-import", extension = ?extension, file = ?file);
|
||||
|
||||
// Build the CSV reader
|
||||
let mut csv_reader = csv::ReaderBuilder::new()
|
||||
.has_headers(true)
|
||||
.delimiter(b' ')
|
||||
//.comment(Some(b'#'))
|
||||
//.flexible(true)
|
||||
.from_reader(file);
|
||||
{
|
||||
// We nest this call in its own scope because of lifetimes.
|
||||
let headers = csv_reader.headers()?;
|
||||
trace!(target: "csv-import", header = ?headers);
|
||||
}
|
||||
|
||||
// Iterate over each record, deserialize und write to our structures
|
||||
let mut count : u64 = 0;
|
||||
for result in csv_reader.deserialize() {
|
||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||
// error here.
|
||||
let record: PolicyData = result?;
|
||||
//if verbose > 3 {
|
||||
// println!("{:?}", record);
|
||||
//}
|
||||
|
||||
// WIP: write to redis backend
|
||||
// for now: append the policy_number to the HashMap
|
||||
policy_numbers.insert(record.policy_number, record.policy_code);
|
||||
|
||||
// push record as new vector elements
|
||||
data_list.push(record);
|
||||
|
||||
count +=1;
|
||||
*policy_data_count = count;
|
||||
};
|
||||
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start)
|
||||
.expect("Clock may have gone backwards");
|
||||
trace!(target: "csv-import", record_count = ?count, duration = ?duration);
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.import.finished", lang);
|
||||
let datetime: DateTime<Local> = time_end.into();
|
||||
trace!(target: "csv-import", process = ?res, state = ?state, date_stop = ?datetime.to_string());
|
||||
|
||||
Ok((count, duration))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import() {
|
||||
// Takes a reference and returns Option<&V>
|
||||
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
|
||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||
|
||||
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
||||
let mut policy_data_count: u64 = 0;
|
||||
let lang = "en".to_string();
|
||||
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &mut policy_data_count,
|
||||
&lang) {
|
||||
Ok((count, duration)) => {
|
||||
println!("import {:?} records. Duration: {:?}", count, duration);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running CSV-Import: {}", err);
|
||||
}
|
||||
};
|
||||
|
||||
for p in &my_policy_numbers {
|
||||
match policy_numbers.get(&p) {
|
||||
Some(policy_code) => {
|
||||
println!("Test: Policy-Number {:?} => Policy-Type {:?}, as expected!",
|
||||
p, policy_code);
|
||||
},
|
||||
_ => println!("Test: Policy-Number {:?} => not valid, can't dereference the Policy-Type as expected", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
30
crates/advotracker/src/services/imports/csv-test.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
use std::process;
|
||||
|
||||
/// Testing: import from csv format (Standard in)
|
||||
fn import() -> Result<(), Box<dyn Error>> {
|
||||
// Build the CSV reader and iterate over each record.
|
||||
let mut csv_reader = csv::Reader::from_reader(io::stdin());
|
||||
for result in csv_reader.records() {
|
||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||
// error here.
|
||||
let record = result?;
|
||||
println!("{:?}", record);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = import() {
|
||||
println!("import error: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
9
crates/advotracker/src/services/imports/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// Importing Allianz DirecCall data
|
||||
pub mod allianzdirectcall;
|
||||
12
crates/advotracker/src/services/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// advotracker import modules
|
||||
pub mod imports;
|
||||
|
||||
/// advotracker export modules
|
||||
pub mod exports;
|
||||