picluster/web/syslog.html
Verita84 48111c89c0 fix
2021-08-25 08:44:55 -06:00

103 lines
3.0 KiB
HTML

<html>
<head>
<script src="/assets/jquery.min.js"></script>
<link rel="stylesheet" href="/assets/jquery-ui.css">
<script src="/assets/jquery-ui.js"></script>
<script src="/assets/moment.js"></script>
<script src="/assets/distLogo.js"></script>
<link rel="stylesheet" href="/assets/picluster-iframe.css">
<script>
function exec() {
$.get("/syslog?token=" + parent.token, function(data) {
// var output = data.replace(/(?:\r\n|\r|\n)/g, '<br />');
if ($('#query').val()) {
var search_string = $('#query').val();
var modified_data = data.split("\n");
var search_output = "";
for (i = 0; i != modified_data.length; i++) {
if (modified_data[i].toLowerCase().indexOf(search_string.toLowerCase()) > -1) {
search_output += "\n" + modified_data[i];
}
}
$("#command_output").val(search_output);
} else {
$("#command_output").val(data);
}
});
}
function search(day, id) {
var day_check = moment().format("D");
var date = day_check.length > 1 ? moment().format("MMM D") : moment().format("MMM D");
day.indexOf("today") > -1 ? $("#query").val(date) : $("#query").val(day);
exec();
document.getElementById(id).checked = false;
};
</script>
</head>
<body>
<div id="modal_container" class="modal">
<div class="modal-content modal-large">
<div class="modal-header">
<span class="close">&times;</span>
<h2>PiCluster Syslog Viewer</h2>
</div>
<div class="modal-body">
<div id="log_search">
<div id="log_search_bar">
<input id="query" type="text" rows="30" cols="60" name="query" name="query">
</div>
<div id="log_search_button">
<button id="submit_button">Search</button>
</div>
</div>
<div id="log_type">
<div id="log_type_error" class="log_type_box">
<label><input type="checkbox" id="error" onchange="search('error','error')" value="error">Errors</label><br>
</div>
<div id="log_type_failure" class="log_type_box">
<label><input type="checkbox" id="failure" onchange="search('failure','failure')" value="failure">Failures</label><br>
</div>
<div id="log_type_warning" class="log_type_box">
<label><input type="checkbox" id="warning" onchange="search('warning','warning')" value="warning">Warnings</label><br>
</div>
<div id="log_type_today" class="log_type_box">
<label><input type="checkbox" id="today" onchange="search('today','today')" value="today">Today</label><br>
</div>
</div>
<div id="log_output">
<textarea id="command_output" name="command_output" value="" enctype="application/json"></textarea>
</div>
</div>
</div>
</div>
<script>
var modal = document.getElementById('modal_container');
var span = document.getElementsByClassName("close")[0];
var submit_button = document.getElementById("submit_button");
span.onclick = function () {
modal.style.display = "none";
}
submit_button.onclick = function () {
exec();
}
modal.style.display = "block";
exec();
</script>
</html>