Delete a template from Dashboard (#257)

* Integrated embedded config parsing #245

* cleanup

* Cleanup in remotelog

* Fixed MS Visual Studio 2019 compatibility

* Embedded config parsing only for miner not server

* wip

* Finished delete template
This commit is contained in:
Ben Gräf 2019-07-24 13:58:28 -07:00 committed by GitHub
parent 5b0fed8be9
commit 78809d44bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 3 deletions

View file

@ -155,6 +155,8 @@ unsigned Service::handlePOST(const Options* options, const std::string& url, con
resultCode = setClientConfig(options, clientId, data, resp);
} else if (url.rfind("/admin/setClientCommand", 0) == 0) {
resultCode = setClientCommand(clientId, data, resp);
} else if (url.rfind("/admin/deleteClientConfig", 0) == 0) {
resultCode = deleteClientConfig(options, clientId, resp);
} else {
LOG_WARN("[%s] 400 BAD REQUEST - Request does not contain clientId (%s)", clientIp.c_str(), url.c_str());
}
@ -482,6 +484,20 @@ void Service::setClientLog(size_t maxRows, const std::string& clientId, const st
}
}
unsigned Service::deleteClientConfig(const Options* options, const std::string& clientId, std::string& resp)
{
if (!clientId.empty()) {
std::string clientConfigFileName = getClientConfigFileName(options, clientId);
if (!clientConfigFileName.empty() && remove(clientConfigFileName.c_str()) == 0) {
return MHD_HTTP_OK;
} else {
return MHD_HTTP_NOT_FOUND;
}
} else {
return MHD_HTTP_BAD_REQUEST;
}
}
unsigned Service::resetClientStatusList(const std::string& data, std::string& resp)
{
m_clientStatus.clear();

View file

@ -60,6 +60,7 @@ private:
static unsigned setClientStatus(const Options* options, const std::string& clientIp, const std::string& clientId, const std::string& data, std::string& resp);
static unsigned setClientCommand(const std::string& clientId, const std::string& data, std::string& resp);
static unsigned setClientConfig(const Options* options, const std::string &clientId, const std::string &data, std::string &resp);
static unsigned deleteClientConfig(const Options* options, const std::string& clientId, std::string& resp);
static unsigned resetClientStatusList(const std::string& data, std::string& resp);
static void setClientLog(size_t maxRows, const std::string& clientId, const std::string& log);