From 64c497ce0dbfa8e6703f1f92ef12b491f1cd8fe9 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Thu, 16 May 2024 12:31:55 +0200 Subject: [PATCH] Upload to Connect changes --- src/slic3r/GUI/Plater.cpp | 32 +++++++++++++++++++++++-------- src/slic3r/Utils/PrintHost.hpp | 4 ++++ src/slic3r/Utils/PrusaConnect.cpp | 16 +++++++++++++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 13f2b3f35e..6289f60293 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6059,12 +6059,12 @@ void Plater::connect_gcode() std::string printer_uuid; std::string team_id; */ - bool set_ready = true; - int position = -1; - int wait_until = 0; - std::string filename = "print.bgcode"; - std::string printer_uuid = "1234-1234-1234-1234"; - std::string team_id = "1234"; + std::string set_ready = p->user_account->get_keyword_from_json(dialog_msg, "set_ready"); + std::string position = p->user_account->get_keyword_from_json(dialog_msg, "position"); + std::string wait_until = p->user_account->get_keyword_from_json(dialog_msg, "wait_until"); + std::string filename = p->user_account->get_keyword_from_json(dialog_msg, "filename"); + std::string printer_uuid = p->user_account->get_keyword_from_json(dialog_msg, "printer_uuid"); + std::string team_id = p->user_account->get_keyword_from_json(dialog_msg, "team_id"); PhysicalPrinter ph_printer("connect_temp_printer", wxGetApp().preset_bundle->physical_printers.default_config(), *selected_printer_preset); ph_printer.config.set_key_value("host_type", new ConfigOptionEnum(htPrusaConnectNew)); @@ -6075,8 +6075,24 @@ void Plater::connect_gcode() PrintHostJob upload_job(physical_printer_config); assert(!upload_job.empty()); - - upload_job.upload_data.upload_path = filename; + /* + wxArrayString storage_paths; + wxArrayString storage_names; + { + wxBusyCursor wait; + try { + upload_job.printhost->get_storage(storage_paths, storage_names); + } + catch (const Slic3r::IOError& ex) { + show_error(this, ex.what(), false); + return; + } + } + */ + upload_job.upload_data.set_ready = set_ready; + upload_job.upload_data.position = position; + upload_job.upload_data.wait_until = wait_until; + upload_job.upload_data.upload_path = filename + ".bgcode"; upload_job.upload_data.post_action = PrintHostPostUploadAction::None; p->export_gcode(fs::path(), false, std::move(upload_job)); diff --git a/src/slic3r/Utils/PrintHost.hpp b/src/slic3r/Utils/PrintHost.hpp index 89f0e1168a..f7b3a5175c 100644 --- a/src/slic3r/Utils/PrintHost.hpp +++ b/src/slic3r/Utils/PrintHost.hpp @@ -41,6 +41,10 @@ struct PrintHostUpload std::string storage; PrintHostPostUploadAction post_action { PrintHostPostUploadAction::None }; + + std::string set_ready; + std::string position; + std::string wait_until; }; class PrintHost diff --git a/src/slic3r/Utils/PrusaConnect.cpp b/src/slic3r/Utils/PrusaConnect.cpp index e7e35794e1..d3c8119ac9 100644 --- a/src/slic3r/Utils/PrusaConnect.cpp +++ b/src/slic3r/Utils/PrusaConnect.cpp @@ -159,7 +159,21 @@ bool PrusaConnectNew::upload(PrintHostUpload upload_data, ProgressFn progress_fn const std::string escaped_upload_path = upload_data.storage + "/" + escape_path_by_element(upload_data.upload_path.string()); const std::string to_print = upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false"; const std::string to_queue = upload_data.post_action == PrintHostPostUploadAction::QueuePrint ? "true" : "false"; - std::string url = GUI::format("%1%/app/teams/%2%/files/raw?upload_id=%3%&force=true&printer_uuid=%4%&path=%5%&to_print=%6%&to_queue=%7%", get_host(), m_team_id, upload_id, m_uuid, escaped_upload_path, to_print, to_queue); + const std::string set_ready = upload_data.set_ready.empty() ? "" : "&set_ready=" + upload_data.set_ready; + const std::string position = upload_data.position.empty() ? "" : "&position=" + upload_data.position; + const std::string wait_until = upload_data.wait_until.empty() ? "" : "&wait_until=" + upload_data.wait_until; + const std::string url = GUI::format( + "%1%/app/teams/%2%/files/raw" + "?upload_id=%3%" + "&force=true" + "&printer_uuid=%4%" + "&path=%5%" + "&to_print=%6%" + "&to_queue=%7%" + "%8%" + "%9%" + "%10%" + , get_host(), m_team_id, upload_id, m_uuid, escaped_upload_path, to_print, to_queue, set_ready, position, wait_until); bool res = true; BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%")