Skip to content

Commit

Permalink
Added resetClientStatusList button to Dashboard #129
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendr0id committed Jun 12, 2018
1 parent f4bd7c1 commit 3e57539
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
32 changes: 32 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@
}
});

new $.fn.dataTable.Buttons(table, {
buttons: [
{ text: '<i class="fa fa-trash-o"> Reset ClientStatusList</i>',
className: 'btn-danger',
enabled: true,
action: function () {
resetClientStatusList();
}
}
]
});

table.buttons(1, null ).container().appendTo(
table.table().container()
);


table.on('xhr.dt', function ( e, settings, json, xhr ) {
// check version
if (latestRelease === "" && json !== undefined) {
Expand Down Expand Up @@ -488,6 +505,21 @@
});
}

function resetClientStatusList() {
$.ajax({
type: "POST",
url: "/admin/resetClientStatusList",
dataType:"text",
data: '',
success: function(data){
setSuccess('<strong>Successfully send the reset client status list request to the Server.</strong> - Now just wait for the next refresh.');
},
error: function (data) {
setError('<strong>Failed to send the reset client status list request to the Server.</strong> \nError: ' + JSON.stringify(data,undefined, 2));
}
});
}

function uptime( data, type, row ) {
if (type !== 'sort') {
var lastStatus = row.client_status.last_status_update * 1000;
Expand Down
9 changes: 9 additions & 0 deletions src/cc/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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/resetClientStatusList", 0) == 0) {
resultCode = resetClientStatusList(data, resp);
}

uv_mutex_unlock(&m_mutex);
Expand Down Expand Up @@ -280,6 +282,13 @@ unsigned Service::setClientCommand(const std::string& clientId, const std::strin
}
}

unsigned Service::resetClientStatusList(const std::string& data, std::string& resp)
{
m_clientStatus.clear();

return MHD_HTTP_OK;
}

unsigned Service::getAdminPage(const Options* options, std::string& resp)
{
std::stringstream data;
Expand Down
1 change: 1 addition & 0 deletions src/cc/Service.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Service
static unsigned setClientStatus(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 resetClientStatusList(const std::string& data, std::string& resp);

static std::string getClientConfigFileName(const Options *options, const std::string &clientId);

Expand Down

0 comments on commit 3e57539

Please sign in to comment.