diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 6c5d833..7a64514 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,10 +1,10 @@ - + EnvironmentId - {d36652ff-969b-426b-a63f-1edd325096c5} + {551ef6b3-a39b-43e2-9ee3-ad56e19ff4f4} ProjectExplorer.Project.ActiveTarget @@ -13,8 +13,8 @@ ProjectExplorer.Project.EditorSettings + true true - false true Cpp @@ -33,14 +33,16 @@ false 4 false + 0 80 true true 1 + 0 false true false - 0 + 2 true true 0 @@ -68,7 +70,9 @@ true true + false + 0 true @@ -76,6 +80,7 @@ true Builtin.DefaultTidyAndClazy 8 + true @@ -87,19 +92,26 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop - Desktop - {15eefee5-3141-47ab-aab0-72db66b5555b} + true + Importiertes Kit + Importiertes Kit + {c305b734-2e7c-49c6-bd3a-cd5bcb4ae45e} 0 0 0 - Release + Debug + 2 false - -DCMAKE_GENERATOR:STRING=Ninja Multi-Config --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /mnt/share/torsten/Programs/SingleChat /home/torsten/Programs/SingleChat/build @@ -140,17 +152,92 @@ false - Debug + Debug (importiert) CMakeProjectManager.CMakeBuildConfiguration + 0 + 0 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Application Manager-Paket installieren + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + singlechat.wt + CMakeProjectManager.CMakeRunConfiguration. + singlechat.wt + false + true + true + true + /home/torsten/Programs/SingleChat/build/Debug + + 1 Release + 2 false - -DCMAKE_GENERATOR:STRING=Ninja Multi-Config --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} - /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /mnt/share/torsten/Programs/SingleChat + /home/torsten/Programs/SingleChat/build @@ -188,17 +275,73 @@ false - Release + Release (importiert) CMakeProjectManager.CMakeBuildConfiguration + 0 + -1 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + install + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Application Manager-Paket installieren + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + 0 RelWithDebInfo + 2 false - -DCMAKE_GENERATOR:STRING=Ninja Multi-Config --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} - /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /mnt/share/torsten/Programs/SingleChat + /home/torsten/Programs/SingleChat/build @@ -236,107 +379,60 @@ false - Release mit Debuginformationen + Release mit Debuginformationen (importiert) CMakeProjectManager.CMakeBuildConfiguration + 0 + -1 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + install + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Application Manager-Paket installieren + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + 0 - - RelWithDebInfo - false - - -DCMAKE_GENERATOR:STRING=Ninja Multi-Config --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} - 0 - /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - Erstellen - Erstellen - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - Bereinigen - Bereinigen - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - CMakeProjectManager.CMakeBuildConfiguration - - - MinSizeRel - false - - -DCMAKE_GENERATOR:STRING=Ninja Multi-Config --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} - /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - Erstellen - Erstellen - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - Bereinigen - Bereinigen - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release (kleinstmöglich) - CMakeProjectManager.CMakeBuildConfiguration - - 5 + 3 0 @@ -349,25 +445,59 @@ false ProjectExplorer.DefaultDeployConfiguration - 1 + + + + + + + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Application Manager-Paket installieren + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 true true + 0 true - /usr/bin/valgrind 2 + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 singlechat.wt - CMakeProjectManager.CMakeRunConfiguration.singlechat.wt + CMakeProjectManager.CMakeRunConfiguration. singlechat.wt - --docroot="../../docroot" --http-address=0.0.0.0 --http-port=5050 - false + false true true - false true - /home/torsten/Programs/SingleChat/build/Release + /home/torsten/Programs/SingleChat/build/Debug 1 diff --git a/CMakeLists.txt.user.d36652f b/CMakeLists.txt.user.d36652f new file mode 100644 index 0000000..6c5d833 --- /dev/null +++ b/CMakeLists.txt.user.d36652f @@ -0,0 +1,387 @@ + + + + + + EnvironmentId + {d36652ff-969b-426b-a63f-1edd325096c5} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {15eefee5-3141-47ab-aab0-72db66b5555b} + 0 + 0 + 0 + + Release + false + + -DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + /home/torsten/Programs/SingleChat/build + + + + + all + + false + + true + Erstellen + CMakeProjectManager.MakeStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + Erstellen + CMakeProjectManager.MakeStep + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + Release + false + + -DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + false + + -DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release mit Debuginformationen + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + false + + -DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + 0 + /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + CMakeProjectManager.CMakeBuildConfiguration + + + MinSizeRel + false + + -DCMAKE_GENERATOR:STRING=Ninja Multi-Config +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} + /home/torsten/Programs/SingleChat/../build-SingleChat-Desktop + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release (kleinstmöglich) + CMakeProjectManager.CMakeBuildConfiguration + + 5 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + /usr/bin/valgrind + + 2 + + singlechat.wt + CMakeProjectManager.CMakeRunConfiguration.singlechat.wt + singlechat.wt + --docroot="../../docroot" --http-address=0.0.0.0 --http-port=5050 + false + true + true + false + true + /home/torsten/Programs/SingleChat/build/Release + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/docroot/style.css b/docroot/style.css index 2cdfd5d..52b0a7b 100644 --- a/docroot/style.css +++ b/docroot/style.css @@ -31,6 +31,7 @@ h1 { color: #ffffff; height: 2em; margin: 0.2em 0.4em; + cursor: pointer; } .horizontal-box { height: calc(100% - 6em); diff --git a/src/app.cpp b/src/app.cpp index dda03fc..c41686e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -605,6 +605,8 @@ void App::showAdminLogins() { table->elementAt(0, 1)->addNew("Country"); table->elementAt(0, 2)->addNew("Gender"); table->elementAt(0, 3)->addNew("Age"); + table->elementAt(0, 4)->addNew("Datum"); + table->elementAt(0, 5)->addNew("Uhrzeit"); int row = 1; for (const auto& item : jsonArray) { Wt::Json::Object jsonData = item; @@ -612,13 +614,45 @@ void App::showAdminLogins() { std::string country = jsonData.get("country").orIfNull(""); std::string gender = jsonData.get("gender").orIfNull(""); int age = jsonData.get("age").orIfNull(0); + std::string timestamp = jsonData.get("timestamp").orIfNull(""); auto nameCell = table->elementAt(row, 0)->addNew(name); nameCell->setStyleClass("padding-right"); auto countryCell = table->elementAt(row, 1)->addNew(country); countryCell->setStyleClass("padding-right"); auto genderCell = table->elementAt(row, 2)->addNew(gender); genderCell->setStyleClass("padding-right"); - table->elementAt(row, 3)->addNew(std::to_string(age)); + auto ageCell = table->elementAt(row, 3)->addNew(std::to_string(age)); + ageCell->setStyleClass("padding-right"); + + // Zeitstempel in deutsches Format umwandeln (falls vorhanden und gültig) + if (!timestamp.empty()) { + std::istringstream ss(timestamp); + std::tm tm{}; + ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S"); + + if (!ss.fail()) { + std::ostringstream dateStream; + std::ostringstream timeStream; + dateStream.imbue(std::locale("de_DE.utf8")); + timeStream.imbue(std::locale("de_DE.utf8")); + dateStream << std::put_time(&tm, "%d.%m.%Y"); + timeStream << std::put_time(&tm, "%H:%M:%S"); + + auto dateCell = table->elementAt(row, 4)->addNew(dateStream.str()); + dateCell->setStyleClass("padding-right"); + table->elementAt(row, 5)->addNew(timeStream.str()); + } else { + // Fallback bei ungültigem Zeitstempel + auto dateCell = table->elementAt(row, 4)->addNew("-"); + dateCell->setStyleClass("padding-right"); + table->elementAt(row, 5)->addNew("-"); + } + } else { + // Fallback für alte Einträge ohne Zeitstempel + auto dateCell = table->elementAt(row, 4)->addNew("-"); + dateCell->setStyleClass("padding-right"); + table->elementAt(row, 5)->addNew("-"); + } row++; } } @@ -1182,14 +1216,21 @@ void App::showHistory(Wt::Json::Object broadcast) { auto headerWidget = contentContainer_->addNew("

Conversations with already logged in users

"); headerWidget->setInline(false); auto listWidget = contentContainer_->addNew(); - for (Wt::Json::Object user: (Wt::Json::Array)broadcast["data"]) { - auto userName = std::make_shared((std::string)user["name"]); - auto tableCell = listWidget->elementAt(listWidget->rowCount(), 0); - tableCell->addNew(Wt::WString("{1} ({2})").arg(*userName).arg((int)user["age"])); - tableCell->setStyleClass(Wt::WString("user-conversation-info userlist-item userlist-gender-{1}").arg((std::string)user["gender"])); - tableCell->clicked().connect([=, this]() { - requestConversation(*userName); - }); + auto dataArray = (Wt::Json::Array)broadcast["data"]; + + if (dataArray.empty()) { + // Keine bisherigen Unterhaltungen vorhanden + contentContainer_->addNew("No previous conversations available."); + } else { + for (Wt::Json::Object user: dataArray) { + auto userName = std::make_shared((std::string)user["name"]); + auto tableCell = listWidget->elementAt(listWidget->rowCount(), 0); + tableCell->addNew(Wt::WString("{1} ({2})").arg(*userName).arg((int)user["age"])); + tableCell->setStyleClass(Wt::WString("user-conversation-info userlist-item userlist-gender-{1}").arg((std::string)user["gender"])); + tableCell->clicked().connect([=, this]() { + requestConversation(*userName); + }); + } } } catch(std::exception &e) { std::cout << e.what() << std::endl; diff --git a/src/broadcast.cpp b/src/broadcast.cpp index f8ef7fb..985085c 100644 --- a/src/broadcast.cpp +++ b/src/broadcast.cpp @@ -75,7 +75,14 @@ void Broadcast::logClientLogin(const Wt::Json::Object &clientJson) { Wt::Json::parse(fileContent, logArray); } } - logArray.push_back(clientJson); + + // Zeitstempel hinzufügen + Wt::Json::Object logEntry = clientJson; + Wt::WDateTime now = Wt::WDateTime::currentDateTime(); + std::string timestamp = now.toString("yyyy-MM-dd HH:mm:ss").toUTF8(); + logEntry["timestamp"] = Wt::Json::Value(timestamp); + + logArray.push_back(logEntry); std::ofstream outfile(logFilePath); if (outfile.is_open()) { outfile << Wt::Json::serialize(logArray) << std::endl;