From 7ef49b49244292df00d23a88539b2857ecc5bcab Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Thu, 14 Aug 2025 11:10:09 +0200 Subject: [PATCH] added new logout button and fixed pdf viewing --- .../WarehouseShippingNoteController.php | 5 +++++ .../WarehouseShippingNote.js | 1 + .../vue/tt-components/css/tt-file-gallery.css | 15 ++++++++++++++ .../vue/tt-components/tt-file-gallery.js | 20 +++++++++++++------ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/application/WarehouseShippingNote/WarehouseShippingNoteController.php b/application/WarehouseShippingNote/WarehouseShippingNoteController.php index 9cedd2d6d..30dbe3d2a 100644 --- a/application/WarehouseShippingNote/WarehouseShippingNoteController.php +++ b/application/WarehouseShippingNote/WarehouseShippingNoteController.php @@ -680,6 +680,11 @@ class WarehouseShippingNoteController extends TTCrud { return; } + if (strpos($_SERVER['REMOTE_ADDR'], '172.18') === 0) { + self::returnJson([]); + return; + } + $calendars = CalendarModel::getAll(); // loop through all calendars and find the one with user_id as the worker's id diff --git a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js index f53530c94..631b1e63d 100644 --- a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js +++ b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js @@ -586,6 +586,7 @@ Vue.component('warehouse-shipping-note', { let hiddenTime = null; const RELOAD_AFTER_SECONDS = 300; document.addEventListener('visibilitychange', () => { + if (!window.matchMedia('(display-mode: standalone)').matches) return; if (document.visibilityState === 'hidden') { hiddenTime = new Date(); } else if (document.visibilityState === 'visible' && hiddenTime) { diff --git a/public/plugins/vue/tt-components/css/tt-file-gallery.css b/public/plugins/vue/tt-components/css/tt-file-gallery.css index f33043e53..2999cdbd8 100644 --- a/public/plugins/vue/tt-components/css/tt-file-gallery.css +++ b/public/plugins/vue/tt-components/css/tt-file-gallery.css @@ -179,6 +179,21 @@ background-color: white; } + .tt-fullscreen-pdf-standalone-container { + width: calc(100vw - 40px); + height: calc(100vh - 40px); + overflow: scroll; /* or 'auto' - This is the key change! */ + background-color: #555; /* A background for the scroll area */ + text-align: center; /* Helps center the canvas if it's smaller than the container */ + } + + .tt-fullscreen-pdf-standalone { + border: none; + box-shadow: 0 0 15px rgba(0,0,0,0.5); + margin: 20px 0; /* Add some vertical margin for spacing */ + } + + .tt-fullscreen-nav-btn { position: absolute; top: 50%; diff --git a/public/plugins/vue/tt-components/tt-file-gallery.js b/public/plugins/vue/tt-components/tt-file-gallery.js index 627d0d111..07c7c5025 100644 --- a/public/plugins/vue/tt-components/tt-file-gallery.js +++ b/public/plugins/vue/tt-components/tt-file-gallery.js @@ -14,7 +14,6 @@ Vue.component('tt-fullscreen-viewer', { panStart: { x: 0, y: 0 }, lastPinchDist: 0, isLoading: true, - // NEW: Flag to determine if running as a PWA/standalone app isStandalone: false, }), computed: { @@ -125,7 +124,8 @@ Vue.component('tt-fullscreen-viewer', { const script = document.createElement('script'); script.id = 'pdfjs-script'; - script.src = 'https://mozilla.github.io/pdf.js/build/pdf.js'; // CDN URL + script.type = 'module'; + script.src = 'https://unpkg.com/pdfjs-dist@5.4.54/build/pdf.mjs'; // CDN URL script.onload = () => resolve(); script.onerror = (err) => { console.error("Failed to load PDF.js script.", err); @@ -143,7 +143,7 @@ Vue.component('tt-fullscreen-viewer', { try { await this.loadPdfJsScript(); - pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js'; + pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@5.4.54/build/pdf.worker.min.mjs'; const pdf = await pdfjsLib.getDocument(url).promise; // For simplicity, we render the first page. Add pagination controls as needed. @@ -151,9 +151,17 @@ Vue.component('tt-fullscreen-viewer', { const canvas = this.$refs.pdfCanvas; if (!canvas) return; // Exit if canvas is not available + const container = canvas.parentElement; // Get the container to calculate size from + if (!container) return; const context = canvas.getContext('2d'); - const viewport = page.getViewport({ scale: 1.5 }); + const unscaledViewport = page.getViewport({ scale: 1 }); + const scale = Math.min( + container.clientWidth / unscaledViewport.width, + container.clientHeight / unscaledViewport.height + ); + + const viewport = page.getViewport({ scale: scale }); canvas.height = viewport.height; canvas.width = viewport.width; @@ -217,8 +225,8 @@ Vue.component('tt-fullscreen-viewer', { -
- +
+