ArgusSite/static/scripts/table-reports.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-07-03 22:31:18 +00:00
const createTable = () => {
const table = document.getElementById("deviceTable");
const tbody = table.querySelector("tbody");
// Очищаем таблицу
tbody.innerHTML = "";
devices.forEach((device) => {
2023-07-03 22:31:18 +00:00
const row = document.createElement("tr");
// Добавляем ячейки с данными
const name = document.createElement("td");
2023-07-24 04:53:11 +00:00
name.textContent = device.type;
2023-07-03 22:31:18 +00:00
row.appendChild(name);
const reportID = document.createElement("td");
2023-07-24 04:53:11 +00:00
reportID.textContent = device.id;
2023-07-03 22:31:18 +00:00
row.appendChild(reportID);
const plate = document.createElement("td");
2023-09-25 16:37:21 +00:00
plate.textContent = device.number;
2023-07-03 22:31:18 +00:00
row.appendChild(plate);
const numberTS = document.createElement("td");
2023-07-24 04:53:11 +00:00
numberTS.textContent = device.serial;
2023-07-03 22:31:18 +00:00
row.appendChild(numberTS);
const time = document.createElement("td");
time.textContent = device.time;
row.appendChild(time);
const place = document.createElement("td");
2023-07-24 04:53:11 +00:00
place.textContent = device.geo;
2023-07-03 22:31:18 +00:00
row.appendChild(place);
// Добавляем кнопку удаления после каждого ряда
const shareCell = document.createElement("td");
const shareButton = document.createElement("button");
shareButton.setAttribute("class", "share");
2023-08-07 11:44:15 +00:00
shareButton.setAttribute("onclick", `location.href = '/reports/${device.id}';`);
2023-07-03 22:31:18 +00:00
shareButton.value = `delete-device-${device.id}`;
shareButton.id = `delete-device-${device.id}`;
shareCell.appendChild(shareButton);
row.appendChild(shareCell);
tbody.appendChild(row);
});
};
createTable();