REDACTED-rig/index.html
BenDroid 7cc38f768f Added current algo to clientStatus
Added client config editor to dashboard
Little beautifying of dashboard
2017-11-01 22:43:04 +01:00

182 lines
No EOL
7.3 KiB
HTML

<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"utf-8\">
<title>XMRigCC Dashboard</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
.right{text-align:right;}
.center{text-align:center;}
</style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.6.1/jquery.timeago.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/6b3cdfc597.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var table = $('#clientStatusList').DataTable({
dom: 'Bfrtip',
processing : true,
bPaginate : false,
ajax : {
url : "/admin/getClientStatusList",
dataSrc : 'client_status_list'
},
columns: [
{ data: "client_status.client_id"},
{ data: "client_status.current_pool"},
{ data: "client_status.current_status"},
{ data: "client_status.current_algo_name"},
{ data: "client_status.hashrate_short", render: round, className: "right"},
{ data: "client_status.hashrate_medium", render: round, className: "right"},
{ data: "client_status.hashrate_long", render: round, className: "right"},
{ data: "client_status.hashrate_highest", render: round, className: "right"},
{ data: "client_status.hashes_total", className: "right"},
{ data: "client_status.avg_time", className: "right"},
{ data: "client_status.shares_good", className: "right"},
{ data: "client_status.shares_total", className: "right"},
{ data: "client_status.last_status_update", render: laststatus},
{
targets: -1,
data: null,
defaultContent:
"<div class='btn-group btn-group-xs'>" +
"<button type='button' id='START' class='btn btn-success' data-toggle='tooltip' title='Start'><i class='fa fa-play'></i></button>" +
"<button type='button' id='STOP' class='btn btn-warning' data-toggle='tooltip' title='Stop'><i class='fa fa-pause'></i></button>" +
"<button type='button' id='RESTART' class='btn' data-toggle='tooltip' title='Restart'><i class='fa fa-repeat'></i></button>" +
"<button type='button' id='UPDATE_CONFIG' class='btn btn-info' data-toggle='tooltip' title='Update Config'><i class='fa fa-refresh'></i></button>" +
"<button type='button' id='EDIT' class='btn btn-primary' data-toggle='tooltip' title='Edit Client Config'><i class='fa fa-cog'></i></button>" +
"<button type='button' id='SHUTDOWN' class='btn btn-danger' data-toggle='tooltip' title='Stutdown Client'><i class='fa fa-power-off'></i></button>" +
"</div>",
className: "center"
}
],
order: [ 11, 'desc' ],
});
$('#clientStatusList tbody').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
var clientId = data['client_status']['client_id'];
var action = this.id;
if (action != "EDIT"){
$.ajax({
type: "POST",
url: "/admin/setClientCommand?clientId=" + clientId,
dataType:"text",
data: '{"control_command":{"command": "' + action + '"}}',
success: function(data){
alert("Successfully send: " + action + " to: " + clientId);
},
error: function (data) {
alert("Failed to send: " + action +" to: " + clientId + "\nError: " + JSON.stringify(data,undefined, 2));
}
});
}
else {
$.get("/admin/getClientConfig?clientId="+clientId, function (jsonClientConfig) {
var htmlContent = "<div class='form-group' id='editor' data-value='" + clientId + "'>" +
"<label for='config'>Config for: " + clientId + "</label>"+
"<textarea class='form-control' rows='20' id='config'>" +
JSON.stringify(jsonClientConfig,undefined, 2); +
"</textarea>" +
"</div>";
$('#editConfig').find('.modal-body').html(htmlContent);
$('#editConfig').modal('show');
});
}
});
$('button.btn.btn-success').click(function(event)
{
var clientId = $('#editConfig').find('.form-group')["0"].dataset.value;
event.preventDefault();
$.ajax({
url: "/admin/setClientConfig?clientId=" + clientId,
type: 'POST',
dataType: "text",
data: $('#config').val(),
success: function(data){
alert("Successfully saved config for: " + clientId);
},
error: function (data) {
alert("Failed to store config for: " + clientId + "\nError: " + JSON.stringify(data,undefined, 2));
}
});
});
setInterval(function () {
table.ajax.reload();
}, 10000);
});
function laststatus( data, type, row ) {
var date = new Date(data*1000);
return '<span data-toggle="tooltip" title="' + date + '">' + jQuery.timeago(date) + '</span>';
}
function round( data, type, row ) {
return Math.round(data).toFixed();
}
</script>
</head>
<body>
<br/>
<div style="width: 90%; margin:0 auto;">
<div class="center">
<h1>XMRigCC Dashboard</h1>
</div>
<table id="clientStatusList" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Client Id</th>
<th>Pool</th>
<th>Status</th>
<th>Algo</th>
<th>Hashrate</th>
<th>Hashrate 5m</th>
<th>Hashrate 60m</th>
<th>Hashrate Highest</th>
<th>Hashes Total</th>
<th>Avg. Time</th>
<th>Shares Good</th>
<th>Shares Total</th>
<th>Last Update</th>
<th>Action</th>
</tr>
</thead>
</table>
<div class="modal fade" id="editConfig" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Config editor</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>