51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
class AnomalyLogs extends ControllerBase {
|
|
// Конструктор
|
|
constructor(url) {
|
|
super(url, "anomaly_logs/get");
|
|
|
|
this.last_index = -1;
|
|
}
|
|
|
|
// Отправка запроса на сервер
|
|
SendRequest() {
|
|
var request = {};
|
|
request.parameters = {
|
|
'last_index': this.last_index
|
|
};
|
|
|
|
let request_data = JSON.stringify(request);
|
|
super.SendRequestImpl(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 item of logs) {
|
|
var row = window.anomaly_logs_table.insertRow();
|
|
var cell = row.insertCell(0);
|
|
cell.innerHTML = item["data"];
|
|
|
|
let index = Number(item["id"]);
|
|
if (index > last_index)
|
|
last_index = index;
|
|
}
|
|
|
|
this.last_index = last_index
|
|
}
|
|
}
|
|
|
|
function UpdateAnomalyLogs() {
|
|
window.anomaly_logs.SendRequest()
|
|
}
|