2024-01-18 12:39:10 +00:00
|
|
|
{% extends 'base.html.twig' %}
|
|
|
|
|
2024-01-19 07:38:32 +00:00
|
|
|
{% block javascripts %}
|
|
|
|
<script>
|
2024-01-19 08:12:17 +00:00
|
|
|
function addTableData(tableRow, data) {
|
|
|
|
const tableData = document.createElement('td');
|
|
|
|
tableData.textContent = data;
|
|
|
|
|
|
|
|
tableRow.appendChild(tableData);
|
|
|
|
}
|
|
|
|
|
|
|
|
function addPrinterToTable(tableBody, printer) {
|
|
|
|
const tableRow = document.createElement('tr');
|
|
|
|
addTableData(tableRow, printer.name);
|
|
|
|
addTableData(tableRow, printer.price.toFixed(2) + '$');
|
|
|
|
addTableData(tableRow, printer.build_volume);
|
|
|
|
addTableData(tableRow, printer.max_speed);
|
|
|
|
|
|
|
|
tableBody.appendChild(tableRow);
|
2024-01-18 15:35:37 +00:00
|
|
|
}
|
|
|
|
|
2024-01-19 07:38:32 +00:00
|
|
|
function reloadTable() {
|
|
|
|
fetch('/printer', {method: 'GET'}).then(response => {
|
|
|
|
response.json().then(json => {
|
|
|
|
for (printer of json) {
|
2024-01-19 08:12:17 +00:00
|
|
|
const tableBody = document.getElementById('table-body');
|
|
|
|
tableBody.innerHTML = null;
|
|
|
|
addPrinterToTable(tableBody, printer);
|
2024-01-19 07:38:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2024-01-18 15:35:37 +00:00
|
|
|
}
|
|
|
|
|
2024-01-19 07:38:32 +00:00
|
|
|
reloadTable();
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|
2024-01-18 15:35:37 +00:00
|
|
|
|
2024-01-19 07:38:32 +00:00
|
|
|
{% block body %}
|
2024-01-18 12:39:10 +00:00
|
|
|
<h1>Printers</h1>
|
|
|
|
<table id="table">
|
2024-01-18 15:35:37 +00:00
|
|
|
<thead>
|
2024-01-18 12:39:10 +00:00
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Price</th>
|
|
|
|
<th>Build Volume</th>
|
|
|
|
<th>Max Speed</th>
|
2024-01-18 15:35:37 +00:00
|
|
|
<th>Actions</th>
|
2024-01-18 12:39:10 +00:00
|
|
|
</tr>
|
2024-01-18 15:35:37 +00:00
|
|
|
</thead>
|
|
|
|
<tbody id="table-body">
|
|
|
|
|
|
|
|
</tbody>
|
2024-01-18 12:39:10 +00:00
|
|
|
</table>
|
2024-01-18 15:35:37 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
</script>
|
2024-01-18 12:39:10 +00:00
|
|
|
{% endblock %}
|