working ratatui frontend

This commit is contained in:
filipriec
2025-02-16 20:35:57 +01:00
parent 598db07f16
commit ffa8931f62
18 changed files with 871 additions and 42 deletions

538
Cargo.lock generated
View File

@@ -32,6 +32,21 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.18"
@@ -234,6 +249,12 @@ dependencies = [
"generic-array",
]
[[package]]
name = "bumpalo"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]]
name = "byteorder"
version = "1.5.0"
@@ -246,6 +267,21 @@ version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
[[package]]
name = "cassowary"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "castaway"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5"
dependencies = [
"rustversion",
]
[[package]]
name = "cc"
version = "1.2.14"
@@ -261,6 +297,19 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
dependencies = [
"android-tzdata",
"iana-time-zone",
"num-traits",
"serde",
"windows-targets 0.52.6",
]
[[package]]
name = "clap"
version = "4.5.29"
@@ -307,6 +356,20 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "compact_str"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32"
dependencies = [
"castaway",
"cfg-if",
"itoa",
"rustversion",
"ryu",
"static_assertions",
]
[[package]]
name = "concurrent-queue"
version = "2.5.0"
@@ -316,6 +379,19 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "console"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"unicode-width 0.2.0",
"windows-sys 0.59.0",
]
[[package]]
name = "const-oid"
version = "0.9.6"
@@ -377,6 +453,31 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crossterm"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
"bitflags",
"crossterm_winapi",
"mio",
"parking_lot",
"rustix",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
@@ -387,6 +488,41 @@ dependencies = [
"typenum",
]
[[package]]
name = "darling"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "der"
version = "0.7.9"
@@ -398,6 +534,29 @@ dependencies = [
"zeroize",
]
[[package]]
name = "deranged"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
dependencies = [
"powerfmt",
"serde",
]
[[package]]
name = "dialoguer"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de"
dependencies = [
"console",
"shell-words",
"tempfile",
"thiserror 1.0.69",
"zeroize",
]
[[package]]
name = "digest"
version = "0.10.7"
@@ -436,6 +595,12 @@ dependencies = [
"serde",
]
[[package]]
name = "encode_unicode"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -827,6 +992,29 @@ dependencies = [
"tracing",
]
[[package]]
name = "iana-time-zone"
version = "0.1.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "icu_collections"
version = "1.5.0"
@@ -945,6 +1133,12 @@ dependencies = [
"syn",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "1.0.3"
@@ -974,6 +1168,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
"serde",
]
[[package]]
@@ -984,6 +1179,26 @@ checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
"serde",
]
[[package]]
name = "indoc"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
[[package]]
name = "instability"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf9fed6d91cfb734e7476a06bde8300a1b94e217e1b523b6f0cd1a01998c71d"
dependencies = [
"darling",
"indoc",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@@ -992,6 +1207,15 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.14.0"
@@ -1007,6 +1231,16 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
@@ -1066,6 +1300,15 @@ version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
[[package]]
name = "lru"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
dependencies = [
"hashbrown 0.15.2",
]
[[package]]
name = "matchit"
version = "0.7.3"
@@ -1110,6 +1353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
dependencies = [
"libc",
"log",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.52.0",
]
@@ -1119,8 +1363,15 @@ name = "multieko2"
version = "0.1.0"
dependencies = [
"clap",
"console",
"crossterm",
"dialoguer",
"dotenvy",
"prost",
"ratatui",
"serde",
"serde_json",
"serde_with",
"sqlx",
"tokio",
"tonic",
@@ -1179,6 +1430,12 @@ dependencies = [
"zeroize",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-integer"
version = "0.1.46"
@@ -1303,6 +1560,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pem-rfc7468"
version = "0.7.0"
@@ -1387,6 +1650,12 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.20"
@@ -1432,7 +1701,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf"
dependencies = [
"heck",
"itertools",
"itertools 0.14.0",
"log",
"multimap",
"once_cell",
@@ -1452,7 +1721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d"
dependencies = [
"anyhow",
"itertools",
"itertools 0.14.0",
"proc-macro2",
"quote",
"syn",
@@ -1506,6 +1775,27 @@ dependencies = [
"getrandom 0.2.15",
]
[[package]]
name = "ratatui"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
dependencies = [
"bitflags",
"cassowary",
"compact_str",
"crossterm",
"indoc",
"instability",
"itertools 0.13.0",
"lru",
"paste",
"strum",
"unicode-segmentation",
"unicode-truncate",
"unicode-width 0.2.0",
]
[[package]]
name = "redox_syscall"
version = "0.5.8"
@@ -1677,6 +1967,36 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_with"
version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa"
dependencies = [
"base64",
"chrono",
"hex",
"indexmap 1.9.3",
"indexmap 2.7.1",
"serde",
"serde_derive",
"serde_json",
"serde_with_macros",
"time",
]
[[package]]
name = "serde_with_macros"
version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "sha1"
version = "0.10.6"
@@ -1708,12 +2028,39 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-mio"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
@@ -1820,7 +2167,8 @@ dependencies = [
"serde_json",
"sha2",
"smallvec",
"thiserror",
"thiserror 2.0.11",
"time",
"tokio",
"tokio-stream",
"tracing",
@@ -1903,7 +2251,8 @@ dependencies = [
"smallvec",
"sqlx-core",
"stringprep",
"thiserror",
"thiserror 2.0.11",
"time",
"tracing",
"whoami",
]
@@ -1940,7 +2289,8 @@ dependencies = [
"smallvec",
"sqlx-core",
"stringprep",
"thiserror",
"thiserror 2.0.11",
"time",
"tracing",
"whoami",
]
@@ -1964,6 +2314,7 @@ dependencies = [
"serde",
"serde_urlencoded",
"sqlx-core",
"time",
"tracing",
"url",
]
@@ -1974,6 +2325,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stringprep"
version = "0.1.5"
@@ -1991,6 +2348,28 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "subtle"
version = "2.6.1"
@@ -2039,13 +2418,33 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
dependencies = [
"thiserror-impl",
"thiserror-impl 2.0.11",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
@@ -2069,6 +2468,37 @@ dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de"
dependencies = [
"num-conv",
"time-core",
]
[[package]]
name = "tinystr"
version = "0.7.6"
@@ -2334,6 +2764,35 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-truncate"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
dependencies = [
"itertools 0.13.0",
"unicode-segmentation",
"unicode-width 0.1.14",
]
[[package]]
name = "unicode-width"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
[[package]]
name = "unicode-width"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "url"
version = "2.5.4"
@@ -2411,6 +2870,64 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]]
name = "whoami"
version = "1.5.2"
@@ -2443,6 +2960,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.48.0"

View File

@@ -5,9 +5,16 @@ edition = "2021"
[dependencies]
clap = { version = "4.5.29", features = ["derive"] }
console = "0.15.10"
crossterm = "0.28.1"
dialoguer = "0.11.0"
dotenvy = "0.15.7"
prost = "0.13.5"
sqlx = { version = "0.8.3", features = ["postgres", "runtime-tokio", "runtime-tokio-native-tls"] }
ratatui = "0.29.0"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.138"
serde_with = "3.12.0"
sqlx = { version = "0.8.3", features = ["postgres", "runtime-tokio", "runtime-tokio-native-tls", "time"] }
tokio = { version = "1.43.0", features = ["full", "macros"] }
tonic = "0.12.3"
tonic-build = "0.12.3"

BIN
docs/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
docs/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
docs/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
docs/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
docs/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
docs/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

2
docs/sqlx_migration.txt Normal file
View File

@@ -0,0 +1,2 @@
DELETE FROM _sqlx_migrations WHERE version = 'number';
DROP TABLE table_name;

View File

@@ -0,0 +1,20 @@
-- Add migration script here
CREATE TABLE adresar (
id BIGSERIAL PRIMARY KEY,
firma TEXT NOT NULL,
kz TEXT,
drc TEXT,
ulica TEXT,
psc TEXT,
mesto TEXT,
stat TEXT,
banka TEXT,
ucet TEXT,
skladm TEXT,
ico TEXT,
kontakt TEXT,
telefon TEXT,
skladu TEXT,
fax TEXT,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);

View File

@@ -7,6 +7,47 @@ service DataProcessor {
rpc ProcessData (DataRequest) returns (DataResponse);
}
service Adresar {
rpc CreateAdresar (AdresarRequest) returns (AdresarResponse);
}
message AdresarRequest {
string firma = 1;
string kz = 2;
string drc = 3;
string ulica = 4;
string psc = 5;
string mesto = 6;
string stat = 7;
string banka = 8;
string ucet = 9;
string skladm = 10;
string ico = 11;
string kontakt = 12;
string telefon = 13;
string skladu = 14;
string fax = 15;
}
message AdresarResponse {
int64 id = 1;
string firma = 2;
string kz = 3;
string drc = 4;
string ulica = 5;
string psc = 6;
string mesto = 7;
string stat = 8;
string banka = 9;
string ucet = 10;
string skladm = 11;
string ico = 12;
string kontakt = 13;
string telefon = 14;
string skladu = 15;
string fax = 16;
}
message DataRequest {
string data = 1;
}

4
src/adresar/handlers.rs Normal file
View File

@@ -0,0 +1,4 @@
// src/adresar/handlers.rs
pub mod create_adresar;
pub use create_adresar::create_adresar;

View File

@@ -0,0 +1,57 @@
// src/adresar/handlers/create_adresar.rs
use tonic::{Request, Response, Status};
use sqlx::PgPool;
use crate::adresar::models::Adresar;
use crate::proto::multieko2::{AdresarRequest, AdresarResponse};
pub async fn create_adresar(
db_pool: &PgPool,
request: AdresarRequest,
) -> Result<AdresarResponse, Status> {
let adresar = sqlx::query_as!(
Adresar,
r#"
INSERT INTO adresar (
firma, kz, drc, ulica, psc, mesto, stat, banka, ucet, skladm, ico, kontakt, telefon, skladu, fax
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
RETURNING id, firma, kz, drc, ulica, psc, mesto, stat, banka, ucet, skladm, ico, kontakt, telefon, skladu, fax
"#,
request.firma,
request.kz,
request.drc,
request.ulica,
request.psc,
request.mesto,
request.stat,
request.banka,
request.ucet,
request.skladm,
request.ico,
request.kontakt,
request.telefon,
request.skladu,
request.fax
)
.fetch_one(db_pool)
.await
.map_err(|e| Status::internal(e.to_string()))?;
Ok(AdresarResponse {
id: adresar.id,
firma: adresar.firma,
kz: adresar.kz.unwrap_or_default(),
drc: adresar.drc.unwrap_or_default(),
ulica: adresar.ulica.unwrap_or_default(),
psc: adresar.psc.unwrap_or_default(),
mesto: adresar.mesto.unwrap_or_default(),
stat: adresar.stat.unwrap_or_default(),
banka: adresar.banka.unwrap_or_default(),
ucet: adresar.ucet.unwrap_or_default(),
skladm: adresar.skladm.unwrap_or_default(),
ico: adresar.ico.unwrap_or_default(),
kontakt: adresar.kontakt.unwrap_or_default(),
telefon: adresar.telefon.unwrap_or_default(),
skladu: adresar.skladu.unwrap_or_default(),
fax: adresar.fax.unwrap_or_default(),
})
}

4
src/adresar/mod.rs Normal file
View File

@@ -0,0 +1,4 @@
// src/adresar/mod.rs
pub mod models;
pub mod handlers;

22
src/adresar/models.rs Normal file
View File

@@ -0,0 +1,22 @@
// src/adresar/models.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Adresar {
pub id: i64,
pub firma: String,
pub kz: Option<String>,
pub drc: Option<String>,
pub ulica: Option<String>,
pub psc: Option<String>,
pub mesto: Option<String>,
pub stat: Option<String>,
pub banka: Option<String>,
pub ucet: Option<String>,
pub skladm: Option<String>,
pub ico: Option<String>,
pub kontakt: Option<String>,
pub telefon: Option<String>,
pub skladu: Option<String>,
pub fax: Option<String>,
}

View File

@@ -1,18 +1,177 @@
// src/client/mod.rs
use tonic::transport::Channel;
use crate::proto::multieko2::data_processor_client::DataProcessorClient;
use crate::proto::multieko2::DataRequest;
use ratatui::{
backend::CrosstermBackend,
widgets::{Block, Borders, Paragraph},
layout::{Layout, Constraint, Direction},
Terminal,
style::{Style, Color},
Frame,
};
use crossterm::{
event::{self, Event, KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use std::io;
use crate::proto::multieko2::{
AdresarRequest,
adresar_client::AdresarClient,
};
pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
let mut client = DataProcessorClient::connect("http://[::1]:50051").await?;
// Setup terminal
enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen)?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let request = tonic::Request::new(DataRequest {
data: "hello world".to_string(),
let mut client = AdresarClient::connect("http://[::1]:50051").await?;
let mut firma = String::new();
let mut kz = String::new();
let mut drc = String::new();
let mut ulica = String::new();
let mut psc = String::new();
let mut mesto = String::new();
let mut stat = String::new();
let mut banka = String::new();
let mut ucet = String::new();
let mut skladm = String::new();
let mut ico = String::new();
let mut kontakt = String::new();
let mut telefon = String::new();
let mut skladu = String::new();
let mut fax = String::new();
let mut current_field = 0;
let fields = vec!["Firma", "KZ", "DRC", "Ulica", "PSC", "Mesto", "Stat", "Banka", "Ucet", "Skladm", "ICO", "Kontakt", "Telefon", "Skladu", "Fax"];
loop {
terminal.draw(|f| {
ui(f, &fields, &mut current_field, &[
&firma, &kz, &drc, &ulica, &psc, &mesto, &stat, &banka, &ucet, &skladm, &ico, &kontakt, &telefon, &skladu, &fax,
]);
})?;
if let Event::Key(key) = event::read()? {
match key.code {
KeyCode::Char(c) => {
match current_field {
0 => firma.push(c),
1 => kz.push(c),
2 => drc.push(c),
3 => ulica.push(c),
4 => psc.push(c),
5 => mesto.push(c),
6 => stat.push(c),
7 => banka.push(c),
8 => ucet.push(c),
9 => skladm.push(c),
10 => ico.push(c),
11 => kontakt.push(c),
12 => telefon.push(c),
13 => skladu.push(c),
14 => fax.push(c),
_ => (),
}
}
KeyCode::Backspace => {
match current_field {
0 => firma.pop(),
1 => kz.pop(),
2 => drc.pop(),
3 => ulica.pop(),
4 => psc.pop(),
5 => mesto.pop(),
6 => stat.pop(),
7 => banka.pop(),
8 => ucet.pop(),
9 => skladm.pop(),
10 => ico.pop(),
11 => kontakt.pop(),
12 => telefon.pop(),
13 => skladu.pop(),
14 => fax.pop(),
_ => None,
};
}
KeyCode::Down => {
if current_field < fields.len() - 1 {
current_field += 1;
}
}
KeyCode::Up => {
if current_field > 0 {
current_field -= 1;
}
}
KeyCode::Enter => {
if current_field == fields.len() - 1 {
break;
} else {
current_field += 1;
}
}
_ => {}
}
}
}
// Cleanup terminal
disable_raw_mode()?;
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
let request = tonic::Request::new(AdresarRequest {
firma,
kz,
drc,
ulica,
psc,
mesto,
stat,
banka,
ucet,
skladm,
ico,
kontakt,
telefon,
skladu,
fax,
});
let response = client.process_data(request).await?;
println!("RESPONSE={:?}", response.into_inner().processed_data);
let response = client.create_adresar(request).await?;
println!("Adresar created: {:?}", response.into_inner());
Ok(())
}
fn ui(
f: &mut Frame,
fields: &[&str],
current_field: &mut usize,
inputs: &[&String],
) {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints::<&[Constraint]>(
&fields
.iter()
.map(|_| Constraint::Length(3))
.collect::<Vec<Constraint>>(),
)
.split(f.area());
for (i, field) in fields.iter().enumerate() {
let input = inputs[i].clone();
let paragraph = Paragraph::new(input)
.block(Block::default().borders(Borders::ALL).title(*field))
.style(if i == *current_field {
Style::default().fg(Color::Yellow)
} else {
Style::default()
});
f.render_widget(paragraph, chunks[i]);
}
}

View File

@@ -3,3 +3,4 @@ pub mod db;
pub mod client;
pub mod server;
pub mod proto;
pub mod adresar;

View File

@@ -1,49 +1,35 @@
// src/server/mod.rs
use tonic::{Request, Response, Status};
use crate::db;
use crate::adresar::handlers::create_adresar;
use crate::proto::multieko2::{
data_processor_server::{DataProcessor, DataProcessorServer},
DataRequest, DataResponse
AdresarRequest, AdresarResponse,
adresar_server::{Adresar, AdresarServer},
};
pub struct DataProcessorService {
pub struct AdresarService {
db_pool: sqlx::PgPool,
}
#[tonic::async_trait]
impl DataProcessor for DataProcessorService {
async fn process_data(
impl Adresar for AdresarService {
async fn create_adresar(
&self,
request: Request<DataRequest>,
) -> Result<Response<DataResponse>, Status> {
let data = request.into_inner().data;
// Store data in database
let stored_data = sqlx::query!(
"INSERT INTO processed_data (content) VALUES ($1) RETURNING id",
data
)
.fetch_one(&self.db_pool)
.await
.map_err(|e| Status::internal(e.to_string()))?;
// Simple processing: convert to uppercase
let processed_data = data.to_uppercase();
Ok(Response::new(DataResponse {
processed_data: format!("Processed data with ID: {}", stored_data.id)
}))
request: Request<AdresarRequest>,
) -> Result<Response<AdresarResponse>, Status> {
let response = create_adresar(&self.db_pool, request.into_inner()).await?;
Ok(Response::new(response))
}
}
pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:50051".parse()?;
let service = DataProcessorService { db_pool };
let adresar_service = AdresarService { db_pool: db_pool.clone() };
println!("Server listening on {}", addr);
tonic::transport::Server::builder()
.add_service(DataProcessorServer::new(service))
.add_service(AdresarServer::new(adresar_service))
.serve(addr)
.await?;