Добавил сайт
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
class AnomalyLogs {
|
||||
// Конструктор
|
||||
constructor() {
|
||||
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);
|
||||
}
|
||||
|
||||
// Обработка ответа от сервера
|
||||
// respone -- ответ сервера
|
||||
ProcessResponse(response) {
|
||||
this.UpdateData(response);
|
||||
}
|
||||
|
||||
// Обновление данных
|
||||
// respone -- ответ от сервера
|
||||
UpdateData(response) {
|
||||
let logs = response["result"];
|
||||
if (logs == null)
|
||||
return;
|
||||
|
||||
var last_index = this.last_index;
|
||||
for (const key in logs) {
|
||||
var row = window.anomaly_logs_table.insertRow();
|
||||
var cell = row.insertCell(0);
|
||||
cell.innerHTML = logs[key];
|
||||
|
||||
let index = Number(key);
|
||||
if (index > last_index)
|
||||
last_index = index;
|
||||
}
|
||||
|
||||
this.last_index = last_index
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateAnomalyLogs() {
|
||||
window.anomaly_logs.SendRequest()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function InitAnomalyLogs() {
|
||||
window.anomaly_logs = new AnomalyLogs();
|
||||
window.anomaly_logs_table = document.getElementById("anomaly-logs-table");
|
||||
}
|
||||
Reference in New Issue
Block a user