From 151d544985343137fd3984cc0c3ecda70df9ee9c Mon Sep 17 00:00:00 2001 From: Harvey Fong Date: Thu, 13 Mar 2025 19:06:44 -0600 Subject: [PATCH] added TODO comments and fleshed out include comments --- poomer-fxtui-modal_select.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/poomer-fxtui-modal_select.cpp b/poomer-fxtui-modal_select.cpp index 9cb575c..790bbb6 100644 --- a/poomer-fxtui-modal_select.cpp +++ b/poomer-fxtui-modal_select.cpp @@ -8,16 +8,15 @@ // It is a lightweight library that is easy to use and understand. // It is a modern C++ library that provides a functional approach to building terminal applications. -#include // for allocator, shared_ptr, __shared_ptr_access +#include // for allocator, shared_ptr, __shared_ptr_access, used in ftxui #include // for string, basic_string, char_traits, operator+ -#include // for vector -#include // for regex validation -#include // for string stream -#include // for cout -#include // for ifstream, ofstream -#include // for nlohmann/json -#include // for std::this_thread -#include // for std::chrono +#include // for vector, for server_address_labels and bsz_files +#include // for regex validation , for ipv4 and fqdn validation +#include // for cout, cerr +#include // for ifstream, ofstream, for reading and writing to servers.json +#include // for nlohmann/json, for parsing and writing to servers.json +#include // for std::this_thread, for running the progress animation in a separate thread +#include // for std::chrono, for sleeping the progress animation #include "ftxui/component/captured_mouse.hpp" // for ftxui #include "ftxui/component/component.hpp" // for Button, Renderer, Horizontal, Tab @@ -108,6 +107,9 @@ int main() { // At depth=0, two buttons. One for rating FTXUI and one for quitting. auto ftxui_button_bsz = Button("Select .bsz", [&] { depth = FILE_SELECTION; }); + auto ftxui_button_address = Button("Select Server", [&] { depth = SERVER_SELECTION; }); + auto ftxui_input_address = Input(&address_input, "FQDN or IP address"); + auto ftxui_button_render = Button("Upload and render", [&] { depth = MAIN_SCREEN; @@ -115,6 +117,13 @@ int main() { percentage = 0.0f; // Launch a separate thread for updating the progress + // This is a lambda function that will be called when the button is clicked + // This is a stand-in for the actual uploading process + // [TODO] tie this into the ZMQ chunk upload process + // [TODO] chedck the server address is valid + // [TODO] check the server is reachable + // [TODO] check the file is a valid .bsz file + std::thread animation_thread([&]() { // Update percentage from 0 to 100% in small increments for (float p = 0.0f; p <= 1.0f; p += 0.01f) { @@ -135,9 +144,8 @@ int main() { // Detach the thread so it continues running independently animation_thread.detach(); }); - auto ftxui_button_address = Button("Select Server", [&] { depth = SERVER_SELECTION; }); + auto ftxui_button_quit = Button("Quit", screen.ExitLoopClosure()); - auto ftxui_input_address = Input(&address_input, "FQDN or IP address"); // 1. Read existing JSON file nlohmann::json j;