修复偏移问题,修复代理问题
This commit is contained in:
@@ -1,20 +1,38 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
/* Prevent the outer page from scrolling */
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
/* Make the main container take exactly the viewport height and act as a flex column */
|
||||
main {
|
||||
height: 100vh;
|
||||
padding-bottom: 0 !important;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
/* Let the iframe container fill all the remaining height automatically */
|
||||
.octo-panel-container {
|
||||
flex-grow: 1;
|
||||
margin-bottom: 0 !important;
|
||||
border-radius: 0px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2"><i class="bi bi-window-sidebar text-info me-2"></i>{{ _('OctoPrint Panel (Embedded)') }}</h1>
|
||||
</div>
|
||||
|
||||
{% if embed_url %}
|
||||
<div class="card shadow rounded overflow-hidden" style="height: calc(100vh - 180px); min-height: 500px;">
|
||||
<!-- iFrame wrapper for responsivness -->
|
||||
<div class="w-100 h-100 position-relative">
|
||||
<iframe src="{{ embed_url }}"
|
||||
class="position-absolute border-0 w-100 h-100"
|
||||
style="top: 0; left: 0;"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
<div class="card shadow overflow-hidden octo-panel-container position-relative">
|
||||
<iframe src="{{ embed_url }}"
|
||||
class="position-absolute border-0 w-100 h-100"
|
||||
style="top: 0; left: 0;"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning shadow-sm border-0 d-flex align-items-center" role="alert">
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
@keyframes blink-fade {
|
||||
0% { background-color: rgba(255, 193, 7, 0.4); box-shadow: 0 0 15px rgba(255, 193, 7, 0.6); }
|
||||
50% { background-color: rgba(255, 193, 7, 0); box-shadow: 0 0 0 rgba(255, 193, 7, 0); }
|
||||
100% { background-color: rgba(255, 193, 7, 0.4); box-shadow: 0 0 15px rgba(255, 193, 7, 0.6); }
|
||||
}
|
||||
.animate-blink {
|
||||
animation: blink-fade 0.8s ease-in-out 4;
|
||||
border: 2px solid #ffc107 !important;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.transition-style {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2"><i class="bi bi-file-earmark-plus text-primary me-2"></i>{{ _('Prepare Print') }}</h1>
|
||||
<div>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm rounded shadow-sm fw-bold" onclick="document.getElementById('gcodeUploadInput').click();">
|
||||
<i class="bi bi-upload me-1"></i>{{ _('Upload External GCode') }}
|
||||
</button>
|
||||
<input type="file" id="gcodeUploadInput" style="display: none;" accept=".gcode,.gco,.g" onchange="uploadExternalGcode(this)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if error %}
|
||||
@@ -17,12 +38,13 @@
|
||||
<div class="list-group list-group-flush">
|
||||
{% for f in files %}
|
||||
{% if f.type == 'machinecode' %}
|
||||
<div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center py-3">
|
||||
<div id="file-{{ f.id }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center py-3 transition-style">
|
||||
<div class="me-auto text-truncate" style="max-width: 80%;">
|
||||
<h6 class="mb-1"><i class="bi bi-file-earmark-code text-primary me-2"></i>{{ f.name }}</h6>
|
||||
<small class="text-muted d-block">{{ _('Size:') }} {{ f.size }} bytes, {{ _('Time:') }} {{ f.gcodeAnalysis.estimatedPrintTime if f.gcodeAnalysis else 'Unknown' }}s</small>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ url_for('main.preview_gcode', file_id=f.id) }}" class="btn btn-sm btn-outline-info rounded-pill px-3 shadow-sm me-2"><i class="bi bi-eye me-1"></i>{{ _('Preview') }}</a>
|
||||
<button class="btn btn-sm btn-outline-success rounded-pill px-3 shadow-sm" onclick="printFile('{{ f.origin }}', '{{ f.path }}')"><i class="bi bi-play-fill me-1"></i>{{ _('Print Now') }}</button>
|
||||
<!-- <button class="btn btn-sm btn-outline-secondary rounded-pill ms-2" onclick="selectFile('{{ f.origin }}', '{{ f.path }}')">{{ _('Select') }}</button> -->
|
||||
</div>
|
||||
@@ -59,6 +81,54 @@ function printFile(origin, path) {
|
||||
.catch(err => window.customAlert("Error: " + err));
|
||||
});
|
||||
}
|
||||
|
||||
function uploadExternalGcode(input) {
|
||||
if (!input.files || input.files.length === 0) return;
|
||||
|
||||
let file = input.files[0];
|
||||
let formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
window.showToast("{{ _('Uploading and linking GCode...') }}", "info");
|
||||
let btn = document.querySelector('button[onclick="document.getElementById(\'gcodeUploadInput\').click();"]');
|
||||
let oldBtnHtml = btn.innerHTML;
|
||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Upload/Sync...';
|
||||
btn.disabled = true;
|
||||
|
||||
fetch("{{ url_for('printer.upload_gcode') }}", {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if(data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
window.customAlert("Upload failed: " + data.error);
|
||||
btn.innerHTML = oldBtnHtml;
|
||||
btn.disabled = false;
|
||||
}
|
||||
}).catch(e => {
|
||||
window.customAlert("Error: " + e);
|
||||
btn.innerHTML = oldBtnHtml;
|
||||
btn.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
if(window.location.hash) {
|
||||
let el = document.querySelector(window.location.hash);
|
||||
if(el) {
|
||||
setTimeout(() => {
|
||||
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
el.classList.add('animate-blink');
|
||||
|
||||
// fallback to remove class later
|
||||
setTimeout(() => el.classList.remove('animate-blink'), 3500);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user