Added timestamp logging for client logins, enhanced admin login display with date and time columns, and updated CSS for improved user interaction. Adjusted CMake configuration for better project management.
This commit is contained in:
59
src/app.cpp
59
src/app.cpp
@@ -605,6 +605,8 @@ void App::showAdminLogins() {
|
||||
table->elementAt(0, 1)->addNew<Wt::WText>("Country");
|
||||
table->elementAt(0, 2)->addNew<Wt::WText>("Gender");
|
||||
table->elementAt(0, 3)->addNew<Wt::WText>("Age");
|
||||
table->elementAt(0, 4)->addNew<Wt::WText>("Datum");
|
||||
table->elementAt(0, 5)->addNew<Wt::WText>("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<Wt::WText>(name);
|
||||
nameCell->setStyleClass("padding-right");
|
||||
auto countryCell = table->elementAt(row, 1)->addNew<Wt::WText>(country);
|
||||
countryCell->setStyleClass("padding-right");
|
||||
auto genderCell = table->elementAt(row, 2)->addNew<Wt::WText>(gender);
|
||||
genderCell->setStyleClass("padding-right");
|
||||
table->elementAt(row, 3)->addNew<Wt::WText>(std::to_string(age));
|
||||
auto ageCell = table->elementAt(row, 3)->addNew<Wt::WText>(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<Wt::WText>(dateStream.str());
|
||||
dateCell->setStyleClass("padding-right");
|
||||
table->elementAt(row, 5)->addNew<Wt::WText>(timeStream.str());
|
||||
} else {
|
||||
// Fallback bei ungültigem Zeitstempel
|
||||
auto dateCell = table->elementAt(row, 4)->addNew<Wt::WText>("-");
|
||||
dateCell->setStyleClass("padding-right");
|
||||
table->elementAt(row, 5)->addNew<Wt::WText>("-");
|
||||
}
|
||||
} else {
|
||||
// Fallback für alte Einträge ohne Zeitstempel
|
||||
auto dateCell = table->elementAt(row, 4)->addNew<Wt::WText>("-");
|
||||
dateCell->setStyleClass("padding-right");
|
||||
table->elementAt(row, 5)->addNew<Wt::WText>("-");
|
||||
}
|
||||
row++;
|
||||
}
|
||||
}
|
||||
@@ -1182,14 +1216,21 @@ void App::showHistory(Wt::Json::Object broadcast) {
|
||||
auto headerWidget = contentContainer_->addNew<Wt::WText>("<h2>Conversations with already logged in users</h2>");
|
||||
headerWidget->setInline(false);
|
||||
auto listWidget = contentContainer_->addNew<Wt::WTable>();
|
||||
for (Wt::Json::Object user: (Wt::Json::Array)broadcast["data"]) {
|
||||
auto userName = std::make_shared<std::string>((std::string)user["name"]);
|
||||
auto tableCell = listWidget->elementAt(listWidget->rowCount(), 0);
|
||||
tableCell->addNew<Wt::WText>(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<Wt::WText>("No previous conversations available.");
|
||||
} else {
|
||||
for (Wt::Json::Object user: dataArray) {
|
||||
auto userName = std::make_shared<std::string>((std::string)user["name"]);
|
||||
auto tableCell = listWidget->elementAt(listWidget->rowCount(), 0);
|
||||
tableCell->addNew<Wt::WText>(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;
|
||||
|
||||
Reference in New Issue
Block a user