<%@ page class="AdminTopicPage" %> <%@ page form="true" %> <%@ page compressed="true" %> <%@ page baseClass="SessionHTTPRequestHandler" %> <%@ page ctorArg="Session*" %> <%@ header include="SessionHTTPRequestHandler.h" %> <%! #include "../controller/HederaAccount.h" #include "../controller/HederaTopic.h" #include "../controller/Group.h" #include "../SingletonManager/SessionManager.h" #include "../ServerConfig.h" #include "../lib/DataTypeConverter.h" #include "../lib/Profiler.h" #include "../lib/Success.h" #include "Poco/Timespan.h" #include "Poco/URI.h" %> <%% const char* pageName = "Topic"; auto user = mSession->getNewUser(); auto sm = SessionManager::getInstance(); Profiler hedera_time; std::string name = ""; int auto_renew_account = 0; int auto_renew_period = 604800; // 7 Tage int group_id = 0; Poco::URI uri(request.getURI()); auto uri_query = uri.getQueryParameters(); std::string action = ""; Poco::AutoPtr query_hedera_topic; // parsing get query params if(uri_query.size() >= 2) { if(uri_query[0].first == "action") { action = uri_query[0].second; } if(uri_query[1].first == "topic_id") { std::string topic_id_from_query; int topic_id = 0; topic_id_from_query = uri_query[1].second; if(DataTypeConverter::strToInt(topic_id_from_query, topic_id) != DataTypeConverter::NUMBER_PARSE_OKAY) { addError(new Error("Int Convert Error", "Error converting topic_id_from_query to int")); } else { auto hedera_topic = controller::HederaTopic::load(topic_id); if(hedera_topic.isNull()) { addError(new Error("Action", "hedera topic not found")); } else { query_hedera_topic = hedera_topic; } } } } // actions if(!query_hedera_topic.isNull()) { if(action == "getTopicInfos") { hedera_time.reset(); if(query_hedera_topic->updateWithGetTopicInfos(user)) { addNotification(new ParamSuccess("Hedera", "hedera get topic infos success in ", hedera_time.string())); } else { addError(new ParamError("Hedera", "hedera get topic infos failed in ", hedera_time.string())); } getErrors(query_hedera_topic); } } else if(!form.empty()) { name = form.get("topic-name", ""); auto auto_renew_account_string = form.get("topic-auto-renew-account", "0"); auto auto_renew_period_string = form.get("topic-auto-renew-period", "604800"); auto group_id_string = form.get("topic-group", "-1"); if(name != "" && !sm->isValid(name, VALIDATE_NAME)) { addError(new Error("Topic", "Name not valid, at least 3 Character")); } if(!sm->isValid(auto_renew_account_string, VALIDATE_ONLY_INTEGER)) { addError(new Error("Topic", "auto renew account id not an integer")); } else { if(DataTypeConverter::strToInt(auto_renew_account_string, auto_renew_account) != DataTypeConverter::NUMBER_PARSE_OKAY) { addError(new Error("Int convert error", "Error converting auto renew account id to int")); } } if(!sm->isValid(auto_renew_period_string, VALIDATE_ONLY_INTEGER)) { addError(new Error("Topic", "auto renew period not an integer")); } else { if(DataTypeConverter::strToInt(auto_renew_period_string, auto_renew_period) != DataTypeConverter::NUMBER_PARSE_OKAY) { addError(new Error("Int convert error", "Error converting auto renew period to int")); } } if(!sm->isValid(group_id_string, VALIDATE_ONLY_INTEGER)) { addError(new Error("Topic", "group_id not an integer")); } else { if(DataTypeConverter::strToInt(group_id_string, group_id) != DataTypeConverter::NUMBER_PARSE_OKAY) { addError(new Error("Int convert error", "Error converting group_id to int")); } } } auto hedera_accounts = controller::HederaAccount::load("user_id", user->getModel()->getID()); //std::vector> hedera_accounts; auto groups = controller::Group::listAll(); std::map group_indices; int count = 0; for(auto it = groups.begin(); it != groups.end(); it++) { group_indices.insert(std::pair((*it)->getModel()->getID(), count)); count++; } auto hedera_topics = controller::HederaTopic::listAll(); //std::vector> hedera_topics; %><%@ include file="header_large.cpsp" %> <%= getErrorsHtml() %>

Topic Admin Page

Hedera Topics

Topic ID
Name
Network Type
Auto Renew Account Balance
Auto Renew Period
Group ID
Current Timeout
Sequence Number
Last Updated
Aktionen
<% for(auto it = hedera_topics.begin(); it != hedera_topics.end(); it++) { auto hedera_topic_model = (*it)->getModel(); auto updateUrl = ServerConfig::g_serverPath + "/topic?action=getTopicInfos&topic_id=" + std::to_string(hedera_topic_model->getID()); auto auto_renew_account = (*it)->getAutoRenewAccount(); auto renew_account_model = auto_renew_account->getModel(); std::string timeout_color = "success-color"; if(hedera_topic_model->getCurrentTimeout() < Poco::DateTime()) { timeout_color = "alert-color"; } else if((hedera_topic_model->getCurrentTimeout() - Poco::DateTime()) < Poco::Timespan(2,0,0,0,0)) { timeout_color = "orange-color"; } %>
<%= (*it)->getTopicHederaId()->getModel()->toString() %>
<%= hedera_topic_model->getName() %>
<%= model::table::HederaAccount::hederaNetworkTypeToString(renew_account_model->getNetworkType()) %>
<%= renew_account_model->getBalanceString() %>
<%= hedera_topic_model->getAutoRenewPeriodString() %>
<%= hedera_topic_model->getGroupId() %>
<%= hedera_topic_model->getCurrentTimeoutString() %>
<%= hedera_topic_model->getSequenceNumber() %>
<%= hedera_topic_model->getUpdatedString() %>
<% } %>

Ein neues Topic anlegen

">
<%@ include file="footer.cpsp" %>