Добавил фронтенд
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
class GetLogsClusters extends ControllerBase {
|
||||
// Конструктор
|
||||
constructor() {
|
||||
super("logs_clusters");
|
||||
this.clusters = null
|
||||
}
|
||||
|
||||
// Отправка запроса на сервер
|
||||
async SendRequest() {
|
||||
await super.Get({});
|
||||
}
|
||||
|
||||
// Обработка ответа от сервера
|
||||
// respone -- ответ сервера
|
||||
ProcessResponse(response) {
|
||||
this.clusters = response["result"];
|
||||
|
||||
for (const cluster of this.clusters) {
|
||||
let row = window.logs_cluters_table.insertRow();
|
||||
|
||||
let cell = row.insertCell(0);
|
||||
cell.innerHTML = cluster["id"];
|
||||
|
||||
cell = row.insertCell(1);
|
||||
cell.innerHTML = cluster["name"];
|
||||
|
||||
cell = row.insertCell(2);
|
||||
cell.innerHTML = cluster["description"];
|
||||
|
||||
cell = row.insertCell(3);
|
||||
cell.innerHTML = cluster["recommendation"];
|
||||
}
|
||||
|
||||
// Формирование списка кластеров
|
||||
let select_cluster = document.createElement("select");
|
||||
|
||||
let option = document.createElement("option");
|
||||
option.text = "Неизвестный кластер. Выберите один из существующих";
|
||||
|
||||
select_cluster.add(option);
|
||||
|
||||
for (let index of Array.from({length: this.clusters.length - 1}, (_, i) => i + 1)) {
|
||||
const cluster = this.clusters[index];
|
||||
this.AddCluster(select_cluster, cluster)
|
||||
}
|
||||
|
||||
window.select_cluster = select_cluster;
|
||||
}
|
||||
|
||||
AddCluster(select_cluster, cluster) {
|
||||
let option = document.createElement("option");
|
||||
option.value = cluster["id"];
|
||||
option.text = cluster["name"];
|
||||
|
||||
select_cluster.add(option);
|
||||
}
|
||||
}
|
||||
|
||||
async function UpdateClusters() {
|
||||
await window.get_logs_clusters.SendRequest()
|
||||
}
|
||||
Reference in New Issue
Block a user