This commit is contained in:
Janis Steiner
2024-12-08 13:10:35 +00:00
parent 4880e1dee0
commit 5658f45f96

View File

@@ -304,55 +304,9 @@ if (own_id == printer.userid || cancel_all == "1") {
// Reattach the iframe at the placeholder // Reattach the iframe at the placeholder
const placeholder = printerCard.querySelector('#iframe-placeholder'); const placeholder = printerCard.querySelector('#iframe-placeholder');
placeholder.parentNode.replaceChild(newIframe, placeholder); placeholder.parentNode.replaceChild(newIframe, placeholder);
}1~if (own_id == printer.userid || cancel_all == "1") {
// Get the current iframe
const iframe = printerCard.querySelector('iframe');
// Store necessary iframe attributes if needed
const iframeSrc = iframe ? iframe.src : null;
// Remove iframe temporarily
if (iframe) {
printerCard.removeChild(iframe);
} }
// Update the innerHTML, excluding the iframe initially
printerCard.innerHTML = `
<div class="card-body">
<h5 class="card-title">Drucker ${printer.printer_id}</h5>
</div>
<div class="card-body">
<!-- Placeholder for iframe reattachment -->
<div id="iframe-placeholder"></div>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: ${printer.progress}%" aria-valuenow="${printer.progress}" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<table class="table table-borderless">
<thead>
<tr><td>Status</td><td style="color: ${getColorByStatus(printer.view)}">${printerStatus}</td></tr>
<tr><td>Genutzt von</td><td>${printer.username}</td></tr>
<tr><td>Filamentfarbe</td><td>${printer.filament_color}</td></tr>
<tr><td>Erwartete Druckzeit</td><td>${printer.print_time_total}</td></tr>
<tr><td>Verbleibende Druckzeit</td><td>${printer.print_time_left}</td></tr>
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</td></tr>
<tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr>
</thead>
<tr><td><a class='btn btn-success' href='overview.php?free=${printer.printer_id}&rid=<?php echo($_SESSION["rid"]); ?>'>Freigeben</a></td></tr>
</table>
</div>
`;
// Create a new iframe element or use the existing one if it was stored
const newIframe = document.createElement('iframe');
newIframe.height = "230px";
newIframe.scrolling = "no";
newIframe.width = "100%";
newIframe.src = iframeSrc ? iframeSrc : `/app/webcam.php?printer_id=${printer.printer_id}&username=<?php echo($username); ?>&url=${printer.url}`;
// Reattach the iframe at the placeholder
const placeholder = printerCard.querySelector('#iframe-placeholder');
placeholder.parentNode.replaceChild(newIframe, placeholder);
}
}else{ }else{
printerCard.innerHTML = ` printerCard.innerHTML = `
<div class="card-body"> <div class="card-body">