Добавил фронтенд
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
class GetAnomalyLogs extends ControllerBase {
|
||||
// Конструктор
|
||||
constructor(url) {
|
||||
super("anomaly_logs");
|
||||
|
||||
this.last_id = -1;
|
||||
}
|
||||
|
||||
// Отправка запроса на сервер
|
||||
SendRequest() {
|
||||
let parameters = {
|
||||
'last_id': this.last_id
|
||||
};
|
||||
|
||||
super.Get(parameters);
|
||||
}
|
||||
|
||||
// Обработка ответа от сервера
|
||||
// respone -- ответ сервера
|
||||
ProcessResponse(response) {
|
||||
this.UpdateData(response);
|
||||
}
|
||||
|
||||
// Обновление данных
|
||||
// respone -- ответ от сервера
|
||||
UpdateData(response) {
|
||||
let logs = response["result"];
|
||||
if (logs == null)
|
||||
return;
|
||||
|
||||
let last_id = this.last_id;
|
||||
for (const item of logs) {
|
||||
let row = window.anomaly_logs_table.insertRow();
|
||||
|
||||
const id = Number(item["id"]);
|
||||
|
||||
let cell = row.insertCell(0);
|
||||
cell.innerHTML = String(id);
|
||||
|
||||
cell = row.insertCell(1);
|
||||
cell.innerHTML = item["data"];
|
||||
|
||||
cell = row.insertCell(2);
|
||||
const cluster_id = Number(item["cluster_id"]);
|
||||
cell.innerHTML = window.get_logs_clusters.clusters[cluster_id]["name"];
|
||||
|
||||
DecorateClusterCell(id, cluster_id, cell);
|
||||
|
||||
if (id > last_id)
|
||||
last_id = id;
|
||||
}
|
||||
|
||||
this.last_id = last_id;
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateAnomalyLogs() {
|
||||
window.get_anomaly_logs.SendRequest()
|
||||
}
|
||||
Reference in New Issue
Block a user