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:
parent
5b0fed8be9
commit
78809d44bc
3 changed files with 67 additions and 3 deletions
53
index.html
53
index.html
|
@ -292,12 +292,14 @@
|
||||||
|
|
||||||
if (arrayLength > 0 ) {
|
if (arrayLength > 0 ) {
|
||||||
$('#templateEditorSave').prop('disabled', false);
|
$('#templateEditorSave').prop('disabled', false);
|
||||||
|
$('#templateEditorDeleteDialog').prop('disabled', false);
|
||||||
|
|
||||||
$('#templateSelector').html(htmlContent);
|
$('#templateSelector').html(htmlContent);
|
||||||
$('#templateSelector').selectpicker('refresh');
|
$('#templateSelector').selectpicker('refresh');
|
||||||
$('#templateSelector').trigger('change');
|
$('#templateSelector').trigger('change');
|
||||||
} else {
|
} else {
|
||||||
$('#templateEditorSave').prop('disabled', true);
|
$('#templateEditorSave').prop('disabled', true);
|
||||||
|
$('#templateEditorDeleteDialog').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#templateEditor').modal('show');
|
$('#templateEditor').modal('show');
|
||||||
|
@ -511,6 +513,10 @@
|
||||||
$('#templateDialogSaveAs').modal('show');
|
$('#templateDialogSaveAs').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#templateEditorDeleteDialog').click(function(event) {
|
||||||
|
$('#templateDialogDelete').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
$('#templateEditorSaveAs').click(function(event) {
|
$('#templateEditorSaveAs').click(function(event) {
|
||||||
var templateId = $('#templateName').val();
|
var templateId = $('#templateName').val();
|
||||||
var template = $('#template').val();
|
var template = $('#template').val();
|
||||||
|
@ -520,6 +526,12 @@
|
||||||
$('#templateEditor').modal('hide');
|
$('#templateEditor').modal('hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#templateEditorDelete').click(function(event) {
|
||||||
|
var templateId = $('#templateSelector').val();
|
||||||
|
|
||||||
|
deleteTemplateConfig(templateId, template);
|
||||||
|
});
|
||||||
|
|
||||||
$('#clientStatusList tbody').on( 'click', 'button#LOG', function () {
|
$('#clientStatusList tbody').on( 'click', 'button#LOG', function () {
|
||||||
var data = table.row( $(this).parents('tr') ).data();
|
var data = table.row( $(this).parents('tr') ).data();
|
||||||
var clientId = data['client_status']['client_id'];
|
var clientId = data['client_status']['client_id'];
|
||||||
|
@ -856,6 +868,20 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteTemplateConfig(templateId) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/admin/deleteClientConfig?clientId=template_" + templateId,
|
||||||
|
type: 'POST',
|
||||||
|
dataType: "text",
|
||||||
|
success: function(data){
|
||||||
|
setSuccess('<strong>Successfully deleted template: ' + templateId + '</strong>');
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
setError('<strong>Failed to delete template: ' + templateId + '</strong> \nError: ' + JSON.stringify(data,undefined, 2));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
@ -982,7 +1008,8 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="templateEditorSave" type="button" class="btn btn-success" data-dismiss="modal">Save</button>
|
<button id="templateEditorSave" type="button" class="btn btn-success" data-dismiss="modal">Save</button>
|
||||||
<button id="templateEditorSaveAsDialog" type="button" class="btn btn-primary">Save As...</button>
|
<button id="templateEditorSaveAsDialog" type="button" class="btn btn-primary">Save As...</button>
|
||||||
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
|
<button id="templateEditorDeleteDialog" type="button" class="btn btn-danger" data-dismiss="modal">Delete</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1003,7 +1030,27 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="templateEditorSaveAs" type="button" class="btn btn-success" data-dismiss="modal">Save</button>
|
<button id="templateEditorSaveAs" type="button" class="btn btn-success" data-dismiss="modal">Save</button>
|
||||||
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="templateDialogDelete" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title">Delete</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="templateName">Do you really want to delete this template?</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button id="templateEditorDelete" type="button" class="btn btn-danger" data-dismiss="modal">Delete</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1034,7 +1081,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="assignTemplate" type="button" class="btn btn-success" data-dismiss="modal">Assign</button>
|
<button id="assignTemplate" type="button" class="btn btn-success" data-dismiss="modal">Assign</button>
|
||||||
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -155,6 +155,8 @@ unsigned Service::handlePOST(const Options* options, const std::string& url, con
|
||||||
resultCode = setClientConfig(options, clientId, data, resp);
|
resultCode = setClientConfig(options, clientId, data, resp);
|
||||||
} else if (url.rfind("/admin/setClientCommand", 0) == 0) {
|
} else if (url.rfind("/admin/setClientCommand", 0) == 0) {
|
||||||
resultCode = setClientCommand(clientId, data, resp);
|
resultCode = setClientCommand(clientId, data, resp);
|
||||||
|
} else if (url.rfind("/admin/deleteClientConfig", 0) == 0) {
|
||||||
|
resultCode = deleteClientConfig(options, clientId, resp);
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("[%s] 400 BAD REQUEST - Request does not contain clientId (%s)", clientIp.c_str(), url.c_str());
|
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)
|
unsigned Service::resetClientStatusList(const std::string& data, std::string& resp)
|
||||||
{
|
{
|
||||||
m_clientStatus.clear();
|
m_clientStatus.clear();
|
||||||
|
|
|
@ -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 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 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 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 unsigned resetClientStatusList(const std::string& data, std::string& resp);
|
||||||
|
|
||||||
static void setClientLog(size_t maxRows, const std::string& clientId, const std::string& log);
|
static void setClientLog(size_t maxRows, const std::string& clientId, const std::string& log);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue