Обновление веб-интерфейса

This commit is contained in:
2024-02-21 11:45:53 +03:00
parent 4043250ca5
commit 20b3cea0b0
7 changed files with 61 additions and 52 deletions
+8 -7
View File
@@ -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;
}
+2 -2
View File
@@ -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");
}