From cd9ac4a02f9dd88f46c59fd30b8c2eb6f8444576 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 14 Mar 2025 19:33:05 -0500 Subject: [PATCH] add mount via ui --- repertory/repertory/include/ui/handlers.hpp | 4 +++- repertory/repertory/src/ui/handlers.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/repertory/repertory/include/ui/handlers.hpp b/repertory/repertory/include/ui/handlers.hpp index 83d3eeac..408e9e03 100644 --- a/repertory/repertory/include/ui/handlers.hpp +++ b/repertory/repertory/include/ui/handlers.hpp @@ -57,9 +57,11 @@ private: void handle_get_mount_status(auto &&req, auto &&res) const; + void handle_post_add_mount(auto &&req, auto &&res) const; + void handle_post_mount(auto &&req, auto &&res) const; - void handle_put_set_value_by_name(auto &&req, auto &&res); + void handle_put_set_value_by_name(auto &&req, auto &&res) const; auto launch_process(provider_type prov, std::string_view name, std::string_view args, bool background = false) const diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index 349ada85..092246f0 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -104,6 +104,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server) server->Post("/api/v1/mount", [this](auto &&req, auto &&res) { handle_post_mount(req, res); }); + server->Post("/api/v1/add_mount", [this](auto &&req, auto &&res) { + handle_post_add_mount(req, res); + }); + server->Put("/api/v1/set_value_by_name", [this](auto &&req, auto &&res) { handle_put_set_value_by_name(req, res); }); @@ -253,6 +257,16 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const { res.status = http_error_codes::ok; } +void handlers::handle_post_add_mount(auto &&req, auto &&res) const { + auto name = req.get_param_value("name"); + auto prov = provider_type_from_string(req.get_param_value("type")); + auto cfg = nlohmann::json::parse(req.get_param_value("config")); + fmt::println("config: {}-{}-{}", name, app_config::get_provider_name(prov), + cfg.dump(2)); + + res.status = http_error_codes::ok; +} + void handlers::handle_post_mount(auto &&req, auto &&res) const { auto location = utils::path::absolute(req.get_param_value("location")); auto name = req.get_param_value("name"); @@ -268,7 +282,7 @@ void handlers::handle_post_mount(auto &&req, auto &&res) const { res.status = http_error_codes::ok; } -void handlers::handle_put_set_value_by_name(auto &&req, auto &&res) { +void handlers::handle_put_set_value_by_name(auto &&req, auto &&res) const { auto key = req.get_param_value("key"); auto name = req.get_param_value("name"); auto prov = provider_type_from_string(req.get_param_value("type"));