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

View File

@@ -256,30 +256,103 @@ function updatePrinterData(data) {
} }
if(printer.view==0 || printer.view==2){ if(printer.view==0 || printer.view==2){
if(own_id==printer.userid || cancel_all=="1"){ if (own_id == printer.userid || cancel_all == "1") {
printerCard.innerHTML = ` // Get the current iframe
<div class="card-body"> const iframe = printerCard.querySelector('iframe');
<h5 class="card-title">Drucker ${printer.printer_id}</h5>
</div> // Store necessary iframe attributes if needed
<div class="card-body"> const iframeSrc = iframe ? iframe.src : null;
<iframe height="230px" scrolling="no" width="100%" src="/app/webcam.php?printer_id=${printer.printer_id}&username=<?php echo($username); ?>&url=${printer.url}"></iframe>
<div class="progress"> // Remove iframe temporarily
<div class="progress-bar" role="progressbar" style="width: ${printer.progress}%" aria-valuenow="${printer.progress}" aria-valuemin="0" aria-valuemax="100"></div> if (iframe) {
</div> printerCard.removeChild(iframe);
<table class="table table-borderless"> }
<thead>
<tr><td>Status</td><td style="color: ${getColorByStatus(printer.view)}">${printerStatus}</td></tr> // Update the innerHTML, excluding the iframe initially
<tr><td>Genutzt von</td><td>${printer.username}</td></tr> printerCard.innerHTML = `
<tr><td>Filamentfarbe</td><td>${printer.filament_color}</td></tr> <div class="card-body">
<tr><td>Erwartete Druckzeit</td><td>${printer.print_time_total}</td></tr> <h5 class="card-title">Drucker ${printer.printer_id}</h5>
<tr><td>Verbleibende Druckzeit</td><td>${printer.print_time_left}</td></tr> </div>
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</td></tr> <div class="card-body">
<tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr> <!-- Placeholder for iframe reattachment -->
</thead> <div id="iframe-placeholder"></div>
<tr><td><a class='btn btn-success' href='overview.php?free=${printer.printer_id}&rid=<?php echo($_SESSION["rid"]); ?>'>Freigeben</a></td></tr> <div class="progress">
</table> <div class="progress-bar" role="progressbar" style="width: ${printer.progress}%" aria-valuenow="${printer.progress}" aria-valuemin="0" aria-valuemax="100"></div>
</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);
}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">
@@ -298,7 +371,7 @@ function updatePrinterData(data) {
<tr><td>Erwartete Druckzeit</td><td>${printer.print_time_total}</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>Verbleibende Druckzeit</td><td>${printer.print_time_left}</td></tr>
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</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> </thead>
</table> </table>
</div> </div>
@@ -323,7 +396,7 @@ function updatePrinterData(data) {
<tr><td>Erwartete Druckzeit</td><td>${printer.print_time_total}</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>Verbleibende Druckzeit</td><td>${printer.print_time_left}</td></tr>
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</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> </thead>
<tr><td><button class='btn btn-danger' onclick='update_cancel_modal(${printer.printer_id},<?php echo($_SESSION["rid"]); ?>)'>Abbrechen</button></td></tr> <tr><td><button class='btn btn-danger' onclick='update_cancel_modal(${printer.printer_id},<?php echo($_SESSION["rid"]); ?>)'>Abbrechen</button></td></tr>
</table> </table>
@@ -347,7 +420,7 @@ function updatePrinterData(data) {
<tr><td>Erwartete Druckzeit</td><td>${printer.print_time_total}</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>Verbleibende Druckzeit</td><td>${printer.print_time_left}</td></tr>
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</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> </thead>
</table> </table>
</div> </div>