|
|
@@ -10,6 +10,7 @@
|
|
|
|
|
|
#include "saura/cmd/sandbox/client/client.hpp"
|
|
|
#include "saura/cmd/sandbox/folder/folder.hpp"
|
|
|
+#include "saura/cmd/sandbox/user/user.hpp"
|
|
|
#include "server/server.hpp"
|
|
|
|
|
|
namespace saura {
|
|
|
@@ -20,6 +21,7 @@ static int32_t selected_node = -1;
|
|
|
struct SandboxApp : AppBase {
|
|
|
std::shared_ptr<ServerAPI> server_api_ctx;
|
|
|
std::vector<ClientInfo> clients;
|
|
|
+ std::vector<UserInfo> users;
|
|
|
Folder category_root;
|
|
|
|
|
|
void start() override {
|
|
|
@@ -27,6 +29,7 @@ struct SandboxApp : AppBase {
|
|
|
|
|
|
this->server_api_ctx = std::make_shared<ServerAPI>();
|
|
|
this->clients = server_api_ctx->fetch_clients(10, 0);
|
|
|
+ this->users = server_api_ctx->fetch_users(10, 0);
|
|
|
|
|
|
category_root = Folder("root");
|
|
|
category_root.add("A")->add("B");
|
|
|
@@ -51,8 +54,9 @@ struct SandboxApp : AppBase {
|
|
|
|
|
|
ImGuiTreeNodeFlags node_flags =
|
|
|
ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanAvailWidth;
|
|
|
- bool open = ImGui::TreeNodeEx(fmt::format("{}#{}", f.name.c_str(), i).c_str(), node_flags, "%s",
|
|
|
- f.name.c_str());
|
|
|
+ bool open =
|
|
|
+ ImGui::TreeNodeEx(fmt::format("{}#{}", f.name.c_str(), i).c_str(),
|
|
|
+ node_flags, "%s", f.name.c_str());
|
|
|
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
spdlog::info("Clieked: {}", i);
|
|
|
@@ -259,8 +263,90 @@ struct SandboxApp : AppBase {
|
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
|
|
|
|
+ if (ImGui::BeginTabItem("Пользователи")) {
|
|
|
+ ImGuiTableFlags flags =
|
|
|
+ ImGuiTableFlags_Resizable | ImGuiTableFlags_Borders |
|
|
|
+ ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY;
|
|
|
+
|
|
|
+ if (ImGui::Button("Создать пользователя")) {
|
|
|
+ ImGui::OpenPopup("Test");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ImGui::BeginPopupModal("Test", NULL,
|
|
|
+ ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
+ ImGui::Text("This is the modal content!");
|
|
|
+ ImGui::Separator();
|
|
|
+
|
|
|
+ if (ImGui::Button("Close", ImVec2(120, 0))) {
|
|
|
+ ImGui::CloseCurrentPopup();
|
|
|
+ }
|
|
|
+ ImGui::EndPopup();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ImGui::BeginTable("UserDataTable", 9, flags)) {
|
|
|
+ ImGui::TableSetupColumn("#");
|
|
|
+ ImGui::TableSetupColumn("Логин");
|
|
|
+ ImGui::TableSetupColumn("Роль");
|
|
|
+ ImGui::TableSetupColumn("ФИО");
|
|
|
+ ImGui::TableSetupColumn("Телефон");
|
|
|
+ ImGui::TableSetupColumn("Эл. почта");
|
|
|
+ ImGui::TableSetupColumn("Дата регистрации");
|
|
|
+ ImGui::TableSetupColumn(""); // Edit
|
|
|
+ ImGui::TableSetupColumn(""); // Delete
|
|
|
+ ImGui::TableHeadersRow();
|
|
|
+
|
|
|
+ int32_t selected_row_idx = -1;
|
|
|
+ for (size_t idx = 0; idx < this->users.size(); idx++) {
|
|
|
+ auto &client = this->users[idx];
|
|
|
+
|
|
|
+ ImGui::TableNextRow();
|
|
|
+
|
|
|
+ // #
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%03d", (int)idx + 1);
|
|
|
+
|
|
|
+ // Логин
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.login.c_str());
|
|
|
+
|
|
|
+ // Роль
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.role.c_str());
|
|
|
+
|
|
|
+ // ФИО
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.full_name.c_str());
|
|
|
+
|
|
|
+ // Телефон
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.phone.c_str());
|
|
|
+
|
|
|
+ // Эл. почта
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.email.c_str());
|
|
|
+
|
|
|
+ // Дата регистрации
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::Text("%s", client.reg_date.c_str());
|
|
|
+
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::PushID(fmt::format("{}Edit", idx).c_str());
|
|
|
+ ImGui::Button("Edit");
|
|
|
+ ImGui::PopID();
|
|
|
+
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::PushID(fmt::format("{}Delete", idx).c_str());
|
|
|
+ ImGui::Button("Delete");
|
|
|
+ ImGui::PopID();
|
|
|
+ }
|
|
|
+
|
|
|
+ ImGui::EndTable();
|
|
|
+ }
|
|
|
+ ImGui::EndTabItem();
|
|
|
+ }
|
|
|
+
|
|
|
if (ImGui::BeginTabItem("Настройки")) {
|
|
|
- ImGui::Text("Hello from the third tab.");
|
|
|
+ ImGui::Text("Hello");
|
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
|
ImGui::EndTabBar();
|