This commit is contained in:
Janis Steiner
2024-12-08 13:08:05 +00:00
parent 7295152038
commit 4880e1dee0

View File

@@ -256,13 +256,26 @@ function updatePrinterData(data) {
}
if(printer.view==0 || printer.view==2){
if(own_id==printer.userid || cancel_all=="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">
<iframe height="230px" scrolling="no" width="100%" src="/app/webcam.php?printer_id=${printer.printer_id}&username=<?php echo($username); ?>&url=${printer.url}"></iframe>
<!-- 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>
@@ -280,6 +293,66 @@ function updatePrinterData(data) {
</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);
}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{
printerCard.innerHTML = `
<div class="card-body">
@@ -298,7 +371,7 @@ function updatePrinterData(data) {
<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>${printer.file}</td></tr>
<tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr>
</thead>
</table>
</div>
@@ -323,7 +396,7 @@ function updatePrinterData(data) {
<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>${printer.file}</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><button class='btn btn-danger' onclick='update_cancel_modal(${printer.printer_id},<?php echo($_SESSION["rid"]); ?>)'>Abbrechen</button></td></tr>
</table>
@@ -347,7 +420,7 @@ function updatePrinterData(data) {
<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>${printer.file}</td></tr>
<tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr>
</thead>
</table>
</div>