Обновление веб-интерфейса
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
class AnomalyLogs {
|
||||
class AnomalyLogs extends ControllerBase {
|
||||
// Конструктор
|
||||
constructor() {
|
||||
constructor(url) {
|
||||
super(url, "anomaly_logs/get");
|
||||
|
||||
this.last_index = -1;
|
||||
}
|
||||
|
||||
// Отправка запроса на сервер
|
||||
SendRequest() {
|
||||
var request = {};
|
||||
request.command = 'anomaly_logs';
|
||||
request.parameters = {
|
||||
'last_index': this.last_index
|
||||
};
|
||||
|
||||
let request_data = JSON.stringify(request);
|
||||
socket.send(request_data);
|
||||
super.SendRequestImpl(request_data);
|
||||
}
|
||||
|
||||
// Обработка ответа от сервера
|
||||
@@ -30,12 +31,12 @@ class AnomalyLogs {
|
||||
return;
|
||||
|
||||
var last_index = this.last_index;
|
||||
for (const key in logs) {
|
||||
for (const item of logs) {
|
||||
var row = window.anomaly_logs_table.insertRow();
|
||||
var cell = row.insertCell(0);
|
||||
cell.innerHTML = logs[key];
|
||||
cell.innerHTML = item["data"];
|
||||
|
||||
let index = Number(key);
|
||||
let index = Number(item["id"]);
|
||||
if (index > last_index)
|
||||
last_index = index;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function InitAnomalyLogs() {
|
||||
window.anomaly_logs = new AnomalyLogs();
|
||||
function InitAnomalyLogs(url) {
|
||||
window.anomaly_logs = new AnomalyLogs(url);
|
||||
window.anomaly_logs_table = document.getElementById("anomaly-logs-table");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user