added new logout button and fixed pdf viewing
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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%;
|
||||
|
||||
@@ -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', {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-else-if="isPdf(currentItem) && isStandalone" v-show="!isLoading" class="tt-fullscreen-pdf-container">
|
||||
<canvas ref="pdfCanvas" class="tt-fullscreen-pdf"></canvas>
|
||||
<div v-else-if="isPdf(currentItem) && isStandalone" v-show="!isLoading" class="tt-fullscreen-pdf-standalone-container">
|
||||
<canvas ref="pdfCanvas" class="tt-fullscreen-pdf-standalone"></canvas>
|
||||
</div>
|
||||
|
||||
<iframe v-else-if="isPdf(currentItem)" v-show="!isLoading" :src="contentSrc" class="tt-fullscreen-pdf"
|
||||
|
||||
Reference in New Issue
Block a user