2022-12-07 17:47:38 +00:00
|
|
|
<!--
|
2024-01-01 10:31:45 +00:00
|
|
|
Copyright (C) 2019 Nicola Murino
|
2022-12-07 17:47:38 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, version 3.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2023-01-03 09:18:30 +00:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2022-12-07 17:47:38 +00:00
|
|
|
-->
|
|
|
|
{{template "base" .}}
|
|
|
|
|
|
|
|
{{define "title"}}{{.Title}}{{end}}
|
|
|
|
|
|
|
|
{{define "extra_css"}}
|
|
|
|
<link href="{{.StaticURL}}/vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/datatables/buttons.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/datatables/fixedHeader.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/datatables/responsive.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/datatables/select.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet">
|
|
|
|
<link href="{{.StaticURL}}/vendor/daterangepicker/daterangepicker.css" rel="stylesheet">
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{define "page_body"}}
|
2023-10-29 07:17:24 +00:00
|
|
|
<div id="errorMsg" class="alert alert-warning fade show" style="display: none;" role="alert">
|
2023-02-10 17:07:23 +00:00
|
|
|
<span id="errorTxt"></span>
|
2023-10-29 07:17:24 +00:00
|
|
|
<button type="button" class="close" aria-label="Close" onclick="dismissErrorMsg();">
|
2023-02-10 17:07:23 +00:00
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
2022-12-07 17:47:38 +00:00
|
|
|
</div>
|
2023-10-29 07:17:24 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
function dismissErrorMsg(){
|
|
|
|
$('#errorMsg').hide();
|
|
|
|
}
|
|
|
|
</script>
|
2022-12-07 17:47:38 +00:00
|
|
|
<div class="card shadow mb-4">
|
|
|
|
<div class="card-header py-3">
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Search logs</h6>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
|
|
<select class="form-control selectpicker" id="idEventType" name="events_type" onchange="onEventChanged(this.value)">
|
|
|
|
<option value="1" selected>Fs events</option>
|
|
|
|
<option value="2">Provider events</option>
|
2023-05-12 16:34:59 +00:00
|
|
|
<option value="3">Other events</option>
|
2022-12-07 17:47:38 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
|
|
<select class="form-control selectpicker" id="idActions" name="actions" title="Actions" multiple>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
2023-01-15 19:20:39 +00:00
|
|
|
<input type="text" class="form-control" id="idUsername" name="username" spellcheck="false" placeholder="Username">
|
2022-12-07 17:47:38 +00:00
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
|
|
<input type="text" class="form-control" id="idIp" name="ip" placeholder="IP address">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
2023-05-12 16:34:59 +00:00
|
|
|
<select class="form-control selectpicker fs-events" id="idStatuses" name="statuses" title="Statuses" multiple>
|
|
|
|
<option value="1">OK</option>
|
|
|
|
<option value="2">KO</option>
|
|
|
|
<option value="3">Quota exceeded</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<select class="form-control selectpicker fs-events log-events" id="idProtocols" name="protocols" title="Protocols" multiple>
|
2022-12-07 17:47:38 +00:00
|
|
|
<option value="SFTP">SFTP</option>
|
|
|
|
<option value="SCP">SCP</option>
|
|
|
|
<option value="SSH">SSH</option>
|
|
|
|
<option value="FTP">FTP</option>
|
|
|
|
<option value="DAV">DAV</option>
|
|
|
|
<option value="HTTP">HTTP</option>
|
|
|
|
<option value="OIDC">OIDC</option>
|
|
|
|
<option value="HTTPShare">HTTPShare</option>
|
|
|
|
<option value="DataRetention">DataRetention</option>
|
|
|
|
<option value="EventAction">EventAction</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<div class="input-group">
|
|
|
|
<input type="text" id="dateTimeRange" class="form-control bg-light border-0" aria-describedby="search-button">
|
|
|
|
<div class="input-group-append">
|
|
|
|
<button id="search-button" class="btn btn-primary" type="button" onclick="onSearchClicked()">
|
|
|
|
<i class="fas fa-search fa-sm"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-12">
|
|
|
|
<button class="btn btn-secondary mt-1 mb-1 px-5" type="button" onclick="onExportClicked()">Export</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="table-responsive fs-events">
|
|
|
|
<table class="table table-hover nowrap" id="dataTableFs" width="100%" cellspacing="0">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>Time</th>
|
|
|
|
<th>Action</th>
|
|
|
|
<th>Path</th>
|
|
|
|
<th>User</th>
|
|
|
|
<th>Proto</th>
|
|
|
|
<th>IP</th>
|
|
|
|
<th>Info</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="table-responsive provider-events">
|
|
|
|
<table class="table table-hover nowrap" id="dataTableProvider" width="100%" cellspacing="0">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>Time</th>
|
|
|
|
<th>Action</th>
|
|
|
|
<th>Object</th>
|
|
|
|
<th>User</th>
|
|
|
|
<th>IP</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
2023-05-12 16:34:59 +00:00
|
|
|
<div class="table-responsive log-events">
|
|
|
|
<table class="table table-hover nowrap" id="dataTableLog" width="100%" cellspacing="0">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>Time</th>
|
|
|
|
<th>Action</th>
|
|
|
|
<th>User</th>
|
|
|
|
<th>Proto</th>
|
|
|
|
<th>IP</th>
|
|
|
|
<th>Message</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
2022-12-07 17:47:38 +00:00
|
|
|
<div id="paginationContainer" class="m-4 d-none">
|
|
|
|
<nav aria-label="Pagination">
|
|
|
|
<ul class="pagination justify-content-end">
|
|
|
|
<li id="pageItemPrev" class="page-item disabled"><a id="pagePrevious" class="page-link" href="#" onclick="prevClicked()">Previous</a></li>
|
|
|
|
<li id="pageItemNext" class="page-item disabled"><a id="pageNext" class="page-link" href="#" onclick="nextClicked()">Next</a></li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{define "extra_js"}}
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/jquery.dataTables.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/dataTables.buttons.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/buttons.bootstrap4.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/buttons.colVis.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/dataTables.fixedHeader.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/dataTables.responsive.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/responsive.bootstrap4.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/dataTables.select.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/datatables/ellipsis.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/bootstrap-select/js/bootstrap-select.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/moment/js/moment.min.js"></script>
|
|
|
|
<script src="{{.StaticURL}}/vendor/daterangepicker/daterangepicker.min.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
let dateFn = $.fn.dataTable.render.datetime();
|
|
|
|
let isFsDataTableInitialized = false;
|
|
|
|
let isProviderDataTableInitialized = false;
|
2023-05-12 16:34:59 +00:00
|
|
|
let isLogDataTableInitialized = false;
|
2023-02-09 08:33:33 +00:00
|
|
|
const pageSize = 20;
|
2022-12-07 17:47:38 +00:00
|
|
|
const paginationData = new Map();
|
|
|
|
|
|
|
|
function fileSizeIEC(a,b,c,d,e){
|
|
|
|
return (b=Math,c=b.log,d=1024,e=c(a)/c(d)|0,a/b.pow(d,e)).toFixed(1)
|
|
|
|
+' '+(e?'KMGTPEZY'[--e]+'iB':'Bytes')
|
|
|
|
}
|
|
|
|
|
2023-02-13 11:58:21 +00:00
|
|
|
function humanizeMilliseconds(val) {
|
|
|
|
if (val < 1000){
|
|
|
|
return val+"ms";
|
|
|
|
}
|
|
|
|
let secs = Math.floor(val/1000);
|
|
|
|
if (secs < 60){
|
|
|
|
return secs+"s";
|
|
|
|
}
|
|
|
|
if (secs < 3600){
|
|
|
|
let minutes = Math.floor(secs / 60);
|
|
|
|
let seconds = secs - (minutes * 60);
|
|
|
|
return minutes+"m"+seconds+"s";
|
|
|
|
}
|
|
|
|
if (secs < 86400){
|
|
|
|
let hours = Math.floor(secs / 3600);
|
|
|
|
let minutes = Math.floor((secs - (hours * 3600)) / 60);
|
|
|
|
let seconds = secs - (hours * 3600) - (minutes * 60);
|
|
|
|
return hours+"h"+minutes+"m"+seconds+"s";
|
|
|
|
}
|
|
|
|
let days = Math.floor(secs / 86400);
|
|
|
|
let hours = Math.floor((secs - (days * 86400)) / 3600);
|
|
|
|
let minutes = Math.floor((secs - (days * 86400) - (hours * 3600)) / 60);
|
|
|
|
let seconds = secs - (days * 86400) - (hours * 3600) - (minutes * 60);
|
|
|
|
return days+"d"+ hours+"h"+minutes+"m"+seconds+"s";
|
|
|
|
}
|
|
|
|
|
2022-12-07 17:47:38 +00:00
|
|
|
function resetPagination() {
|
|
|
|
$('#pageItemPrev').addClass("disabled");
|
|
|
|
$('#pageItemNext').addClass("disabled");
|
|
|
|
$('#paginationContainer').addClass("d-none");
|
|
|
|
paginationData.delete("firstId");
|
|
|
|
paginationData.delete("firstTs");
|
|
|
|
paginationData.delete("lastId");
|
|
|
|
paginationData.delete("lastTs");
|
|
|
|
paginationData.set("prevClicked",false);
|
|
|
|
paginationData.set("nextClicked",false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function prevClicked(){
|
|
|
|
paginationData.set("prevClicked",true);
|
|
|
|
paginationData.set("nextClicked",false);
|
|
|
|
doSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextClicked(){
|
|
|
|
paginationData.set("prevClicked",false);
|
|
|
|
paginationData.set("nextClicked",true);
|
|
|
|
doSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleResponseData(data) {
|
|
|
|
let length = data.length;
|
|
|
|
let isNext = paginationData.get("nextClicked");
|
|
|
|
let isPrev = paginationData.get("prevClicked");
|
|
|
|
|
|
|
|
if (length > pageSize) {
|
|
|
|
data.pop();
|
|
|
|
length--;
|
|
|
|
if (isPrev || isNext){
|
|
|
|
$('#pageItemPrev').removeClass("disabled");
|
|
|
|
}
|
|
|
|
$('#pageItemNext').removeClass("disabled");
|
|
|
|
} else {
|
|
|
|
if (isPrev){
|
|
|
|
$('#pageItemPrev').addClass("disabled");
|
|
|
|
$('#pageItemNext').removeClass("disabled");
|
|
|
|
} else if (isNext){
|
|
|
|
$('#pageItemPrev').removeClass("disabled");
|
|
|
|
$('#pageItemNext').addClass("disabled");
|
|
|
|
} else {
|
|
|
|
$('#pageItemNext').addClass("disabled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isPrev){
|
|
|
|
data = data.reverse();
|
|
|
|
}
|
|
|
|
if (length > 0){
|
|
|
|
paginationData.set("lastId",data[0].id);
|
|
|
|
paginationData.set("lastTs",data[0].timestamp);
|
|
|
|
paginationData.set("firstId",data[length-1].id);
|
|
|
|
paginationData.set("firstTs",data[length-1].timestamp);
|
|
|
|
$('#paginationContainer').removeClass("d-none");
|
|
|
|
} else {
|
|
|
|
resetPagination();
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onExportClicked() {
|
|
|
|
paginationData.set("prevClicked",false);
|
|
|
|
paginationData.set("nextClicked",false);
|
|
|
|
let exportURL = getSearchURL(true);
|
2023-02-09 08:33:33 +00:00
|
|
|
let ts = new Date().getTime().toString();
|
2022-12-07 17:47:38 +00:00
|
|
|
window.open(`${exportURL}&_=${ts}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSearchClicked() {
|
|
|
|
resetPagination();
|
|
|
|
doSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
function doSearch() {
|
|
|
|
let eventType = $('#idEventType').val();
|
|
|
|
let table;
|
|
|
|
if (eventType == 1){
|
|
|
|
if (!isFsDataTableInitialized){
|
|
|
|
initFsDatatable();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
table = $('#dataTableFs').DataTable();
|
2023-05-12 16:34:59 +00:00
|
|
|
} else if (eventType == 2) {
|
2022-12-07 17:47:38 +00:00
|
|
|
if (!isProviderDataTableInitialized){
|
|
|
|
initProviderDatatable();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
table = $('#dataTableProvider').DataTable();
|
2023-05-12 16:34:59 +00:00
|
|
|
} else {
|
|
|
|
if (!isLogDataTableInitialized){
|
|
|
|
initLogDatatable();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
table = $('#dataTableLog').DataTable();
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
table.clear().draw();
|
|
|
|
table.ajax.url(getSearchURL(false)).load();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSearchURL(csvExport) {
|
|
|
|
let url = "";
|
|
|
|
let eventType = $('#idEventType').val();
|
|
|
|
let order = "DESC";
|
|
|
|
let limit = pageSize + 1;
|
|
|
|
if (csvExport){
|
|
|
|
order = "ASC";
|
|
|
|
}
|
|
|
|
if (eventType == 1){
|
|
|
|
url = "{{.FsEventsSearchURL}}?limit="+limit;
|
|
|
|
let protocols = [];
|
|
|
|
$('#idProtocols').find('option:selected').each(function(){
|
|
|
|
protocols.push($(this).val());
|
|
|
|
});
|
|
|
|
if (protocols.length > 0){
|
|
|
|
url+="&protocols="+encodeURIComponent(String(protocols));
|
|
|
|
}
|
|
|
|
let statuses = [];
|
|
|
|
$('#idStatuses').find('option:selected').each(function(){
|
|
|
|
statuses.push($(this).val());
|
|
|
|
});
|
|
|
|
if (statuses.length > 0){
|
|
|
|
url+="&statuses="+encodeURIComponent(String(statuses));
|
|
|
|
}
|
2023-05-12 16:34:59 +00:00
|
|
|
} else if (eventType == 2) {
|
2022-12-08 09:02:12 +00:00
|
|
|
url = "{{.ProviderEventsSearchURL}}?omit_object_data=true&limit="+limit;
|
2023-05-12 16:34:59 +00:00
|
|
|
} else {
|
|
|
|
url = "{{.LogEventsSearchURL}}?limit="+limit;
|
|
|
|
let protocols = [];
|
|
|
|
$('#idProtocols').find('option:selected').each(function(){
|
|
|
|
protocols.push($(this).val());
|
|
|
|
});
|
|
|
|
if (protocols.length > 0){
|
|
|
|
url+="&protocols="+encodeURIComponent(String(protocols));
|
|
|
|
}
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
let actions = [];
|
|
|
|
$('#idActions').find('option:selected').each(function(){
|
|
|
|
actions.push($(this).val());
|
|
|
|
});
|
|
|
|
if (actions.length > 0){
|
2023-05-12 16:34:59 +00:00
|
|
|
if (eventType == 3){
|
|
|
|
url+="&events="+encodeURIComponent(String(actions));
|
|
|
|
} else {
|
|
|
|
url+="&actions="+encodeURIComponent(String(actions));
|
|
|
|
}
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
let username = $('#idUsername').val();
|
|
|
|
if (username){
|
|
|
|
url+="&username="+encodeURIComponent(username);
|
|
|
|
}
|
|
|
|
let ip = $('#idIp').val();
|
|
|
|
if (ip){
|
|
|
|
url+="&ip="+encodeURIComponent(ip);
|
|
|
|
}
|
|
|
|
let drp = $('#dateTimeRange').data('daterangepicker');
|
2023-05-12 16:34:59 +00:00
|
|
|
let fromID = "";
|
2022-12-07 17:47:38 +00:00
|
|
|
let start_ts;
|
|
|
|
if (!csvExport && paginationData.get("prevClicked") && paginationData.has("lastId") && paginationData.has("lastTs")){
|
|
|
|
order = "ASC";
|
|
|
|
start_ts = paginationData.get("lastTs");
|
2023-05-12 16:34:59 +00:00
|
|
|
fromID = paginationData.get("lastId");
|
2022-12-07 17:47:38 +00:00
|
|
|
} else {
|
|
|
|
start_ts = drp.startDate.valueOf()*1000000;
|
|
|
|
}
|
|
|
|
let end_ts;
|
|
|
|
if (!csvExport && paginationData.get("nextClicked") && paginationData.has("firstId") && paginationData.has("firstTs")){
|
|
|
|
end_ts = paginationData.get("firstTs");
|
2023-05-12 16:34:59 +00:00
|
|
|
fromID = paginationData.get("firstId");
|
2022-12-07 17:47:38 +00:00
|
|
|
} else {
|
|
|
|
end_ts = drp.endDate.valueOf()*1000000;
|
|
|
|
}
|
|
|
|
url+="&start_timestamp="+encodeURIComponent(start_ts);
|
|
|
|
url+="&end_timestamp="+encodeURIComponent(end_ts);
|
2023-05-12 16:34:59 +00:00
|
|
|
if (fromID){
|
|
|
|
url+="&from_id="+encodeURIComponent(fromID);
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
url+="&order="+order;
|
|
|
|
if (csvExport){
|
|
|
|
url+="&csv_export=true";
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2023-05-12 16:34:59 +00:00
|
|
|
function initLogDatatable(){
|
|
|
|
$('#errorMsg').hide();
|
|
|
|
let tableLog = $('#dataTableLog').DataTable({
|
|
|
|
"ajax": {
|
|
|
|
"url": getSearchURL(false),
|
|
|
|
"dataSrc": handleResponseData,
|
|
|
|
"error": function ($xhr, textStatus, errorThrown) {
|
|
|
|
$(".dataTables_processing").hide();
|
|
|
|
let txt = "Failed to get log events";
|
|
|
|
if ($xhr) {
|
|
|
|
let json = $xhr.responseJSON;
|
|
|
|
if (json) {
|
|
|
|
if (json.message){
|
|
|
|
txt += ": " + json.message;
|
|
|
|
} else {
|
|
|
|
txt += ": " + json.error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#errorTxt').text(txt);
|
|
|
|
$('#errorMsg').show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"deferRender": true,
|
|
|
|
"processing": true,
|
|
|
|
"columns": [
|
|
|
|
{ "data": "id" },
|
|
|
|
{
|
|
|
|
"data": "timestamp",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
return dateFn(data/1000000,type);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "event",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
switch (data){
|
|
|
|
case 1:
|
|
|
|
return "Login failed";
|
|
|
|
case 2:
|
|
|
|
return "Login with non-existent user";
|
|
|
|
case 3:
|
|
|
|
return "No login tried";
|
|
|
|
case 4:
|
|
|
|
return "Algorithm negotiation failed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "username",
|
|
|
|
"defaultContent": "",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
if (!data){
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return escapeHTML(data);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "protocol",
|
|
|
|
"defaultContent": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "ip",
|
|
|
|
"defaultContent": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "message",
|
|
|
|
"defaultContent": "",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
if (!data){
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return '<span style="white-space:normal">' + escapeHTML(data) + "</span>"
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"buttons": [],
|
|
|
|
"lengthChange": false,
|
|
|
|
"columnDefs": [
|
|
|
|
{
|
|
|
|
"targets": [0],
|
|
|
|
"visible": false,
|
|
|
|
"searchable": false
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"responsive": true,
|
|
|
|
"searching": false,
|
|
|
|
"paging": false,
|
|
|
|
"info": false,
|
|
|
|
"ordering": false,
|
|
|
|
"language": {
|
|
|
|
"loadingRecords": "",
|
|
|
|
"emptyTable": "No logs found"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
new $.fn.dataTable.FixedHeader(tableLog);
|
|
|
|
|
|
|
|
isLogDataTableInitialized = true;
|
|
|
|
}
|
|
|
|
|
2022-12-07 17:47:38 +00:00
|
|
|
function initProviderDatatable(){
|
2023-02-10 17:07:23 +00:00
|
|
|
$('#errorMsg').hide();
|
2022-12-07 17:47:38 +00:00
|
|
|
let tableProvider = $('#dataTableProvider').DataTable({
|
|
|
|
"ajax": {
|
|
|
|
"url": getSearchURL(false),
|
|
|
|
"dataSrc": handleResponseData,
|
|
|
|
"error": function ($xhr, textStatus, errorThrown) {
|
|
|
|
$(".dataTables_processing").hide();
|
2023-02-09 08:33:33 +00:00
|
|
|
let txt = "Failed to get provider events";
|
2022-12-07 17:47:38 +00:00
|
|
|
if ($xhr) {
|
2023-02-09 08:33:33 +00:00
|
|
|
let json = $xhr.responseJSON;
|
2022-12-07 17:47:38 +00:00
|
|
|
if (json) {
|
|
|
|
if (json.message){
|
|
|
|
txt += ": " + json.message;
|
|
|
|
} else {
|
|
|
|
txt += ": " + json.error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#errorTxt').text(txt);
|
|
|
|
$('#errorMsg').show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"deferRender": true,
|
|
|
|
"processing": true,
|
|
|
|
"columns": [
|
|
|
|
{ "data": "id" },
|
|
|
|
{
|
|
|
|
"data": "timestamp",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
return dateFn(data/1000000,type);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "action"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "object_type",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
2023-03-28 10:28:38 +00:00
|
|
|
let ellipsisFn = $.fn.dataTable.render.ellipsis(70, true, true);
|
2022-12-07 17:47:38 +00:00
|
|
|
return ellipsisFn(`${data}: ${row["object_name"]}`,type);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "username",
|
2023-03-28 10:28:38 +00:00
|
|
|
"defaultContent": "",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
2023-04-16 13:38:49 +00:00
|
|
|
if (!data){
|
|
|
|
return "";
|
|
|
|
}
|
2023-03-28 10:28:38 +00:00
|
|
|
return escapeHTML(data);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2022-12-07 17:47:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "ip",
|
|
|
|
"defaultContent": ""
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"buttons": [],
|
|
|
|
"lengthChange": false,
|
|
|
|
"columnDefs": [
|
|
|
|
{
|
|
|
|
"targets": [0],
|
|
|
|
"visible": false,
|
|
|
|
"searchable": false
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"responsive": true,
|
|
|
|
"searching": false,
|
|
|
|
"paging": false,
|
|
|
|
"info": false,
|
|
|
|
"ordering": false,
|
|
|
|
"language": {
|
|
|
|
"loadingRecords": "",
|
|
|
|
"emptyTable": "No logs found"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
new $.fn.dataTable.FixedHeader(tableProvider);
|
|
|
|
|
|
|
|
isProviderDataTableInitialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initFsDatatable(){
|
2023-02-10 17:07:23 +00:00
|
|
|
$('#errorMsg').hide();
|
2022-12-07 17:47:38 +00:00
|
|
|
let tableFs = $('#dataTableFs').DataTable({
|
|
|
|
"ajax": {
|
|
|
|
"url": getSearchURL(false),
|
|
|
|
"dataSrc": handleResponseData,
|
|
|
|
"error": function ($xhr, textStatus, errorThrown) {
|
|
|
|
$(".dataTables_processing").hide();
|
2023-02-09 08:33:33 +00:00
|
|
|
let txt = "Failed to get filesystem events";
|
2022-12-07 17:47:38 +00:00
|
|
|
if ($xhr) {
|
|
|
|
let json = $xhr.responseJSON;
|
|
|
|
if (json) {
|
|
|
|
if (json.message){
|
|
|
|
txt += ": " + json.message;
|
|
|
|
} else {
|
|
|
|
txt += ": " + json.error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#errorTxt').text(txt);
|
|
|
|
$('#errorMsg').show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"deferRender": true,
|
|
|
|
"processing": true,
|
|
|
|
"columns": [
|
|
|
|
{ "data": "id" },
|
|
|
|
{
|
|
|
|
"data": "timestamp",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
return dateFn(data/1000000,type);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "action"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "virtual_path",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
2023-04-16 13:38:49 +00:00
|
|
|
if (!data){
|
|
|
|
return "";
|
|
|
|
}
|
2023-03-28 10:28:38 +00:00
|
|
|
let ellipsisFn = $.fn.dataTable.render.ellipsis(70, true, true);
|
2022-12-07 17:47:38 +00:00
|
|
|
if (row["virtual_target_path"]){
|
|
|
|
return ellipsisFn(`${data} => ${row["virtual_target_path"]}`,type);
|
|
|
|
}
|
|
|
|
return ellipsisFn(data,type);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "username",
|
2023-03-28 10:28:38 +00:00
|
|
|
"defaultContent": "",
|
|
|
|
"render": function (data, type, row) {
|
2023-04-16 13:38:49 +00:00
|
|
|
if (!data){
|
|
|
|
return "";
|
|
|
|
}
|
2023-03-28 10:28:38 +00:00
|
|
|
if (type === 'display') {
|
|
|
|
return escapeHTML(data);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2022-12-07 17:47:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "protocol",
|
|
|
|
"defaultContent": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "ip",
|
|
|
|
"defaultContent": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "status",
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
if (type === 'display') {
|
|
|
|
let info = 'OK';
|
|
|
|
if (data == 2){
|
|
|
|
info = 'KO';
|
|
|
|
} else if (data == 3){
|
2023-02-13 11:58:21 +00:00
|
|
|
info = 'Quota exceeded';
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
if (row["file_size"]){
|
|
|
|
let humanSize = fileSizeIEC(row["file_size"]);
|
2023-02-13 11:58:21 +00:00
|
|
|
info+=`. ${humanSize}`;
|
|
|
|
}
|
|
|
|
if (row["elapsed"]){
|
|
|
|
info+=". "+humanizeMilliseconds(row["elapsed"]);
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
if (row["ssh_cmd"]){
|
2023-02-13 11:58:21 +00:00
|
|
|
info+=`. Command: ${row["ssh_cmd"]}`;
|
2022-12-07 17:47:38 +00:00
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"buttons": [],
|
|
|
|
"lengthChange": false,
|
|
|
|
"columnDefs": [
|
|
|
|
{
|
|
|
|
"targets": [0],
|
|
|
|
"visible": false,
|
|
|
|
"searchable": false
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"responsive": true,
|
|
|
|
"searching": false,
|
|
|
|
"paging": false,
|
|
|
|
"info": false,
|
|
|
|
"ordering": false,
|
|
|
|
"language": {
|
|
|
|
"loadingRecords": "",
|
|
|
|
"emptyTable": "No logs found"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
new $.fn.dataTable.FixedHeader(tableFs);
|
|
|
|
isFsDataTableInitialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectFsEvents(){
|
|
|
|
let idActions = $('#idActions');
|
|
|
|
idActions.selectpicker('deselectAll');
|
|
|
|
idActions.find('option').remove();
|
|
|
|
idActions.find('li').remove();
|
|
|
|
idActions.append($('<option>').val('upload').text('Upload'));
|
|
|
|
idActions.append($('<option>').val('download').text('Download'));
|
|
|
|
idActions.append($('<option>').val('mkdir').text('Mkdir'));
|
|
|
|
idActions.append($('<option>').val('rmdir').text('Rmdir'));
|
|
|
|
idActions.append($('<option>').val('rename').text('Rename'));
|
|
|
|
idActions.append($('<option>').val('delete').text('Delete'));
|
|
|
|
idActions.append($('<option>').val('first-upload').text('First upload'));
|
|
|
|
idActions.append($('<option>').val('first-download').text('First download'));
|
|
|
|
idActions.append($('<option>').val('ssh_cmd').text('SSH command'));
|
|
|
|
idActions.selectpicker('refresh');
|
|
|
|
|
|
|
|
$('#idUsername').val("");
|
|
|
|
$('#idIp').val("");
|
|
|
|
$('.provider-events').hide();
|
2023-05-12 16:34:59 +00:00
|
|
|
$('.log-events').hide();
|
2022-12-07 17:47:38 +00:00
|
|
|
$('.fs-events').show();
|
|
|
|
onSearchClicked();
|
|
|
|
}
|
|
|
|
|
2023-05-12 16:34:59 +00:00
|
|
|
function selectLogEvents(){
|
|
|
|
let idActions = $('#idActions');
|
|
|
|
idActions.selectpicker('deselectAll');
|
|
|
|
idActions.find('option').remove();
|
|
|
|
idActions.find('li').remove();
|
|
|
|
idActions.append($('<option>').val('1').text('Login failed'));
|
|
|
|
idActions.append($('<option>').val('2').text('Login with non-existent user'));
|
|
|
|
idActions.append($('<option>').val('3').text('No login tried'));
|
|
|
|
idActions.append($('<option>').val('4').text('Algorithm negotiation failed'));
|
|
|
|
idActions.selectpicker('refresh');
|
|
|
|
|
|
|
|
$('#idUsername').val("");
|
|
|
|
$('#idIp').val("");
|
|
|
|
$('.provider-events').hide();
|
|
|
|
$('.fs-events').hide();
|
|
|
|
$('.log-events').show();
|
|
|
|
onSearchClicked();
|
|
|
|
}
|
|
|
|
|
2022-12-07 17:47:38 +00:00
|
|
|
function selectProviderEvents(){
|
|
|
|
let idActions = $('#idActions');
|
|
|
|
idActions.selectpicker('deselectAll');
|
|
|
|
idActions.find('option').remove();
|
|
|
|
idActions.find('li').remove();
|
|
|
|
idActions.append($('<option>').val('add').text('Add'));
|
|
|
|
idActions.append($('<option>').val('update').text('Update'));
|
|
|
|
idActions.append($('<option>').val('delete').text('Delete'));
|
|
|
|
idActions.selectpicker('refresh');
|
|
|
|
|
|
|
|
$('#idUsername').val("");
|
|
|
|
$('#idIp').val("");
|
|
|
|
$('.fs-events').hide();
|
2023-05-12 16:34:59 +00:00
|
|
|
$('.log-events').hide();
|
2022-12-07 17:47:38 +00:00
|
|
|
$('.provider-events').show();
|
|
|
|
onSearchClicked();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onEventChanged(val){
|
|
|
|
switch (val){
|
|
|
|
case '1':
|
|
|
|
selectFsEvents();
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
selectProviderEvents();
|
|
|
|
break;
|
2023-05-12 16:34:59 +00:00
|
|
|
case '3':
|
|
|
|
selectLogEvents();
|
|
|
|
break;
|
2022-12-07 17:47:38 +00:00
|
|
|
default:
|
|
|
|
console.log(`unsupported event type: ${val}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$('#dateTimeRange').daterangepicker({
|
|
|
|
timePicker: true,
|
|
|
|
timePicker24Hour: true,
|
|
|
|
opens: 'left',
|
|
|
|
startDate: moment().add(-1,'hour'),
|
|
|
|
endDate: moment(),
|
|
|
|
locale: {
|
|
|
|
format: 'DD/MM HH:mm'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$.fn.dataTable.ext.errMode = 'none';
|
|
|
|
|
|
|
|
onEventChanged('1');
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{{end}}
|