2019-10-07 16:19:01 +00:00
|
|
|
|
{{template "base" .}}
|
|
|
|
|
|
|
|
|
|
{{define "title"}}{{.Title}}{{end}}
|
|
|
|
|
|
|
|
|
|
{{define "extra_css"}}
|
|
|
|
|
<link href="/static/vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
|
<link href="/static/vendor/datatables/select.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
|
<link href="/static/vendor/datatables/buttons.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
|
|
{{define "page_body"}}
|
|
|
|
|
<div id="errorMsg" class="card mb-4 border-left-warning" style="display: none;">
|
|
|
|
|
<div id="errorTxt" class="card-body text-form-error"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card shadow mb-4">
|
|
|
|
|
<div class="card-header py-3">
|
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">View and manage connections</h6>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body">
|
2021-01-23 08:28:45 +00:00
|
|
|
|
{{if .Connections}}
|
2019-10-07 16:19:01 +00:00
|
|
|
|
<div class="table-responsive">
|
|
|
|
|
<table class="table table-striped table-bordered" id="dataTable" width="100%" cellspacing="0">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>Username</th>
|
|
|
|
|
<th>Time</th>
|
|
|
|
|
<th>Info</th>
|
|
|
|
|
<th>Transfers</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{{range .Connections}}
|
|
|
|
|
<tr>
|
|
|
|
|
<td>{{.ConnectionID}}</td>
|
|
|
|
|
<td>{{.Username}}</td>
|
|
|
|
|
<td>{{.GetConnectionDuration}}</td>
|
|
|
|
|
<td>{{.GetConnectionInfo}}</td>
|
|
|
|
|
<td>{{.GetTransfersAsString}}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
{{end}}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
2021-01-23 08:28:45 +00:00
|
|
|
|
{{else}}
|
2021-01-23 09:32:15 +00:00
|
|
|
|
<div class="card mb-2 border-left-info">
|
2021-01-23 08:28:45 +00:00
|
|
|
|
<div class="card-body">No user connected</div>
|
|
|
|
|
</div>
|
|
|
|
|
{{end}}
|
2019-10-07 16:19:01 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
|
|
{{define "dialog"}}
|
|
|
|
|
<div class="modal fade" id="disconnectModal" tabindex="-1" role="dialog" aria-labelledby="disconnectModalLabel"
|
|
|
|
|
aria-hidden="true">
|
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h5 class="modal-title" id="disconnectModalLabel">
|
|
|
|
|
Confirmation required
|
|
|
|
|
</h5>
|
|
|
|
|
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
|
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">Do you want to close the selected connection?</div>
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button class="btn btn-secondary" type="button" data-dismiss="modal">
|
|
|
|
|
Cancel
|
|
|
|
|
</button>
|
|
|
|
|
<a class="btn btn-warning" href="#" onclick="disconnectAction()">
|
|
|
|
|
Disconnect
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
|
|
{{define "extra_js"}}
|
|
|
|
|
<script src="/static/vendor/datatables/jquery.dataTables.min.js"></script>
|
|
|
|
|
<script src="/static/vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
|
|
|
|
<script src="/static/vendor/datatables/dataTables.select.min.js"></script>
|
|
|
|
|
<script src="/static/vendor/datatables/select.bootstrap4.min.js"></script>
|
|
|
|
|
<script src="/static/vendor/datatables/dataTables.buttons.min.js"></script>
|
|
|
|
|
<script src="/static/vendor/datatables/buttons.bootstrap4.min.js"></script>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
function disconnectAction() {
|
|
|
|
|
var table = $('#dataTable').DataTable();
|
2021-01-17 21:29:08 +00:00
|
|
|
|
table.button('disconnect:name').enable(false);
|
2019-10-07 16:19:01 +00:00
|
|
|
|
var connectionID = table.row({ selected: true }).data()[0];
|
2021-01-17 21:29:08 +00:00
|
|
|
|
var path = '{{.ConnectionsURL}}' + "/" + connectionID;
|
2019-10-07 16:19:01 +00:00
|
|
|
|
$('#disconnectModal').modal('hide');
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: path,
|
|
|
|
|
type: 'DELETE',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
timeout: 15000,
|
|
|
|
|
success: function (result) {
|
|
|
|
|
setTimeout(function () {
|
2021-01-17 21:29:08 +00:00
|
|
|
|
table.button('disconnect:name').enable(true);
|
2019-10-07 16:19:01 +00:00
|
|
|
|
window.location.href = '{{.ConnectionsURL}}';
|
|
|
|
|
}, 1000);
|
|
|
|
|
},
|
|
|
|
|
error: function ($xhr, textStatus, errorThrown) {
|
2021-01-17 21:29:08 +00:00
|
|
|
|
table.button('disconnect:name').enable(true);
|
2019-10-07 16:19:01 +00:00
|
|
|
|
var txt = "Unable to close the selected connection";
|
|
|
|
|
if ($xhr) {
|
|
|
|
|
var json = $xhr.responseJSON;
|
|
|
|
|
if (json) {
|
|
|
|
|
txt += ": " + json.message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$('#errorTxt').text(txt);
|
|
|
|
|
$('#errorMsg').show();
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
$('#errorMsg').hide();
|
|
|
|
|
}, 5000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
$.fn.dataTable.ext.buttons.disconnect = {
|
|
|
|
|
text: 'Disconnect',
|
2021-01-17 21:29:08 +00:00
|
|
|
|
name: 'disconnect',
|
2019-10-07 16:19:01 +00:00
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
|
$('#disconnectModal').modal('show');
|
|
|
|
|
},
|
|
|
|
|
enabled: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var table = $('#dataTable').DataTable({
|
|
|
|
|
dom: "<'row'<'col-sm-12'B>>" +
|
|
|
|
|
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
|
|
|
|
|
"<'row'<'col-sm-12'tr>>" +
|
|
|
|
|
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
|
|
|
|
select: true,
|
2021-01-17 21:29:08 +00:00
|
|
|
|
buttons: [],
|
2019-10-07 16:19:01 +00:00
|
|
|
|
"columnDefs": [
|
|
|
|
|
{
|
|
|
|
|
"targets": [0],
|
|
|
|
|
"visible": false,
|
|
|
|
|
"searchable": false
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"scrollX": false,
|
|
|
|
|
"order": [[1, 'asc']]
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-17 21:29:08 +00:00
|
|
|
|
{{if .LoggedAdmin.HasPermission "close_conns"}}
|
|
|
|
|
table.button().add(0,'disconnect');
|
|
|
|
|
|
2019-10-07 16:19:01 +00:00
|
|
|
|
table.on('select deselect', function () {
|
|
|
|
|
var selectedRows = table.rows({ selected: true }).count();
|
2021-01-17 21:29:08 +00:00
|
|
|
|
table.button('disconnect:name').enable(selectedRows == 1);
|
2019-10-07 16:19:01 +00:00
|
|
|
|
});
|
2021-01-17 21:29:08 +00:00
|
|
|
|
{{end}}
|
2019-10-07 16:19:01 +00:00
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
{{end}}
|