mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Make server logs call API
This commit is contained in:
parent
16e01aed85
commit
10f696edcc
@ -74,6 +74,6 @@ class ApiServersServerLogsHandler(BaseApiHandler):
|
||||
|
||||
if use_html:
|
||||
for line in lines:
|
||||
self.write(f"{line}<br />")
|
||||
else:
|
||||
self.finish_json(200, {"status": "ok", "data": lines})
|
||||
line = f"{line}<br />"
|
||||
|
||||
self.finish_json(200, {"status": "ok", "data": lines})
|
||||
|
@ -188,23 +188,36 @@
|
||||
|
||||
// Populate logs and filter if present
|
||||
const serverId = new URLSearchParams(document.location.search).get('id')
|
||||
function get_server_log() {
|
||||
async function get_server_log() {
|
||||
var token = getCookie("_xsrf")
|
||||
let colors=true;
|
||||
if (!$("#stop_scroll").is(':checked')) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/ajax/server_log?id=' + serverId + '&full=1',
|
||||
dataType: 'text',
|
||||
success: function (data) {
|
||||
console.log('Got Log From Server')
|
||||
$('#virt_console').html(data);
|
||||
scroll();
|
||||
lines = document.querySelectorAll('.box');
|
||||
hideFilteredWords();
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/logs?colors=${colors}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-XSRFToken': token
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
let responseData = await res.json();
|
||||
html = ``
|
||||
if (responseData.status === "ok") {
|
||||
for(i=0; i < responseData.data.length; i++) {
|
||||
html += `<span class='box'>${responseData.data[i]}<br /></span>`
|
||||
}
|
||||
console.log('Got Log From Server')
|
||||
$('#virt_console').html(html);
|
||||
scroll();
|
||||
lines = document.querySelectorAll('.box');
|
||||
hideFilteredWords();
|
||||
} else {
|
||||
|
||||
bootbox.alert({
|
||||
title: responseData.status,
|
||||
message: responseData.error
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
$(document).ready(function () {
|
||||
console.log("ready!");
|
||||
get_server_log();
|
||||
|
@ -229,17 +229,31 @@
|
||||
}
|
||||
//{% end %}
|
||||
|
||||
function get_server_log() {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/ajax/server_log?id=' + serverId,
|
||||
dataType: 'text',
|
||||
success: function (data) {
|
||||
async function get_server_log() {
|
||||
var token = getCookie("_xsrf")
|
||||
let colors=true;
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/logs?colors=${colors}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-XSRFToken': token
|
||||
},
|
||||
});
|
||||
let responseData = await res.json();
|
||||
html = ``
|
||||
if (responseData.status === "ok") {
|
||||
for(i=0; i < responseData.data.length; i++) {
|
||||
html += `<span class='box'>${responseData.data[i]}<br /></span>`
|
||||
}
|
||||
console.log('Got Log From Server')
|
||||
$('#virt_console').html(data);
|
||||
$('#virt_console').html(html);
|
||||
scrollConsole();
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
bootbox.alert({
|
||||
title: responseData.status,
|
||||
message: responseData.error
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user