Files
dag_engine_ui/main.cpp
T
egutierrez 44026d0a70 feat: cliente HTTP REST + main panel demo (issue 0095 step 3)
- http_client.{h,cpp}: TCP plain (copia de registry_dashboard, sin SSL).
- data_http.{h,cpp}: API DAG (list/get/runs/trigger) + parser nlohmann/json.
- vendor/nlohmann/json.hpp: vendored.
- main.cpp: panel "Fetch /api/dags" demo, lista DAGs con schedule.
- CMakeLists.txt: anade http_client.cpp + data_http.cpp.

Build verificado. WS y tabs (data_table::render) en commits siguientes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 16:44:40 +02:00

74 lines
2.5 KiB
C++

#include <imgui.h>
#include "app_base.h"
#include "core/panel_menu.h"
#include "core/icons_tabler.h"
#include "core/logger.h"
#include "data_http.h"
#include <string>
#include <vector>
// Config global del backend HTTP. Persistido por imgui.ini via Mantine-no-go.
static std::string g_api_url = "http://127.0.0.1:8090";
// Cache en memoria del primer fetch. Tabs proximos updates via WS.
static std::vector<dag_ui::DagInfo> g_dags;
static std::string g_last_error;
// Toggles de paneles (visibles desde el menu View del menubar canonico)
static bool g_show_main = true;
static void draw_main() {
if (!ImGui::Begin(TI_HOME " Main", &g_show_main)) {
ImGui::End();
return;
}
ImGui::Text("API: %s", g_api_url.c_str());
if (ImGui::Button("Fetch /api/dags")) {
g_dags.clear();
g_last_error.clear();
if (!dag_ui::list_dags_http(g_api_url, g_dags)) {
g_last_error = "list_dags_http failed (see stderr)";
}
}
if (!g_last_error.empty()) {
ImGui::TextColored(ImVec4(1, 0.4f, 0.4f, 1), "%s", g_last_error.c_str());
}
ImGui::Separator();
ImGui::Text("DAGs: %zu", g_dags.size());
for (auto& d : g_dags) {
ImGui::BulletText("%s (%s) schedule=%s",
d.name.c_str(),
d.valid ? "valid" : "invalid",
d.schedule.empty() ? "none" : d.schedule[0].c_str());
}
ImGui::End();
}
static void render() {
// El framework dibuja menubar (View/Layouts/Settings/About) y un
// DockSpaceOverViewport central (auto_dockspace=true por defecto).
// Aqui solo se dibujan los paneles propios de la app.
if (g_show_main) draw_main();
// === Data panel (uncomment to enable) ===
// static data_table::State data_state;
// static std::vector<data_table::TableInput> data_tables; // populate from your source
// data_table::render("main_data", data_tables, data_state);
}
int main(int /*argc*/, char** /*argv*/) {
static fn_ui::PanelToggle panels[] = {
{ "Main", nullptr, &g_show_main },
};
fn::AppConfig cfg;
cfg.title = "dag_engine_ui — Frontend ImGui para dag_engine. Lista, lanza e inspecciona DAGs con live updates via WS.";
cfg.about = { "dag_engine_ui", "0.1.0", "Frontend ImGui para dag_engine. Lista, lanza e inspecciona DAGs con live updates via WS." };
cfg.log = { "dag_engine_ui.log", 1 };
cfg.panels = panels;
cfg.panel_count = sizeof(panels) / sizeof(panels[0]);
return fn::run_app(cfg, render);
}